milieu.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* $OpenBSD: milieu.h,v 1.3 2008/06/26 05:42:20 ray Exp $ */
  2. /* $NetBSD: milieu.h,v 1.1 2001/04/26 03:10:47 ross Exp $ */
  3. /* This is a derivative work. */
  4. /*-
  5. * Copyright (c) 2001 The NetBSD Foundation, Inc.
  6. * All rights reserved.
  7. *
  8. * This code is derived from software contributed to The NetBSD Foundation
  9. * by Ross Harvey.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  22. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  24. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. /*
  33. ===============================================================================
  34. This C header file is part of TestFloat, Release 2a, a package of programs
  35. for testing the correctness of floating-point arithmetic complying to the
  36. IEC/IEEE Standard for Floating-Point.
  37. Written by John R. Hauser. More information is available through the Web
  38. page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
  39. THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable
  40. effort has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT
  41. WILL AT TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS
  42. RESTRICTED TO PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL
  43. RESPONSIBILITY FOR ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM
  44. THEIR OWN USE OF THE SOFTWARE, AND WHO ALSO EFFECTIVELY INDEMNIFY
  45. (possibly via similar legal warning) JOHN HAUSER AND THE INTERNATIONAL
  46. COMPUTER SCIENCE INSTITUTE AGAINST ALL LOSSES, COSTS, OR OTHER PROBLEMS
  47. ARISING FROM THE USE OF THE SOFTWARE BY THEIR CUSTOMERS AND CLIENTS.
  48. Derivative works are acceptable, even for commercial purposes, so long as
  49. (1) they include prominent notice that the work is derivative, and (2) they
  50. include prominent notice akin to these four paragraphs for those parts of
  51. this code that are retained.
  52. ===============================================================================
  53. */
  54. #ifndef MILIEU_H
  55. #define MILIEU_H
  56. #include <sys/types.h>
  57. #include <sys/endian.h>
  58. enum {
  59. FALSE = 0,
  60. TRUE = 1
  61. };
  62. /*
  63. -------------------------------------------------------------------------------
  64. One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined.
  65. -------------------------------------------------------------------------------
  66. */
  67. #if _BYTE_ORDER == _LITTLE_ENDIAN
  68. #define LITTLEENDIAN
  69. #else
  70. #define BIGENDIAN
  71. #endif
  72. #define BITS64
  73. /*
  74. -------------------------------------------------------------------------------
  75. Each of the following `typedef's defines the most convenient type that holds
  76. integers of at least as many bits as specified. For example, `uint8' should
  77. be the most convenient type that can hold unsigned integers of as many as
  78. 8 bits. The `flag' type must be able to hold either a 0 or 1. For most
  79. implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
  80. to the same as `int'.
  81. -------------------------------------------------------------------------------
  82. */
  83. typedef int flag;
  84. typedef unsigned int uint8;
  85. typedef signed int int8;
  86. typedef unsigned int uint16;
  87. typedef int int16;
  88. typedef unsigned int uint32;
  89. typedef signed int int32;
  90. #ifdef BITS64
  91. typedef uint64_t uint64;
  92. typedef int64_t int64;
  93. #endif
  94. /*
  95. -------------------------------------------------------------------------------
  96. Each of the following `typedef's defines a type that holds integers
  97. of _exactly_ the number of bits specified. For instance, for most
  98. implementation of C, `bits16' and `sbits16' should be `typedef'ed to
  99. `unsigned short int' and `signed short int' (or `short int'), respectively.
  100. -------------------------------------------------------------------------------
  101. */
  102. typedef uint8_t bits8;
  103. typedef int8_t sbits8;
  104. typedef uint16_t bits16;
  105. typedef int16_t sbits16;
  106. typedef uint32_t bits32;
  107. typedef int32_t sbits32;
  108. #ifdef BITS64
  109. typedef uint64_t bits64;
  110. typedef int64_t sbits64;
  111. #endif
  112. #ifdef BITS64
  113. /*
  114. -------------------------------------------------------------------------------
  115. The `LIT64' macro takes as its argument a textual integer literal and
  116. if necessary ``marks'' the literal as having a 64-bit integer type.
  117. For example, the GNU C Compiler (`gcc') requires that 64-bit literals be
  118. appended with the letters `LL' standing for `long long', which is `gcc's
  119. name for the 64-bit integer type. Some compilers may allow `LIT64' to be
  120. defined as the identity macro: `#define LIT64( a ) a'.
  121. -------------------------------------------------------------------------------
  122. */
  123. #define LIT64( a ) a##LL
  124. #endif
  125. /*
  126. -------------------------------------------------------------------------------
  127. The macro `INLINE' can be used before functions that should be inlined. If
  128. a compiler does not support explicit inlining, this macro should be defined
  129. to be `static'.
  130. -------------------------------------------------------------------------------
  131. */
  132. #define INLINE static inline
  133. #endif