ieeefp.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. #ifndef __SOFTFP__
  68. # define _SUPPORTS_ERREXCEPT
  69. #endif
  70. #endif
  71. #if defined (__aarch64__)
  72. #if defined (__AARCH64EL__)
  73. #define __IEEE_LITTLE_ENDIAN
  74. #else
  75. #define __IEEE_BIG_ENDIAN
  76. #endif
  77. #define __OBSOLETE_MATH_DEFAULT 0
  78. #ifdef __ARM_FP
  79. # define _SUPPORTS_ERREXCEPT
  80. #endif
  81. #endif
  82. #ifdef __epiphany__
  83. #define __IEEE_LITTLE_ENDIAN
  84. #define Sudden_Underflow 1
  85. #endif
  86. #ifdef __hppa__
  87. #define __IEEE_BIG_ENDIAN
  88. #endif
  89. #ifdef __nds32__
  90. #ifdef __big_endian__
  91. #define __IEEE_BIG_ENDIAN
  92. #else
  93. #define __IEEE_LITTLE_ENDIAN
  94. #endif
  95. #endif
  96. #ifdef __SPU__
  97. #define __IEEE_BIG_ENDIAN
  98. #define isfinite(__y) \
  99. (__extension__ ({int __cy; \
  100. (sizeof (__y) == sizeof (float)) ? (1) : \
  101. (__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;}))
  102. #define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x))
  103. #define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x))
  104. /*
  105. * Macros for use in ieeefp.h. We can't just define the real ones here
  106. * (like those above) as we have name space issues when this is *not*
  107. * included via generic the ieeefp.h.
  108. */
  109. #define __ieeefp_isnanf(x) 0
  110. #define __ieeefp_isinff(x) 0
  111. #define __ieeefp_finitef(x) 1
  112. #endif
  113. #ifdef __sparc__
  114. #ifdef __LITTLE_ENDIAN_DATA__
  115. #define __IEEE_LITTLE_ENDIAN
  116. #else
  117. #define __IEEE_BIG_ENDIAN
  118. #endif
  119. #endif
  120. #if defined(__m68k__) || defined(__mc68000__)
  121. #define __IEEE_BIG_ENDIAN
  122. #endif
  123. #if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
  124. #define __IEEE_BIG_ENDIAN
  125. #ifdef __HAVE_SHORT_DOUBLE__
  126. # define _DOUBLE_IS_32BITS
  127. #endif
  128. #endif
  129. #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
  130. #define __IEEE_BIG_ENDIAN
  131. #define _FLOAT_ARG float
  132. #define _DOUBLE_IS_32BITS
  133. #endif
  134. #if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
  135. #define __IEEE_LITTLE_ENDIAN
  136. #define _FLOAT_ARG float
  137. #define _DOUBLE_IS_32BITS
  138. #endif
  139. #ifdef __sh__
  140. #ifdef __LITTLE_ENDIAN__
  141. #define __IEEE_LITTLE_ENDIAN
  142. #else
  143. #define __IEEE_BIG_ENDIAN
  144. #endif
  145. #if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__)
  146. #define _DOUBLE_IS_32BITS
  147. #endif
  148. #endif
  149. #ifdef _AM29K
  150. #define __IEEE_BIG_ENDIAN
  151. #endif
  152. #ifdef _WIN32
  153. #define __IEEE_LITTLE_ENDIAN
  154. #endif
  155. #ifdef __i386__
  156. #define __IEEE_LITTLE_ENDIAN
  157. # define _SUPPORTS_ERREXCEPT
  158. #endif
  159. #ifdef __riscv
  160. #define __IEEE_LITTLE_ENDIAN
  161. #ifdef __riscv_flen
  162. # define _SUPPORTS_ERREXCEPT
  163. #endif
  164. #endif
  165. #ifdef __i960__
  166. #define __IEEE_LITTLE_ENDIAN
  167. #endif
  168. #ifdef __lm32__
  169. #define __IEEE_BIG_ENDIAN
  170. #endif
  171. #ifdef __M32R__
  172. #define __IEEE_BIG_ENDIAN
  173. #endif
  174. #ifdef __nvptx__
  175. #define __IEEE_LITTLE_ENDIAN
  176. #endif
  177. #if defined(_C4x) || defined(_C3x)
  178. #define __IEEE_BIG_ENDIAN
  179. #define _DOUBLE_IS_32BITS
  180. #endif
  181. #ifdef __TMS320C6X__
  182. #ifdef _BIG_ENDIAN
  183. #define __IEEE_BIG_ENDIAN
  184. #else
  185. #define __IEEE_LITTLE_ENDIAN
  186. #endif
  187. #endif
  188. #ifdef __TIC80__
  189. #define __IEEE_LITTLE_ENDIAN
  190. #endif
  191. #ifdef __MIPSEL__
  192. #define __IEEE_LITTLE_ENDIAN
  193. #endif
  194. #ifdef __MIPSEB__
  195. #define __IEEE_BIG_ENDIAN
  196. #endif
  197. #ifdef __MMIX__
  198. #define __IEEE_BIG_ENDIAN
  199. #endif
  200. #ifdef __D30V__
  201. #define __IEEE_BIG_ENDIAN
  202. #endif
  203. /* necv70 was __IEEE_LITTLE_ENDIAN. */
  204. #ifdef __W65__
  205. #define __IEEE_LITTLE_ENDIAN
  206. #define _DOUBLE_IS_32BITS
  207. #endif
  208. #if defined(__Z8001__) || defined(__Z8002__)
  209. #define __IEEE_BIG_ENDIAN
  210. #endif
  211. #ifdef __m88k__
  212. #define __IEEE_BIG_ENDIAN
  213. #endif
  214. #ifdef __mn10300__
  215. #define __IEEE_LITTLE_ENDIAN
  216. #endif
  217. #ifdef __mn10200__
  218. #define __IEEE_LITTLE_ENDIAN
  219. #define _DOUBLE_IS_32BITS
  220. #endif
  221. #ifdef __v800
  222. #define __IEEE_LITTLE_ENDIAN
  223. #endif
  224. #ifdef __v850
  225. #define __IEEE_LITTLE_ENDIAN
  226. #endif
  227. #ifdef __D10V__
  228. #define __IEEE_BIG_ENDIAN
  229. #if __DOUBLE__ == 32
  230. #define _DOUBLE_IS_32BITS
  231. #endif
  232. #endif
  233. #ifdef __PPC__
  234. #if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
  235. #define __IEEE_BIG_ENDIAN
  236. #else
  237. #if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32)
  238. #define __IEEE_LITTLE_ENDIAN
  239. #endif
  240. #endif
  241. #endif
  242. #ifdef __xstormy16__
  243. #define __IEEE_LITTLE_ENDIAN
  244. #endif
  245. #ifdef __arc__
  246. #ifdef __big_endian__
  247. #define __IEEE_BIG_ENDIAN
  248. #else
  249. #define __IEEE_LITTLE_ENDIAN
  250. #endif
  251. #endif
  252. #ifdef __CRX__
  253. #define __IEEE_LITTLE_ENDIAN
  254. #endif
  255. #ifdef __CSKY__
  256. #ifdef __CSKYBE__
  257. #define __IEEE_BIG_ENDIAN
  258. #else
  259. #define __IEEE_LITTLE_ENDIAN
  260. #endif
  261. #endif
  262. #ifdef __fr30__
  263. #define __IEEE_BIG_ENDIAN
  264. #endif
  265. #ifdef __FT32__
  266. #define __IEEE_LITTLE_ENDIAN
  267. #endif
  268. #ifdef __mcore__
  269. #define __IEEE_BIG_ENDIAN
  270. #endif
  271. #ifdef __mt__
  272. #define __IEEE_BIG_ENDIAN
  273. #endif
  274. #ifdef __frv__
  275. #define __IEEE_BIG_ENDIAN
  276. #endif
  277. #ifdef __moxie__
  278. #ifdef __MOXIE_BIG_ENDIAN__
  279. #define __IEEE_BIG_ENDIAN
  280. #else
  281. #define __IEEE_LITTLE_ENDIAN
  282. #endif
  283. #endif
  284. #ifdef __ia64__
  285. #ifdef __BIG_ENDIAN__
  286. #define __IEEE_BIG_ENDIAN
  287. #else
  288. #define __IEEE_LITTLE_ENDIAN
  289. #endif
  290. #endif
  291. #ifdef __AVR__
  292. #define __IEEE_LITTLE_ENDIAN
  293. #define _DOUBLE_IS_32BITS
  294. #endif
  295. #if defined(__or1k__) || defined(__OR1K__) || defined(__OR1KND__)
  296. #define __IEEE_BIG_ENDIAN
  297. #endif
  298. #ifdef __IP2K__
  299. #define __IEEE_BIG_ENDIAN
  300. #define __SMALL_BITFIELDS
  301. #define _DOUBLE_IS_32BITS
  302. #endif
  303. #ifdef __iq2000__
  304. #define __IEEE_BIG_ENDIAN
  305. #endif
  306. #ifdef __MAVERICK__
  307. #ifdef __ARMEL__
  308. # define __IEEE_LITTLE_ENDIAN
  309. #else /* must be __ARMEB__ */
  310. # define __IEEE_BIG_ENDIAN
  311. #endif /* __ARMEL__ */
  312. #endif /* __MAVERICK__ */
  313. #ifdef __m32c__
  314. #define __IEEE_LITTLE_ENDIAN
  315. #define __SMALL_BITFIELDS
  316. #endif
  317. #ifdef __CRIS__
  318. #define __IEEE_LITTLE_ENDIAN
  319. #endif
  320. #ifdef __BFIN__
  321. #define __IEEE_LITTLE_ENDIAN
  322. #endif
  323. #ifdef __x86_64__
  324. #define __IEEE_LITTLE_ENDIAN
  325. # define _SUPPORTS_ERREXCEPT
  326. #endif
  327. #ifdef __mep__
  328. #ifdef __LITTLE_ENDIAN__
  329. #define __IEEE_LITTLE_ENDIAN
  330. #else
  331. #define __IEEE_BIG_ENDIAN
  332. #endif
  333. #endif
  334. #ifdef __MICROBLAZE__
  335. #ifndef __MICROBLAZEEL__
  336. #define __IEEE_BIG_ENDIAN
  337. #else
  338. #define __IEEE_LITTLE_ENDIAN
  339. #endif
  340. #endif
  341. #ifdef __MSP430__
  342. #define __IEEE_LITTLE_ENDIAN
  343. #define __SMALL_BITFIELDS /* 16 Bit INT */
  344. #endif
  345. #ifdef __PRU__
  346. #define __IEEE_LITTLE_ENDIAN
  347. #endif
  348. #ifdef __RL78__
  349. #define __IEEE_LITTLE_ENDIAN
  350. #define __SMALL_BITFIELDS /* 16 Bit INT */
  351. #ifndef __RL78_64BIT_DOUBLES__
  352. #define _DOUBLE_IS_32BITS
  353. #endif
  354. #endif
  355. #ifdef __RX__
  356. #ifdef __RX_BIG_ENDIAN__
  357. #define __IEEE_BIG_ENDIAN
  358. #else
  359. #define __IEEE_LITTLE_ENDIAN
  360. #endif
  361. #ifndef __RX_64BIT_DOUBLES__
  362. #define _DOUBLE_IS_32BITS
  363. #endif
  364. #ifdef __RX_16BIT_INTS__
  365. #define __SMALL_BITFIELDS
  366. #endif
  367. #endif
  368. #if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
  369. #define __IEEE_LITTLE_ENDIAN
  370. #define __SMALL_BITFIELDS /* 16 Bit INT */
  371. #endif
  372. #ifdef __NIOS2__
  373. # ifdef __nios2_big_endian__
  374. # define __IEEE_BIG_ENDIAN
  375. # else
  376. # define __IEEE_LITTLE_ENDIAN
  377. # endif
  378. #endif
  379. #ifdef __VISIUM__
  380. #define __IEEE_BIG_ENDIAN
  381. #endif
  382. #ifdef __AMDGCN__
  383. #define __IEEE_LITTLE_ENDIAN
  384. #endif
  385. #ifdef __XTENSA_EL__
  386. #define __IEEE_LITTLE_ENDIAN
  387. #endif
  388. #ifdef __CYGWIN__
  389. #define __OBSOLETE_MATH_DEFAULT 0
  390. #endif
  391. #ifndef __OBSOLETE_MATH_DEFAULT
  392. /* Use old math code by default. */
  393. #define __OBSOLETE_MATH_DEFAULT 1
  394. #endif
  395. #ifndef __OBSOLETE_MATH
  396. #define __OBSOLETE_MATH __OBSOLETE_MATH_DEFAULT
  397. #endif
  398. #ifndef __IEEE_BIG_ENDIAN
  399. #ifndef __IEEE_LITTLE_ENDIAN
  400. #error Endianess not declared!!
  401. #endif /* not __IEEE_LITTLE_ENDIAN */
  402. #endif /* not __IEEE_BIG_ENDIAN */
  403. #endif /* not __IEEE_LITTLE_ENDIAN */
  404. #endif /* not __IEEE_BIG_ENDIAN */