1*ce099b40Smartin /* $NetBSD: milieu.h,v 1.4 2008/04/28 20:23:04 martin Exp $ */ 2159fa2a0Sross 3159fa2a0Sross /* This is a derivative work. */ 4159fa2a0Sross 5159fa2a0Sross /*- 6159fa2a0Sross * Copyright (c) 2001 The NetBSD Foundation, Inc. 7159fa2a0Sross * All rights reserved. 8159fa2a0Sross * 9159fa2a0Sross * This code is derived from software contributed to The NetBSD Foundation 10159fa2a0Sross * by Ross Harvey. 11159fa2a0Sross * 12159fa2a0Sross * Redistribution and use in source and binary forms, with or without 13159fa2a0Sross * modification, are permitted provided that the following conditions 14159fa2a0Sross * are met: 15159fa2a0Sross * 1. Redistributions of source code must retain the above copyright 16159fa2a0Sross * notice, this list of conditions and the following disclaimer. 17159fa2a0Sross * 2. Redistributions in binary form must reproduce the above copyright 18159fa2a0Sross * notice, this list of conditions and the following disclaimer in the 19159fa2a0Sross * documentation and/or other materials provided with the distribution. 20159fa2a0Sross * 21159fa2a0Sross * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22159fa2a0Sross * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23159fa2a0Sross * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24159fa2a0Sross * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25159fa2a0Sross * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26159fa2a0Sross * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27159fa2a0Sross * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28159fa2a0Sross * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29159fa2a0Sross * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30159fa2a0Sross * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31159fa2a0Sross * POSSIBILITY OF SUCH DAMAGE. 32159fa2a0Sross */ 33159fa2a0Sross 34159fa2a0Sross /* 35159fa2a0Sross =============================================================================== 36159fa2a0Sross 37159fa2a0Sross This C header file is part of TestFloat, Release 2a, a package of programs 38159fa2a0Sross for testing the correctness of floating-point arithmetic complying to the 39159fa2a0Sross IEC/IEEE Standard for Floating-Point. 40159fa2a0Sross 41159fa2a0Sross Written by John R. Hauser. More information is available through the Web 42159fa2a0Sross page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'. 43159fa2a0Sross 44159fa2a0Sross THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 45159fa2a0Sross has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 46159fa2a0Sross TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 47159fa2a0Sross PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 48159fa2a0Sross AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 49159fa2a0Sross 50159fa2a0Sross Derivative works are acceptable, even for commercial purposes, so long as 51159fa2a0Sross (1) they include prominent notice that the work is derivative, and (2) they 52159fa2a0Sross include prominent notice akin to these four paragraphs for those parts of 53159fa2a0Sross this code that are retained. 54159fa2a0Sross 55159fa2a0Sross =============================================================================== 56159fa2a0Sross */ 57159fa2a0Sross 58159fa2a0Sross #ifndef MILIEU_H 59159fa2a0Sross #define MILIEU_H 60159fa2a0Sross 61159fa2a0Sross #include <inttypes.h> 62159fa2a0Sross #include <sys/endian.h> 63159fa2a0Sross 64159fa2a0Sross enum { 65159fa2a0Sross FALSE = 0, 66159fa2a0Sross TRUE = 1 67159fa2a0Sross }; 68159fa2a0Sross 69159fa2a0Sross 70159fa2a0Sross /* 71159fa2a0Sross ------------------------------------------------------------------------------- 72159fa2a0Sross One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. 73159fa2a0Sross ------------------------------------------------------------------------------- 74159fa2a0Sross */ 75159fa2a0Sross 76159fa2a0Sross #if _BYTE_ORDER == _LITTLE_ENDIAN 77159fa2a0Sross #define LITTLEENDIAN 78159fa2a0Sross #else 79159fa2a0Sross #define BIGENDIAN 80159fa2a0Sross #endif 81159fa2a0Sross 82159fa2a0Sross #define BITS64 83159fa2a0Sross 84159fa2a0Sross /* 85159fa2a0Sross ------------------------------------------------------------------------------- 86159fa2a0Sross Each of the following `typedef's defines the most convenient type that holds 87159fa2a0Sross integers of at least as many bits as specified. For example, `uint8' should 88159fa2a0Sross be the most convenient type that can hold unsigned integers of as many as 89159fa2a0Sross 8 bits. The `flag' type must be able to hold either a 0 or 1. For most 90159fa2a0Sross implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 91159fa2a0Sross to the same as `int'. 92159fa2a0Sross ------------------------------------------------------------------------------- 93159fa2a0Sross */ 94159fa2a0Sross typedef int flag; 95159fa2a0Sross typedef unsigned int uint8; 96159fa2a0Sross typedef signed int int8; 97159fa2a0Sross typedef unsigned int uint16; 98159fa2a0Sross typedef int int16; 99159fa2a0Sross typedef unsigned int uint32; 100159fa2a0Sross typedef signed int int32; 101159fa2a0Sross #ifdef BITS64 102a41c3721Sross typedef uint64_t uint64; 103159fa2a0Sross typedef int64_t int64; 104159fa2a0Sross #endif 105159fa2a0Sross 106159fa2a0Sross /* 107159fa2a0Sross ------------------------------------------------------------------------------- 108159fa2a0Sross Each of the following `typedef's defines a type that holds integers 109159fa2a0Sross of _exactly_ the number of bits specified. For instance, for most 110159fa2a0Sross implementation of C, `bits16' and `sbits16' should be `typedef'ed to 111159fa2a0Sross `unsigned short int' and `signed short int' (or `short int'), respectively. 112159fa2a0Sross ------------------------------------------------------------------------------- 113159fa2a0Sross */ 114a41c3721Sross typedef uint8_t bits8; 115159fa2a0Sross typedef int8_t sbits8; 116a41c3721Sross typedef uint16_t bits16; 117159fa2a0Sross typedef int16_t sbits16; 118a41c3721Sross typedef uint32_t bits32; 119159fa2a0Sross typedef int32_t sbits32; 120159fa2a0Sross #ifdef BITS64 121a41c3721Sross typedef uint64_t bits64; 122159fa2a0Sross typedef int64_t sbits64; 123159fa2a0Sross #endif 124159fa2a0Sross 125159fa2a0Sross #ifdef BITS64 126159fa2a0Sross /* 127159fa2a0Sross ------------------------------------------------------------------------------- 128159fa2a0Sross The `LIT64' macro takes as its argument a textual integer literal and 129159fa2a0Sross if necessary ``marks'' the literal as having a 64-bit integer type. 130159fa2a0Sross For example, the GNU C Compiler (`gcc') requires that 64-bit literals be 131159fa2a0Sross appended with the letters `LL' standing for `long long', which is `gcc's 132159fa2a0Sross name for the 64-bit integer type. Some compilers may allow `LIT64' to be 133159fa2a0Sross defined as the identity macro: `#define LIT64( a ) a'. 134159fa2a0Sross ------------------------------------------------------------------------------- 135159fa2a0Sross */ 136159fa2a0Sross #define LIT64( a ) a##LL 137159fa2a0Sross #endif 138159fa2a0Sross 139159fa2a0Sross /* 140159fa2a0Sross ------------------------------------------------------------------------------- 141159fa2a0Sross The macro `INLINE' can be used before functions that should be inlined. If 142159fa2a0Sross a compiler does not support explicit inlining, this macro should be defined 143159fa2a0Sross to be `static'. 144159fa2a0Sross ------------------------------------------------------------------------------- 145159fa2a0Sross */ 146159fa2a0Sross #define INLINE static inline 147159fa2a0Sross 148159fa2a0Sross #endif 149