ieeefp.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. #ifndef __IEEE_BIG_ENDIAN
  2. #ifndef __IEEE_LITTLE_ENDIAN
  3. /* This file can define macros to choose variations of the IEEE float
  4. format:
  5. _FLT_LARGEST_EXPONENT_IS_NORMAL
  6. Defined if the float format uses the largest exponent for finite
  7. numbers rather than NaN and infinity representations. Such a
  8. format cannot represent NaNs or infinities at all, but it's FLT_MAX
  9. is twice the IEEE value.
  10. _FLT_NO_DENORMALS
  11. Defined if the float format does not support IEEE denormals. Every
  12. float with a zero exponent is taken to be a zero representation.
  13. ??? At the moment, there are no equivalent macros above for doubles and
  14. the macros are not fully supported by --enable-newlib-hw-fp.
  15. __IEEE_BIG_ENDIAN
  16. Defined if the float format is big endian. This is mutually exclusive
  17. with __IEEE_LITTLE_ENDIAN.
  18. __IEEE_LITTLE_ENDIAN
  19. Defined if the float format is little endian. This is mutually exclusive
  20. with __IEEE_BIG_ENDIAN.
  21. Note that one of __IEEE_BIG_ENDIAN or __IEEE_LITTLE_ENDIAN must be specified for a
  22. platform or error will occur.
  23. __IEEE_BYTES_LITTLE_ENDIAN
  24. This flag is used in conjunction with __IEEE_BIG_ENDIAN to describe a situation
  25. whereby multiple words of an IEEE floating point are in big endian order, but the
  26. words themselves are little endian with respect to the bytes.
  27. _DOUBLE_IS_32BITS
  28. This is used on platforms that support double by using the 32-bit IEEE
  29. float type.
  30. _FLOAT_ARG
  31. This represents what type a float arg is passed as. It is used when the type is
  32. not promoted to double.
  33. */
  34. #ifdef __HAVE_SHORT_DOUBLE__
  35. #if (__SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__)
  36. #define _DOUBLE_IS_32BITS
  37. #endif
  38. #endif
  39. #ifdef __tricore__
  40. #define __IEEE_LITTLE_ENDIAN
  41. #endif
  42. #if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
  43. /* ARM traditionally used big-endian words; and within those words the
  44. byte ordering was big or little endian depending upon the target.
  45. Modern floating-point formats are naturally ordered; in this case
  46. __VFP_FP__ will be defined, even if soft-float. */
  47. #ifdef __VFP_FP__
  48. # ifdef __ARMEL__
  49. # define __IEEE_LITTLE_ENDIAN
  50. # else
  51. # define __IEEE_BIG_ENDIAN
  52. # endif
  53. #else
  54. # ifdef __ARMEL__
  55. # define __IEEE_LITTLE_ENDIAN
  56. # else
  57. # define __IEEE_BIG_ENDIAN
  58. # endif
  59. # ifdef __ARMWEL__
  60. # define __IEEE_BYTES_LITTLE_ENDIAN
  61. # endif
  62. #endif
  63. #endif
  64. #ifdef __hppa__
  65. #define __IEEE_BIG_ENDIAN
  66. #endif
  67. #ifdef __SPU__
  68. #define __IEEE_BIG_ENDIAN
  69. #define isfinite(y) \
  70. (__extension__ ({__typeof__(y) __y = (y); \
  71. (sizeof (__y) == sizeof (float)) ? (1) : \
  72. fpclassify(__y) != FP_INFINITE && fpclassify(__y) != FP_NAN;}))
  73. #define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x))
  74. #define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x))
  75. /*
  76. * Macros for use in ieeefp.h. We can't just define the real ones here
  77. * (like those above) as we have name space issues when this is *not*
  78. * included via generic the ieeefp.h.
  79. */
  80. #define __ieeefp_isnanf(x) 0
  81. #define __ieeefp_isinff(x) 0
  82. #define __ieeefp_finitef(x) 1
  83. #endif
  84. #ifdef __sparc__
  85. #ifdef __LITTLE_ENDIAN_DATA__
  86. #define __IEEE_LITTLE_ENDIAN
  87. #else
  88. #define __IEEE_BIG_ENDIAN
  89. #endif
  90. #endif
  91. #if defined(__m68k__) || defined(__mc68000__)
  92. #define __IEEE_BIG_ENDIAN
  93. #endif
  94. #if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
  95. #define __IEEE_BIG_ENDIAN
  96. #endif
  97. #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
  98. #define __IEEE_BIG_ENDIAN
  99. #define _FLOAT_ARG float
  100. #define _DOUBLE_IS_32BITS
  101. #endif
  102. #if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
  103. #define __IEEE_LITTLE_ENDIAN
  104. #define _FLOAT_ARG float
  105. #define _DOUBLE_IS_32BITS
  106. #endif
  107. #ifdef __sh__
  108. #ifdef __LITTLE_ENDIAN__
  109. #define __IEEE_LITTLE_ENDIAN
  110. #else
  111. #define __IEEE_BIG_ENDIAN
  112. #endif
  113. #if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__)
  114. #define _DOUBLE_IS_32BITS
  115. #endif
  116. #endif
  117. #ifdef _AM29K
  118. #define __IEEE_BIG_ENDIAN
  119. #endif
  120. #ifdef _WIN32
  121. #define __IEEE_LITTLE_ENDIAN
  122. #endif
  123. #ifdef __i386__
  124. #define __IEEE_LITTLE_ENDIAN
  125. #endif
  126. #ifdef __i960__
  127. #define __IEEE_LITTLE_ENDIAN
  128. #endif
  129. #ifdef __lm32__
  130. #define __IEEE_BIG_ENDIAN
  131. #endif
  132. #ifdef __M32R__
  133. #define __IEEE_BIG_ENDIAN
  134. #endif
  135. #if defined(_C4x) || defined(_C3x)
  136. #define __IEEE_BIG_ENDIAN
  137. #define _DOUBLE_IS_32BITS
  138. #endif
  139. #ifdef __TIC80__
  140. #define __IEEE_LITTLE_ENDIAN
  141. #endif
  142. #ifdef __MIPSEL__
  143. #define __IEEE_LITTLE_ENDIAN
  144. #endif
  145. #ifdef __MIPSEB__
  146. #define __IEEE_BIG_ENDIAN
  147. #endif
  148. #ifdef __MMIX__
  149. #define __IEEE_BIG_ENDIAN
  150. #endif
  151. #ifdef __D30V__
  152. #define __IEEE_BIG_ENDIAN
  153. #endif
  154. /* necv70 was __IEEE_LITTLE_ENDIAN. */
  155. #ifdef __W65__
  156. #define __IEEE_LITTLE_ENDIAN
  157. #define _DOUBLE_IS_32BITS
  158. #endif
  159. #if defined(__Z8001__) || defined(__Z8002__)
  160. #define __IEEE_BIG_ENDIAN
  161. #endif
  162. #ifdef __m88k__
  163. #define __IEEE_BIG_ENDIAN
  164. #endif
  165. #ifdef __mn10300__
  166. #define __IEEE_LITTLE_ENDIAN
  167. #endif
  168. #ifdef __mn10200__
  169. #define __IEEE_LITTLE_ENDIAN
  170. #define _DOUBLE_IS_32BITS
  171. #endif
  172. #ifdef __v800
  173. #define __IEEE_LITTLE_ENDIAN
  174. #endif
  175. #ifdef __v850
  176. #define __IEEE_LITTLE_ENDIAN
  177. #endif
  178. #ifdef __D10V__
  179. #define __IEEE_BIG_ENDIAN
  180. #if __DOUBLE__ == 32
  181. #define _DOUBLE_IS_32BITS
  182. #endif
  183. #endif
  184. #ifdef __PPC__
  185. #if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
  186. #define __IEEE_BIG_ENDIAN
  187. #else
  188. #if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32)
  189. #define __IEEE_LITTLE_ENDIAN
  190. #endif
  191. #endif
  192. #endif
  193. #ifdef __xstormy16__
  194. #define __IEEE_LITTLE_ENDIAN
  195. #endif
  196. #ifdef __arc__
  197. #ifdef __big_endian__
  198. #define __IEEE_BIG_ENDIAN
  199. #else
  200. #define __IEEE_LITTLE_ENDIAN
  201. #endif
  202. #endif
  203. #ifdef __CRX__
  204. #define __IEEE_LITTLE_ENDIAN
  205. #endif
  206. #ifdef __fr30__
  207. #define __IEEE_BIG_ENDIAN
  208. #endif
  209. #ifdef __mcore__
  210. #define __IEEE_BIG_ENDIAN
  211. #endif
  212. #ifdef __mt__
  213. #define __IEEE_BIG_ENDIAN
  214. #endif
  215. #ifdef __frv__
  216. #define __IEEE_BIG_ENDIAN
  217. #endif
  218. #ifdef __moxie__
  219. #define __IEEE_BIG_ENDIAN
  220. #endif
  221. #ifdef __ia64__
  222. #ifdef __BIG_ENDIAN__
  223. #define __IEEE_BIG_ENDIAN
  224. #else
  225. #define __IEEE_LITTLE_ENDIAN
  226. #endif
  227. #endif
  228. #ifdef __AVR__
  229. #define __IEEE_LITTLE_ENDIAN
  230. #define _DOUBLE_IS_32BITS
  231. #endif
  232. #if defined(__or32__) || defined(__or1k__) || defined(__or16__)
  233. #define __IEEE_BIG_ENDIAN
  234. #endif
  235. #ifdef __IP2K__
  236. #define __IEEE_BIG_ENDIAN
  237. #define __SMALL_BITFIELDS
  238. #define _DOUBLE_IS_32BITS
  239. #endif
  240. #ifdef __iq2000__
  241. #define __IEEE_BIG_ENDIAN
  242. #endif
  243. #ifdef __MAVERICK__
  244. #ifdef __ARMEL__
  245. # define __IEEE_LITTLE_ENDIAN
  246. #else /* must be __ARMEB__ */
  247. # define __IEEE_BIG_ENDIAN
  248. #endif /* __ARMEL__ */
  249. #endif /* __MAVERICK__ */
  250. #ifdef __m32c__
  251. #define __IEEE_LITTLE_ENDIAN
  252. #define __SMALL_BITFIELDS
  253. #endif
  254. #ifdef __CRIS__
  255. #define __IEEE_LITTLE_ENDIAN
  256. #endif
  257. #ifdef __BFIN__
  258. #define __IEEE_LITTLE_ENDIAN
  259. #endif
  260. #ifdef __x86_64__
  261. #define __IEEE_LITTLE_ENDIAN
  262. #endif
  263. #ifdef __mep__
  264. #ifdef __LITTLE_ENDIAN__
  265. #define __IEEE_LITTLE_ENDIAN
  266. #else
  267. #define __IEEE_BIG_ENDIAN
  268. #endif
  269. #endif
  270. #ifdef __MICROBLAZE__
  271. #define __IEEE_BIG_ENDIAN
  272. #endif
  273. #ifdef __RX__
  274. #ifdef __RX_BIG_ENDIAN__
  275. #define __IEEE_BIG_ENDIAN
  276. #else
  277. #define __IEEE_LITTLE_ENDIAN
  278. #endif
  279. #ifndef __RX_64BIT_DOUBLES__
  280. #define _DOUBLE_IS_32BITS
  281. #endif
  282. #ifdef __RX_16BIT_INTS__
  283. #define __SMALL_BITFIELDS
  284. #endif
  285. #endif
  286. #ifndef __IEEE_BIG_ENDIAN
  287. #ifndef __IEEE_LITTLE_ENDIAN
  288. #error Endianess not declared!!
  289. #endif /* not __IEEE_LITTLE_ENDIAN */
  290. #endif /* not __IEEE_BIG_ENDIAN */
  291. #endif /* not __IEEE_LITTLE_ENDIAN */
  292. #endif /* not __IEEE_BIG_ENDIAN */