1*40c38bd9Sthorpej /* $NetBSD: milieu.h,v 1.5 2020/09/02 03:43:22 thorpej Exp $ */ 22df695b1Sross 32df695b1Sross /* This is a derivative work. */ 42df695b1Sross 52df695b1Sross /*- 62df695b1Sross * Copyright (c) 2001 The NetBSD Foundation, Inc. 72df695b1Sross * All rights reserved. 82df695b1Sross * 92df695b1Sross * This code is derived from software contributed to The NetBSD Foundation 102df695b1Sross * by Ross Harvey. 112df695b1Sross * 122df695b1Sross * Redistribution and use in source and binary forms, with or without 132df695b1Sross * modification, are permitted provided that the following conditions 142df695b1Sross * are met: 152df695b1Sross * 1. Redistributions of source code must retain the above copyright 162df695b1Sross * notice, this list of conditions and the following disclaimer. 172df695b1Sross * 2. Redistributions in binary form must reproduce the above copyright 182df695b1Sross * notice, this list of conditions and the following disclaimer in the 192df695b1Sross * documentation and/or other materials provided with the distribution. 202df695b1Sross * 212df695b1Sross * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 222df695b1Sross * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 232df695b1Sross * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 242df695b1Sross * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 252df695b1Sross * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 262df695b1Sross * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 272df695b1Sross * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 282df695b1Sross * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 292df695b1Sross * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 302df695b1Sross * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 312df695b1Sross * POSSIBILITY OF SUCH DAMAGE. 322df695b1Sross */ 332df695b1Sross 34*40c38bd9Sthorpej /*============================================================================ 352df695b1Sross 36*40c38bd9Sthorpej This C header file template is part of the Berkeley SoftFloat IEEE Floating- 37*40c38bd9Sthorpej Point Arithmetic Package, Release 2c, by John R. Hauser. 382df695b1Sross 39*40c38bd9Sthorpej THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has 40*40c38bd9Sthorpej been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES 41*40c38bd9Sthorpej RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS 42*40c38bd9Sthorpej AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR OTHER 43*40c38bd9Sthorpej PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN HAUSER OR 44*40c38bd9Sthorpej THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE EFFECTIVELY 45*40c38bd9Sthorpej INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE 46*40c38bd9Sthorpej (possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR OTHER 47*40c38bd9Sthorpej PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE, OR 48*40c38bd9Sthorpej INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF THE 49*40c38bd9Sthorpej SOFTWARE. 502df695b1Sross 51*40c38bd9Sthorpej Derivative works require also that (1) the source code for the derivative work 52*40c38bd9Sthorpej includes prominent notice that the work is derivative, and (2) the source code 53*40c38bd9Sthorpej includes prominent notice of these three paragraphs for those parts of this 54*40c38bd9Sthorpej code that are retained. 552df695b1Sross 56*40c38bd9Sthorpej =============================================================================*/ 572df695b1Sross 582df695b1Sross #ifndef MILIEU_H 592df695b1Sross #define MILIEU_H 602df695b1Sross 612df695b1Sross #if !defined(_KERNEL) && !defined(_STANDALONE) 622df695b1Sross #include <inttypes.h> 632df695b1Sross #else 642df695b1Sross #include <sys/inttypes.h> 652df695b1Sross #endif 662df695b1Sross 672df695b1Sross #include <sys/endian.h> 682df695b1Sross 69*40c38bd9Sthorpej /*---------------------------------------------------------------------------- 70*40c38bd9Sthorpej | One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. 71*40c38bd9Sthorpej *----------------------------------------------------------------------------*/ 722df695b1Sross #if _BYTE_ORDER == _LITTLE_ENDIAN 732df695b1Sross #define LITTLEENDIAN 742df695b1Sross #else 752df695b1Sross #define BIGENDIAN 762df695b1Sross #endif 772df695b1Sross 78*40c38bd9Sthorpej /*---------------------------------------------------------------------------- 79*40c38bd9Sthorpej | The macro `BITS64' can be defined to indicate that 64-bit integer types are 80*40c38bd9Sthorpej | supported by the compiler. 81*40c38bd9Sthorpej *----------------------------------------------------------------------------*/ 822df695b1Sross #define BITS64 832df695b1Sross 84*40c38bd9Sthorpej /*---------------------------------------------------------------------------- 85*40c38bd9Sthorpej | Each of the following `typedef's defines the most convenient type that holds 86*40c38bd9Sthorpej | integers of at least as many bits as specified. For example, `uint8' should 87*40c38bd9Sthorpej | be the most convenient type that can hold unsigned integers of as many as 88*40c38bd9Sthorpej | 8 bits. The `flag' type must be able to hold either a 0 or 1. For most 89*40c38bd9Sthorpej | implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 90*40c38bd9Sthorpej | to the same as `int'. 91*40c38bd9Sthorpej *----------------------------------------------------------------------------*/ 922df695b1Sross typedef int flag; 932df695b1Sross typedef unsigned int uint8; 942df695b1Sross typedef signed int int8; 952df695b1Sross typedef unsigned int uint16; 962df695b1Sross typedef int int16; 972df695b1Sross typedef unsigned int uint32; 982df695b1Sross typedef signed int int32; 992df695b1Sross #ifdef BITS64 1002df695b1Sross typedef uint64_t uint64; 1012df695b1Sross typedef int64_t int64; 1022df695b1Sross #endif 1032df695b1Sross 104*40c38bd9Sthorpej /*---------------------------------------------------------------------------- 105*40c38bd9Sthorpej | Each of the following `typedef's defines a type that holds integers 106*40c38bd9Sthorpej | of _exactly_ the number of bits specified. For instance, for most 107*40c38bd9Sthorpej | implementation of C, `bits16' and `sbits16' should be `typedef'ed to 108*40c38bd9Sthorpej | `unsigned short int' and `signed short int' (or `short int'), respectively. 109*40c38bd9Sthorpej *----------------------------------------------------------------------------*/ 1102df695b1Sross typedef uint8_t bits8; 1112df695b1Sross typedef int8_t sbits8; 1122df695b1Sross typedef uint16_t bits16; 1132df695b1Sross typedef int16_t sbits16; 1142df695b1Sross typedef uint32_t bits32; 1152df695b1Sross typedef int32_t sbits32; 1162df695b1Sross #ifdef BITS64 1172df695b1Sross typedef uint64_t bits64; 1182df695b1Sross typedef int64_t sbits64; 1192df695b1Sross #endif 1202df695b1Sross 1212df695b1Sross #ifdef BITS64 122*40c38bd9Sthorpej /*---------------------------------------------------------------------------- 123*40c38bd9Sthorpej | The `LIT64' macro takes as its argument a textual integer literal and 124*40c38bd9Sthorpej | if necessary ``marks'' the literal as having a 64-bit integer type. 125*40c38bd9Sthorpej | For example, the GNU C Compiler (`gcc') requires that 64-bit literals be 126*40c38bd9Sthorpej | appended with the letters `LL' standing for `long long', which is `gcc's 127*40c38bd9Sthorpej | name for the 64-bit integer type. Some compilers may allow `LIT64' to be 128*40c38bd9Sthorpej | defined as the identity macro: `#define LIT64( a ) a'. 129*40c38bd9Sthorpej *----------------------------------------------------------------------------*/ 1302df695b1Sross #define LIT64( a ) a##LL 1312df695b1Sross #endif 1322df695b1Sross 133*40c38bd9Sthorpej /*---------------------------------------------------------------------------- 134*40c38bd9Sthorpej | The macro `INLINE' can be used before functions that should be inlined. If 135*40c38bd9Sthorpej | a compiler does not support explicit inlining, this macro should be defined 136*40c38bd9Sthorpej | to be `static'. 137*40c38bd9Sthorpej *----------------------------------------------------------------------------*/ 13887fd18f8Schristos #define INLINE static __inline 1392df695b1Sross 140*40c38bd9Sthorpej #endif /* MILIEU_H */ 141