blob: f6c2dd45ed84bbd43283c45dd01081aea19a8f29 [file] [log] [blame]
Daniel Dunbar24768732009-10-27 17:48:46 +00001/* ===-- int_lib.h - configuration header for compiler-rt -----------------===
Edward O'Callaghandf720462009-08-05 01:47:29 +00002 *
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 *
Daniel Dunbar24768732009-10-27 17:48:46 +000010 * This file is a configuration header for compiler-rt.
Edward O'Callaghandf720462009-08-05 01:47:29 +000011 * This file is not part of the interface of this library.
12 *
13 * ===----------------------------------------------------------------------===
14 */
Daniel Dunbarfd089992009-06-26 16:47:03 +000015
16#ifndef INT_LIB_H
17#define INT_LIB_H
18
Edward O'Callaghandf720462009-08-05 01:47:29 +000019/* Assumption: signed integral is 2's complement */
20/* Assumption: right shift of signed negative is arithmetic shift */
Daniel Dunbarfd089992009-06-26 16:47:03 +000021
22#include <limits.h>
Edward O'Callaghandabf71f2009-08-05 19:06:50 +000023#include "endianness.h"
Edward O'Callaghan30009e72009-08-04 03:30:10 +000024#include <math.h>
25
Daniel Dunbarf2870082010-03-31 17:00:45 +000026#define compilerrt_abort() abort()
27
Edward O'Callaghan30009e72009-08-04 03:30:10 +000028#if !defined(INFINITY) && defined(HUGE_VAL)
29#define INFINITY HUGE_VAL
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +000030#endif /* INFINITY */
Daniel Dunbarfd089992009-06-26 16:47:03 +000031
Daniel Dunbarfd089992009-06-26 16:47:03 +000032typedef int si_int;
33typedef unsigned su_int;
34
35typedef long long di_int;
36typedef unsigned long long du_int;
37
38typedef union
39{
40 di_int all;
41 struct
42 {
43#if _YUGA_LITTLE_ENDIAN
44 su_int low;
45 si_int high;
46#else
47 si_int high;
48 su_int low;
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +000049#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghanccf48132009-08-09 18:41:02 +000050 }s;
Daniel Dunbarfd089992009-06-26 16:47:03 +000051} dwords;
52
53typedef union
54{
55 du_int all;
56 struct
57 {
58#if _YUGA_LITTLE_ENDIAN
59 su_int low;
60 su_int high;
61#else
62 su_int high;
63 su_int low;
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +000064#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghanccf48132009-08-09 18:41:02 +000065 }s;
Daniel Dunbarfd089992009-06-26 16:47:03 +000066} udwords;
67
68#if __x86_64
69
70typedef int ti_int __attribute__ ((mode (TI)));
71typedef unsigned tu_int __attribute__ ((mode (TI)));
72
73typedef union
74{
75 ti_int all;
76 struct
77 {
78#if _YUGA_LITTLE_ENDIAN
79 du_int low;
80 di_int high;
81#else
82 di_int high;
83 du_int low;
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +000084#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghanccf48132009-08-09 18:41:02 +000085 }s;
Daniel Dunbarfd089992009-06-26 16:47:03 +000086} twords;
87
88typedef union
89{
90 tu_int all;
91 struct
92 {
93#if _YUGA_LITTLE_ENDIAN
94 du_int low;
95 du_int high;
96#else
97 du_int high;
98 du_int low;
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +000099#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghanccf48132009-08-09 18:41:02 +0000100 }s;
Daniel Dunbarfd089992009-06-26 16:47:03 +0000101} utwords;
102
Daniel Dunbar24768732009-10-27 17:48:46 +0000103static inline ti_int make_ti(di_int h, di_int l) {
104 twords r;
105 r.s.high = h;
106 r.s.low = l;
107 return r.all;
108}
109
110static inline tu_int make_tu(du_int h, du_int l) {
111 utwords r;
112 r.s.high = h;
113 r.s.low = l;
114 return r.all;
115}
116
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +0000117#endif /* __x86_64 */
Daniel Dunbarfd089992009-06-26 16:47:03 +0000118
119typedef union
120{
121 su_int u;
122 float f;
123} float_bits;
124
125typedef union
126{
127 udwords u;
128 double f;
129} double_bits;
130
131typedef struct
132{
133#if _YUGA_LITTLE_ENDIAN
134 udwords low;
135 udwords high;
136#else
137 udwords high;
138 udwords low;
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +0000139#endif /* _YUGA_LITTLE_ENDIAN */
Daniel Dunbarfd089992009-06-26 16:47:03 +0000140} uqwords;
141
142typedef union
143{
144 uqwords u;
145 long double f;
146} long_double_bits;
147
Edward O'Callaghan7a6cb5f2009-08-05 19:57:20 +0000148#endif /* INT_LIB_H */