SWILIB API (X75)    
Loading...
Searching...
No Matches
gcc.h
Go to the documentation of this file.
1#pragma once
2
7#pragma weak __ex
8#pragma weak __sys_switab_addres
9
10#ifdef __cplusplus
11extern "C" const int __sys_switab_addres[];
12#else
13extern const int __sys_switab_addres[];
14#endif
15
16/* Modern */
17#ifdef __cplusplus
18 #define __swilib_begin \
19 _Pragma("GCC diagnostic push") \
20 _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
21 extern "C" {
22 #define __swilib_end } \
23 _Pragma("GCC diagnostic pop")
24#else
25 #define __swilib_begin \
26 _Pragma("GCC diagnostic push") \
27 _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
28 #define __swilib_end \
29 _Pragma("GCC diagnostic pop")
30#endif
31
32#ifdef SWILIB_NAMED_IMPORTS
33 #define __swi_stringify_(value) #value
34 #define __swi_stringify(value) __swi_stringify_(value)
35 #define __swi_import_name(number) "\"" __swi_stringify(number) "\""
36
37 #define __swi_begin(number)
38 #define __swi_end(number, func, call) __asm__(__swi_import_name(number)) __attribute__((weak))
39
40 #define __swi_noreturn_begin(number)
41 #define __swi_noreturn_end(number, func, call) \
42 __asm__(__swi_import_name(number)) __attribute__((weak, noreturn))
43
44 #define __swi_returns_twice_begin(number)
45 #define __swi_returns_twice_end(number, func, call) \
46 __asm__(__swi_import_name(number)) __attribute__((weak, returns_twice))
47
48 #define __swi_variadic_begin(number)
49 #define __swi_variadic_end(number, func, ...) \
50 __asm__(__swi_import_name(number)) __attribute__((weak))
51
52#else
53 #define __swi_begin(number) static inline __attribute__((flatten))
54 #define __swi_end(number, func, call) { \
55 if (number < 0x8000) { \
56 return ((__typeof__(&func)) __sys_switab_addres[number])call; \
57 } else { \
58 return ((__typeof__(func call)) __sys_switab_addres[number - 0x8000]); \
59 } \
60 }
61
62 #define __swi_noreturn_begin(number) static inline __attribute__((flatten, noreturn))
63 #define __swi_noreturn_end(number, func, call) { \
64 ((__typeof__(&func)) __sys_switab_addres[number])call; \
65 }
66
67 #define __swi_returns_twice_begin(number) static inline __attribute__((always_inline, returns_twice))
68 #define __swi_returns_twice_end(number, func, call) { \
69 return ((__typeof__(&func)) __sys_switab_addres[number])call; \
70 }
71
72 #define __swi_variadic_begin(number) \
73 _Pragma("GCC diagnostic push") \
74 _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") \
75 static inline __attribute__((always_inline))
76 #define __swi_variadic_end(number, func, ...) { \
77 return ((__typeof__(&func)) __sys_switab_addres[number])(__VA_ARGS__, __builtin_va_arg_pack()); \
78 } \
79 _Pragma("GCC diagnostic pop")
80
81#endif
82
83#define __swi_format(type, ...) \
84 __attribute__((format(type, ##__VA_ARGS__)))
85
86#define __swi_invoke(number, func, ...) \
87 ((__typeof__(&(func))) __sys_switab_addres[number])(__VA_ARGS__)
const int __sys_switab_addres[]
GCC compiler support.