blob: 8f07ba2cb8972d620f0190e365869522521f7e75 [file] [log] [blame]
Edward O'Callaghan0e4ad9c2009-08-05 01:47:29 +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 */
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 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000048 };
49} 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 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000063 };
64} 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 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000083 };
84} 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 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +000098 };
99} utwords;
100
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000101#endif /* __x86_64 */
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000102
103typedef union
104{
105 su_int u;
106 float f;
107} float_bits;
108
109typedef union
110{
111 udwords u;
112 double f;
113} double_bits;
114
115typedef struct
116{
117#if _YUGA_LITTLE_ENDIAN
118 udwords low;
119 udwords high;
120#else
121 udwords high;
122 udwords low;
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000123#endif /* _YUGA_LITTLE_ENDIAN */
Daniel Dunbarb3a69012009-06-26 16:47:03 +0000124} uqwords;
125
126typedef union
127{
128 uqwords u;
129 long double f;
130} long_double_bits;
131
Edward O'Callaghan0898ee92009-08-05 19:57:20 +0000132#endif /* INT_LIB_H */