infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
infix_config.h
Go to the documentation of this file.
1
32
#pragma once
33
// System Feature Test Macros
42
#if !defined(_POSIX_C_SOURCE)
43
#define _POSIX_C_SOURCE 200809L
44
#endif
45
#if (defined(__linux__) || defined(__gnu_linux__)) && !defined(_GNU_SOURCE)
46
#define _GNU_SOURCE
47
#endif
48
// Operating System Detection
54
#if defined(_WIN32)
55
#define INFIX_OS_WINDOWS
56
#include <windows.h>
// Included early for common types like SYSTEM_INFO, HANDLE, etc.
57
// Compatibility shim for POSIX types not present in Clang/MSVC headers.
58
#if !defined(__CYGWIN__)
// Cygwin provides its own full POSIX environment
59
#include <stddef.h>
// For ptrdiff_t
60
#ifndef ssize_t
61
// Define ssize_t as ptrdiff_t, the standard signed counterpart to size_t.
62
typedef
ptrdiff_t ssize_t;
63
#endif
64
#endif
65
#if defined(__MSYS__)
66
#define INFIX_ENV_MSYS 1
67
#elif defined(__CYGWIN__)
68
#define INFIX_ENV_CYGWIN 1
69
#define INFIX_ENV_POSIX 1
70
#elif defined(__MINGW32__) || defined(__MINGW64__)
71
#define INFIX_ENV_MINGW 1
72
#endif
73
#elif defined(__TERMUX__)
74
#define INFIX_OS_TERMUX
75
#define INFIX_OS_ANDROID
76
#define INFIX_OS_LINUX
77
#define INFIX_ENV_POSIX
78
#define INFIX_ENV_TERMUX 1
79
#elif defined(__ANDROID__)
80
#define INFIX_OS_ANDROID
81
#define INFIX_OS_LINUX
82
#define INFIX_ENV_POSIX
83
#elif defined(__APPLE__)
84
#define INFIX_ENV_POSIX
85
#define _DARWIN_C_SOURCE
86
#include <TargetConditionals.h>
87
#include <libkern/OSCacheControl.h>
88
#include <pthread.h>
89
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
90
#define INFIX_OS_IOS
91
#elif TARGET_OS_MAC
92
#define INFIX_OS_MACOS
93
#else
94
#error "Unsupported/unknown Apple platform"
95
#endif
96
#elif defined(__linux__)
97
#define INFIX_OS_LINUX
98
#define INFIX_ENV_POSIX
99
#elif defined(__FreeBSD__)
100
#define INFIX_OS_FREEBSD
101
#define INFIX_ENV_POSIX
102
#elif defined(__OpenBSD__)
103
#define INFIX_OS_OPENBSD
104
#define INFIX_ENV_POSIX
105
#elif defined(__NetBSD__)
106
#define INFIX_OS_NETBSD
107
#define INFIX_ENV_POSIX
108
#elif defined(__DragonFly__)
109
#define INFIX_OS_DRAGONFLY
110
#define INFIX_ENV_POSIX
111
#elif defined(__sun) && defined(__SVR4)
112
#define INFIX_OS_SOLARIS
113
#define INFIX_ENV_POSIX
114
#elif defined(__HAIKU__)
115
#define INFIX_OS_HAIKU
116
#define INFIX_ENV_POSIX
117
#else
118
#warning "Unsupported/unknown operating system"
119
#endif
120
// Compiler Detection
125
#if defined(__clang__)
126
#define INFIX_COMPILER_CLANG
127
#elif defined(_MSC_VER)
128
#define INFIX_COMPILER_MSVC
129
#elif defined(__GNUC__)
130
#define INFIX_COMPILER_GCC
131
#else
132
#warning "Compiler: Unknown compiler detected."
133
#define INFIX_COMPILER_NFI
134
#endif
135
// CPU Architecture Detection
141
#if defined(__aarch64__) || defined(_M_ARM64)
142
#define INFIX_ARCH_AARCH64
143
#elif defined(__x86_64__) || defined(_M_X64)
144
#define INFIX_ARCH_X64
145
#else
146
#error "Unsupported architecture. Only x86-64 and AArch64 are currently supported."
147
#endif
148
// Target ABI Logic Selection
162
#if defined(INFIX_FORCE_ABI_WINDOWS_X64)
163
#define INFIX_ABI_WINDOWS_X64 1
164
#define INFIX_ABI_FORCED 1
165
#elif defined(INFIX_FORCE_ABI_SYSV_X64)
166
#define INFIX_ABI_SYSV_X64 1
167
#define INFIX_ABI_FORCED 1
168
#elif defined(INFIX_FORCE_ABI_AAPCS64)
169
#define INFIX_ABI_AAPCS64 1
170
#define INFIX_ABI_FORCED 1
171
#endif
172
// Automatic ABI detection if not forced by the user.
173
#ifndef INFIX_ABI_FORCED
174
#if defined(INFIX_ARCH_AARCH64)
175
// All AArch64 platforms (Linux, macOS, Windows) use the same base calling
176
// convention (AAPCS64), although with minor differences for variadic arguments
177
// that are handled within the `abi_arm64.c` implementation.
178
#define INFIX_ABI_AAPCS64
179
#elif defined(INFIX_ARCH_X64)
180
#if defined(INFIX_OS_WINDOWS)
181
// Windows on x86-64 uses the Microsoft x64 calling convention.
182
#define INFIX_ABI_WINDOWS_X64
183
#else
184
// All other x86-64 platforms (Linux, macOS, BSDs, etc.) use the System V AMD64 ABI.
185
#define INFIX_ABI_SYSV_X64
186
#endif
187
#endif
188
#endif
// INFIX_ABI_FORCED
189
// Miscellaneous Constants
201
#define INFIX_TRAMPOLINE_HEADROOM 128
src
common
infix_config.h
Generated by
1.9.8