int_lib.h revision 214152
1/* ===-- int_lib.h - configuration header for compiler-rt -----------------=== 2 * 3 * The LLVM Compiler Infrastructure 4 * 5 * This file is distributed under the University of Illinois Open Source 6 * License. See LICENSE.TXT for details. 7 * 8 * ===----------------------------------------------------------------------=== 9 * 10 * This file is a configuration header for compiler-rt. 11 * This file is not part of the interface of this library. 12 * 13 * ===----------------------------------------------------------------------=== 14 */ 15 16#ifndef INT_LIB_H 17#define INT_LIB_H 18 19/* Assumption: signed integral is 2's complement */ 20/* Assumption: right shift of signed negative is arithmetic shift */ 21 22#include <limits.h> 23#include "endianness.h" 24#include <math.h> 25 26/* If compiling for kernel use, call panic() instead of abort(). */ 27#ifdef KERNEL_USE 28extern void panic (const char *, ...); 29#define compilerrt_abort() \ 30 panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__) 31#else 32#define compilerrt_abort() abort() 33#endif 34 35#if !defined(INFINITY) && defined(HUGE_VAL) 36#define INFINITY HUGE_VAL 37#endif /* INFINITY */ 38 39typedef int si_int; 40typedef unsigned su_int; 41 42typedef long long di_int; 43typedef unsigned long long du_int; 44 45typedef union 46{ 47 di_int all; 48 struct 49 { 50#if _YUGA_LITTLE_ENDIAN 51 su_int low; 52 si_int high; 53#else 54 si_int high; 55 su_int low; 56#endif /* _YUGA_LITTLE_ENDIAN */ 57 }s; 58} dwords; 59 60typedef union 61{ 62 du_int all; 63 struct 64 { 65#if _YUGA_LITTLE_ENDIAN 66 su_int low; 67 su_int high; 68#else 69 su_int high; 70 su_int low; 71#endif /* _YUGA_LITTLE_ENDIAN */ 72 }s; 73} udwords; 74 75#if __x86_64 76 77typedef int ti_int __attribute__ ((mode (TI))); 78typedef unsigned tu_int __attribute__ ((mode (TI))); 79 80typedef union 81{ 82 ti_int all; 83 struct 84 { 85#if _YUGA_LITTLE_ENDIAN 86 du_int low; 87 di_int high; 88#else 89 di_int high; 90 du_int low; 91#endif /* _YUGA_LITTLE_ENDIAN */ 92 }s; 93} twords; 94 95typedef union 96{ 97 tu_int all; 98 struct 99 { 100#if _YUGA_LITTLE_ENDIAN 101 du_int low; 102 du_int high; 103#else 104 du_int high; 105 du_int low; 106#endif /* _YUGA_LITTLE_ENDIAN */ 107 }s; 108} utwords; 109 110static inline ti_int make_ti(di_int h, di_int l) { 111 twords r; 112 r.s.high = h; 113 r.s.low = l; 114 return r.all; 115} 116 117static inline tu_int make_tu(du_int h, du_int l) { 118 utwords r; 119 r.s.high = h; 120 r.s.low = l; 121 return r.all; 122} 123 124#endif /* __x86_64 */ 125 126typedef union 127{ 128 su_int u; 129 float f; 130} float_bits; 131 132typedef union 133{ 134 udwords u; 135 double f; 136} double_bits; 137 138typedef struct 139{ 140#if _YUGA_LITTLE_ENDIAN 141 udwords low; 142 udwords high; 143#else 144 udwords high; 145 udwords low; 146#endif /* _YUGA_LITTLE_ENDIAN */ 147} uqwords; 148 149typedef union 150{ 151 uqwords u; 152 long double f; 153} long_double_bits; 154 155#endif /* INT_LIB_H */ 156