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.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
10 #ifndef _MLTON_CENV_H_
11 #define _MLTON_CENV_H_
13 #define _FILE_OFFSET_BITS 64
22 // #include <complex.h>
25 // fenv.h (or approximate equivalent) comes from the n-way OS switch below.
28 // inttypes.h (or approximate equivalent) comes from the n-way OS switch below.
29 // #include <inttypes.h>
32 // #include <locale.h>
34 // #include <setjmp.h>
39 // stdint.h (or approximate equivalent) comes from the n-way OS switch below.
40 // #include <stdint.h>
44 // #include <tgmath.h>
47 // #include <wctype.h>
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);
59 #if (defined (__APPLE_CC__))
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"
86 #error unknown platform os
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"
117 #error unknown platform arch
122 #if UINTPTR_MAX == UINT32_MAX
123 #define POINTER_BITS 32
124 #elif UINTPTR_MAX == UINT64_MAX
125 #define POINTER_BITS 64
127 #error Platform did not set POINTER_BITS and could not guess it.
132 #define ADDRESS_BITS POINTER_BITS
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
);
148 #endif /* _MLTON_CENV_H_ */