| ... | ... | @@ -7869,6 +7869,30 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 7869 | 7869 | //assert(EndianBig == 0); |
| 7870 | 7870 | //assert(EndianLittle == 1); |
| 7871 | 7871 | } |
| 7872 | { |
| 7873 | buf_appendf(contents, |
| 7874 | "pub const SubSystem = enum {\n" |
| 7875 | " Auto,\n" |
| 7876 | " Console,\n" |
| 7877 | " Windows,\n" |
| 7878 | " Posix,\n" |
| 7879 | " Native,\n" |
| 7880 | " EfiApplication,\n" |
| 7881 | " EfiBootServiceDriver,\n" |
| 7882 | " EfiRom,\n" |
| 7883 | " EfiRuntimeDriver,\n" |
| 7884 | "};\n\n"); |
| 7885 | |
| 7886 | assert(TargetSubsystemAuto == 0); |
| 7887 | assert(TargetSubsystemConsole == 1); |
| 7888 | assert(TargetSubsystemWindows == 2); |
| 7889 | assert(TargetSubsystemPosix == 3); |
| 7890 | assert(TargetSubsystemNative == 4); |
| 7891 | assert(TargetSubsystemEfiApplication == 5); |
| 7892 | assert(TargetSubsystemEfiBootServiceDriver == 6); |
| 7893 | assert(TargetSubsystemEfiRom == 7); |
| 7894 | assert(TargetSubsystemEfiRuntimeDriver == 8); |
| 7895 | } |
| 7872 | 7896 | { |
| 7873 | 7897 | const char *endian_str = g->is_big_endian ? "Endian.Big" : "Endian.Little"; |
| 7874 | 7898 | buf_appendf(contents, "pub const endian = %s;\n", endian_str); |
| ... | ... | @@ -7885,6 +7909,21 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 7885 | 7909 | buf_appendf(contents, "pub const valgrind_support = %s;\n", bool_to_str(want_valgrind_support(g))); |
| 7886 | 7910 | buf_appendf(contents, "pub const position_independent_code = %s;\n", bool_to_str(g->have_pic)); |
| 7887 | 7911 | |
| 7912 | { |
| 7913 | static const char* subsystem_strings[] = { |
| 7914 | "Auto", |
| 7915 | "Console", |
| 7916 | "Windows", |
| 7917 | "Posix", |
| 7918 | "Native", |
| 7919 | "EfiApplication", |
| 7920 | "EfiBootServiceDriver", |
| 7921 | "EfiRom", |
| 7922 | "EfiRuntimeDriver", |
| 7923 | }; |
| 7924 | buf_appendf(contents, "pub const subsystem = SubSystem.%s;\n", subsystem_strings[g->subsystem]); |
| 7925 | } |
| 7926 | |
| 7888 | 7927 | if (g->is_test_build) { |
| 7889 | 7928 | buf_appendf(contents, |
| 7890 | 7929 | "const TestFn = struct {\n" |
| ... | ... | @@ -7928,6 +7967,7 @@ static Error define_builtin_compile_vars(CodeGen *g) { |
| 7928 | 7967 | cache_bool(&cache_hash, g->have_err_ret_tracing); |
| 7929 | 7968 | cache_bool(&cache_hash, g->libc_link_lib != nullptr); |
| 7930 | 7969 | cache_bool(&cache_hash, g->valgrind_support); |
| 7970 | cache_int(&cache_hash, g->subsystem); |
| 7931 | 7971 | |
| 7932 | 7972 | Buf digest = BUF_INIT; |
| 7933 | 7973 | buf_resize(&digest, 0); |