-
Notifications
You must be signed in to change notification settings - Fork 2
/
System.h
82 lines (63 loc) · 2.11 KB
/
System.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
streflop: STandalone REproducible FLOating-Point
Nicolas Brodu, 2006
Code released according to the GNU Lesser General Public License
Heavily relies on GNU Libm, itself depending on netlib fplibm, GNU MP, and IBM MP lib.
Uses SoftFloat too.
Please read the history and copyright information in the documentation provided with the source code
*/
#ifndef STREFLOP_SYSTEM_H
#define STREFLOP_SYSTEM_H
#if defined(STREFLOP_SSE) || defined(STREFLOP_X87)
// SSE or X87 machines are little-endian
#define __BYTE_ORDER 1234
#define __FLOAT_WORD_ORDER 1234
// Softfloat or other unknown FPU. TODO: Try some header autodetect?
#else
#define __BYTE_ORDER 1234
#define __FLOAT_WORD_ORDER 1234
/*
#include <endian.h>
#if !defined(__FLOAT_WORD_ORDER) || !defined(__BYTE_ORDER)
#undef __FLOAT_WORD_ORDER
#undef __BYTE_ORDER
#if defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN) || defined(LITTLE_ENDIAN)
// avoid conflicting defs
#undef _LITTLE_ENDIAN
#undef LITTLE_ENDIAN
#undef __LITTLE_ENDIAN
#undef __BYTE_ORDER
#define __BYTE_ORDER 1234
#define __FLOAT_WORD_ORDER 1234
#elif defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) || defined(BIG_ENDIAN)
// avoid conflicting defs
#undef _BIG_ENDIAN
#undef BIG_ENDIAN
#undef __BIG_ENDIAN
#undef __BYTE_ORDER
#define __BYTE_ORDER 4321
#define __FLOAT_WORD_ORDER 4321
#else
// Unfortunately, the endianity for the compilation target cannot be deduced at compile time
// => preprocessor #define is necessary, possibly with heuristics
#error Could not detect endianity.
#endif
#endif
*/
#endif
#include "IntegerTypes.h"
// Avoid conflict with system types, if any
namespace streflop {
// Use the assumption above for char
typedef char int8_t;
typedef unsigned char uint8_t;
// Now "run" the meta-program to define the types
// Entry point is (unsigned) short, then all types above are tried till the size match
typedef SizedInteger<16>::Type int16_t;
typedef SizedUnsignedInteger<16>::Type uint16_t;
typedef SizedInteger<32>::Type int32_t;
typedef SizedUnsignedInteger<32>::Type uint32_t;
typedef SizedInteger<64>::Type int64_t;
typedef SizedUnsignedInteger<64>::Type uint64_t;
}
#endif