Backport from sid to buster
[hcoop/debian/mlton.git] / runtime / cenv.h
1 /* Copyright (C) 2012,2017 Matthew Fluet.
2 * Copyright (C) 1999-2009 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
8 */
9
10 #ifndef _MLTON_CENV_H_
11 #define _MLTON_CENV_H_
12
13 #define _FILE_OFFSET_BITS 64
14
15 #ifndef ASSERT
16 #define ASSERT 0
17 #define NDEBUG
18 #endif
19
20 /* C99 headers */
21 #include <assert.h>
22 // #include <complex.h>
23 #include <ctype.h>
24 #include <errno.h>
25 // fenv.h (or approximate equivalent) comes from the n-way OS switch below.
26 // #include <fenv.h>
27 #include <float.h>
28 // inttypes.h (or approximate equivalent) comes from the n-way OS switch below.
29 // #include <inttypes.h>
30 #include <iso646.h>
31 #include <limits.h>
32 // #include <locale.h>
33 #include <math.h>
34 // #include <setjmp.h>
35 #include <signal.h>
36 #include <stdarg.h>
37 #include <stdbool.h>
38 #include <stddef.h>
39 // stdint.h (or approximate equivalent) comes from the n-way OS switch below.
40 // #include <stdint.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 // #include <tgmath.h>
45 #include <time.h>
46 // #include <wchar.h>
47 // #include <wctype.h>
48
49 #include <gmp.h>
50
51
52 #define COMPILE_TIME_ASSERT(name, x) \
53 typedef int _COMPILE_TIME_ASSERT___##name[(x) ? 1 : -1]
54 COMPILE_TIME_ASSERT(CHAR_BIT__is_eight, CHAR_BIT == 8);
55 COMPILE_TIME_ASSERT(sizeof_float__is_four, sizeof(float) == 4);
56 COMPILE_TIME_ASSERT(sizeof_double__is_eight, sizeof(double) == 8);
57
58
59 #if (defined (__APPLE_CC__))
60 #define __Darwin__
61 #endif
62
63 #if (defined (_AIX))
64 #include "platform/aix.h"
65 #elif (defined (__CYGWIN__))
66 #include "platform/cygwin.h"
67 #elif (defined (__Darwin__))
68 #include "platform/darwin.h"
69 #elif (defined (__FreeBSD__) || defined(__FreeBSD_kernel__))
70 #include "platform/freebsd.h"
71 #elif (defined (__hpux__))
72 #include "platform/hpux.h"
73 #elif (defined (__GNU__))
74 #include "platform/hurd.h"
75 #elif (defined (__linux__))
76 #include "platform/linux.h"
77 #elif (defined (__MINGW32__))
78 #include "platform/mingw.h"
79 #elif (defined (__NetBSD__))
80 #include "platform/netbsd.h"
81 #elif (defined (__OpenBSD__))
82 #include "platform/openbsd.h"
83 #elif (defined (__sun__))
84 #include "platform/solaris.h"
85 #else
86 #error unknown platform os
87 #endif
88
89
90 #if (defined (__alpha__))
91 #include "platform/alpha.h"
92 #elif (defined (__x86_64__))
93 #include "platform/amd64.h"
94 #elif (defined (__arm__))
95 #include "platform/arm.h"
96 #elif (defined (__aarch64__))
97 #include "platform/arm64.h"
98 #elif (defined (__hppa__))
99 #include "platform/hppa.h"
100 #elif (defined (__ia64__))
101 #include "platform/ia64.h"
102 #elif (defined (__m68k__))
103 #include "platform/m68k.h"
104 #elif (defined (__mips__))
105 #include "platform/mips.h"
106 #elif (defined (__powerpc64__))
107 #include "platform/powerpc64.h"
108 #elif (defined (__ppc__)) || (defined (__powerpc__))
109 #include "platform/powerpc.h"
110 #elif (defined (__s390__))
111 #include "platform/s390.h"
112 #elif (defined (__sparc__))
113 #include "platform/sparc.h"
114 #elif (defined (__i386__))
115 #include "platform/x86.h"
116 #else
117 #error unknown platform arch
118 #endif
119
120
121 #ifndef POINTER_BITS
122 #if UINTPTR_MAX == UINT32_MAX
123 #define POINTER_BITS 32
124 #elif UINTPTR_MAX == UINT64_MAX
125 #define POINTER_BITS 64
126 #else
127 #error Platform did not set POINTER_BITS and could not guess it.
128 #endif
129 #endif
130
131 #ifndef ADDRESS_BITS
132 #define ADDRESS_BITS POINTER_BITS
133 #endif
134
135 COMPILE_TIME_ASSERT(sizeof_uintptr_t__is__sizeof_voidStar,
136 sizeof(uintptr_t) == sizeof(void*));
137 COMPILE_TIME_ASSERT(sizeof_uintptr_t__is__sizeof_size_t,
138 sizeof(uintptr_t) == sizeof(size_t));
139 COMPILE_TIME_ASSERT(sizeof_uintptr_t__is__sizeof_ptrdiff_t,
140 sizeof(uintptr_t) == sizeof(ptrdiff_t));
141 COMPILE_TIME_ASSERT(sizeof_voidStar__is__pointer_bits,
142 sizeof(void*)*CHAR_BIT == POINTER_BITS);
143 COMPILE_TIME_ASSERT(address_bits__lte__pointer_bits,
144 ADDRESS_BITS <= POINTER_BITS);
145
146 #include "export.h"
147
148 #endif /* _MLTON_CENV_H_ */