Daniel Dunbar | 4467b65 | 2009-10-27 17:48:46 +0000 | [diff] [blame] | 1 | /* ===-- int_lib.h - configuration header for compiler-rt -----------------=== |
Edward O'Callaghan | 0e4ad9c | 2009-08-05 01:47:29 +0000 | [diff] [blame] | 2 | * |
| 3 | * The LLVM Compiler Infrastructure |
| 4 | * |
Howard Hinnant | 9ad441f | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | * This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | * Source Licenses. See LICENSE.TXT for details. |
Edward O'Callaghan | 0e4ad9c | 2009-08-05 01:47:29 +0000 | [diff] [blame] | 7 | * |
| 8 | * ===----------------------------------------------------------------------=== |
| 9 | * |
Daniel Dunbar | 4467b65 | 2009-10-27 17:48:46 +0000 | [diff] [blame] | 10 | * This file is a configuration header for compiler-rt. |
Edward O'Callaghan | 0e4ad9c | 2009-08-05 01:47:29 +0000 | [diff] [blame] | 11 | * This file is not part of the interface of this library. |
| 12 | * |
| 13 | * ===----------------------------------------------------------------------=== |
| 14 | */ |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 15 | |
| 16 | #ifndef INT_LIB_H |
| 17 | #define INT_LIB_H |
| 18 | |
Daniel Dunbar | 0ae9d25 | 2011-11-15 18:34:44 +0000 | [diff] [blame^] | 19 | /* ABI macro definitions */ |
| 20 | |
| 21 | #if __ARM_EABI__ |
| 22 | # define ARM_EABI_FNALIAS(aeabi_name, name) \ |
| 23 | void __aeabi_##aeabi_name() __attribute__((alias("__" #name))); |
| 24 | # define COMPILER_RT_ABI __attribute__((pcs("aapcs"))) |
| 25 | #else |
| 26 | # define ARM_EABI_FNALIAS(aeabi_name, name) |
| 27 | # define COMPILER_RT_ABI |
| 28 | #endif |
| 29 | |
Edward O'Callaghan | 0e4ad9c | 2009-08-05 01:47:29 +0000 | [diff] [blame] | 30 | /* Assumption: signed integral is 2's complement */ |
| 31 | /* Assumption: right shift of signed negative is arithmetic shift */ |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 32 | |
| 33 | #include <limits.h> |
Nick Kledzik | c31717b | 2011-01-07 19:09:06 +0000 | [diff] [blame] | 34 | #include <stdint.h> |
Edward O'Callaghan | 1fcb40b | 2009-08-05 19:06:50 +0000 | [diff] [blame] | 35 | #include "endianness.h" |
Edward O'Callaghan | df479b6 | 2009-08-04 03:30:10 +0000 | [diff] [blame] | 36 | #include <math.h> |
| 37 | |
Daniel Dunbar | d3d2263 | 2010-03-31 17:00:48 +0000 | [diff] [blame] | 38 | /* If compiling for kernel use, call panic() instead of abort(). */ |
| 39 | #ifdef KERNEL_USE |
| 40 | extern void panic (const char *, ...); |
| 41 | #define compilerrt_abort() \ |
| 42 | panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__) |
| 43 | #else |
Daniel Dunbar | 48f46ac | 2010-03-31 17:00:45 +0000 | [diff] [blame] | 44 | #define compilerrt_abort() abort() |
Daniel Dunbar | d3d2263 | 2010-03-31 17:00:48 +0000 | [diff] [blame] | 45 | #endif |
Daniel Dunbar | 48f46ac | 2010-03-31 17:00:45 +0000 | [diff] [blame] | 46 | |
Edward O'Callaghan | df479b6 | 2009-08-04 03:30:10 +0000 | [diff] [blame] | 47 | #if !defined(INFINITY) && defined(HUGE_VAL) |
| 48 | #define INFINITY HUGE_VAL |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 49 | #endif /* INFINITY */ |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 50 | |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 51 | typedef int si_int; |
| 52 | typedef unsigned su_int; |
| 53 | |
| 54 | typedef long long di_int; |
| 55 | typedef unsigned long long du_int; |
| 56 | |
| 57 | typedef union |
| 58 | { |
| 59 | di_int all; |
| 60 | struct |
| 61 | { |
| 62 | #if _YUGA_LITTLE_ENDIAN |
| 63 | su_int low; |
| 64 | si_int high; |
| 65 | #else |
| 66 | si_int high; |
| 67 | su_int low; |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 68 | #endif /* _YUGA_LITTLE_ENDIAN */ |
Edward O'Callaghan | 8bf1e09 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 69 | }s; |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 70 | } dwords; |
| 71 | |
| 72 | typedef union |
| 73 | { |
| 74 | du_int all; |
| 75 | struct |
| 76 | { |
| 77 | #if _YUGA_LITTLE_ENDIAN |
| 78 | su_int low; |
| 79 | su_int high; |
| 80 | #else |
| 81 | su_int high; |
| 82 | su_int low; |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 83 | #endif /* _YUGA_LITTLE_ENDIAN */ |
Edward O'Callaghan | 8bf1e09 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 84 | }s; |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 85 | } udwords; |
| 86 | |
| 87 | #if __x86_64 |
| 88 | |
| 89 | typedef int ti_int __attribute__ ((mode (TI))); |
| 90 | typedef unsigned tu_int __attribute__ ((mode (TI))); |
| 91 | |
| 92 | typedef union |
| 93 | { |
| 94 | ti_int all; |
| 95 | struct |
| 96 | { |
| 97 | #if _YUGA_LITTLE_ENDIAN |
| 98 | du_int low; |
| 99 | di_int high; |
| 100 | #else |
| 101 | di_int high; |
| 102 | du_int low; |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 103 | #endif /* _YUGA_LITTLE_ENDIAN */ |
Edward O'Callaghan | 8bf1e09 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 104 | }s; |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 105 | } twords; |
| 106 | |
| 107 | typedef union |
| 108 | { |
| 109 | tu_int all; |
| 110 | struct |
| 111 | { |
| 112 | #if _YUGA_LITTLE_ENDIAN |
| 113 | du_int low; |
| 114 | du_int high; |
| 115 | #else |
| 116 | du_int high; |
| 117 | du_int low; |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 118 | #endif /* _YUGA_LITTLE_ENDIAN */ |
Edward O'Callaghan | 8bf1e09 | 2009-08-09 18:41:02 +0000 | [diff] [blame] | 119 | }s; |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 120 | } utwords; |
| 121 | |
Daniel Dunbar | 4467b65 | 2009-10-27 17:48:46 +0000 | [diff] [blame] | 122 | static inline ti_int make_ti(di_int h, di_int l) { |
| 123 | twords r; |
| 124 | r.s.high = h; |
| 125 | r.s.low = l; |
| 126 | return r.all; |
| 127 | } |
| 128 | |
| 129 | static inline tu_int make_tu(du_int h, du_int l) { |
| 130 | utwords r; |
| 131 | r.s.high = h; |
| 132 | r.s.low = l; |
| 133 | return r.all; |
| 134 | } |
| 135 | |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 136 | #endif /* __x86_64 */ |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 137 | |
| 138 | typedef union |
| 139 | { |
| 140 | su_int u; |
| 141 | float f; |
| 142 | } float_bits; |
| 143 | |
| 144 | typedef union |
| 145 | { |
| 146 | udwords u; |
| 147 | double f; |
| 148 | } double_bits; |
| 149 | |
| 150 | typedef struct |
| 151 | { |
| 152 | #if _YUGA_LITTLE_ENDIAN |
| 153 | udwords low; |
| 154 | udwords high; |
| 155 | #else |
| 156 | udwords high; |
| 157 | udwords low; |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 158 | #endif /* _YUGA_LITTLE_ENDIAN */ |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 159 | } uqwords; |
| 160 | |
| 161 | typedef union |
| 162 | { |
| 163 | uqwords u; |
| 164 | long double f; |
| 165 | } long_double_bits; |
| 166 | |
Edward O'Callaghan | 0898ee9 | 2009-08-05 19:57:20 +0000 | [diff] [blame] | 167 | #endif /* INT_LIB_H */ |