int_types.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* ===-- int_lib.h - configuration header for compiler-rt -----------------===
  2. *
  3. * The LLVM Compiler Infrastructure
  4. *
  5. * This file is dual licensed under the MIT and the University of Illinois Open
  6. * Source Licenses. See LICENSE.TXT for details.
  7. *
  8. * ===----------------------------------------------------------------------===
  9. *
  10. * This file is not part of the interface of this library.
  11. *
  12. * This file defines various standard types, most importantly a number of unions
  13. * used to access parts of larger types.
  14. *
  15. * ===----------------------------------------------------------------------===
  16. */
  17. #ifndef INT_TYPES_H
  18. #define INT_TYPES_H
  19. #include "int_endianness.h"
  20. typedef int si_int;
  21. typedef unsigned su_int;
  22. typedef long long di_int;
  23. typedef unsigned long long du_int;
  24. typedef union
  25. {
  26. di_int all;
  27. struct
  28. {
  29. #if _YUGA_LITTLE_ENDIAN
  30. su_int low;
  31. si_int high;
  32. #else
  33. si_int high;
  34. su_int low;
  35. #endif /* _YUGA_LITTLE_ENDIAN */
  36. }s;
  37. } dwords;
  38. typedef union
  39. {
  40. du_int all;
  41. struct
  42. {
  43. #if _YUGA_LITTLE_ENDIAN
  44. su_int low;
  45. su_int high;
  46. #else
  47. su_int high;
  48. su_int low;
  49. #endif /* _YUGA_LITTLE_ENDIAN */
  50. }s;
  51. } udwords;
  52. #if __LP64__
  53. #define CRT_HAS_128BIT
  54. #endif
  55. #ifdef CRT_HAS_128BIT
  56. typedef int ti_int __attribute__ ((mode (TI)));
  57. typedef unsigned tu_int __attribute__ ((mode (TI)));
  58. typedef union
  59. {
  60. ti_int all;
  61. struct
  62. {
  63. #if _YUGA_LITTLE_ENDIAN
  64. du_int low;
  65. di_int high;
  66. #else
  67. di_int high;
  68. du_int low;
  69. #endif /* _YUGA_LITTLE_ENDIAN */
  70. }s;
  71. } twords;
  72. typedef union
  73. {
  74. tu_int all;
  75. struct
  76. {
  77. #if _YUGA_LITTLE_ENDIAN
  78. du_int low;
  79. du_int high;
  80. #else
  81. du_int high;
  82. du_int low;
  83. #endif /* _YUGA_LITTLE_ENDIAN */
  84. }s;
  85. } utwords;
  86. static inline ti_int make_ti(di_int h, di_int l) {
  87. twords r;
  88. r.s.high = h;
  89. r.s.low = l;
  90. return r.all;
  91. }
  92. static inline tu_int make_tu(du_int h, du_int l) {
  93. utwords r;
  94. r.s.high = h;
  95. r.s.low = l;
  96. return r.all;
  97. }
  98. #endif /* CRT_HAS_128BIT */
  99. typedef union
  100. {
  101. su_int u;
  102. float f;
  103. } float_bits;
  104. typedef union
  105. {
  106. udwords u;
  107. double f;
  108. } double_bits;
  109. typedef struct
  110. {
  111. #if _YUGA_LITTLE_ENDIAN
  112. udwords low;
  113. udwords high;
  114. #else
  115. udwords high;
  116. udwords low;
  117. #endif /* _YUGA_LITTLE_ENDIAN */
  118. } uqwords;
  119. typedef union
  120. {
  121. uqwords u;
  122. long double f;
  123. } long_double_bits;
  124. #endif /* INT_TYPES_H */