mirror of
https://github.com/ziglang/zig.git
synced 2026-02-07 15:07:12 +00:00
* std.ArrayList gains `moveToUnmanaged` and dead code `ArrayListUnmanaged.appendWrite` is deleted. * emit_h state is attached to Module rather than Compilation. * remove the implementation of emit-h because it did not properly integrate with incremental compilation. I will re-implement it in a follow-up commit. * Compilation: use the .codegen_failure tag rather than .dependency_failure tag for when `bin_file.updateDecl` fails. C backend: * Use a CValue tagged union instead of strings for C values. * Cleanly separate state into Object and DeclGen: - Object is present only when generating a .c file - DeclGen is present for both generating a .c and .h * Move some functions into their respective Object/DeclGen namespace. * Forward decls are managed by the incremental compilation frontend; C backend no longer renders function signatures based on callsites. For simplicity, all functions always get forward decls. * Constants are managed by the incremental compilation frontend. C backend no longer has a "constants" section. * Participate in incremental compilation. Each Decl gets an ArrayList for its generated C code and it is updated when the Decl is updated. During flush(), all these are joined together in the output file. * The new CValue tagged union is used to clean up using of assigning to locals without an additional pointer local. * Fix bug with bitcast of non-pointers making the memcpy destination immutable.
46 lines
1005 B
C
46 lines
1005 B
C
#if __STDC_VERSION__ >= 199901L
|
|
#include <stdbool.h>
|
|
#else
|
|
#define bool unsigned char
|
|
#define true 1
|
|
#define false 0
|
|
#endif
|
|
|
|
#if __STDC_VERSION__ >= 201112L
|
|
#define zig_noreturn _Noreturn
|
|
#elif __GNUC__
|
|
#define zig_noreturn __attribute__ ((noreturn))
|
|
#elif _MSC_VER
|
|
#define zig_noreturn __declspec(noreturn)
|
|
#else
|
|
#define zig_noreturn
|
|
#endif
|
|
|
|
#if defined(__GNUC__)
|
|
#define zig_unreachable() __builtin_unreachable()
|
|
#else
|
|
#define zig_unreachable()
|
|
#endif
|
|
|
|
#if defined(_MSC_VER)
|
|
#define zig_breakpoint __debugbreak()
|
|
#else
|
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
|
#define zig_breakpoint __debugbreak()
|
|
#elif defined(__clang__)
|
|
#define zig_breakpoint __builtin_debugtrap()
|
|
#elif defined(__GNUC__)
|
|
#define zig_breakpoint __builtin_trap()
|
|
#elif defined(__i386__) || defined(__x86_64__)
|
|
#define zig_breakpoint __asm__ volatile("int $0x03");
|
|
#else
|
|
#define zig_breakpoint raise(SIGTRAP)
|
|
#endif
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#define int128_t __int128
|
|
#define uint128_t unsigned __int128
|
|
#include <string.h>
|
|
|