diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-02-23 05:16:23 -0500 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-02-23 10:54:26 -0500 |
| commit | a0d7fd162b7568c0291ebcfc561a2852c7077e15 (patch) | |
| tree | 476a76289e5e5a3b25631d2d15e21a704189ead5 /lib/zig.h | |
| parent | 57f6adf85da58c0c91a036deaa614c30df010b78 (diff) | |
| download | zig-a0d7fd162b7568c0291ebcfc561a2852c7077e15.tar.gz zig-a0d7fd162b7568c0291ebcfc561a2852c7077e15.zip | |
CBE: support call attributes
* Support always_tail and never_tail/never_inline with a comptime callee using clang
* Support never_inline using gcc
* Support never_inline using msvc
Unfortunately, can't enable behavior tests because of the conditional support.
Diffstat (limited to 'lib/zig.h')
| -rw-r--r-- | lib/zig.h | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -78,6 +78,32 @@ typedef char bool; #define zig_cold #endif +#if zig_has_attribute(flatten) +#define zig_maybe_flatten __attribute__((flatten)) +#else +#define zig_maybe_flatten +#endif + +#if zig_has_attribute(noinline) +#define zig_never_inline __attribute__((noinline)) zig_maybe_flatten +#elif defined(_MSC_VER) +#define zig_never_inline __declspec(noinline) zig_maybe_flatten +#else +#define zig_never_inline zig_never_inline_unavailable +#endif + +#if zig_has_attribute(not_tail_called) +#define zig_never_tail __attribute__((not_tail_called)) zig_never_inline +#else +#define zig_never_tail zig_never_tail_unavailable +#endif + +#if zig_has_attribute(always_inline) +#define zig_always_tail __attribute__((musttail)) +#else +#define zig_always_tail zig_always_tail_unavailable +#endif + #if __STDC_VERSION__ >= 199901L #define zig_restrict restrict #elif defined(__GNUC__) |
