blob: 7d09c856f5e2601c86445f546614bcfed6d294a7 [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001//===-- int_lib.h - configuration header for libgcc replacement -----------===//
2//
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//
10// This file is a configuration header for libgcc replacement.
11// This file is not part of the interface of this library.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef INT_LIB_H
16#define INT_LIB_H
17
18// Assumption: signed integral is 2's complement
19// Assumption: right shift of signed negative is arithmetic shift
20
21#include <limits.h>
22
23#ifdef __LITTLE_ENDIAN__
24#if __LITTLE_ENDIAN__
25#define _YUGA_LITTLE_ENDIAN 1
26#define _YUGA_BIG_ENDIAN 0
27#endif
28#endif
29
30#ifdef __BIG_ENDIAN__
31#if __BIG_ENDIAN__
32#define _YUGA_LITTLE_ENDIAN 0
33#define _YUGA_BIG_ENDIAN 1
34#endif
35#endif
36
37#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
38#error unable to determine endian
39#endif
40
41typedef int si_int;
42typedef unsigned su_int;
43
44typedef long long di_int;
45typedef unsigned long long du_int;
46
47typedef union
48{
49 di_int all;
50 struct
51 {
52#if _YUGA_LITTLE_ENDIAN
53 su_int low;
54 si_int high;
55#else
56 si_int high;
57 su_int low;
58#endif
59 };
60} dwords;
61
62typedef union
63{
64 du_int all;
65 struct
66 {
67#if _YUGA_LITTLE_ENDIAN
68 su_int low;
69 su_int high;
70#else
71 su_int high;
72 su_int low;
73#endif
74 };
75} udwords;
76
77#if __x86_64
78
79typedef int ti_int __attribute__ ((mode (TI)));
80typedef unsigned tu_int __attribute__ ((mode (TI)));
81
82typedef union
83{
84 ti_int all;
85 struct
86 {
87#if _YUGA_LITTLE_ENDIAN
88 du_int low;
89 di_int high;
90#else
91 di_int high;
92 du_int low;
93#endif
94 };
95} twords;
96
97typedef union
98{
99 tu_int all;
100 struct
101 {
102#if _YUGA_LITTLE_ENDIAN
103 du_int low;
104 du_int high;
105#else
106 du_int high;
107 du_int low;
108#endif
109 };
110} utwords;
111
112#endif
113
114typedef union
115{
116 su_int u;
117 float f;
118} float_bits;
119
120typedef union
121{
122 udwords u;
123 double f;
124} double_bits;
125
126typedef struct
127{
128#if _YUGA_LITTLE_ENDIAN
129 udwords low;
130 udwords high;
131#else
132 udwords high;
133 udwords low;
134#endif
135} uqwords;
136
137typedef union
138{
139 uqwords u;
140 long double f;
141} long_double_bits;
142
143#endif