blob: 27d01fdbb49b1f3c4fd811fcff45c76d4aa45824 [file] [log] [blame]
Daniel Dunbar4467b652009-10-27 17:48:46 +00001/* ===-- int_lib.h - configuration header for compiler-rt -----------------===
Edward O'Callaghan0e4ad9c2009-08-05 01:47:29 +00002 *
3 * The LLVM Compiler Infrastructure
4 *
Howard Hinnant9ad441f2010-11-16 22:13:33 +00005 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
Edward O'Callaghan0e4ad9c2009-08-05 01:47:29 +00007 *
8 * ===----------------------------------------------------------------------===
9 *
Daniel Dunbar4467b652009-10-27 17:48:46 +000010 * This file is a configuration header for compiler-rt.
Edward O'Callaghan0e4ad9c2009-08-05 01:47:29 +000011 * This file is not part of the interface of this library.
12 *
13 * ===----------------------------------------------------------------------===
14 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000015
16#ifndef INT_LIB_H
17#define INT_LIB_H
18
Daniel Dunbar0ae9d252011-11-15 18:34:44 +000019/* 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'Callaghan0e4ad9c2009-08-05 01:47:29 +000030/* Assumption: signed integral is 2's complement */
31/* Assumption: right shift of signed negative is arithmetic shift */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000032
33#include <limits.h>
Nick Kledzikc31717b2011-01-07 19:09:06 +000034#include <stdint.h>
Edward O'Callaghan1fcb40b2009-08-05 19:06:50 +000035#include "endianness.h"
Edward O'Callaghandf479b62009-08-04 03:30:10 +000036#include <math.h>
37
Daniel Dunbard3d22632010-03-31 17:00:48 +000038/* If compiling for kernel use, call panic() instead of abort(). */
39#ifdef KERNEL_USE
40extern void panic (const char *, ...);
41#define compilerrt_abort() \
42 panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__)
43#else
Daniel Dunbar48f46ac2010-03-31 17:00:45 +000044#define compilerrt_abort() abort()
Daniel Dunbard3d22632010-03-31 17:00:48 +000045#endif
Daniel Dunbar48f46ac2010-03-31 17:00:45 +000046
Edward O'Callaghandf479b62009-08-04 03:30:10 +000047#if !defined(INFINITY) && defined(HUGE_VAL)
48#define INFINITY HUGE_VAL
Edward O'Callaghan0898ee92009-08-05 19:57:20 +000049#endif /* INFINITY */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000050
Daniel Dunbarb3a69012009-06-26 16:47:03 +000051typedef int si_int;
52typedef unsigned su_int;
53
54typedef long long di_int;
55typedef unsigned long long du_int;
56
57typedef 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'Callaghan0898ee92009-08-05 19:57:20 +000068#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000069 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +000070} dwords;
71
72typedef 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'Callaghan0898ee92009-08-05 19:57:20 +000083#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000084 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +000085} udwords;
86
87#if __x86_64
88
89typedef int ti_int __attribute__ ((mode (TI)));
90typedef unsigned tu_int __attribute__ ((mode (TI)));
91
92typedef 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'Callaghan0898ee92009-08-05 19:57:20 +0000103#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +0000104 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000105} twords;
106
107typedef 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'Callaghan0898ee92009-08-05 19:57:20 +0000118#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +0000119 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000120} utwords;
121
Daniel Dunbar4467b652009-10-27 17:48:46 +0000122static 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
129static 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'Callaghan0898ee92009-08-05 19:57:20 +0000136#endif /* __x86_64 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000137
138typedef union
139{
140 su_int u;
141 float f;
142} float_bits;
143
144typedef union
145{
146 udwords u;
147 double f;
148} double_bits;
149
150typedef struct
151{
152#if _YUGA_LITTLE_ENDIAN
153 udwords low;
154 udwords high;
155#else
156 udwords high;
157 udwords low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000158#endif /* _YUGA_LITTLE_ENDIAN */
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000159} uqwords;
160
161typedef union
162{
163 uqwords u;
164 long double f;
165} long_double_bits;
166
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000167#endif /* INT_LIB_H */