milieu.h revision 1.4
11.4Schristos/* $NetBSD: milieu.h,v 1.4 2018/04/19 21:50:09 christos Exp $ */ 21.1Sross 31.1Sross/* This is a derivative work. */ 41.1Sross 51.1Sross/*- 61.1Sross * Copyright (c) 2001 The NetBSD Foundation, Inc. 71.1Sross * All rights reserved. 81.1Sross * 91.1Sross * This code is derived from software contributed to The NetBSD Foundation 101.1Sross * by Ross Harvey. 111.1Sross * 121.1Sross * Redistribution and use in source and binary forms, with or without 131.1Sross * modification, are permitted provided that the following conditions 141.1Sross * are met: 151.1Sross * 1. Redistributions of source code must retain the above copyright 161.1Sross * notice, this list of conditions and the following disclaimer. 171.1Sross * 2. Redistributions in binary form must reproduce the above copyright 181.1Sross * notice, this list of conditions and the following disclaimer in the 191.1Sross * documentation and/or other materials provided with the distribution. 201.1Sross * 211.1Sross * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 221.1Sross * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 231.1Sross * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 241.1Sross * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 251.1Sross * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 261.1Sross * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 271.1Sross * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 281.1Sross * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 291.1Sross * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 301.1Sross * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 311.1Sross * POSSIBILITY OF SUCH DAMAGE. 321.1Sross */ 331.1Sross 341.1Sross/* 351.1Sross=============================================================================== 361.1Sross 371.1SrossThis C header file is part of TestFloat, Release 2a, a package of programs 381.1Srossfor testing the correctness of floating-point arithmetic complying to the 391.1SrossIEC/IEEE Standard for Floating-Point. 401.1Sross 411.1SrossWritten by John R. Hauser. More information is available through the Web 421.1Srosspage `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'. 431.1Sross 441.1SrossTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 451.1Srosshas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 461.1SrossTIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO 471.1SrossPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY 481.1SrossAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. 491.1Sross 501.1SrossDerivative works are acceptable, even for commercial purposes, so long as 511.1Sross(1) they include prominent notice that the work is derivative, and (2) they 521.1Srossinclude prominent notice akin to these four paragraphs for those parts of 531.1Srossthis code that are retained. 541.1Sross 551.1Sross=============================================================================== 561.1Sross*/ 571.1Sross 581.1Sross#ifndef MILIEU_H 591.1Sross#define MILIEU_H 601.1Sross 611.1Sross#if !defined(_KERNEL) && !defined(_STANDALONE) 621.1Sross#include <inttypes.h> 631.1Sross#else 641.1Sross#include <sys/inttypes.h> 651.1Sross#endif 661.1Sross 671.1Sross#include <sys/endian.h> 681.1Sross 691.1Sross/* 701.1Sross------------------------------------------------------------------------------- 711.1SrossOne of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. 721.1Sross------------------------------------------------------------------------------- 731.1Sross*/ 741.1Sross 751.1Sross#if _BYTE_ORDER == _LITTLE_ENDIAN 761.1Sross#define LITTLEENDIAN 771.1Sross#else 781.1Sross#define BIGENDIAN 791.1Sross#endif 801.1Sross 811.1Sross#define BITS64 821.1Sross 831.1Sross/* 841.1Sross------------------------------------------------------------------------------- 851.1SrossEach of the following `typedef's defines the most convenient type that holds 861.1Srossintegers of at least as many bits as specified. For example, `uint8' should 871.1Srossbe the most convenient type that can hold unsigned integers of as many as 881.1Sross8 bits. The `flag' type must be able to hold either a 0 or 1. For most 891.1Srossimplementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 901.1Srossto the same as `int'. 911.1Sross------------------------------------------------------------------------------- 921.1Sross*/ 931.1Srosstypedef int flag; 941.1Srosstypedef unsigned int uint8; 951.1Srosstypedef signed int int8; 961.1Srosstypedef unsigned int uint16; 971.1Srosstypedef int int16; 981.1Srosstypedef unsigned int uint32; 991.1Srosstypedef signed int int32; 1001.1Sross#ifdef BITS64 1011.1Srosstypedef uint64_t uint64; 1021.1Srosstypedef int64_t int64; 1031.1Sross#endif 1041.1Sross 1051.1Sross/* 1061.1Sross------------------------------------------------------------------------------- 1071.1SrossEach of the following `typedef's defines a type that holds integers 1081.1Srossof _exactly_ the number of bits specified. For instance, for most 1091.1Srossimplementation of C, `bits16' and `sbits16' should be `typedef'ed to 1101.1Sross`unsigned short int' and `signed short int' (or `short int'), respectively. 1111.1Sross------------------------------------------------------------------------------- 1121.1Sross*/ 1131.1Srosstypedef uint8_t bits8; 1141.1Srosstypedef int8_t sbits8; 1151.1Srosstypedef uint16_t bits16; 1161.1Srosstypedef int16_t sbits16; 1171.1Srosstypedef uint32_t bits32; 1181.1Srosstypedef int32_t sbits32; 1191.1Sross#ifdef BITS64 1201.1Srosstypedef uint64_t bits64; 1211.1Srosstypedef int64_t sbits64; 1221.1Sross#endif 1231.1Sross 1241.1Sross#ifdef BITS64 1251.1Sross/* 1261.1Sross------------------------------------------------------------------------------- 1271.1SrossThe `LIT64' macro takes as its argument a textual integer literal and 1281.1Srossif necessary ``marks'' the literal as having a 64-bit integer type. 1291.1SrossFor example, the GNU C Compiler (`gcc') requires that 64-bit literals be 1301.1Srossappended with the letters `LL' standing for `long long', which is `gcc's 1311.1Srossname for the 64-bit integer type. Some compilers may allow `LIT64' to be 1321.1Srossdefined as the identity macro: `#define LIT64( a ) a'. 1331.1Sross------------------------------------------------------------------------------- 1341.1Sross*/ 1351.1Sross#define LIT64( a ) a##LL 1361.1Sross#endif 1371.1Sross 1381.1Sross/* 1391.1Sross------------------------------------------------------------------------------- 1401.1SrossThe macro `INLINE' can be used before functions that should be inlined. If 1411.1Srossa compiler does not support explicit inlining, this macro should be defined 1421.1Srossto be `static'. 1431.1Sross------------------------------------------------------------------------------- 1441.1Sross*/ 1451.4Schristos#define INLINE static __inline 1461.1Sross 1471.1Sross#endif 148