ieeefp.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. #if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
  35. /* ARM traditionally used big-endian words; and within those words the
  36. byte ordering was big or little endian depending upon the target.
  37. Modern floating-point formats are naturally ordered; in this case
  38. __VFP_FP__ will be defined, even if soft-float. */
  39. #ifdef __VFP_FP__
  40. # ifdef __ARMEL__
  41. # define __IEEE_LITTLE_ENDIAN
  42. # else
  43. # define __IEEE_BIG_ENDIAN
  44. # endif
  45. #else
  46. # define __IEEE_BIG_ENDIAN
  47. # ifdef __ARMEL__
  48. # define __IEEE_BYTES_LITTLE_ENDIAN
  49. # endif
  50. #endif
  51. #endif
  52. #if defined (__aarch64__)
  53. #if defined (__AARCH64EL__)
  54. #define __IEEE_LITTLE_ENDIAN
  55. #else
  56. #define __IEEE_BIG_ENDIAN
  57. #endif
  58. #endif
  59. #ifdef __epiphany__
  60. #define __IEEE_LITTLE_ENDIAN
  61. #define Sudden_Underflow 1
  62. #endif
  63. #ifdef __hppa__
  64. #define __IEEE_BIG_ENDIAN
  65. #endif
  66. #ifdef __nds32__
  67. #ifdef __big_endian__
  68. #define __IEEE_BIG_ENDIAN
  69. #else
  70. #define __IEEE_LITTLE_ENDIAN
  71. #endif
  72. #endif
  73. #ifdef __SPU__
  74. #define __IEEE_BIG_ENDIAN
  75. #define isfinite(__y) \
  76. (__extension__ ({int __cy; \
  77. (sizeof (__y) == sizeof (float)) ? (1) : \
  78. (__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;}))
  79. #define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x))
  80. #define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x))
  81. /*
  82. * Macros for use in ieeefp.h. We can't just define the real ones here
  83. * (like those above) as we have name space issues when this is *not*
  84. * included via generic the ieeefp.h.
  85. */
  86. #define __ieeefp_isnanf(x) 0
  87. #define __ieeefp_isinff(x) 0
  88. #define __ieeefp_finitef(x) 1
  89. #endif
  90. #ifdef __sparc__
  91. #ifdef __LITTLE_ENDIAN_DATA__
  92. #define __IEEE_LITTLE_ENDIAN
  93. #else
  94. #define __IEEE_BIG_ENDIAN
  95. #endif
  96. #endif
  97. #if defined(__m68k__) || defined(__mc68000__)
  98. #define __IEEE_BIG_ENDIAN
  99. #endif
  100. #if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
  101. #define __IEEE_BIG_ENDIAN
  102. #ifdef __HAVE_SHORT_DOUBLE__
  103. # define _DOUBLE_IS_32BITS
  104. #endif
  105. #endif
  106. #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
  107. #define __IEEE_BIG_ENDIAN
  108. #define _FLOAT_ARG float
  109. #define _DOUBLE_IS_32BITS
  110. #endif
  111. #if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
  112. #define __IEEE_LITTLE_ENDIAN
  113. #define _FLOAT_ARG float
  114. #define _DOUBLE_IS_32BITS
  115. #endif
  116. #ifdef __sh__
  117. #ifdef __LITTLE_ENDIAN__
  118. #define __IEEE_LITTLE_ENDIAN
  119. #else
  120. #define __IEEE_BIG_ENDIAN
  121. #endif
  122. #if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__)
  123. #define _DOUBLE_IS_32BITS
  124. #endif
  125. #endif
  126. #ifdef _AM29K
  127. #define __IEEE_BIG_ENDIAN
  128. #endif
  129. #ifdef _WIN32
  130. #define __IEEE_LITTLE_ENDIAN
  131. #endif
  132. #ifdef __i386__
  133. #define __IEEE_LITTLE_ENDIAN
  134. #endif
  135. #ifdef __i960__
  136. #define __IEEE_LITTLE_ENDIAN
  137. #endif
  138. #ifdef __lm32__
  139. #define __IEEE_BIG_ENDIAN
  140. #endif
  141. #ifdef __M32R__
  142. #define __IEEE_BIG_ENDIAN
  143. #endif
  144. #if defined(_C4x) || defined(_C3x)
  145. #define __IEEE_BIG_ENDIAN
  146. #define _DOUBLE_IS_32BITS
  147. #endif
  148. #ifdef __TMS320C6X__
  149. #ifdef _BIG_ENDIAN
  150. #define __IEEE_BIG_ENDIAN
  151. #else
  152. #define __IEEE_LITTLE_ENDIAN
  153. #endif
  154. #endif
  155. #ifdef __TIC80__
  156. #define __IEEE_LITTLE_ENDIAN
  157. #endif
  158. #ifdef __MIPSEL__
  159. #define __IEEE_LITTLE_ENDIAN
  160. #endif
  161. #ifdef __MIPSEB__
  162. #define __IEEE_BIG_ENDIAN
  163. #endif
  164. #ifdef __MMIX__
  165. #define __IEEE_BIG_ENDIAN
  166. #endif
  167. #ifdef __D30V__
  168. #define __IEEE_BIG_ENDIAN
  169. #endif
  170. /* necv70 was __IEEE_LITTLE_ENDIAN. */
  171. #ifdef __W65__
  172. #define __IEEE_LITTLE_ENDIAN
  173. #define _DOUBLE_IS_32BITS
  174. #endif
  175. #if defined(__Z8001__) || defined(__Z8002__)
  176. #define __IEEE_BIG_ENDIAN
  177. #endif
  178. #ifdef __m88k__
  179. #define __IEEE_BIG_ENDIAN
  180. #endif
  181. #ifdef __mn10300__
  182. #define __IEEE_LITTLE_ENDIAN
  183. #endif
  184. #ifdef __mn10200__
  185. #define __IEEE_LITTLE_ENDIAN
  186. #define _DOUBLE_IS_32BITS
  187. #endif
  188. #ifdef __v800
  189. #define __IEEE_LITTLE_ENDIAN
  190. #endif
  191. #ifdef __v850
  192. #define __IEEE_LITTLE_ENDIAN
  193. #endif
  194. #ifdef __D10V__
  195. #define __IEEE_BIG_ENDIAN
  196. #if __DOUBLE__ == 32
  197. #define _DOUBLE_IS_32BITS
  198. #endif
  199. #endif
  200. #ifdef __PPC__
  201. #if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
  202. #define __IEEE_BIG_ENDIAN
  203. #else
  204. #if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32)
  205. #define __IEEE_LITTLE_ENDIAN
  206. #endif
  207. #endif
  208. #endif
  209. #ifdef __xstormy16__
  210. #define __IEEE_LITTLE_ENDIAN
  211. #endif
  212. #ifdef __arc__
  213. #ifdef __big_endian__
  214. #define __IEEE_BIG_ENDIAN
  215. #else
  216. #define __IEEE_LITTLE_ENDIAN
  217. #endif
  218. #endif
  219. #ifdef __CRX__
  220. #define __IEEE_LITTLE_ENDIAN
  221. #endif
  222. #ifdef __fr30__
  223. #define __IEEE_BIG_ENDIAN
  224. #endif
  225. #ifdef __mcore__
  226. #define __IEEE_BIG_ENDIAN
  227. #endif
  228. #ifdef __mt__
  229. #define __IEEE_BIG_ENDIAN
  230. #endif
  231. #ifdef __frv__
  232. #define __IEEE_BIG_ENDIAN
  233. #endif
  234. #ifdef __moxie__
  235. #ifdef __MOXIE_BIG_ENDIAN__
  236. #define __IEEE_BIG_ENDIAN
  237. #else
  238. #define __IEEE_LITTLE_ENDIAN
  239. #endif
  240. #endif
  241. #ifdef __ia64__
  242. #ifdef __BIG_ENDIAN__
  243. #define __IEEE_BIG_ENDIAN
  244. #else
  245. #define __IEEE_LITTLE_ENDIAN
  246. #endif
  247. #endif
  248. #ifdef __AVR__
  249. #define __IEEE_LITTLE_ENDIAN
  250. #define _DOUBLE_IS_32BITS
  251. #endif
  252. #if defined(__or1k__) || defined(__OR1K__) || defined(__OR1KND__)
  253. #define __IEEE_BIG_ENDIAN
  254. #endif
  255. #ifdef __IP2K__
  256. #define __IEEE_BIG_ENDIAN
  257. #define __SMALL_BITFIELDS
  258. #define _DOUBLE_IS_32BITS
  259. #endif
  260. #ifdef __iq2000__
  261. #define __IEEE_BIG_ENDIAN
  262. #endif
  263. #ifdef __MAVERICK__
  264. #ifdef __ARMEL__
  265. # define __IEEE_LITTLE_ENDIAN
  266. #else /* must be __ARMEB__ */
  267. # define __IEEE_BIG_ENDIAN
  268. #endif /* __ARMEL__ */
  269. #endif /* __MAVERICK__ */
  270. #ifdef __m32c__
  271. #define __IEEE_LITTLE_ENDIAN
  272. #define __SMALL_BITFIELDS
  273. #endif
  274. #ifdef __CRIS__
  275. #define __IEEE_LITTLE_ENDIAN
  276. #endif
  277. #ifdef __BFIN__
  278. #define __IEEE_LITTLE_ENDIAN
  279. #endif
  280. #ifdef __x86_64__
  281. #define __IEEE_LITTLE_ENDIAN
  282. #endif
  283. #ifdef __mep__
  284. #ifdef __LITTLE_ENDIAN__
  285. #define __IEEE_LITTLE_ENDIAN
  286. #else
  287. #define __IEEE_BIG_ENDIAN
  288. #endif
  289. #endif
  290. #ifdef __MICROBLAZE__
  291. #ifndef __MICROBLAZEEL__
  292. #define __IEEE_BIG_ENDIAN
  293. #else
  294. #define __IEEE_LITTLE_ENDIAN
  295. #endif
  296. #endif
  297. #ifdef __MSP430__
  298. #define __IEEE_LITTLE_ENDIAN
  299. #define __SMALL_BITFIELDS /* 16 Bit INT */
  300. #endif
  301. #ifdef __RL78__
  302. #define __IEEE_LITTLE_ENDIAN
  303. #define __SMALL_BITFIELDS /* 16 Bit INT */
  304. #ifndef __RL78_64BIT_DOUBLES__
  305. #define _DOUBLE_IS_32BITS
  306. #endif
  307. #endif
  308. #ifdef __RX__
  309. #ifdef __RX_BIG_ENDIAN__
  310. #define __IEEE_BIG_ENDIAN
  311. #else
  312. #define __IEEE_LITTLE_ENDIAN
  313. #endif
  314. #ifndef __RX_64BIT_DOUBLES__
  315. #define _DOUBLE_IS_32BITS
  316. #endif
  317. #ifdef __RX_16BIT_INTS__
  318. #define __SMALL_BITFIELDS
  319. #endif
  320. #endif
  321. #if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
  322. #define __IEEE_LITTLE_ENDIAN
  323. #define __SMALL_BITFIELDS /* 16 Bit INT */
  324. #endif
  325. #ifdef __NIOS2__
  326. # ifdef __nios2_big_endian__
  327. # define __IEEE_BIG_ENDIAN
  328. # else
  329. # define __IEEE_LITTLE_ENDIAN
  330. # endif
  331. #endif
  332. #if (defined(__XTENSA__))
  333. # ifdef __XTENSA_EB__
  334. # define __IEEE_BIG_ENDIAN
  335. # else
  336. # define __IEEE_LITTLE_ENDIAN
  337. # endif
  338. #endif
  339. #ifndef __IEEE_BIG_ENDIAN
  340. #ifndef __IEEE_LITTLE_ENDIAN
  341. #error Endianess not declared!!
  342. #endif /* not __IEEE_LITTLE_ENDIAN */
  343. #endif /* not __IEEE_BIG_ENDIAN */
  344. #endif /* not __IEEE_LITTLE_ENDIAN */
  345. #endif /* not __IEEE_BIG_ENDIAN */