| author | |
| committer | |
| log | 8b6ea9ffe78480f9c73e9dee24edc5975c7f064e |
| tree | fbd338ce3434338ab29336fae2022037db1514b7 |
| parent | 4cb2f11693b1bf13770b8ad6a8b8a1e37101a516 |
2 files changed, 17 insertions(+), 1 deletions(-)
src/codegen/c.zig+3-1| ... | ... | @@ -2214,7 +2214,9 @@ fn airBreakpoint(f: *Function) !CValue { |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | fn airRetAddr(f: *Function) !CValue { |
| 2217 | return f.fail("TODO implement codegen for airRetAddr", .{}); | |
| 2217 | const local = try f.allocLocal(Type.usize, .Const); | |
| 2218 | try f.object.writer().writeAll(" = zig_return_address();\n"); | |
| 2219 | return local; | |
| 2218 | 2220 | } |
| 2219 | 2221 | |
| 2220 | 2222 | fn airFence(f: *Function, inst: Air.Inst.Index) !CValue { |
src/link/C/zig.h+14| ... | ... | @@ -60,6 +60,20 @@ |
| 60 | 60 | #define zig_breakpoint() raise(SIGTRAP) |
| 61 | 61 | #endif |
| 62 | 62 | |
| 63 | #if defined(_MSC_VER) | |
| 64 | #define zig_return_address() _ReturnAddress() | |
| 65 | #elif defined(__GNUC__) | |
| 66 | #define zig_return_address() __builtin_extract_return_addr(__builtin_return_address(0)) | |
| 67 | #else | |
| 68 | #define zig_return_address() 0 | |
| 69 | #endif | |
| 70 | ||
| 71 | #if defined(__GNUC__) | |
| 72 | #define zig_frame_address() __builtin_frame_address(0) | |
| 73 | #else | |
| 74 | #define zig_frame_address() 0 | |
| 75 | #endif | |
| 76 | ||
| 63 | 77 | #if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) |
| 64 | 78 | #include <stdatomic.h> |
| 65 | 79 | #define zig_cmpxchg_strong(obj, expected, desired, succ, fail) atomic_compare_exchange_strong_explicit(obj, &(expected), desired, succ, fail) |