infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
infix_config.h
Go to the documentation of this file.
1
#pragma once
73
// Define feature-test macros to ensure declarations for shm_open, ftruncate, etc.,
74
// are visible on all POSIX-compliant systems.
75
#if !defined(_POSIX_C_SOURCE)
76
#define _POSIX_C_SOURCE 200809L
77
#endif
78
#if (defined(__linux__) || defined(__gnu_linux__)) && !defined(_GNU_SOURCE)
79
#define _GNU_SOURCE
80
#endif
81
82
// Host Platform and Architecture Detection
83
// This block ALWAYS detects the native host. It is NOT overridden by the ABI flag.
84
#if defined(_WIN32)
85
#define INFIX_OS_WINDOWS
86
#include <windows.h>
87
#if defined(__MSYS__)
88
#define INFIX_ENV_MSYS 1
89
#elif defined(__CYGWIN__)
90
#define INFIX_ENV_CYGWIN 1
91
#define INFIX_ENV_POSIX 1
92
#elif defined(__MINGW32__) || defined(__MINGW64__)
93
#define INFIX_ENV_MINGW 1
94
#endif
95
#elif defined(__TERMUX__)
96
#define INFIX_OS_TERMUX
97
#define INFIX_OS_ANDROID
// Container
98
#define INFIX_OS_LINUX
99
#define INFIX_ENV_POSIX
100
#define INFIX_ENV_TERMUX 1
101
#elif defined(__ANDROID__)
102
#define INFIX_OS_ANDROID
103
#define INFIX_OS_LINUX
// Android is close enough...
104
#define INFIX_ENV_POSIX
105
#elif defined(__APPLE__)
106
#define INFIX_ENV_POSIX
107
#define _DARWIN_C_SOURCE
108
#include <TargetConditionals.h>
109
#include <libkern/OSCacheControl.h>
110
#include <pthread.h>
111
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
112
#define INFIX_OS_IOS
113
#elif TARGET_OS_MAC
114
#define INFIX_OS_MACOS
115
#else
116
#error "Unsupported/unknown Apple platform"
117
#endif
118
#elif defined(__linux__)
119
#define INFIX_OS_LINUX
120
#define INFIX_ENV_POSIX
121
#elif defined(__FreeBSD__)
122
#define INFIX_OS_FREEBSD
123
#define INFIX_ENV_POSIX
124
#elif defined(__OpenBSD__)
125
#define INFIX_OS_OPENBSD
126
#define INFIX_ENV_POSIX
127
#elif defined(__NetBSD__)
128
#define INFIX_OS_NETBSD
129
#define INFIX_ENV_POSIX
130
#elif defined(__DragonFly__)
131
#define INFIX_OS_DRAGONFLY
132
#define INFIX_ENV_POSIX
133
#elif defined(__sun) && defined(__SVR4)
134
#define INFIX_OS_SOLARIS
135
#define INFIX_ENV_POSIX
136
#elif defined(__HAIKU__)
137
#define INFIX_OS_HAIKU
138
#define INFIX_ENV_POSIX
139
#else
140
#warning "Unsupported/unknown operating system"
141
#endif
142
143
#if defined(__clang__)
144
#define INFIX_COMPILER_CLANG
145
#elif defined(_MSC_VER)
146
#define INFIX_COMPILER_MSVC
147
#elif defined(__GNUC__)
148
#define INFIX_COMPILER_GCC
149
#else
150
#warning "Compiler: Unknown compiler detected."
151
#define INFIX_COMPILER_NFI
152
#endif
153
154
#if defined(__aarch64__) || defined(_M_ARM64)
155
#define INFIX_ARCH_AARCH64
156
#elif defined(__x86_64__) || defined(_M_X64)
157
#define INFIX_ARCH_X64
158
#else
159
#error "Unsupported architecture. Only x86-64 and AArch64 are currently supported."
160
#endif
161
162
/*
163
* This block determines which ABI implementation to use. It can be overridden
164
* by a compiler flag (e.g., -DINFIX_FORCE_ABI_WINDOWS_X64), which is useful for
165
* cross-ABI testing and fuzzing on a single platform.
166
*/
167
#if defined(INFIX_FORCE_ABI_WINDOWS_X64)
168
#define INFIX_ABI_WINDOWS_X64 1
169
#define INFIX_ABI_FORCED 1
170
#elif defined(INFIX_FORCE_ABI_SYSV_X64)
171
#define INFIX_ABI_SYSV_X64 1
172
#define INFIX_ABI_FORCED 1
173
#elif defined(INFIX_FORCE_ABI_AAPCS64)
174
#define INFIX_ABI_AAPCS64 1
175
#define INFIX_ABI_FORCED 1
176
#endif
177
178
/*
179
* If no ABI was forced via a compiler flag, detect it automatically based on
180
* the host operating system and architecture.
181
*/
182
#ifndef INFIX_ABI_FORCED
183
#if defined(INFIX_ARCH_AARCH64)
184
#define INFIX_ABI_AAPCS64
185
#elif defined(INFIX_ARCH_X64)
186
#if defined(INFIX_OS_WINDOWS)
187
#define INFIX_ABI_WINDOWS_X64
188
#else
189
#define INFIX_ABI_SYSV_X64
190
#endif
191
#endif
192
#endif
193
194
/*
195
* @internal
196
* @brief The amount of extra headroom (in bytes) to add to a trampoline's
197
* internal arena. This provides a small buffer for metadata beyond the
198
* space needed for the deep-copied type graph.
199
*/
200
#define INFIX_TRAMPOLINE_HEADROOM 128
src
common
infix_config.h
Generated by
1.9.8