1*d874cce4Sray /* $OpenBSD: milieu.h,v 1.3 2008/06/26 05:42:20 ray Exp $ */ 2433075b6Spvalchev /* $NetBSD: milieu.h,v 1.1 2001/04/26 03:10:47 ross Exp $ */ 3433075b6Spvalchev 4433075b6Spvalchev /* This is a derivative work. */ 5433075b6Spvalchev 6433075b6Spvalchev /*- 7433075b6Spvalchev * Copyright (c) 2001 The NetBSD Foundation, Inc. 8433075b6Spvalchev * All rights reserved. 9433075b6Spvalchev * 10433075b6Spvalchev * This code is derived from software contributed to The NetBSD Foundation 11433075b6Spvalchev * by Ross Harvey. 12433075b6Spvalchev * 13433075b6Spvalchev * Redistribution and use in source and binary forms, with or without 14433075b6Spvalchev * modification, are permitted provided that the following conditions 15433075b6Spvalchev * are met: 16433075b6Spvalchev * 1. Redistributions of source code must retain the above copyright 17433075b6Spvalchev * notice, this list of conditions and the following disclaimer. 18433075b6Spvalchev * 2. Redistributions in binary form must reproduce the above copyright 19433075b6Spvalchev * notice, this list of conditions and the following disclaimer in the 20433075b6Spvalchev * documentation and/or other materials provided with the distribution. 21433075b6Spvalchev * 22433075b6Spvalchev * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23433075b6Spvalchev * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24433075b6Spvalchev * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25433075b6Spvalchev * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26433075b6Spvalchev * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27433075b6Spvalchev * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28433075b6Spvalchev * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29433075b6Spvalchev * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30433075b6Spvalchev * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31433075b6Spvalchev * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32433075b6Spvalchev * POSSIBILITY OF SUCH DAMAGE. 33433075b6Spvalchev */ 34433075b6Spvalchev 35433075b6Spvalchev /* 36433075b6Spvalchev =============================================================================== 37433075b6Spvalchev 38433075b6Spvalchev This C header file is part of TestFloat, Release 2a, a package of programs 39433075b6Spvalchev for testing the correctness of floating-point arithmetic complying to the 40433075b6Spvalchev IEC/IEEE Standard for Floating-Point. 41433075b6Spvalchev 42433075b6Spvalchev Written by John R. Hauser. More information is available through the Web 43433075b6Spvalchev page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'. 44433075b6Spvalchev 45433075b6Spvalchev THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable 46433075b6Spvalchev effort has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT 47433075b6Spvalchev WILL AT TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS 48433075b6Spvalchev RESTRICTED TO PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL 49433075b6Spvalchev RESPONSIBILITY FOR ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM 50433075b6Spvalchev THEIR OWN USE OF THE SOFTWARE, AND WHO ALSO EFFECTIVELY INDEMNIFY 51433075b6Spvalchev (possibly via similar legal warning) JOHN HAUSER AND THE INTERNATIONAL 52433075b6Spvalchev COMPUTER SCIENCE INSTITUTE AGAINST ALL LOSSES, COSTS, OR OTHER PROBLEMS 53433075b6Spvalchev ARISING FROM THE USE OF THE SOFTWARE BY THEIR CUSTOMERS AND CLIENTS. 54433075b6Spvalchev 55433075b6Spvalchev Derivative works are acceptable, even for commercial purposes, so long as 56433075b6Spvalchev (1) they include prominent notice that the work is derivative, and (2) they 57433075b6Spvalchev include prominent notice akin to these four paragraphs for those parts of 58433075b6Spvalchev this code that are retained. 59433075b6Spvalchev 60433075b6Spvalchev =============================================================================== 61433075b6Spvalchev */ 62433075b6Spvalchev 63433075b6Spvalchev #ifndef MILIEU_H 64433075b6Spvalchev #define MILIEU_H 65433075b6Spvalchev 66433075b6Spvalchev #include <sys/types.h> 67433075b6Spvalchev #include <sys/endian.h> 68433075b6Spvalchev 69433075b6Spvalchev enum { 70433075b6Spvalchev FALSE = 0, 71433075b6Spvalchev TRUE = 1 72433075b6Spvalchev }; 73433075b6Spvalchev 74433075b6Spvalchev 75433075b6Spvalchev /* 76433075b6Spvalchev ------------------------------------------------------------------------------- 77433075b6Spvalchev One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. 78433075b6Spvalchev ------------------------------------------------------------------------------- 79433075b6Spvalchev */ 80433075b6Spvalchev 81433075b6Spvalchev #if _BYTE_ORDER == _LITTLE_ENDIAN 82433075b6Spvalchev #define LITTLEENDIAN 83433075b6Spvalchev #else 84433075b6Spvalchev #define BIGENDIAN 85433075b6Spvalchev #endif 86433075b6Spvalchev 87433075b6Spvalchev #define BITS64 88433075b6Spvalchev 89433075b6Spvalchev /* 90433075b6Spvalchev ------------------------------------------------------------------------------- 91433075b6Spvalchev Each of the following `typedef's defines the most convenient type that holds 92433075b6Spvalchev integers of at least as many bits as specified. For example, `uint8' should 93433075b6Spvalchev be the most convenient type that can hold unsigned integers of as many as 94433075b6Spvalchev 8 bits. The `flag' type must be able to hold either a 0 or 1. For most 95433075b6Spvalchev implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 96433075b6Spvalchev to the same as `int'. 97433075b6Spvalchev ------------------------------------------------------------------------------- 98433075b6Spvalchev */ 99433075b6Spvalchev typedef int flag; 100433075b6Spvalchev typedef unsigned int uint8; 101433075b6Spvalchev typedef signed int int8; 102433075b6Spvalchev typedef unsigned int uint16; 103433075b6Spvalchev typedef int int16; 104433075b6Spvalchev typedef unsigned int uint32; 105433075b6Spvalchev typedef signed int int32; 106433075b6Spvalchev #ifdef BITS64 107433075b6Spvalchev typedef uint64_t uint64; 108433075b6Spvalchev typedef int64_t int64; 109433075b6Spvalchev #endif 110433075b6Spvalchev 111433075b6Spvalchev /* 112433075b6Spvalchev ------------------------------------------------------------------------------- 113433075b6Spvalchev Each of the following `typedef's defines a type that holds integers 114433075b6Spvalchev of _exactly_ the number of bits specified. For instance, for most 115433075b6Spvalchev implementation of C, `bits16' and `sbits16' should be `typedef'ed to 116433075b6Spvalchev `unsigned short int' and `signed short int' (or `short int'), respectively. 117433075b6Spvalchev ------------------------------------------------------------------------------- 118433075b6Spvalchev */ 119433075b6Spvalchev typedef uint8_t bits8; 120433075b6Spvalchev typedef int8_t sbits8; 121433075b6Spvalchev typedef uint16_t bits16; 122433075b6Spvalchev typedef int16_t sbits16; 123433075b6Spvalchev typedef uint32_t bits32; 124433075b6Spvalchev typedef int32_t sbits32; 125433075b6Spvalchev #ifdef BITS64 126433075b6Spvalchev typedef uint64_t bits64; 127433075b6Spvalchev typedef int64_t sbits64; 128433075b6Spvalchev #endif 129433075b6Spvalchev 130433075b6Spvalchev #ifdef BITS64 131433075b6Spvalchev /* 132433075b6Spvalchev ------------------------------------------------------------------------------- 133433075b6Spvalchev The `LIT64' macro takes as its argument a textual integer literal and 134433075b6Spvalchev if necessary ``marks'' the literal as having a 64-bit integer type. 135433075b6Spvalchev For example, the GNU C Compiler (`gcc') requires that 64-bit literals be 136433075b6Spvalchev appended with the letters `LL' standing for `long long', which is `gcc's 137433075b6Spvalchev name for the 64-bit integer type. Some compilers may allow `LIT64' to be 138433075b6Spvalchev defined as the identity macro: `#define LIT64( a ) a'. 139433075b6Spvalchev ------------------------------------------------------------------------------- 140433075b6Spvalchev */ 141433075b6Spvalchev #define LIT64( a ) a##LL 142433075b6Spvalchev #endif 143433075b6Spvalchev 144433075b6Spvalchev /* 145433075b6Spvalchev ------------------------------------------------------------------------------- 146433075b6Spvalchev The macro `INLINE' can be used before functions that should be inlined. If 147433075b6Spvalchev a compiler does not support explicit inlining, this macro should be defined 148433075b6Spvalchev to be `static'. 149433075b6Spvalchev ------------------------------------------------------------------------------- 150433075b6Spvalchev */ 151433075b6Spvalchev #define INLINE static inline 152433075b6Spvalchev 153433075b6Spvalchev #endif 154