int_lib.h revision 222656
1214152Sed/* ===-- int_lib.h - configuration header for compiler-rt -----------------=== 2214152Sed * 3214152Sed * The LLVM Compiler Infrastructure 4214152Sed * 5222656Sed * This file is dual licensed under the MIT and the University of Illinois Open 6222656Sed * Source Licenses. See LICENSE.TXT for details. 7214152Sed * 8214152Sed * ===----------------------------------------------------------------------=== 9214152Sed * 10214152Sed * This file is a configuration header for compiler-rt. 11214152Sed * This file is not part of the interface of this library. 12214152Sed * 13214152Sed * ===----------------------------------------------------------------------=== 14214152Sed */ 15214152Sed 16214152Sed#ifndef INT_LIB_H 17214152Sed#define INT_LIB_H 18214152Sed 19214152Sed/* Assumption: signed integral is 2's complement */ 20214152Sed/* Assumption: right shift of signed negative is arithmetic shift */ 21214152Sed 22214152Sed#include <limits.h> 23222656Sed#include <stdint.h> 24214152Sed#include "endianness.h" 25214152Sed#include <math.h> 26214152Sed 27214152Sed/* If compiling for kernel use, call panic() instead of abort(). */ 28214152Sed#ifdef KERNEL_USE 29214152Sedextern void panic (const char *, ...); 30214152Sed#define compilerrt_abort() \ 31214152Sed panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__) 32214152Sed#else 33214152Sed#define compilerrt_abort() abort() 34214152Sed#endif 35214152Sed 36214152Sed#if !defined(INFINITY) && defined(HUGE_VAL) 37214152Sed#define INFINITY HUGE_VAL 38214152Sed#endif /* INFINITY */ 39214152Sed 40214152Sedtypedef int si_int; 41214152Sedtypedef unsigned su_int; 42214152Sed 43214152Sedtypedef long long di_int; 44214152Sedtypedef unsigned long long du_int; 45214152Sed 46214152Sedtypedef union 47214152Sed{ 48214152Sed di_int all; 49214152Sed struct 50214152Sed { 51214152Sed#if _YUGA_LITTLE_ENDIAN 52214152Sed su_int low; 53214152Sed si_int high; 54214152Sed#else 55214152Sed si_int high; 56214152Sed su_int low; 57214152Sed#endif /* _YUGA_LITTLE_ENDIAN */ 58214152Sed }s; 59214152Sed} dwords; 60214152Sed 61214152Sedtypedef union 62214152Sed{ 63214152Sed du_int all; 64214152Sed struct 65214152Sed { 66214152Sed#if _YUGA_LITTLE_ENDIAN 67214152Sed su_int low; 68214152Sed su_int high; 69214152Sed#else 70214152Sed su_int high; 71214152Sed su_int low; 72214152Sed#endif /* _YUGA_LITTLE_ENDIAN */ 73214152Sed }s; 74214152Sed} udwords; 75214152Sed 76214152Sed#if __x86_64 77214152Sed 78214152Sedtypedef int ti_int __attribute__ ((mode (TI))); 79214152Sedtypedef unsigned tu_int __attribute__ ((mode (TI))); 80214152Sed 81214152Sedtypedef union 82214152Sed{ 83214152Sed ti_int all; 84214152Sed struct 85214152Sed { 86214152Sed#if _YUGA_LITTLE_ENDIAN 87214152Sed du_int low; 88214152Sed di_int high; 89214152Sed#else 90214152Sed di_int high; 91214152Sed du_int low; 92214152Sed#endif /* _YUGA_LITTLE_ENDIAN */ 93214152Sed }s; 94214152Sed} twords; 95214152Sed 96214152Sedtypedef union 97214152Sed{ 98214152Sed tu_int all; 99214152Sed struct 100214152Sed { 101214152Sed#if _YUGA_LITTLE_ENDIAN 102214152Sed du_int low; 103214152Sed du_int high; 104214152Sed#else 105214152Sed du_int high; 106214152Sed du_int low; 107214152Sed#endif /* _YUGA_LITTLE_ENDIAN */ 108214152Sed }s; 109214152Sed} utwords; 110214152Sed 111214152Sedstatic inline ti_int make_ti(di_int h, di_int l) { 112214152Sed twords r; 113214152Sed r.s.high = h; 114214152Sed r.s.low = l; 115214152Sed return r.all; 116214152Sed} 117214152Sed 118214152Sedstatic inline tu_int make_tu(du_int h, du_int l) { 119214152Sed utwords r; 120214152Sed r.s.high = h; 121214152Sed r.s.low = l; 122214152Sed return r.all; 123214152Sed} 124214152Sed 125214152Sed#endif /* __x86_64 */ 126214152Sed 127214152Sedtypedef union 128214152Sed{ 129214152Sed su_int u; 130214152Sed float f; 131214152Sed} float_bits; 132214152Sed 133214152Sedtypedef union 134214152Sed{ 135214152Sed udwords u; 136214152Sed double f; 137214152Sed} double_bits; 138214152Sed 139214152Sedtypedef struct 140214152Sed{ 141214152Sed#if _YUGA_LITTLE_ENDIAN 142214152Sed udwords low; 143214152Sed udwords high; 144214152Sed#else 145214152Sed udwords high; 146214152Sed udwords low; 147214152Sed#endif /* _YUGA_LITTLE_ENDIAN */ 148214152Sed} uqwords; 149214152Sed 150214152Sedtypedef union 151214152Sed{ 152214152Sed uqwords u; 153214152Sed long double f; 154214152Sed} long_double_bits; 155214152Sed 156214152Sed#endif /* INT_LIB_H */ 157