ieeefp.h 9.7 KB

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