@xnetx/tinyc-native-x86_64-linux-gnu 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/natives/x86_64-linux-gnu/toolchain/aarch64-linux-android/tinyc +0 -0
- package/natives/x86_64-linux-gnu/toolchain/aarch64-linux-gnu/tinyc +0 -0
- package/natives/x86_64-linux-gnu/toolchain/riscv64-linux-gnu/tinyc +0 -0
- package/natives/x86_64-linux-gnu/toolchain/x86_64-linux-android/tinyc +0 -0
- package/natives/x86_64-linux-gnu/toolchain/x86_64-linux-gnu/tinyc +0 -0
- package/natives/x86_64-linux-gnu/toolchain/x86_64-w64-mingw32/tinyc +0 -0
- package/package.json +15 -4
- package/packaging-manifest.json +197 -0
- package/sysroot/aarch64-linux-android/include/libtcc.h +116 -0
- package/sysroot/aarch64-linux-android/include/tinyc_io.h +123 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/float.h +75 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/stdalign.h +16 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/stdarg.h +14 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/stdatomic.h +171 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/stdbool.h +11 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/stddef.h +39 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/stdnoreturn.h +7 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/tccdefs.h +338 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/tcclib.h +82 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/tgmath.h +89 -0
- package/sysroot/aarch64-linux-android/lib/tcc/include/varargs.h +12 -0
- package/sysroot/aarch64-linux-android/lib/tcc/libtcc1.a +0 -0
- package/sysroot/aarch64-linux-android/manifest.json +17 -0
- package/sysroot/aarch64-linux-gnu/include/libtcc.h +116 -0
- package/sysroot/aarch64-linux-gnu/include/tinyc_io.h +123 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/float.h +75 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/stdalign.h +16 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/stdarg.h +14 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/stdatomic.h +171 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/stdbool.h +11 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/stddef.h +39 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/stdnoreturn.h +7 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/tccdefs.h +338 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/tcclib.h +82 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/tgmath.h +89 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/include/varargs.h +12 -0
- package/sysroot/aarch64-linux-gnu/lib/tcc/libtcc1.a +0 -0
- package/sysroot/aarch64-linux-gnu/manifest.json +15 -0
- package/sysroot/riscv64-linux-gnu/include/libtcc.h +116 -0
- package/sysroot/riscv64-linux-gnu/include/tinyc_io.h +123 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/float.h +75 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/stdalign.h +16 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/stdarg.h +14 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/stdatomic.h +171 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/stdbool.h +11 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/stddef.h +39 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/stdnoreturn.h +7 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/tccdefs.h +338 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/tcclib.h +82 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/tgmath.h +89 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/include/varargs.h +12 -0
- package/sysroot/riscv64-linux-gnu/lib/tcc/libtcc1.a +0 -0
- package/sysroot/riscv64-linux-gnu/manifest.json +15 -0
- package/sysroot/x86_64-linux-android/include/libtcc.h +116 -0
- package/sysroot/x86_64-linux-android/include/tinyc_io.h +123 -0
- package/sysroot/x86_64-linux-android/lib/libtcc.a +0 -0
- package/sysroot/x86_64-linux-android/lib/tcc/bcheck.o +0 -0
- package/sysroot/x86_64-linux-android/lib/tcc/bcheck_run.o +0 -0
- package/sysroot/x86_64-linux-android/lib/tcc/bt-exe.o +0 -0
- package/sysroot/x86_64-linux-android/lib/tcc/bt-log.o +0 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/float.h +75 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/stdalign.h +16 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/stdarg.h +14 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/stdatomic.h +171 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/stdbool.h +11 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/stddef.h +39 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/stdnoreturn.h +7 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/tccdefs.h +338 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/tcclib.h +82 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/tgmath.h +89 -0
- package/sysroot/x86_64-linux-android/lib/tcc/include/varargs.h +12 -0
- package/sysroot/x86_64-linux-android/lib/tcc/libtcc1.a +0 -0
- package/sysroot/x86_64-linux-android/lib/tcc/runmain.o +0 -0
- package/sysroot/x86_64-linux-android/manifest.json +17 -0
- package/sysroot/x86_64-linux-gnu/include/libtcc.h +116 -0
- package/sysroot/x86_64-linux-gnu/include/tinyc_io.h +123 -0
- package/sysroot/x86_64-linux-gnu/lib/libtcc.a +0 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/bcheck.o +0 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/bcheck_run.o +0 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/bt-exe.o +0 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/bt-log.o +0 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/float.h +75 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/stdalign.h +16 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/stdarg.h +14 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/stdatomic.h +171 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/stdbool.h +11 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/stddef.h +39 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/stdnoreturn.h +7 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/tccdefs.h +338 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/tcclib.h +82 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/tgmath.h +89 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/include/varargs.h +12 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/libtcc1.a +0 -0
- package/sysroot/x86_64-linux-gnu/lib/tcc/runmain.o +0 -0
- package/sysroot/x86_64-linux-gnu/manifest.json +15 -0
- package/sysroot/x86_64-w64-mingw32/include/libtcc.h +116 -0
- package/sysroot/x86_64-w64-mingw32/include/tinyc_io.h +123 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/_mingw.h +171 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/assert.h +62 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/conio.h +409 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/ctype.h +281 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/dir.h +31 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/direct.h +68 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/dirent.h +135 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/dos.h +55 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/errno.h +75 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/excpt.h +123 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/fcntl.h +52 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/fenv.h +108 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/float.h +75 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/inttypes.h +297 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/io.h +418 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/iso646.h +36 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/limits.h +116 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/locale.h +91 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/malloc.h +181 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/math.h +497 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/mem.h +13 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/memory.h +40 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/process.h +176 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/conio_s.h +42 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/crtdbg_s.h +19 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/io_s.h +33 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/mbstring_s.h +52 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/search_s.h +25 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/stdio_s.h +145 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/stdlib_s.h +67 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/stralign_s.h +30 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/string_s.h +41 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/sys/timeb_s.h +34 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/tchar_s.h +266 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/time_s.h +61 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sec_api/wchar_s.h +128 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/setjmp.h +199 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/share.h +28 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/signal.h +63 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdalign.h +16 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdarg.h +14 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdatomic.h +171 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdbool.h +11 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stddef.h +39 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdint.h +212 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdio.h +429 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdlib.h +606 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/stdnoreturn.h +7 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/string.h +164 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/fcntl.h +13 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/file.h +14 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/locking.h +30 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/stat.h +290 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/time.h +69 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/timeb.h +133 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/types.h +123 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/unistd.h +14 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/sys/utime.h +146 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/tcc/tcc_libm.h +618 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/tccdefs.h +338 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/tcclib.h +82 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/tchar.h +1102 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/tgmath.h +89 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/time.h +287 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/uchar.h +33 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/unistd.h +1 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/vadefs.h +11 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/values.h +4 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/varargs.h +12 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/wchar.h +873 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/wctype.h +172 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/basetsd.h +149 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/basetyps.h +85 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/guiddef.h +156 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/poppack.h +8 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/pshpack1.h +8 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/pshpack2.h +8 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/pshpack4.h +8 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/pshpack8.h +8 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/qos.h +72 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/shellapi.h +59 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winbase.h +2966 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/wincon.h +309 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/windef.h +293 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/windows.h +127 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winerror.h +3166 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/wingdi.h +4080 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winnls.h +778 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winnt.h +5994 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winreg.h +272 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winsock2.h +1474 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winuser.h +5652 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/winver.h +160 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/ws2ipdef.h +21 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/include/winapi/ws2tcpip.h +391 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/lib/gdi32.def +337 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/lib/kernel32.def +776 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/lib/libtcc1.a +0 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/lib/msvcrt.def +1320 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/lib/user32.def +658 -0
- package/sysroot/x86_64-w64-mingw32/lib/tcc/win32/lib/ws2_32.def +198 -0
- package/sysroot/x86_64-w64-mingw32/manifest.json +15 -0
- package/README.md +0 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#ifndef LIBTCC_H
|
|
2
|
+
#define LIBTCC_H
|
|
3
|
+
|
|
4
|
+
#ifndef LIBTCCAPI
|
|
5
|
+
# define LIBTCCAPI
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
extern "C" {
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
/*****************************/
|
|
13
|
+
/* set custom allocator for all allocations (optional), NULL for default. */
|
|
14
|
+
typedef void *TCCReallocFunc(void *ptr, unsigned long size);
|
|
15
|
+
LIBTCCAPI void tcc_set_realloc(TCCReallocFunc *my_realloc);
|
|
16
|
+
|
|
17
|
+
/*****************************/
|
|
18
|
+
typedef struct TCCState TCCState;
|
|
19
|
+
|
|
20
|
+
/* create a new TCC compilation context */
|
|
21
|
+
LIBTCCAPI TCCState *tcc_new(void);
|
|
22
|
+
|
|
23
|
+
/* free a TCC compilation context */
|
|
24
|
+
LIBTCCAPI void tcc_delete(TCCState *s);
|
|
25
|
+
|
|
26
|
+
/* set CONFIG_TCCDIR at runtime */
|
|
27
|
+
LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
|
|
28
|
+
|
|
29
|
+
/* set error/warning callback (optional) */
|
|
30
|
+
typedef void TCCErrorFunc(void *opaque, const char *msg);
|
|
31
|
+
LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque, TCCErrorFunc *error_func);
|
|
32
|
+
|
|
33
|
+
/* set options as from command line (multiple supported) */
|
|
34
|
+
LIBTCCAPI int tcc_set_options(TCCState *s, const char *str);
|
|
35
|
+
|
|
36
|
+
/*****************************/
|
|
37
|
+
/* preprocessor */
|
|
38
|
+
|
|
39
|
+
/* add include path */
|
|
40
|
+
LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
|
|
41
|
+
|
|
42
|
+
/* add in system include path */
|
|
43
|
+
LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
|
|
44
|
+
|
|
45
|
+
/* define preprocessor symbol 'sym'. value can be NULL, sym can be "sym=val" */
|
|
46
|
+
LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
|
|
47
|
+
|
|
48
|
+
/* undefine preprocess symbol 'sym' */
|
|
49
|
+
LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
|
|
50
|
+
|
|
51
|
+
/*****************************/
|
|
52
|
+
/* compiling */
|
|
53
|
+
|
|
54
|
+
/* add a file (C file, dll, object, library, ld script). Return -1 if error. */
|
|
55
|
+
LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename);
|
|
56
|
+
|
|
57
|
+
/* compile a string containing a C source. Return -1 if error. */
|
|
58
|
+
LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
|
|
59
|
+
|
|
60
|
+
/* Tip: to have more specific errors/warnings from tcc_compile_string(),
|
|
61
|
+
you can prefix the string with "#line <num> \"<filename>\"\n" */
|
|
62
|
+
|
|
63
|
+
/*****************************/
|
|
64
|
+
/* linking commands */
|
|
65
|
+
|
|
66
|
+
/* set output type. MUST BE CALLED before any compilation */
|
|
67
|
+
LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
|
|
68
|
+
#define TCC_OUTPUT_MEMORY 1 /* output will be run in memory */
|
|
69
|
+
#define TCC_OUTPUT_EXE 2 /* executable file */
|
|
70
|
+
#define TCC_OUTPUT_DLL 4 /* dynamic library */
|
|
71
|
+
#define TCC_OUTPUT_OBJ 3 /* object file */
|
|
72
|
+
#define TCC_OUTPUT_PREPROCESS 5 /* only preprocess */
|
|
73
|
+
|
|
74
|
+
/* equivalent to -Lpath option */
|
|
75
|
+
LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
|
|
76
|
+
|
|
77
|
+
/* the library name is the same as the argument of the '-l' option */
|
|
78
|
+
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
|
|
79
|
+
|
|
80
|
+
/* add a symbol to the compiled program */
|
|
81
|
+
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
|
|
82
|
+
|
|
83
|
+
/* output an executable, library or object file. DO NOT call
|
|
84
|
+
tcc_relocate() before. */
|
|
85
|
+
LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
|
|
86
|
+
|
|
87
|
+
/* link and run main() function and return its value. DO NOT call
|
|
88
|
+
tcc_relocate() before. */
|
|
89
|
+
LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
|
|
90
|
+
|
|
91
|
+
/* do all relocations (needed before using tcc_get_symbol()) */
|
|
92
|
+
LIBTCCAPI int tcc_relocate(TCCState *s1);
|
|
93
|
+
|
|
94
|
+
/* return symbol value or NULL if not found */
|
|
95
|
+
LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
|
|
96
|
+
|
|
97
|
+
/* list all (global) symbols and their values via 'symbol_cb()' */
|
|
98
|
+
LIBTCCAPI void tcc_list_symbols(TCCState *s, void *ctx,
|
|
99
|
+
void (*symbol_cb)(void *ctx, const char *name, const void *val));
|
|
100
|
+
|
|
101
|
+
/* experimental/advanced section (see libtcc_test_mt.c for an example) */
|
|
102
|
+
|
|
103
|
+
/* catch runtime exceptions (optionally limit backtraces at top_func),
|
|
104
|
+
when using tcc_set_options("-bt") and when not using tcc_run() */
|
|
105
|
+
LIBTCCAPI void *_tcc_setjmp(TCCState *s1, void *jmp_buf, void *top_func, void *longjmp);
|
|
106
|
+
#define tcc_setjmp(s1,jb,f) setjmp(_tcc_setjmp(s1, jb, f, longjmp))
|
|
107
|
+
|
|
108
|
+
/* custom error printer for runtime exceptions. Returning 0 stops backtrace */
|
|
109
|
+
typedef int TCCBtFunc(void *udata, void *pc, const char *file, int line, const char* func, const char *msg);
|
|
110
|
+
LIBTCCAPI void tcc_set_backtrace_func(TCCState *s1, void* userdata, TCCBtFunc*);
|
|
111
|
+
|
|
112
|
+
#ifdef __cplusplus
|
|
113
|
+
}
|
|
114
|
+
#endif
|
|
115
|
+
|
|
116
|
+
#endif
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* tinyc_io.h - IO abstraction for the TinyC dual-form kernel.
|
|
2
|
+
*
|
|
3
|
+
* All compiler-owned input/output goes through a TCCIO object.
|
|
4
|
+
* A NULL TCCIO everywhere in this API means the stdio implementation:
|
|
5
|
+
* output goes directly to the process's real stdout/stderr and input
|
|
6
|
+
* comes from the real stdin.
|
|
7
|
+
*/
|
|
8
|
+
#ifndef TINYC_IO_H
|
|
9
|
+
#define TINYC_IO_H
|
|
10
|
+
|
|
11
|
+
#include <stddef.h>
|
|
12
|
+
#include <stdio.h>
|
|
13
|
+
|
|
14
|
+
#ifdef __cplusplus
|
|
15
|
+
extern "C" {
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
typedef struct TCCIO TCCIO;
|
|
19
|
+
struct TCCIO {
|
|
20
|
+
void *ctx;
|
|
21
|
+
/* Return the number of bytes consumed, or -1 on error. */
|
|
22
|
+
int (*write_out)(void *ctx, const char *buf, size_t len);
|
|
23
|
+
int (*write_err)(void *ctx, const char *buf, size_t len);
|
|
24
|
+
/* Return bytes read (0 = EOF), or -1 on error. */
|
|
25
|
+
int (*read_in)(void *ctx, char *buf, size_t cap);
|
|
26
|
+
void (*flush)(void *ctx);
|
|
27
|
+
/* Internal: release ctx. Set by constructors, used by tcc_io_free. */
|
|
28
|
+
void (*destroy_ctx)(void *ctx);
|
|
29
|
+
int is_singleton; /* stdio/null: tcc_io_free is a no-op */
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/* ---- ready-made implementations ------------------------------------ */
|
|
33
|
+
|
|
34
|
+
/* The default: out -> stdout, err -> stderr, in <- stdin. Singleton. */
|
|
35
|
+
TCCIO *tcc_io_stdio(void);
|
|
36
|
+
/* Discards all output, input is always EOF. Singleton. */
|
|
37
|
+
TCCIO *tcc_io_null(void);
|
|
38
|
+
/* Accumulates out and err in two separate memory buffers. */
|
|
39
|
+
TCCIO *tcc_io_buffer(void);
|
|
40
|
+
/* Accumulates out and err in one shared buffer, in write order. */
|
|
41
|
+
TCCIO *tcc_io_buffer_merged(void);
|
|
42
|
+
/* Writes to files it opens itself (closed by tcc_io_free).
|
|
43
|
+
* err_path == NULL sends err to the same file as out. */
|
|
44
|
+
TCCIO *tcc_io_file(const char *out_path, const char *err_path);
|
|
45
|
+
/* Writes to borrowed file descriptors (never closed by tcc_io_free).
|
|
46
|
+
* A descriptor of -1 leaves that channel on stdio. */
|
|
47
|
+
TCCIO *tcc_io_fd(int out_fd, int err_fd, int in_fd);
|
|
48
|
+
/* Writes to borrowed FILE* streams (never closed by tcc_io_free).
|
|
49
|
+
* A NULL stream leaves that channel on stdio. */
|
|
50
|
+
TCCIO *tcc_io_FILE(FILE *out, FILE *err, FILE *in);
|
|
51
|
+
/* Fully custom callbacks. Any callback may be NULL (channel = stdio). */
|
|
52
|
+
TCCIO *tcc_io_callback(int (*write_out)(void *, const char *, size_t),
|
|
53
|
+
int (*write_err)(void *, const char *, size_t),
|
|
54
|
+
int (*read_in)(void *, char *, size_t),
|
|
55
|
+
void *ctx);
|
|
56
|
+
/* Sends every channel to both a and b. Takes ownership of neither. */
|
|
57
|
+
TCCIO *tcc_io_tee(TCCIO *a, TCCIO *b);
|
|
58
|
+
|
|
59
|
+
void tcc_io_free(TCCIO *io);
|
|
60
|
+
|
|
61
|
+
/* Buffer implementations only: channel 0 = out, 1 = err.
|
|
62
|
+
* For the merged buffer both channels return the same data. */
|
|
63
|
+
const char *tcc_io_buffer_data(TCCIO *io, int channel, size_t *len);
|
|
64
|
+
void tcc_io_buffer_clear(TCCIO *io);
|
|
65
|
+
|
|
66
|
+
/* ---- current IO (used by the compiler's own output paths) ---------- */
|
|
67
|
+
|
|
68
|
+
/* Install io as the current IO for subsequent compiler output.
|
|
69
|
+
* NULL restores the stdio default. */
|
|
70
|
+
void tinyc_set_io(TCCIO *io);
|
|
71
|
+
TCCIO *tinyc_get_io(void);
|
|
72
|
+
|
|
73
|
+
/* Write helpers honoring the current IO (stdio when none is set). */
|
|
74
|
+
int tinyc_io_write_out(const char *buf, size_t len);
|
|
75
|
+
int tinyc_io_write_err(const char *buf, size_t len);
|
|
76
|
+
void tinyc_io_out_str(const char *s);
|
|
77
|
+
void tinyc_io_err_str(const char *s);
|
|
78
|
+
void tinyc_io_out_fmt(const char *fmt, ...);
|
|
79
|
+
void tinyc_io_err_line(const char *s); /* writes s + "\n" to err */
|
|
80
|
+
void tinyc_io_flush_all(void);
|
|
81
|
+
|
|
82
|
+
/* On Linux: a FILE* whose writes forward to the current IO's out
|
|
83
|
+
* channel, or NULL when the current IO is the stdio default. */
|
|
84
|
+
FILE *tinyc_io_open_out_stream(void);
|
|
85
|
+
|
|
86
|
+
/* ---- -run stdio redirection ----------------------------------------- */
|
|
87
|
+
|
|
88
|
+
/* Called by tcc_run around the run program's entry point. When the
|
|
89
|
+
* current IO is a non-stdio TCCIO, the process's fd 0/1/2 are
|
|
90
|
+
* redirected through it for the duration of the run: fd 0 is fed the
|
|
91
|
+
* bytes read_in returns (then EOF), and what the program writes to
|
|
92
|
+
* fd 1/2 is delivered to write_out/write_err, per channel, when the
|
|
93
|
+
* run ends. The host's fds are restored by tinyc_run_redirect_end.
|
|
94
|
+
* With no IO installed, or the stdio IO, both functions are no-ops
|
|
95
|
+
* and the run program uses the process's real stdio.
|
|
96
|
+
* keep_stdin != 0 leaves fd 0 alone (tcc_run has already reopened
|
|
97
|
+
* stdin from a file for the program). Nested calls are counted:
|
|
98
|
+
* only the outermost pair redirects. */
|
|
99
|
+
void tinyc_run_redirect_begin(int keep_stdin);
|
|
100
|
+
void tinyc_run_redirect_end(void);
|
|
101
|
+
|
|
102
|
+
/* ---- run-path diagnostic markers ------------------------------------ */
|
|
103
|
+
|
|
104
|
+
/* Append one line to the platform diagnostic markers file
|
|
105
|
+
* (tinyc_init.markers on Windows). The run path calls these at its
|
|
106
|
+
* internal stage boundaries so that a crash inside tcc_run leaves
|
|
107
|
+
* the last completed stage on record. Only the Windows image has
|
|
108
|
+
* a markers file; everywhere else these are no-ops. */
|
|
109
|
+
void tinyc_diag_mark(const char *line);
|
|
110
|
+
void tinyc_diag_mark_ptr(const char *label, const void *p);
|
|
111
|
+
|
|
112
|
+
/* ---- dual-form entry points ----------------------------------------- */
|
|
113
|
+
|
|
114
|
+
/* The compiler's real main, exported from the dual-form file. */
|
|
115
|
+
int tinyc_main(int argc, char **argv);
|
|
116
|
+
/* tinyc_main with an IO installed for the duration of the call.
|
|
117
|
+
* The previous IO is restored before returning. */
|
|
118
|
+
int tinyc_main_io(int argc, char **argv, TCCIO *io);
|
|
119
|
+
|
|
120
|
+
#ifdef __cplusplus
|
|
121
|
+
}
|
|
122
|
+
#endif
|
|
123
|
+
#endif /* TINYC_IO_H */
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#ifndef _FLOAT_H_
|
|
2
|
+
#define _FLOAT_H_
|
|
3
|
+
|
|
4
|
+
#define FLT_RADIX 2
|
|
5
|
+
|
|
6
|
+
/* IEEE float */
|
|
7
|
+
#define FLT_MANT_DIG 24
|
|
8
|
+
#define FLT_DIG 6
|
|
9
|
+
#define FLT_ROUNDS 1
|
|
10
|
+
#define FLT_EPSILON 1.19209290e-07F
|
|
11
|
+
#define FLT_MIN_EXP (-125)
|
|
12
|
+
#define FLT_MIN 1.17549435e-38F
|
|
13
|
+
#define FLT_MIN_10_EXP (-37)
|
|
14
|
+
#define FLT_MAX_EXP 128
|
|
15
|
+
#define FLT_MAX 3.40282347e+38F
|
|
16
|
+
#define FLT_MAX_10_EXP 38
|
|
17
|
+
|
|
18
|
+
/* IEEE double */
|
|
19
|
+
#define DBL_MANT_DIG 53
|
|
20
|
+
#define DBL_DIG 15
|
|
21
|
+
#define DBL_EPSILON 2.2204460492503131e-16
|
|
22
|
+
#define DBL_MIN_EXP (-1021)
|
|
23
|
+
#define DBL_MIN 2.2250738585072014e-308
|
|
24
|
+
#define DBL_MIN_10_EXP (-307)
|
|
25
|
+
#define DBL_MAX_EXP 1024
|
|
26
|
+
#define DBL_MAX 1.7976931348623157e+308
|
|
27
|
+
#define DBL_MAX_10_EXP 308
|
|
28
|
+
|
|
29
|
+
/* horrible intel long double */
|
|
30
|
+
#if defined __i386__ || defined __x86_64__
|
|
31
|
+
|
|
32
|
+
#define LDBL_MANT_DIG 64
|
|
33
|
+
#define LDBL_DIG 18
|
|
34
|
+
#define LDBL_EPSILON 1.08420217248550443401e-19L
|
|
35
|
+
#define LDBL_MIN_EXP (-16381)
|
|
36
|
+
#define LDBL_MIN 3.36210314311209350626e-4932L
|
|
37
|
+
#define LDBL_MIN_10_EXP (-4931)
|
|
38
|
+
#define LDBL_MAX_EXP 16384
|
|
39
|
+
#define LDBL_MAX 1.18973149535723176502e+4932L
|
|
40
|
+
#define LDBL_MAX_10_EXP 4932
|
|
41
|
+
#define DECIMAL_DIG 21
|
|
42
|
+
|
|
43
|
+
#elif defined __aarch64__ || defined __riscv
|
|
44
|
+
/*
|
|
45
|
+
* Use values from:
|
|
46
|
+
* gcc -dM -E -xc /dev/null | grep LDBL | sed -e "s/__//g"
|
|
47
|
+
*/
|
|
48
|
+
#define LDBL_MANT_DIG 113
|
|
49
|
+
#define LDBL_DIG 33
|
|
50
|
+
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
|
|
51
|
+
#define LDBL_MIN_EXP (-16381)
|
|
52
|
+
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
|
|
53
|
+
#define LDBL_MIN_10_EXP (-4931)
|
|
54
|
+
#define LDBL_MAX_EXP 16384
|
|
55
|
+
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
|
|
56
|
+
#define LDBL_MAX_10_EXP 4932
|
|
57
|
+
#define DECIMAL_DIG 36
|
|
58
|
+
|
|
59
|
+
#else
|
|
60
|
+
|
|
61
|
+
/* same as IEEE double */
|
|
62
|
+
#define LDBL_MANT_DIG 53
|
|
63
|
+
#define LDBL_DIG 15
|
|
64
|
+
#define LDBL_EPSILON 2.2204460492503131e-16L
|
|
65
|
+
#define LDBL_MIN_EXP (-1021)
|
|
66
|
+
#define LDBL_MIN 2.2250738585072014e-308L
|
|
67
|
+
#define LDBL_MIN_10_EXP (-307)
|
|
68
|
+
#define LDBL_MAX_EXP 1024
|
|
69
|
+
#define LDBL_MAX 1.7976931348623157e+308L
|
|
70
|
+
#define LDBL_MAX_10_EXP 308
|
|
71
|
+
#define DECIMAL_DIG 17
|
|
72
|
+
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
#endif /* _FLOAT_H_ */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#ifndef _STDALIGN_H
|
|
2
|
+
#define _STDALIGN_H
|
|
3
|
+
|
|
4
|
+
#if __STDC_VERSION__ < 201112L && (defined(__GNUC__) || defined(__TINYC__))
|
|
5
|
+
# define _Alignas(t) __attribute__((__aligned__(t)))
|
|
6
|
+
# define _Alignof(t) __alignof__(t)
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#define alignas _Alignas
|
|
10
|
+
#define alignof _Alignof
|
|
11
|
+
|
|
12
|
+
#define __alignas_is_defined 1
|
|
13
|
+
#define __alignof_is_defined 1
|
|
14
|
+
|
|
15
|
+
#endif /* _STDALIGN_H */
|
|
16
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#ifndef _STDARG_H
|
|
2
|
+
#define _STDARG_H
|
|
3
|
+
|
|
4
|
+
typedef __builtin_va_list va_list;
|
|
5
|
+
#define va_start __builtin_va_start
|
|
6
|
+
#define va_arg __builtin_va_arg
|
|
7
|
+
#define va_copy __builtin_va_copy
|
|
8
|
+
#define va_end __builtin_va_end
|
|
9
|
+
|
|
10
|
+
/* fix a buggy dependency on GCC in libio.h */
|
|
11
|
+
typedef va_list __gnuc_va_list;
|
|
12
|
+
#define _VA_LIST_DEFINED
|
|
13
|
+
|
|
14
|
+
#endif /* _STDARG_H */
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/* This file is derived from clang's stdatomic.h */
|
|
2
|
+
|
|
3
|
+
/*===---- stdatomic.h - Standard header for atomic types and operations -----===
|
|
4
|
+
*
|
|
5
|
+
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
6
|
+
* See https://llvm.org/LICENSE.txt for license information.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
8
|
+
*
|
|
9
|
+
*===-----------------------------------------------------------------------===
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#ifndef _STDATOMIC_H
|
|
13
|
+
#define _STDATOMIC_H
|
|
14
|
+
|
|
15
|
+
#include <stddef.h>
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
#include <stdbool.h>
|
|
18
|
+
|
|
19
|
+
#define __ATOMIC_RELAXED 0
|
|
20
|
+
#define __ATOMIC_CONSUME 1
|
|
21
|
+
#define __ATOMIC_ACQUIRE 2
|
|
22
|
+
#define __ATOMIC_RELEASE 3
|
|
23
|
+
#define __ATOMIC_ACQ_REL 4
|
|
24
|
+
#define __ATOMIC_SEQ_CST 5
|
|
25
|
+
|
|
26
|
+
/* Memory ordering */
|
|
27
|
+
typedef enum {
|
|
28
|
+
memory_order_relaxed = __ATOMIC_RELAXED,
|
|
29
|
+
memory_order_consume = __ATOMIC_CONSUME,
|
|
30
|
+
memory_order_acquire = __ATOMIC_ACQUIRE,
|
|
31
|
+
memory_order_release = __ATOMIC_RELEASE,
|
|
32
|
+
memory_order_acq_rel = __ATOMIC_ACQ_REL,
|
|
33
|
+
memory_order_seq_cst = __ATOMIC_SEQ_CST,
|
|
34
|
+
} memory_order;
|
|
35
|
+
|
|
36
|
+
/* Atomic typedefs */
|
|
37
|
+
typedef _Atomic(_Bool) atomic_bool;
|
|
38
|
+
typedef _Atomic(char) atomic_char;
|
|
39
|
+
typedef _Atomic(signed char) atomic_schar;
|
|
40
|
+
typedef _Atomic(unsigned char) atomic_uchar;
|
|
41
|
+
typedef _Atomic(short) atomic_short;
|
|
42
|
+
typedef _Atomic(unsigned short) atomic_ushort;
|
|
43
|
+
typedef _Atomic(int) atomic_int;
|
|
44
|
+
typedef _Atomic(unsigned int) atomic_uint;
|
|
45
|
+
typedef _Atomic(long) atomic_long;
|
|
46
|
+
typedef _Atomic(unsigned long) atomic_ulong;
|
|
47
|
+
typedef _Atomic(long long) atomic_llong;
|
|
48
|
+
typedef _Atomic(unsigned long long) atomic_ullong;
|
|
49
|
+
typedef _Atomic(uint_least16_t) atomic_char16_t;
|
|
50
|
+
typedef _Atomic(uint_least32_t) atomic_char32_t;
|
|
51
|
+
typedef _Atomic(wchar_t) atomic_wchar_t;
|
|
52
|
+
typedef _Atomic(int_least8_t) atomic_int_least8_t;
|
|
53
|
+
typedef _Atomic(uint_least8_t) atomic_uint_least8_t;
|
|
54
|
+
typedef _Atomic(int_least16_t) atomic_int_least16_t;
|
|
55
|
+
typedef _Atomic(uint_least16_t) atomic_uint_least16_t;
|
|
56
|
+
typedef _Atomic(int_least32_t) atomic_int_least32_t;
|
|
57
|
+
typedef _Atomic(uint_least32_t) atomic_uint_least32_t;
|
|
58
|
+
typedef _Atomic(int_least64_t) atomic_int_least64_t;
|
|
59
|
+
typedef _Atomic(uint_least64_t) atomic_uint_least64_t;
|
|
60
|
+
typedef _Atomic(int_fast8_t) atomic_int_fast8_t;
|
|
61
|
+
typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t;
|
|
62
|
+
typedef _Atomic(int_fast16_t) atomic_int_fast16_t;
|
|
63
|
+
typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t;
|
|
64
|
+
typedef _Atomic(int_fast32_t) atomic_int_fast32_t;
|
|
65
|
+
typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t;
|
|
66
|
+
typedef _Atomic(int_fast64_t) atomic_int_fast64_t;
|
|
67
|
+
typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t;
|
|
68
|
+
typedef _Atomic(intptr_t) atomic_intptr_t;
|
|
69
|
+
typedef _Atomic(uintptr_t) atomic_uintptr_t;
|
|
70
|
+
typedef _Atomic(size_t) atomic_size_t;
|
|
71
|
+
typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t;
|
|
72
|
+
typedef _Atomic(intmax_t) atomic_intmax_t;
|
|
73
|
+
typedef _Atomic(uintmax_t) atomic_uintmax_t;
|
|
74
|
+
|
|
75
|
+
/* Atomic flag */
|
|
76
|
+
typedef struct {
|
|
77
|
+
atomic_bool value;
|
|
78
|
+
} atomic_flag;
|
|
79
|
+
|
|
80
|
+
#define ATOMIC_FLAG_INIT {0}
|
|
81
|
+
#define ATOMIC_VAR_INIT(value) (value)
|
|
82
|
+
|
|
83
|
+
/* Generic routines */
|
|
84
|
+
#define atomic_init(object, desired) \
|
|
85
|
+
atomic_store_explicit(object, desired, __ATOMIC_RELAXED)
|
|
86
|
+
|
|
87
|
+
#define __atomic_store_n(ptr, val, order) \
|
|
88
|
+
({ __typeof__ ((void)0, *(ptr)) __val = (val); \
|
|
89
|
+
__atomic_store((ptr), &__val, (order)); })
|
|
90
|
+
#define atomic_store_explicit(object, desired, order) \
|
|
91
|
+
({ __typeof__ (object) ptr = (object); \
|
|
92
|
+
__typeof__ (*ptr) tmp = (desired); \
|
|
93
|
+
__atomic_store (ptr, &tmp, (order)); \
|
|
94
|
+
})
|
|
95
|
+
#define atomic_store(object, desired) \
|
|
96
|
+
atomic_store_explicit (object, desired, __ATOMIC_SEQ_CST)
|
|
97
|
+
|
|
98
|
+
#define __atomic_load_n(ptr, order) \
|
|
99
|
+
({ typeof(*(ptr)) __val; \
|
|
100
|
+
__atomic_load((ptr), &__val, (order)); \
|
|
101
|
+
__val; })
|
|
102
|
+
#define atomic_load_explicit(object, order) \
|
|
103
|
+
({ __typeof__ (object) ptr = (object); \
|
|
104
|
+
__typeof__ ((void)0,*ptr) tmp; \
|
|
105
|
+
__atomic_load (ptr, &tmp, (order)); \
|
|
106
|
+
tmp; \
|
|
107
|
+
})
|
|
108
|
+
#define atomic_load(object) atomic_load_explicit (object, __ATOMIC_SEQ_CST)
|
|
109
|
+
|
|
110
|
+
#define atomic_exchange_explicit(object, desired, order) \
|
|
111
|
+
({ __typeof__ (object) ptr = (object); \
|
|
112
|
+
__typeof__ (*ptr) val = (desired); \
|
|
113
|
+
__typeof__ (*ptr) tmp; \
|
|
114
|
+
__atomic_exchange (ptr, &val, &tmp, (order)); \
|
|
115
|
+
tmp; \
|
|
116
|
+
})
|
|
117
|
+
#define atomic_exchange(object, desired) \
|
|
118
|
+
atomic_exchange_explicit (object, desired, __ATOMIC_SEQ_CST)
|
|
119
|
+
#define __atomic_compare_exchange_n(ptr, expected, desired, weak, success, failure) \
|
|
120
|
+
({ typeof(*(ptr)) __desired = (desired); \
|
|
121
|
+
__atomic_compare_exchange((ptr), (expected), &__desired, \
|
|
122
|
+
(weak), (success), (failure)); })
|
|
123
|
+
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
|
124
|
+
({ __typeof__ (object) ptr = (object); \
|
|
125
|
+
__typeof__ (*ptr) tmp = desired; \
|
|
126
|
+
__atomic_compare_exchange(ptr, expected, &tmp, 0, success, failure); \
|
|
127
|
+
})
|
|
128
|
+
#define atomic_compare_exchange_strong(object, expected, desired) \
|
|
129
|
+
atomic_compare_exchange_strong_explicit (object, expected, desired, \
|
|
130
|
+
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
|
|
131
|
+
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
|
132
|
+
({ __typeof__ (object) ptr = (object); \
|
|
133
|
+
__typeof__ (*ptr) tmp = desired; \
|
|
134
|
+
__atomic_compare_exchange(ptr, expected, &tmp, 1, success, failure); \
|
|
135
|
+
})
|
|
136
|
+
#define atomic_compare_exchange_weak(object, expected, desired) \
|
|
137
|
+
atomic_compare_exchange_weak_explicit (object, expected, desired, \
|
|
138
|
+
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
|
|
139
|
+
|
|
140
|
+
#define atomic_fetch_add(object, operand) \
|
|
141
|
+
__atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
|
|
142
|
+
#define atomic_fetch_add_explicit __atomic_fetch_add
|
|
143
|
+
|
|
144
|
+
#define atomic_fetch_sub(object, operand) \
|
|
145
|
+
__atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST)
|
|
146
|
+
#define atomic_fetch_sub_explicit __atomic_fetch_sub
|
|
147
|
+
|
|
148
|
+
#define atomic_fetch_or(object, operand) \
|
|
149
|
+
__atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
|
|
150
|
+
#define atomic_fetch_or_explicit __atomic_fetch_or
|
|
151
|
+
|
|
152
|
+
#define atomic_fetch_xor(object, operand) \
|
|
153
|
+
__atomic_fetch_xor(object, operand, __ATOMIC_SEQ_CST)
|
|
154
|
+
#define atomic_fetch_xor_explicit __atomic_fetch_xor
|
|
155
|
+
|
|
156
|
+
#define atomic_fetch_and(object, operand) \
|
|
157
|
+
__atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
|
|
158
|
+
#define atomic_fetch_and_explicit __atomic_fetch_and
|
|
159
|
+
|
|
160
|
+
extern void atomic_thread_fence (memory_order);
|
|
161
|
+
#define __atomic_thread_fence(order) atomic_thread_fence (order)
|
|
162
|
+
extern void atomic_signal_fence (memory_order);
|
|
163
|
+
#define __atomic_signal_fence(order) atomic_signal_fence(order)
|
|
164
|
+
extern bool __atomic_is_lock_free(size_t size, void *ptr);
|
|
165
|
+
#define atomic_is_lock_free(OBJ) __atomic_is_lock_free (sizeof (*(OBJ)), (OBJ))
|
|
166
|
+
|
|
167
|
+
extern bool atomic_flag_test_and_set(void *object);
|
|
168
|
+
extern bool atomic_flag_test_and_set_explicit(void *object, memory_order order);
|
|
169
|
+
extern void atomic_flag_clear(void *object);
|
|
170
|
+
extern void atomic_flag_clear_explicit(void *object, memory_order order);
|
|
171
|
+
#endif /* _STDATOMIC_H */
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#ifndef _STDDEF_H
|
|
2
|
+
#define _STDDEF_H
|
|
3
|
+
|
|
4
|
+
typedef __SIZE_TYPE__ size_t;
|
|
5
|
+
typedef __PTRDIFF_TYPE__ ssize_t;
|
|
6
|
+
typedef __WCHAR_TYPE__ wchar_t;
|
|
7
|
+
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
|
8
|
+
typedef __PTRDIFF_TYPE__ intptr_t;
|
|
9
|
+
typedef __SIZE_TYPE__ uintptr_t;
|
|
10
|
+
|
|
11
|
+
#if __STDC_VERSION__ >= 201112L
|
|
12
|
+
typedef union { long long __ll; long double __ld; } max_align_t;
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#ifndef NULL
|
|
16
|
+
#define NULL ((void*)0)
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#undef offsetof
|
|
20
|
+
#define offsetof(type, field) __builtin_offsetof(type, field)
|
|
21
|
+
|
|
22
|
+
void *alloca(size_t size);
|
|
23
|
+
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
/* Older glibc require a wint_t from <stddef.h> (when requested
|
|
27
|
+
by __need_wint_t, as otherwise stddef.h isn't allowed to
|
|
28
|
+
define this type). Note that this must be outside the normal
|
|
29
|
+
_STDDEF_H guard, so that it works even when we've included the file
|
|
30
|
+
already (without requiring wint_t). Some other libs define _WINT_T
|
|
31
|
+
if they've already provided that type, so we can use that as guard.
|
|
32
|
+
TCC defines __WINT_TYPE__ for us. */
|
|
33
|
+
#if defined (__need_wint_t)
|
|
34
|
+
#ifndef _WINT_T
|
|
35
|
+
#define _WINT_T
|
|
36
|
+
typedef __WINT_TYPE__ wint_t;
|
|
37
|
+
#endif
|
|
38
|
+
#undef __need_wint_t
|
|
39
|
+
#endif
|