blob: f37d500dd11f8bedddb694f0c4d37d74c5f71470 [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 *
5 * This file is distributed under the University of Illinois Open Source
6 * License. See LICENSE.TXT for details.
7 *
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
Edward O'Callaghan0e4ad9c2009-08-05 01:47:29 +000019/* Assumption: signed integral is 2's complement */
20/* Assumption: right shift of signed negative is arithmetic shift */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000021
22#include <limits.h>
Edward O'Callaghan1fcb40b2009-08-05 19:06:50 +000023#include "endianness.h"
Edward O'Callaghandf479b62009-08-04 03:30:10 +000024#include <math.h>
25
26#if !defined(INFINITY) && defined(HUGE_VAL)
27#define INFINITY HUGE_VAL
Edward O'Callaghan0898ee92009-08-05 19:57:20 +000028#endif /* INFINITY */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000029
Daniel Dunbarb3a69012009-06-26 16:47:03 +000030typedef int si_int;
31typedef unsigned su_int;
32
33typedef long long di_int;
34typedef unsigned long long du_int;
35
36typedef union
37{
38 di_int all;
39 struct
40 {
41#if _YUGA_LITTLE_ENDIAN
42 su_int low;
43 si_int high;
44#else
45 si_int high;
46 su_int low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +000047#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000048 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +000049} dwords;
50
51typedef union
52{
53 du_int all;
54 struct
55 {
56#if _YUGA_LITTLE_ENDIAN
57 su_int low;
58 su_int high;
59#else
60 su_int high;
61 su_int low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +000062#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000063 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +000064} udwords;
65
66#if __x86_64
67
68typedef int ti_int __attribute__ ((mode (TI)));
69typedef unsigned tu_int __attribute__ ((mode (TI)));
70
71typedef union
72{
73 ti_int all;
74 struct
75 {
76#if _YUGA_LITTLE_ENDIAN
77 du_int low;
78 di_int high;
79#else
80 di_int high;
81 du_int low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +000082#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000083 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +000084} twords;
85
86typedef union
87{
88 tu_int all;
89 struct
90 {
91#if _YUGA_LITTLE_ENDIAN
92 du_int low;
93 du_int high;
94#else
95 du_int high;
96 du_int low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +000097#endif /* _YUGA_LITTLE_ENDIAN */
Edward O'Callaghan8bf1e092009-08-09 18:41:02 +000098 }s;
Daniel Dunbarb3a69012009-06-26 16:47:03 +000099} utwords;
100
Daniel Dunbar4467b652009-10-27 17:48:46 +0000101static inline ti_int make_ti(di_int h, di_int l) {
102 twords r;
103 r.s.high = h;
104 r.s.low = l;
105 return r.all;
106}
107
108static inline tu_int make_tu(du_int h, du_int l) {
109 utwords r;
110 r.s.high = h;
111 r.s.low = l;
112 return r.all;
113}
114
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000115#endif /* __x86_64 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000116
117typedef union
118{
119 su_int u;
120 float f;
121} float_bits;
122
123typedef union
124{
125 udwords u;
126 double f;
127} double_bits;
128
129typedef struct
130{
131#if _YUGA_LITTLE_ENDIAN
132 udwords low;
133 udwords high;
134#else
135 udwords high;
136 udwords low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000137#endif /* _YUGA_LITTLE_ENDIAN */
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000138} uqwords;
139
140typedef union
141{
142 uqwords u;
143 long double f;
144} long_double_bits;
145
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000146#endif /* INT_LIB_H */