int_lib.h revision 222656
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 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 <stdint.h> 24#include "endianness.h" 25#include <math.h> 26 27/* If compiling for kernel use, call panic() instead of abort(). */ 28#ifdef KERNEL_USE 29extern void panic (const char *, ...); 30#define compilerrt_abort() \ 31 panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__) 32#else 33#define compilerrt_abort() abort() 34#endif 35 36#if !defined(INFINITY) && defined(HUGE_VAL) 37#define INFINITY HUGE_VAL 38#endif /* INFINITY */ 39 40typedef int si_int; 41typedef unsigned su_int; 42 43typedef long long di_int; 44typedef unsigned long long du_int; 45 46typedef union 47{ 48 di_int all; 49 struct 50 { 51#if _YUGA_LITTLE_ENDIAN 52 su_int low; 53 si_int high; 54#else 55 si_int high; 56 su_int low; 57#endif /* _YUGA_LITTLE_ENDIAN */ 58 }s; 59} dwords; 60 61typedef union 62{ 63 du_int all; 64 struct 65 { 66#if _YUGA_LITTLE_ENDIAN 67 su_int low; 68 su_int high; 69#else 70 su_int high; 71 su_int low; 72#endif /* _YUGA_LITTLE_ENDIAN */ 73 }s; 74} udwords; 75 76#if __x86_64 77 78typedef int ti_int __attribute__ ((mode (TI))); 79typedef unsigned tu_int __attribute__ ((mode (TI))); 80 81typedef union 82{ 83 ti_int all; 84 struct 85 { 86#if _YUGA_LITTLE_ENDIAN 87 du_int low; 88 di_int high; 89#else 90 di_int high; 91 du_int low; 92#endif /* _YUGA_LITTLE_ENDIAN */ 93 }s; 94} twords; 95 96typedef union 97{ 98 tu_int all; 99 struct 100 { 101#if _YUGA_LITTLE_ENDIAN 102 du_int low; 103 du_int high; 104#else 105 du_int high; 106 du_int low; 107#endif /* _YUGA_LITTLE_ENDIAN */ 108 }s; 109} utwords; 110 111static inline ti_int make_ti(di_int h, di_int l) { 112 twords r; 113 r.s.high = h; 114 r.s.low = l; 115 return r.all; 116} 117 118static inline tu_int make_tu(du_int h, du_int l) { 119 utwords r; 120 r.s.high = h; 121 r.s.low = l; 122 return r.all; 123} 124 125#endif /* __x86_64 */ 126 127typedef union 128{ 129 su_int u; 130 float f; 131} float_bits; 132 133typedef union 134{ 135 udwords u; 136 double f; 137} double_bits; 138 139typedef struct 140{ 141#if _YUGA_LITTLE_ENDIAN 142 udwords low; 143 udwords high; 144#else 145 udwords high; 146 udwords low; 147#endif /* _YUGA_LITTLE_ENDIAN */ 148} uqwords; 149 150typedef union 151{ 152 uqwords u; 153 long double f; 154} long_double_bits; 155 156#endif /* INT_LIB_H */ 157