xref: /netbsd-src/regress/lib/libc/ieeefp/testfloat/include/testFunction.h (revision ce099b40997c43048fb78bd578195f81d2456523)
1*ce099b40Smartin /*	$NetBSD: testFunction.h,v 1.4 2008/04/28 20:23:04 martin Exp $	*/
24d8829d5Sross 
34d8829d5Sross /* This is a derivative work. */
44d8829d5Sross 
54d8829d5Sross /*-
64d8829d5Sross  * Copyright (c) 2001 The NetBSD Foundation, Inc.
74d8829d5Sross  * All rights reserved.
84d8829d5Sross  *
94d8829d5Sross  * This code is derived from software contributed to The NetBSD Foundation
104d8829d5Sross  * by Ross Harvey.
114d8829d5Sross  *
124d8829d5Sross  * Redistribution and use in source and binary forms, with or without
134d8829d5Sross  * modification, are permitted provided that the following conditions
144d8829d5Sross  * are met:
154d8829d5Sross  * 1. Redistributions of source code must retain the above copyright
164d8829d5Sross  *    notice, this list of conditions and the following disclaimer.
174d8829d5Sross  * 2. Redistributions in binary form must reproduce the above copyright
184d8829d5Sross  *    notice, this list of conditions and the following disclaimer in the
194d8829d5Sross  *    documentation and/or other materials provided with the distribution.
204d8829d5Sross  *
214d8829d5Sross  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
224d8829d5Sross  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
234d8829d5Sross  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
244d8829d5Sross  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
254d8829d5Sross  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
264d8829d5Sross  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
274d8829d5Sross  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
284d8829d5Sross  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
294d8829d5Sross  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
304d8829d5Sross  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
314d8829d5Sross  * POSSIBILITY OF SUCH DAMAGE.
324d8829d5Sross  */
335a6cac71Sross 
345a6cac71Sross /*
355a6cac71Sross ===============================================================================
365a6cac71Sross 
375a6cac71Sross This C header file is part of TestFloat, Release 2a, a package of programs
385a6cac71Sross for testing the correctness of floating-point arithmetic complying to the
395a6cac71Sross IEC/IEEE Standard for Floating-Point.
405a6cac71Sross 
415a6cac71Sross Written by John R. Hauser.  More information is available through the Web
425a6cac71Sross page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
435a6cac71Sross 
445a6cac71Sross THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
455a6cac71Sross has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
465a6cac71Sross TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
475a6cac71Sross PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
485a6cac71Sross AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
495a6cac71Sross 
505a6cac71Sross Derivative works are acceptable, even for commercial purposes, so long as
515a6cac71Sross (1) they include prominent notice that the work is derivative, and (2) they
525a6cac71Sross include prominent notice akin to these four paragraphs for those parts of
535a6cac71Sross this code that are retained.
545a6cac71Sross 
555a6cac71Sross ===============================================================================
565a6cac71Sross */
575a6cac71Sross 
585a6cac71Sross enum {
595a6cac71Sross     INT32_TO_FLOAT32 = 1,
605a6cac71Sross     INT32_TO_FLOAT64,
615a6cac71Sross     INT32_TO_FLOATX80,
625a6cac71Sross     INT32_TO_FLOAT128,
635a6cac71Sross     INT64_TO_FLOAT32,
645a6cac71Sross     INT64_TO_FLOAT64,
655a6cac71Sross     INT64_TO_FLOATX80,
665a6cac71Sross     INT64_TO_FLOAT128,
675a6cac71Sross     FLOAT32_TO_INT32,
685a6cac71Sross     FLOAT32_TO_INT32_ROUND_TO_ZERO,
695a6cac71Sross     FLOAT32_TO_INT64,
705a6cac71Sross     FLOAT32_TO_INT64_ROUND_TO_ZERO,
715a6cac71Sross     FLOAT32_TO_FLOAT64,
725a6cac71Sross     FLOAT32_TO_FLOATX80,
735a6cac71Sross     FLOAT32_TO_FLOAT128,
745a6cac71Sross     FLOAT32_ROUND_TO_INT,
755a6cac71Sross     FLOAT32_ADD,
765a6cac71Sross     FLOAT32_SUB,
775a6cac71Sross     FLOAT32_MUL,
785a6cac71Sross     FLOAT32_DIV,
795a6cac71Sross     FLOAT32_REM,
805a6cac71Sross     FLOAT32_SQRT,
815a6cac71Sross     FLOAT32_EQ,
825a6cac71Sross     FLOAT32_LE,
835a6cac71Sross     FLOAT32_LT,
845a6cac71Sross     FLOAT32_EQ_SIGNALING,
855a6cac71Sross     FLOAT32_LE_QUIET,
865a6cac71Sross     FLOAT32_LT_QUIET,
875a6cac71Sross     FLOAT64_TO_INT32,
885a6cac71Sross     FLOAT64_TO_INT32_ROUND_TO_ZERO,
895a6cac71Sross     FLOAT64_TO_INT64,
905a6cac71Sross     FLOAT64_TO_INT64_ROUND_TO_ZERO,
915a6cac71Sross     FLOAT64_TO_FLOAT32,
925a6cac71Sross     FLOAT64_TO_FLOATX80,
935a6cac71Sross     FLOAT64_TO_FLOAT128,
945a6cac71Sross     FLOAT64_ROUND_TO_INT,
955a6cac71Sross     FLOAT64_ADD,
965a6cac71Sross     FLOAT64_SUB,
975a6cac71Sross     FLOAT64_MUL,
985a6cac71Sross     FLOAT64_DIV,
995a6cac71Sross     FLOAT64_REM,
1005a6cac71Sross     FLOAT64_SQRT,
1015a6cac71Sross     FLOAT64_EQ,
1025a6cac71Sross     FLOAT64_LE,
1035a6cac71Sross     FLOAT64_LT,
1045a6cac71Sross     FLOAT64_EQ_SIGNALING,
1055a6cac71Sross     FLOAT64_LE_QUIET,
1065a6cac71Sross     FLOAT64_LT_QUIET,
1075a6cac71Sross     FLOATX80_TO_INT32,
1085a6cac71Sross     FLOATX80_TO_INT32_ROUND_TO_ZERO,
1095a6cac71Sross     FLOATX80_TO_INT64,
1105a6cac71Sross     FLOATX80_TO_INT64_ROUND_TO_ZERO,
1115a6cac71Sross     FLOATX80_TO_FLOAT32,
1125a6cac71Sross     FLOATX80_TO_FLOAT64,
1135a6cac71Sross     FLOATX80_TO_FLOAT128,
1145a6cac71Sross     FLOATX80_ROUND_TO_INT,
1155a6cac71Sross     FLOATX80_ADD,
1165a6cac71Sross     FLOATX80_SUB,
1175a6cac71Sross     FLOATX80_MUL,
1185a6cac71Sross     FLOATX80_DIV,
1195a6cac71Sross     FLOATX80_REM,
1205a6cac71Sross     FLOATX80_SQRT,
1215a6cac71Sross     FLOATX80_EQ,
1225a6cac71Sross     FLOATX80_LE,
1235a6cac71Sross     FLOATX80_LT,
1245a6cac71Sross     FLOATX80_EQ_SIGNALING,
1255a6cac71Sross     FLOATX80_LE_QUIET,
1265a6cac71Sross     FLOATX80_LT_QUIET,
1275a6cac71Sross     FLOAT128_TO_INT32,
1285a6cac71Sross     FLOAT128_TO_INT32_ROUND_TO_ZERO,
1295a6cac71Sross     FLOAT128_TO_INT64,
1305a6cac71Sross     FLOAT128_TO_INT64_ROUND_TO_ZERO,
1315a6cac71Sross     FLOAT128_TO_FLOAT32,
1325a6cac71Sross     FLOAT128_TO_FLOAT64,
1335a6cac71Sross     FLOAT128_TO_FLOATX80,
1345a6cac71Sross     FLOAT128_ROUND_TO_INT,
1355a6cac71Sross     FLOAT128_ADD,
1365a6cac71Sross     FLOAT128_SUB,
1375a6cac71Sross     FLOAT128_MUL,
1385a6cac71Sross     FLOAT128_DIV,
1395a6cac71Sross     FLOAT128_REM,
1405a6cac71Sross     FLOAT128_SQRT,
1415a6cac71Sross     FLOAT128_EQ,
1425a6cac71Sross     FLOAT128_LE,
1435a6cac71Sross     FLOAT128_LT,
1445a6cac71Sross     FLOAT128_EQ_SIGNALING,
1455a6cac71Sross     FLOAT128_LE_QUIET,
1465a6cac71Sross     FLOAT128_LT_QUIET,
1475a6cac71Sross     NUM_FUNCTIONS
1485a6cac71Sross };
1495a6cac71Sross 
1505a6cac71Sross typedef struct {
1514d8829d5Sross     const char *name;
1525a6cac71Sross     int8 numInputs;
1535a6cac71Sross     flag roundingPrecision, roundingMode;
1545a6cac71Sross } functionT;
1555a6cac71Sross extern const functionT functions[ NUM_FUNCTIONS ];
1565a6cac71Sross extern const flag functionExists[ NUM_FUNCTIONS ];
1575a6cac71Sross 
1585a6cac71Sross enum {
1595a6cac71Sross     ROUND_NEAREST_EVEN = 1,
1605a6cac71Sross     ROUND_TO_ZERO,
1615a6cac71Sross     ROUND_DOWN,
1625a6cac71Sross     ROUND_UP,
1635a6cac71Sross     NUM_ROUNDINGMODES
1645a6cac71Sross };
1655a6cac71Sross 
1665a6cac71Sross void testFunction( uint8, int8, int8 );
1675a6cac71Sross 
168