| author | |
| committer | |
| log | e932919e680aa6b6ef910e1c4ad969ac1ce0c46d |
| tree | 6bd041ade12f4889ecd82584c99dee2f380dbd47 |
| parent | dde7cc52d2f4780587b37604889c4568b8d79c62 |
15 files changed, 341 insertions(+), 132 deletions(-)
src-self-hosted/target.zig+1-1| ... | @@ -38,7 +38,7 @@ pub const Target = union(enum) { | ... | @@ -38,7 +38,7 @@ pub const Target = union(enum) { |
| 38 | 38 | ||
| 39 | pub fn isDarwin(self: &const Target) -> bool { | 39 | pub fn isDarwin(self: &const Target) -> bool { |
| 40 | return switch (self.getOs()) { | 40 | return switch (self.getOs()) { |
| 41 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => true, | 41 | builtin.Os.ios, builtin.Os.macosx => true, |
| 42 | else => false, | 42 | else => false, |
| 43 | }; | 43 | }; |
| 44 | } | 44 | } |
src/analyze.cpp+9-9| ... | @@ -32,7 +32,7 @@ ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) { | ... | @@ -32,7 +32,7 @@ ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) { |
| 32 | // failed semantic analysis, which isn't supposed to happen | 32 | // failed semantic analysis, which isn't supposed to happen |
| 33 | ErrorMsg *err = add_node_error(g, node->owner->c_import_node, | 33 | ErrorMsg *err = add_node_error(g, node->owner->c_import_node, |
| 34 | buf_sprintf("compiler bug: @cImport generated invalid zig code")); | 34 | buf_sprintf("compiler bug: @cImport generated invalid zig code")); |
| 35 | 35 | ||
| 36 | add_error_note(g, err, node, msg); | 36 | add_error_note(g, err, node, msg); |
| 37 | 37 | ||
| 38 | g->errors.append(err); | 38 | g->errors.append(err); |
| ... | @@ -2425,7 +2425,7 @@ static void resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) { | ... | @@ -2425,7 +2425,7 @@ static void resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) { |
| 2425 | qual_str = "extern"; | 2425 | qual_str = "extern"; |
| 2426 | break; | 2426 | break; |
| 2427 | } | 2427 | } |
| 2428 | AstNode *source_node = (decl_node->data.container_decl.init_arg_expr != nullptr) ? | 2428 | AstNode *source_node = (decl_node->data.container_decl.init_arg_expr != nullptr) ? |
| 2429 | decl_node->data.container_decl.init_arg_expr : decl_node; | 2429 | decl_node->data.container_decl.init_arg_expr : decl_node; |
| 2430 | add_node_error(g, source_node, | 2430 | add_node_error(g, source_node, |
| 2431 | buf_sprintf("%s union does not support enum tag type", qual_str)); | 2431 | buf_sprintf("%s union does not support enum tag type", qual_str)); |
| ... | @@ -2599,17 +2599,17 @@ void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, G | ... | @@ -2599,17 +2599,17 @@ void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, G |
| 2599 | g->windows_subsystem_windows = false; | 2599 | g->windows_subsystem_windows = false; |
| 2600 | g->windows_subsystem_console = true; | 2600 | g->windows_subsystem_console = true; |
| 2601 | } else if (buf_eql_str(symbol_name, "WinMain") && | 2601 | } else if (buf_eql_str(symbol_name, "WinMain") && |
| 2602 | g->zig_target.os == ZigLLVM_Win32) | 2602 | g->zig_target.os == OsWindows) |
| 2603 | { | 2603 | { |
| 2604 | g->have_winmain = true; | 2604 | g->have_winmain = true; |
| 2605 | g->windows_subsystem_windows = true; | 2605 | g->windows_subsystem_windows = true; |
| 2606 | g->windows_subsystem_console = false; | 2606 | g->windows_subsystem_console = false; |
| 2607 | } else if (buf_eql_str(symbol_name, "WinMainCRTStartup") && | 2607 | } else if (buf_eql_str(symbol_name, "WinMainCRTStartup") && |
| 2608 | g->zig_target.os == ZigLLVM_Win32) | 2608 | g->zig_target.os == OsWindows) |
| 2609 | { | 2609 | { |
| 2610 | g->have_winmain_crt_startup = true; | 2610 | g->have_winmain_crt_startup = true; |
| 2611 | } else if (buf_eql_str(symbol_name, "DllMainCRTStartup") && | 2611 | } else if (buf_eql_str(symbol_name, "DllMainCRTStartup") && |
| 2612 | g->zig_target.os == ZigLLVM_Win32) | 2612 | g->zig_target.os == OsWindows) |
| 2613 | { | 2613 | { |
| 2614 | g->have_dllmain_crt_startup = true; | 2614 | g->have_dllmain_crt_startup = true; |
| 2615 | } | 2615 | } |
| ... | @@ -3994,7 +3994,7 @@ void find_libc_include_path(CodeGen *g) { | ... | @@ -3994,7 +3994,7 @@ void find_libc_include_path(CodeGen *g) { |
| 3994 | if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) { | 3994 | if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) { |
| 3995 | ZigWindowsSDK *sdk = get_windows_sdk(g); | 3995 | ZigWindowsSDK *sdk = get_windows_sdk(g); |
| 3996 | 3996 | ||
| 3997 | if (g->zig_target.os == ZigLLVM_Win32) { | 3997 | if (g->zig_target.os == OsWindows) { |
| 3998 | if (os_get_win32_ucrt_include_path(sdk, g->libc_include_dir)) { | 3998 | if (os_get_win32_ucrt_include_path(sdk, g->libc_include_dir)) { |
| 3999 | zig_panic("Unable to determine libc include path."); | 3999 | zig_panic("Unable to determine libc include path."); |
| 4000 | } | 4000 | } |
| ... | @@ -4010,9 +4010,9 @@ void find_libc_include_path(CodeGen *g) { | ... | @@ -4010,9 +4010,9 @@ void find_libc_include_path(CodeGen *g) { |
| 4010 | void find_libc_lib_path(CodeGen *g) { | 4010 | void find_libc_lib_path(CodeGen *g) { |
| 4011 | // later we can handle this better by reporting an error via the normal mechanism | 4011 | // later we can handle this better by reporting an error via the normal mechanism |
| 4012 | if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0 || | 4012 | if (!g->libc_lib_dir || buf_len(g->libc_lib_dir) == 0 || |
| 4013 | (g->zig_target.os == ZigLLVM_Win32 && (g->msvc_lib_dir == nullptr || g->kernel32_lib_dir == nullptr))) | 4013 | (g->zig_target.os == OsWindows && (g->msvc_lib_dir == nullptr || g->kernel32_lib_dir == nullptr))) |
| 4014 | { | 4014 | { |
| 4015 | if (g->zig_target.os == ZigLLVM_Win32) { | 4015 | if (g->zig_target.os == OsWindows) { |
| 4016 | ZigWindowsSDK *sdk = get_windows_sdk(g); | 4016 | ZigWindowsSDK *sdk = get_windows_sdk(g); |
| 4017 | 4017 | ||
| 4018 | Buf* vc_lib_dir = buf_alloc(); | 4018 | Buf* vc_lib_dir = buf_alloc(); |
| ... | @@ -4039,7 +4039,7 @@ void find_libc_lib_path(CodeGen *g) { | ... | @@ -4039,7 +4039,7 @@ void find_libc_lib_path(CodeGen *g) { |
| 4039 | } | 4039 | } |
| 4040 | 4040 | ||
| 4041 | if (!g->libc_static_lib_dir || buf_len(g->libc_static_lib_dir) == 0) { | 4041 | if (!g->libc_static_lib_dir || buf_len(g->libc_static_lib_dir) == 0) { |
| 4042 | if ((g->zig_target.os == ZigLLVM_Win32) && (g->msvc_lib_dir != NULL)) { | 4042 | if ((g->zig_target.os == OsWindows) && (g->msvc_lib_dir != NULL)) { |
| 4043 | return; | 4043 | return; |
| 4044 | } | 4044 | } |
| 4045 | else { | 4045 | else { |
src/codegen.cpp+13-15| ... | @@ -42,7 +42,7 @@ static void init_darwin_native(CodeGen *g) { | ... | @@ -42,7 +42,7 @@ static void init_darwin_native(CodeGen *g) { |
| 42 | g->mmacosx_version_min = buf_create_from_str(osx_target); | 42 | g->mmacosx_version_min = buf_create_from_str(osx_target); |
| 43 | } else if (ios_target) { | 43 | } else if (ios_target) { |
| 44 | g->mios_version_min = buf_create_from_str(ios_target); | 44 | g->mios_version_min = buf_create_from_str(ios_target); |
| 45 | } else if (g->zig_target.os != ZigLLVM_IOS) { | 45 | } else if (g->zig_target.os != OsIOS) { |
| 46 | g->mmacosx_version_min = buf_create_from_str("10.10"); | 46 | g->mmacosx_version_min = buf_create_from_str("10.10"); |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| ... | @@ -136,9 +136,8 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out | ... | @@ -136,9 +136,8 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 136 | g->each_lib_rpath = true; | 136 | g->each_lib_rpath = true; |
| 137 | #endif | 137 | #endif |
| 138 | 138 | ||
| 139 | if (g->zig_target.os == ZigLLVM_Darwin || | 139 | if (g->zig_target.os == OsMacOSX || |
| 140 | g->zig_target.os == ZigLLVM_MacOSX || | 140 | g->zig_target.os == OsIOS) |
| 141 | g->zig_target.os == ZigLLVM_IOS) | ||
| 142 | { | 141 | { |
| 143 | init_darwin_native(g); | 142 | init_darwin_native(g); |
| 144 | } | 143 | } |
| ... | @@ -146,9 +145,8 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out | ... | @@ -146,9 +145,8 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | // On Darwin/MacOS/iOS, we always link libSystem which contains libc. | 147 | // On Darwin/MacOS/iOS, we always link libSystem which contains libc. |
| 149 | if (g->zig_target.os == ZigLLVM_Darwin || | 148 | if (g->zig_target.os == OsMacOSX || |
| 150 | g->zig_target.os == ZigLLVM_MacOSX || | 149 | g->zig_target.os == OsIOS) |
| 151 | g->zig_target.os == ZigLLVM_IOS) | ||
| 152 | { | 150 | { |
| 153 | g->libc_link_lib = create_link_lib(buf_create_from_str("c")); | 151 | g->libc_link_lib = create_link_lib(buf_create_from_str("c")); |
| 154 | g->link_libs_list.append(g->libc_link_lib); | 152 | g->link_libs_list.append(g->libc_link_lib); |
| ... | @@ -363,7 +361,7 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { | ... | @@ -363,7 +361,7 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 363 | g->zig_target.arch.arch == ZigLLVM_x86_64) | 361 | g->zig_target.arch.arch == ZigLLVM_x86_64) |
| 364 | { | 362 | { |
| 365 | // cold calling convention is not supported on windows | 363 | // cold calling convention is not supported on windows |
| 366 | if (g->zig_target.os == ZigLLVM_Win32) { | 364 | if (g->zig_target.os == OsWindows) { |
| 367 | return LLVMCCallConv; | 365 | return LLVMCCallConv; |
| 368 | } else { | 366 | } else { |
| 369 | return LLVMColdCallConv; | 367 | return LLVMColdCallConv; |
| ... | @@ -386,7 +384,7 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { | ... | @@ -386,7 +384,7 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 386 | } | 384 | } |
| 387 | 385 | ||
| 388 | static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) { | 386 | static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) { |
| 389 | if (g->zig_target.os == ZigLLVM_Win32) { | 387 | if (g->zig_target.os == OsWindows) { |
| 390 | addLLVMFnAttr(fn_val, "uwtable"); | 388 | addLLVMFnAttr(fn_val, "uwtable"); |
| 391 | } | 389 | } |
| 392 | } | 390 | } |
| ... | @@ -559,7 +557,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { | ... | @@ -559,7 +557,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { |
| 559 | } | 557 | } |
| 560 | // Note: byval is disabled on windows due to an LLVM bug: | 558 | // Note: byval is disabled on windows due to an LLVM bug: |
| 561 | // https://github.com/zig-lang/zig/issues/536 | 559 | // https://github.com/zig-lang/zig/issues/536 |
| 562 | if (is_byval && g->zig_target.os != ZigLLVM_Win32) { | 560 | if (is_byval && g->zig_target.os != OsWindows) { |
| 563 | addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "byval"); | 561 | addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "byval"); |
| 564 | } | 562 | } |
| 565 | } | 563 | } |
| ... | @@ -2371,7 +2369,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr | ... | @@ -2371,7 +2369,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr |
| 2371 | FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i]; | 2369 | FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i]; |
| 2372 | // Note: byval is disabled on windows due to an LLVM bug: | 2370 | // Note: byval is disabled on windows due to an LLVM bug: |
| 2373 | // https://github.com/zig-lang/zig/issues/536 | 2371 | // https://github.com/zig-lang/zig/issues/536 |
| 2374 | if (gen_info->is_byval && g->zig_target.os != ZigLLVM_Win32) { | 2372 | if (gen_info->is_byval && g->zig_target.os != OsWindows) { |
| 2375 | addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval"); | 2373 | addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval"); |
| 2376 | } | 2374 | } |
| 2377 | } | 2375 | } |
| ... | @@ -5094,7 +5092,7 @@ static void define_builtin_compile_vars(CodeGen *g) { | ... | @@ -5094,7 +5092,7 @@ static void define_builtin_compile_vars(CodeGen *g) { |
| 5094 | buf_appendf(contents, "pub const Os = enum {\n"); | 5092 | buf_appendf(contents, "pub const Os = enum {\n"); |
| 5095 | uint32_t field_count = (uint32_t)target_os_count(); | 5093 | uint32_t field_count = (uint32_t)target_os_count(); |
| 5096 | for (uint32_t i = 0; i < field_count; i += 1) { | 5094 | for (uint32_t i = 0; i < field_count; i += 1) { |
| 5097 | ZigLLVM_OSType os_type = get_target_os(i); | 5095 | Os os_type = get_target_os(i); |
| 5098 | const char *name = get_target_os_name(os_type); | 5096 | const char *name = get_target_os_name(os_type); |
| 5099 | buf_appendf(contents, " %s,\n", name); | 5097 | buf_appendf(contents, " %s,\n", name); |
| 5100 | 5098 | ||
| ... | @@ -5304,7 +5302,7 @@ static void init(CodeGen *g) { | ... | @@ -5304,7 +5302,7 @@ static void init(CodeGen *g) { |
| 5304 | // LLVM creates invalid binaries on Windows sometimes. | 5302 | // LLVM creates invalid binaries on Windows sometimes. |
| 5305 | // See https://github.com/zig-lang/zig/issues/508 | 5303 | // See https://github.com/zig-lang/zig/issues/508 |
| 5306 | // As a workaround we do not use target native features on Windows. | 5304 | // As a workaround we do not use target native features on Windows. |
| 5307 | if (g->zig_target.os == ZigLLVM_Win32) { | 5305 | if (g->zig_target.os == OsWindows) { |
| 5308 | target_specific_cpu_args = ""; | 5306 | target_specific_cpu_args = ""; |
| 5309 | target_specific_features = ""; | 5307 | target_specific_features = ""; |
| 5310 | } else { | 5308 | } else { |
| ... | @@ -5524,13 +5522,13 @@ static void gen_root_source(CodeGen *g) { | ... | @@ -5524,13 +5522,13 @@ static void gen_root_source(CodeGen *g) { |
| 5524 | } | 5522 | } |
| 5525 | report_errors_and_maybe_exit(g); | 5523 | report_errors_and_maybe_exit(g); |
| 5526 | 5524 | ||
| 5527 | if (!g->is_test_build && g->zig_target.os != ZigLLVM_UnknownOS && | 5525 | if (!g->is_test_build && g->zig_target.os != OsFreestanding && |
| 5528 | !g->have_c_main && !g->have_winmain && !g->have_winmain_crt_startup && | 5526 | !g->have_c_main && !g->have_winmain && !g->have_winmain_crt_startup && |
| 5529 | ((g->have_pub_main && g->out_type == OutTypeObj) || g->out_type == OutTypeExe)) | 5527 | ((g->have_pub_main && g->out_type == OutTypeObj) || g->out_type == OutTypeExe)) |
| 5530 | { | 5528 | { |
| 5531 | g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap.zig"); | 5529 | g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap.zig"); |
| 5532 | } | 5530 | } |
| 5533 | if (g->zig_target.os == ZigLLVM_Win32 && !g->have_dllmain_crt_startup && g->out_type == OutTypeLib) { | 5531 | if (g->zig_target.os == OsWindows && !g->have_dllmain_crt_startup && g->out_type == OutTypeLib) { |
| 5534 | g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap_lib.zig"); | 5532 | g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap_lib.zig"); |
| 5535 | } | 5533 | } |
| 5536 | 5534 |
src/link.cpp+1-1| ... | @@ -644,7 +644,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) { | ... | @@ -644,7 +644,7 @@ static void get_darwin_platform(LinkJob *lj, DarwinPlatform *platform) { |
| 644 | platform->kind = MacOS; | 644 | platform->kind = MacOS; |
| 645 | } else if (g->mios_version_min) { | 645 | } else if (g->mios_version_min) { |
| 646 | platform->kind = IPhoneOS; | 646 | platform->kind = IPhoneOS; |
| 647 | } else if (g->zig_target.os == ZigLLVM_MacOSX || g->zig_target.os == ZigLLVM_Darwin) { | 647 | } else if (g->zig_target.os == OsMacOSX) { |
| 648 | platform->kind = MacOS; | 648 | platform->kind = MacOS; |
| 649 | g->mmacosx_version_min = buf_create_from_str("10.10"); | 649 | g->mmacosx_version_min = buf_create_from_str("10.10"); |
| 650 | } else { | 650 | } else { |
src/main.cpp+1-1| ... | @@ -120,7 +120,7 @@ static int print_target_list(FILE *f) { | ... | @@ -120,7 +120,7 @@ static int print_target_list(FILE *f) { |
| 120 | fprintf(f, "\nOperating Systems:\n"); | 120 | fprintf(f, "\nOperating Systems:\n"); |
| 121 | size_t os_count = target_os_count(); | 121 | size_t os_count = target_os_count(); |
| 122 | for (size_t i = 0; i < os_count; i += 1) { | 122 | for (size_t i = 0; i < os_count; i += 1) { |
| 123 | ZigLLVM_OSType os_type = get_target_os(i); | 123 | Os os_type = get_target_os(i); |
| 124 | const char *native_str = (native.os == os_type) ? " (native)" : ""; | 124 | const char *native_str = (native.os == os_type) ? " (native)" : ""; |
| 125 | fprintf(f, " %s%s\n", get_target_os_name(os_type), native_str); | 125 | fprintf(f, " %s%s\n", get_target_os_name(os_type), native_str); |
| 126 | } | 126 | } |
src/target.cpp+257-81| ... | @@ -105,39 +105,39 @@ static const ZigLLVM_VendorType vendor_list[] = { | ... | @@ -105,39 +105,39 @@ static const ZigLLVM_VendorType vendor_list[] = { |
| 105 | ZigLLVM_SUSE, | 105 | ZigLLVM_SUSE, |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | static const ZigLLVM_OSType os_list[] = { | 108 | static const Os os_list[] = { |
| 109 | ZigLLVM_UnknownOS, | 109 | OsFreestanding, |
| 110 | ZigLLVM_Ananas, | 110 | OsAnanas, |
| 111 | ZigLLVM_CloudABI, | 111 | OsCloudABI, |
| 112 | ZigLLVM_Darwin, | 112 | OsDragonFly, |
| 113 | ZigLLVM_DragonFly, | 113 | OsFreeBSD, |
| 114 | ZigLLVM_FreeBSD, | 114 | OsFuchsia, |
| 115 | ZigLLVM_Fuchsia, | 115 | OsIOS, |
| 116 | ZigLLVM_IOS, | 116 | OsKFreeBSD, |
| 117 | ZigLLVM_KFreeBSD, | 117 | OsLinux, |
| 118 | ZigLLVM_Linux, | 118 | OsLv2, // PS3 |
| 119 | ZigLLVM_Lv2, | 119 | OsMacOSX, |
| 120 | ZigLLVM_MacOSX, | 120 | OsNetBSD, |
| 121 | ZigLLVM_NetBSD, | 121 | OsOpenBSD, |
| 122 | ZigLLVM_OpenBSD, | 122 | OsSolaris, |
| 123 | ZigLLVM_Solaris, | 123 | OsWindows, |
| 124 | ZigLLVM_Win32, | 124 | OsHaiku, |
| 125 | ZigLLVM_Haiku, | 125 | OsMinix, |
| 126 | ZigLLVM_Minix, | 126 | OsRTEMS, |
| 127 | ZigLLVM_RTEMS, | 127 | OsNaCl, // Native Client |
| 128 | ZigLLVM_NaCl, | 128 | OsCNK, // BG/P Compute-Node Kernel |
| 129 | ZigLLVM_CNK, | 129 | OsBitrig, |
| 130 | ZigLLVM_Bitrig, | 130 | OsAIX, |
| 131 | ZigLLVM_AIX, | 131 | OsCUDA, // NVIDIA CUDA |
| 132 | ZigLLVM_CUDA, | 132 | OsNVCL, // NVIDIA OpenCL |
| 133 | ZigLLVM_NVCL, | 133 | OsAMDHSA, // AMD HSA Runtime |
| 134 | ZigLLVM_AMDHSA, | 134 | OsPS4, |
| 135 | ZigLLVM_PS4, | 135 | OsELFIAMCU, |
| 136 | ZigLLVM_ELFIAMCU, | 136 | OsTvOS, // Apple tvOS |
| 137 | ZigLLVM_TvOS, | 137 | OsWatchOS, // Apple watchOS |
| 138 | ZigLLVM_WatchOS, | 138 | OsMesa3D, |
| 139 | ZigLLVM_Mesa3D, | 139 | OsContiki, |
| 140 | ZigLLVM_Contiki, | 140 | OsZen, |
| 141 | }; | 141 | }; |
| 142 | 142 | ||
| 143 | static const ZigLLVM_EnvironmentType environ_list[] = { | 143 | static const ZigLLVM_EnvironmentType environ_list[] = { |
| ... | @@ -209,12 +209,187 @@ ZigLLVM_VendorType get_target_vendor(size_t index) { | ... | @@ -209,12 +209,187 @@ ZigLLVM_VendorType get_target_vendor(size_t index) { |
| 209 | size_t target_os_count(void) { | 209 | size_t target_os_count(void) { |
| 210 | return array_length(os_list); | 210 | return array_length(os_list); |
| 211 | } | 211 | } |
| 212 | ZigLLVM_OSType get_target_os(size_t index) { | 212 | Os get_target_os(size_t index) { |
| 213 | return os_list[index]; | 213 | return os_list[index]; |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | const char *get_target_os_name(ZigLLVM_OSType os_type) { | 216 | static ZigLLVM_OSType get_llvm_os_type(Os os_type) { |
| 217 | return (os_type == ZigLLVM_UnknownOS) ? "freestanding" : ZigLLVMGetOSTypeName(os_type); | 217 | switch (os_type) { |
| 218 | case OsFreestanding: | ||
| 219 | case OsZen: | ||
| 220 | return ZigLLVM_UnknownOS; | ||
| 221 | case OsAnanas: | ||
| 222 | return ZigLLVM_Ananas; | ||
| 223 | case OsCloudABI: | ||
| 224 | return ZigLLVM_CloudABI; | ||
| 225 | case OsDragonFly: | ||
| 226 | return ZigLLVM_DragonFly; | ||
| 227 | case OsFreeBSD: | ||
| 228 | return ZigLLVM_FreeBSD; | ||
| 229 | case OsFuchsia: | ||
| 230 | return ZigLLVM_Fuchsia; | ||
| 231 | case OsIOS: | ||
| 232 | return ZigLLVM_IOS; | ||
| 233 | case OsKFreeBSD: | ||
| 234 | return ZigLLVM_KFreeBSD; | ||
| 235 | case OsLinux: | ||
| 236 | return ZigLLVM_Linux; | ||
| 237 | case OsLv2: | ||
| 238 | return ZigLLVM_Lv2; | ||
| 239 | case OsMacOSX: | ||
| 240 | return ZigLLVM_MacOSX; | ||
| 241 | case OsNetBSD: | ||
| 242 | return ZigLLVM_NetBSD; | ||
| 243 | case OsOpenBSD: | ||
| 244 | return ZigLLVM_OpenBSD; | ||
| 245 | case OsSolaris: | ||
| 246 | return ZigLLVM_Solaris; | ||
| 247 | case OsWindows: | ||
| 248 | return ZigLLVM_Win32; | ||
| 249 | case OsHaiku: | ||
| 250 | return ZigLLVM_Haiku; | ||
| 251 | case OsMinix: | ||
| 252 | return ZigLLVM_Minix; | ||
| 253 | case OsRTEMS: | ||
| 254 | return ZigLLVM_RTEMS; | ||
| 255 | case OsNaCl: | ||
| 256 | return ZigLLVM_NaCl; | ||
| 257 | case OsCNK: | ||
| 258 | return ZigLLVM_CNK; | ||
| 259 | case OsBitrig: | ||
| 260 | return ZigLLVM_Bitrig; | ||
| 261 | case OsAIX: | ||
| 262 | return ZigLLVM_AIX; | ||
| 263 | case OsCUDA: | ||
| 264 | return ZigLLVM_CUDA; | ||
| 265 | case OsNVCL: | ||
| 266 | return ZigLLVM_NVCL; | ||
| 267 | case OsAMDHSA: | ||
| 268 | return ZigLLVM_AMDHSA; | ||
| 269 | case OsPS4: | ||
| 270 | return ZigLLVM_PS4; | ||
| 271 | case OsELFIAMCU: | ||
| 272 | return ZigLLVM_ELFIAMCU; | ||
| 273 | case OsTvOS: | ||
| 274 | return ZigLLVM_TvOS; | ||
| 275 | case OsWatchOS: | ||
| 276 | return ZigLLVM_WatchOS; | ||
| 277 | case OsMesa3D: | ||
| 278 | return ZigLLVM_Mesa3D; | ||
| 279 | case OsContiki: | ||
| 280 | return ZigLLVM_Contiki; | ||
| 281 | } | ||
| 282 | zig_unreachable(); | ||
| 283 | } | ||
| 284 | |||
| 285 | static Os get_zig_os_type(ZigLLVM_OSType os_type) { | ||
| 286 | switch (os_type) { | ||
| 287 | case ZigLLVM_UnknownOS: | ||
| 288 | return OsFreestanding; | ||
| 289 | case ZigLLVM_Ananas: | ||
| 290 | return OsAnanas; | ||
| 291 | case ZigLLVM_CloudABI: | ||
| 292 | return OsCloudABI; | ||
| 293 | case ZigLLVM_DragonFly: | ||
| 294 | return OsDragonFly; | ||
| 295 | case ZigLLVM_FreeBSD: | ||
| 296 | return OsFreeBSD; | ||
| 297 | case ZigLLVM_Fuchsia: | ||
| 298 | return OsFuchsia; | ||
| 299 | case ZigLLVM_IOS: | ||
| 300 | return OsIOS; | ||
| 301 | case ZigLLVM_KFreeBSD: | ||
| 302 | return OsKFreeBSD; | ||
| 303 | case ZigLLVM_Linux: | ||
| 304 | return OsLinux; | ||
| 305 | case ZigLLVM_Lv2: | ||
| 306 | return OsLv2; | ||
| 307 | case ZigLLVM_Darwin: | ||
| 308 | case ZigLLVM_MacOSX: | ||
| 309 | return OsMacOSX; | ||
| 310 | case ZigLLVM_NetBSD: | ||
| 311 | return OsNetBSD; | ||
| 312 | case ZigLLVM_OpenBSD: | ||
| 313 | return OsOpenBSD; | ||
| 314 | case ZigLLVM_Solaris: | ||
| 315 | return OsSolaris; | ||
| 316 | case ZigLLVM_Win32: | ||
| 317 | return OsWindows; | ||
| 318 | case ZigLLVM_Haiku: | ||
| 319 | return OsHaiku; | ||
| 320 | case ZigLLVM_Minix: | ||
| 321 | return OsMinix; | ||
| 322 | case ZigLLVM_RTEMS: | ||
| 323 | return OsRTEMS; | ||
| 324 | case ZigLLVM_NaCl: | ||
| 325 | return OsNaCl; | ||
| 326 | case ZigLLVM_CNK: | ||
| 327 | return OsCNK; | ||
| 328 | case ZigLLVM_Bitrig: | ||
| 329 | return OsBitrig; | ||
| 330 | case ZigLLVM_AIX: | ||
| 331 | return OsAIX; | ||
| 332 | case ZigLLVM_CUDA: | ||
| 333 | return OsCUDA; | ||
| 334 | case ZigLLVM_NVCL: | ||
| 335 | return OsNVCL; | ||
| 336 | case ZigLLVM_AMDHSA: | ||
| 337 | return OsAMDHSA; | ||
| 338 | case ZigLLVM_PS4: | ||
| 339 | return OsPS4; | ||
| 340 | case ZigLLVM_ELFIAMCU: | ||
| 341 | return OsELFIAMCU; | ||
| 342 | case ZigLLVM_TvOS: | ||
| 343 | return OsTvOS; | ||
| 344 | case ZigLLVM_WatchOS: | ||
| 345 | return OsWatchOS; | ||
| 346 | case ZigLLVM_Mesa3D: | ||
| 347 | return OsMesa3D; | ||
| 348 | case ZigLLVM_Contiki: | ||
| 349 | return OsContiki; | ||
| 350 | } | ||
| 351 | zig_unreachable(); | ||
| 352 | } | ||
| 353 | |||
| 354 | const char *get_target_os_name(Os os_type) { | ||
| 355 | switch (os_type) { | ||
| 356 | case OsFreestanding: | ||
| 357 | return "freestanding"; | ||
| 358 | case OsZen: | ||
| 359 | return "zen"; | ||
| 360 | case OsAnanas: | ||
| 361 | case OsCloudABI: | ||
| 362 | case OsDragonFly: | ||
| 363 | case OsFreeBSD: | ||
| 364 | case OsFuchsia: | ||
| 365 | case OsIOS: | ||
| 366 | case OsKFreeBSD: | ||
| 367 | case OsLinux: | ||
| 368 | case OsLv2: // PS3 | ||
| 369 | case OsMacOSX: | ||
| 370 | case OsNetBSD: | ||
| 371 | case OsOpenBSD: | ||
| 372 | case OsSolaris: | ||
| 373 | case OsWindows: | ||
| 374 | case OsHaiku: | ||
| 375 | case OsMinix: | ||
| 376 | case OsRTEMS: | ||
| 377 | case OsNaCl: // Native Client | ||
| 378 | case OsCNK: // BG/P Compute-Node Kernel | ||
| 379 | case OsBitrig: | ||
| 380 | case OsAIX: | ||
| 381 | case OsCUDA: // NVIDIA CUDA | ||
| 382 | case OsNVCL: // NVIDIA OpenCL | ||
| 383 | case OsAMDHSA: // AMD HSA Runtime | ||
| 384 | case OsPS4: | ||
| 385 | case OsELFIAMCU: | ||
| 386 | case OsTvOS: // Apple tvOS | ||
| 387 | case OsWatchOS: // Apple watchOS | ||
| 388 | case OsMesa3D: | ||
| 389 | case OsContiki: | ||
| 390 | return ZigLLVMGetOSTypeName(get_llvm_os_type(os_type)); | ||
| 391 | } | ||
| 392 | zig_unreachable(); | ||
| 218 | } | 393 | } |
| 219 | 394 | ||
| 220 | size_t target_environ_count(void) { | 395 | size_t target_environ_count(void) { |
| ... | @@ -225,20 +400,22 @@ ZigLLVM_EnvironmentType get_target_environ(size_t index) { | ... | @@ -225,20 +400,22 @@ ZigLLVM_EnvironmentType get_target_environ(size_t index) { |
| 225 | } | 400 | } |
| 226 | 401 | ||
| 227 | void get_native_target(ZigTarget *target) { | 402 | void get_native_target(ZigTarget *target) { |
| 403 | ZigLLVM_OSType os_type; | ||
| 228 | ZigLLVMGetNativeTarget( | 404 | ZigLLVMGetNativeTarget( |
| 229 | &target->arch.arch, | 405 | &target->arch.arch, |
| 230 | &target->arch.sub_arch, | 406 | &target->arch.sub_arch, |
| 231 | &target->vendor, | 407 | &target->vendor, |
| 232 | &target->os, | 408 | &os_type, |
| 233 | &target->env_type, | 409 | &target->env_type, |
| 234 | &target->oformat); | 410 | &target->oformat); |
| 411 | target->os = get_zig_os_type(os_type); | ||
| 235 | } | 412 | } |
| 236 | 413 | ||
| 237 | void get_unknown_target(ZigTarget *target) { | 414 | void get_unknown_target(ZigTarget *target) { |
| 238 | target->arch.arch = ZigLLVM_UnknownArch; | 415 | target->arch.arch = ZigLLVM_UnknownArch; |
| 239 | target->arch.sub_arch = ZigLLVM_NoSubArch; | 416 | target->arch.sub_arch = ZigLLVM_NoSubArch; |
| 240 | target->vendor = ZigLLVM_UnknownVendor; | 417 | target->vendor = ZigLLVM_UnknownVendor; |
| 241 | target->os = ZigLLVM_UnknownOS; | 418 | target->os = OsFreestanding; |
| 242 | target->env_type = ZigLLVM_UnknownEnvironment; | 419 | target->env_type = ZigLLVM_UnknownEnvironment; |
| 243 | target->oformat = ZigLLVM_UnknownObjectFormat; | 420 | target->oformat = ZigLLVM_UnknownObjectFormat; |
| 244 | } | 421 | } |
| ... | @@ -265,9 +442,9 @@ int parse_target_arch(const char *str, ArchType *out_arch) { | ... | @@ -265,9 +442,9 @@ int parse_target_arch(const char *str, ArchType *out_arch) { |
| 265 | return ErrorFileNotFound; | 442 | return ErrorFileNotFound; |
| 266 | } | 443 | } |
| 267 | 444 | ||
| 268 | int parse_target_os(const char *str, ZigLLVM_OSType *out_os) { | 445 | int parse_target_os(const char *str, Os *out_os) { |
| 269 | for (size_t i = 0; i < array_length(os_list); i += 1) { | 446 | for (size_t i = 0; i < array_length(os_list); i += 1) { |
| 270 | ZigLLVM_OSType os = os_list[i]; | 447 | Os os = os_list[i]; |
| 271 | const char *os_name = get_target_os_name(os); | 448 | const char *os_name = get_target_os_name(os); |
| 272 | if (strcmp(os_name, str) == 0) { | 449 | if (strcmp(os_name, str) == 0) { |
| 273 | *out_os = os; | 450 | *out_os = os; |
| ... | @@ -304,15 +481,14 @@ void get_target_triple(Buf *triple, const ZigTarget *target) { | ... | @@ -304,15 +481,14 @@ void get_target_triple(Buf *triple, const ZigTarget *target) { |
| 304 | buf_resize(triple, 0); | 481 | buf_resize(triple, 0); |
| 305 | buf_appendf(triple, "%s-%s-%s-%s", arch_name, | 482 | buf_appendf(triple, "%s-%s-%s-%s", arch_name, |
| 306 | ZigLLVMGetVendorTypeName(target->vendor), | 483 | ZigLLVMGetVendorTypeName(target->vendor), |
| 307 | ZigLLVMGetOSTypeName(target->os), | 484 | ZigLLVMGetOSTypeName(get_llvm_os_type(target->os)), |
| 308 | ZigLLVMGetEnvironmentTypeName(target->env_type)); | 485 | ZigLLVMGetEnvironmentTypeName(target->env_type)); |
| 309 | } | 486 | } |
| 310 | 487 | ||
| 311 | static bool is_os_darwin(ZigTarget *target) { | 488 | static bool is_os_darwin(ZigTarget *target) { |
| 312 | switch (target->os) { | 489 | switch (target->os) { |
| 313 | case ZigLLVM_Darwin: | 490 | case OsMacOSX: |
| 314 | case ZigLLVM_IOS: | 491 | case OsIOS: |
| 315 | case ZigLLVM_MacOSX: | ||
| 316 | return true; | 492 | return true; |
| 317 | default: | 493 | default: |
| 318 | return false; | 494 | return false; |
| ... | @@ -333,7 +509,7 @@ void resolve_target_object_format(ZigTarget *target) { | ... | @@ -333,7 +509,7 @@ void resolve_target_object_format(ZigTarget *target) { |
| 333 | case ZigLLVM_x86_64: | 509 | case ZigLLVM_x86_64: |
| 334 | if (is_os_darwin(target)) { | 510 | if (is_os_darwin(target)) { |
| 335 | target->oformat = ZigLLVM_MachO; | 511 | target->oformat = ZigLLVM_MachO; |
| 336 | } else if (target->os == ZigLLVM_Win32) { | 512 | } else if (target->os == OsWindows) { |
| 337 | target->oformat = ZigLLVM_COFF; | 513 | target->oformat = ZigLLVM_COFF; |
| 338 | } else { | 514 | } else { |
| 339 | target->oformat = ZigLLVM_ELF; | 515 | target->oformat = ZigLLVM_ELF; |
| ... | @@ -463,7 +639,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) { | ... | @@ -463,7 +639,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) { |
| 463 | 639 | ||
| 464 | uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | 640 | uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 465 | switch (target->os) { | 641 | switch (target->os) { |
| 466 | case ZigLLVM_UnknownOS: | 642 | case OsFreestanding: |
| 467 | switch (id) { | 643 | switch (id) { |
| 468 | case CIntTypeShort: | 644 | case CIntTypeShort: |
| 469 | case CIntTypeUShort: | 645 | case CIntTypeUShort: |
| ... | @@ -480,9 +656,9 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -480,9 +656,9 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 480 | case CIntTypeCount: | 656 | case CIntTypeCount: |
| 481 | zig_unreachable(); | 657 | zig_unreachable(); |
| 482 | } | 658 | } |
| 483 | case ZigLLVM_Linux: | 659 | case OsLinux: |
| 484 | case ZigLLVM_Darwin: | 660 | case OsMacOSX: |
| 485 | case ZigLLVM_MacOSX: | 661 | case OsZen: |
| 486 | switch (id) { | 662 | switch (id) { |
| 487 | case CIntTypeShort: | 663 | case CIntTypeShort: |
| 488 | case CIntTypeUShort: | 664 | case CIntTypeUShort: |
| ... | @@ -499,7 +675,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -499,7 +675,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 499 | case CIntTypeCount: | 675 | case CIntTypeCount: |
| 500 | zig_unreachable(); | 676 | zig_unreachable(); |
| 501 | } | 677 | } |
| 502 | case ZigLLVM_Win32: | 678 | case OsWindows: |
| 503 | switch (id) { | 679 | switch (id) { |
| 504 | case CIntTypeShort: | 680 | case CIntTypeShort: |
| 505 | case CIntTypeUShort: | 681 | case CIntTypeUShort: |
| ... | @@ -515,40 +691,40 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -515,40 +691,40 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 515 | case CIntTypeCount: | 691 | case CIntTypeCount: |
| 516 | zig_unreachable(); | 692 | zig_unreachable(); |
| 517 | } | 693 | } |
| 518 | case ZigLLVM_Ananas: | 694 | case OsAnanas: |
| 519 | case ZigLLVM_CloudABI: | 695 | case OsCloudABI: |
| 520 | case ZigLLVM_DragonFly: | 696 | case OsDragonFly: |
| 521 | case ZigLLVM_FreeBSD: | 697 | case OsFreeBSD: |
| 522 | case ZigLLVM_IOS: | 698 | case OsIOS: |
| 523 | case ZigLLVM_KFreeBSD: | 699 | case OsKFreeBSD: |
| 524 | case ZigLLVM_Lv2: | 700 | case OsLv2: |
| 525 | case ZigLLVM_NetBSD: | 701 | case OsNetBSD: |
| 526 | case ZigLLVM_OpenBSD: | 702 | case OsOpenBSD: |
| 527 | case ZigLLVM_Solaris: | 703 | case OsSolaris: |
| 528 | case ZigLLVM_Haiku: | 704 | case OsHaiku: |
| 529 | case ZigLLVM_Minix: | 705 | case OsMinix: |
| 530 | case ZigLLVM_RTEMS: | 706 | case OsRTEMS: |
| 531 | case ZigLLVM_NaCl: | 707 | case OsNaCl: |
| 532 | case ZigLLVM_CNK: | 708 | case OsCNK: |
| 533 | case ZigLLVM_Bitrig: | 709 | case OsBitrig: |
| 534 | case ZigLLVM_AIX: | 710 | case OsAIX: |
| 535 | case ZigLLVM_CUDA: | 711 | case OsCUDA: |
| 536 | case ZigLLVM_NVCL: | 712 | case OsNVCL: |
| 537 | case ZigLLVM_AMDHSA: | 713 | case OsAMDHSA: |
| 538 | case ZigLLVM_PS4: | 714 | case OsPS4: |
| 539 | case ZigLLVM_ELFIAMCU: | 715 | case OsELFIAMCU: |
| 540 | case ZigLLVM_TvOS: | 716 | case OsTvOS: |
| 541 | case ZigLLVM_WatchOS: | 717 | case OsWatchOS: |
| 542 | case ZigLLVM_Mesa3D: | 718 | case OsMesa3D: |
| 543 | case ZigLLVM_Fuchsia: | 719 | case OsFuchsia: |
| 544 | case ZigLLVM_Contiki: | 720 | case OsContiki: |
| 545 | zig_panic("TODO c type size in bits for this target"); | 721 | zig_panic("TODO c type size in bits for this target"); |
| 546 | } | 722 | } |
| 547 | zig_unreachable(); | 723 | zig_unreachable(); |
| 548 | } | 724 | } |
| 549 | 725 | ||
| 550 | const char *target_o_file_ext(ZigTarget *target) { | 726 | const char *target_o_file_ext(ZigTarget *target) { |
| 551 | if (target->env_type == ZigLLVM_MSVC || target->os == ZigLLVM_Win32) { | 727 | if (target->env_type == ZigLLVM_MSVC || target->os == OsWindows) { |
| 552 | return ".obj"; | 728 | return ".obj"; |
| 553 | } else { | 729 | } else { |
| 554 | return ".o"; | 730 | return ".o"; |
| ... | @@ -564,7 +740,7 @@ const char *target_llvm_ir_file_ext(ZigTarget *target) { | ... | @@ -564,7 +740,7 @@ const char *target_llvm_ir_file_ext(ZigTarget *target) { |
| 564 | } | 740 | } |
| 565 | 741 | ||
| 566 | const char *target_exe_file_ext(ZigTarget *target) { | 742 | const char *target_exe_file_ext(ZigTarget *target) { |
| 567 | if (target->os == ZigLLVM_Win32) { | 743 | if (target->os == OsWindows) { |
| 568 | return ".exe"; | 744 | return ".exe"; |
| 569 | } else { | 745 | } else { |
| 570 | return ""; | 746 | return ""; |
| ... | @@ -664,12 +840,12 @@ bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target | ... | @@ -664,12 +840,12 @@ bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target |
| 664 | return true; | 840 | return true; |
| 665 | } | 841 | } |
| 666 | 842 | ||
| 667 | if (guest_target->os == ZigLLVM_Win32 && host_target->os == ZigLLVM_Win32 && | 843 | if (guest_target->os == OsWindows && host_target->os == OsWindows && |
| 668 | host_target->arch.arch == ZigLLVM_x86_64 && guest_target->arch.arch == ZigLLVM_x86) | 844 | host_target->arch.arch == ZigLLVM_x86_64 && guest_target->arch.arch == ZigLLVM_x86) |
| 669 | { | 845 | { |
| 670 | // 64-bit windows can run 32-bit programs | 846 | // 64-bit windows can run 32-bit programs |
| 671 | return true; | 847 | return true; |
| 672 | } | 848 | } |
| 673 | 849 | ||
| 674 | return false; | 850 | return false; |
| 675 | } | 851 | } |
src/target.hpp+39-4| ... | @@ -17,10 +17,45 @@ struct ArchType { | ... | @@ -17,10 +17,45 @@ struct ArchType { |
| 17 | ZigLLVM_SubArchType sub_arch; | 17 | ZigLLVM_SubArchType sub_arch; |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | enum Os { | ||
| 21 | OsFreestanding, | ||
| 22 | OsAnanas, | ||
| 23 | OsCloudABI, | ||
| 24 | OsDragonFly, | ||
| 25 | OsFreeBSD, | ||
| 26 | OsFuchsia, | ||
| 27 | OsIOS, | ||
| 28 | OsKFreeBSD, | ||
| 29 | OsLinux, | ||
| 30 | OsLv2, // PS3 | ||
| 31 | OsMacOSX, | ||
| 32 | OsNetBSD, | ||
| 33 | OsOpenBSD, | ||
| 34 | OsSolaris, | ||
| 35 | OsWindows, | ||
| 36 | OsHaiku, | ||
| 37 | OsMinix, | ||
| 38 | OsRTEMS, | ||
| 39 | OsNaCl, // Native Client | ||
| 40 | OsCNK, // BG/P Compute-Node Kernel | ||
| 41 | OsBitrig, | ||
| 42 | OsAIX, | ||
| 43 | OsCUDA, // NVIDIA CUDA | ||
| 44 | OsNVCL, // NVIDIA OpenCL | ||
| 45 | OsAMDHSA, // AMD HSA Runtime | ||
| 46 | OsPS4, | ||
| 47 | OsELFIAMCU, | ||
| 48 | OsTvOS, // Apple tvOS | ||
| 49 | OsWatchOS, // Apple watchOS | ||
| 50 | OsMesa3D, | ||
| 51 | OsContiki, | ||
| 52 | OsZen, | ||
| 53 | }; | ||
| 54 | |||
| 20 | struct ZigTarget { | 55 | struct ZigTarget { |
| 21 | ArchType arch; | 56 | ArchType arch; |
| 22 | ZigLLVM_VendorType vendor; | 57 | ZigLLVM_VendorType vendor; |
| 23 | ZigLLVM_OSType os; | 58 | Os os; |
| 24 | ZigLLVM_EnvironmentType env_type; | 59 | ZigLLVM_EnvironmentType env_type; |
| 25 | ZigLLVM_ObjectFormatType oformat; | 60 | ZigLLVM_ObjectFormatType oformat; |
| 26 | }; | 61 | }; |
| ... | @@ -46,8 +81,8 @@ size_t target_vendor_count(void); | ... | @@ -46,8 +81,8 @@ size_t target_vendor_count(void); |
| 46 | ZigLLVM_VendorType get_target_vendor(size_t index); | 81 | ZigLLVM_VendorType get_target_vendor(size_t index); |
| 47 | 82 | ||
| 48 | size_t target_os_count(void); | 83 | size_t target_os_count(void); |
| 49 | ZigLLVM_OSType get_target_os(size_t index); | 84 | Os get_target_os(size_t index); |
| 50 | const char *get_target_os_name(ZigLLVM_OSType os_type); | 85 | const char *get_target_os_name(Os os_type); |
| 51 | 86 | ||
| 52 | size_t target_environ_count(void); | 87 | size_t target_environ_count(void); |
| 53 | ZigLLVM_EnvironmentType get_target_environ(size_t index); | 88 | ZigLLVM_EnvironmentType get_target_environ(size_t index); |
| ... | @@ -61,7 +96,7 @@ void get_native_target(ZigTarget *target); | ... | @@ -61,7 +96,7 @@ void get_native_target(ZigTarget *target); |
| 61 | void get_unknown_target(ZigTarget *target); | 96 | void get_unknown_target(ZigTarget *target); |
| 62 | 97 | ||
| 63 | int parse_target_arch(const char *str, ArchType *arch); | 98 | int parse_target_arch(const char *str, ArchType *arch); |
| 64 | int parse_target_os(const char *str, ZigLLVM_OSType *os); | 99 | int parse_target_os(const char *str, Os *os); |
| 65 | int parse_target_environ(const char *str, ZigLLVM_EnvironmentType *env_type); | 100 | int parse_target_environ(const char *str, ZigLLVM_EnvironmentType *env_type); |
| 66 | 101 | ||
| 67 | void init_all_targets(void); | 102 | void init_all_targets(void); |
std/build.zig+2-2| ... | @@ -800,7 +800,7 @@ const Target = union(enum) { | ... | @@ -800,7 +800,7 @@ const Target = union(enum) { |
| 800 | 800 | ||
| 801 | pub fn isDarwin(self: &const Target) -> bool { | 801 | pub fn isDarwin(self: &const Target) -> bool { |
| 802 | return switch (self.getOs()) { | 802 | return switch (self.getOs()) { |
| 803 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => true, | 803 | builtin.Os.ios, builtin.Os.macosx => true, |
| 804 | else => false, | 804 | else => false, |
| 805 | }; | 805 | }; |
| 806 | } | 806 | } |
| ... | @@ -1011,7 +1011,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1011,7 +1011,7 @@ pub const LibExeObjStep = struct { |
| 1011 | self.out_filename = self.builder.fmt("lib{}.a", self.name); | 1011 | self.out_filename = self.builder.fmt("lib{}.a", self.name); |
| 1012 | } else { | 1012 | } else { |
| 1013 | switch (self.target.getOs()) { | 1013 | switch (self.target.getOs()) { |
| 1014 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => { | 1014 | builtin.Os.ios, builtin.Os.macosx => { |
| 1015 | self.out_filename = self.builder.fmt("lib{}.{d}.{d}.{d}.dylib", | 1015 | self.out_filename = self.builder.fmt("lib{}.{d}.{d}.{d}.dylib", |
| 1016 | self.name, self.version.major, self.version.minor, self.version.patch); | 1016 | self.name, self.version.major, self.version.minor, self.version.patch); |
| 1017 | self.major_only_filename = self.builder.fmt("lib{}.{d}.dylib", self.name, self.version.major); | 1017 | self.major_only_filename = self.builder.fmt("lib{}.{d}.dylib", self.name, self.version.major); |
std/c/index.zig+1-1| ... | @@ -4,7 +4,7 @@ const Os = builtin.Os; | ... | @@ -4,7 +4,7 @@ const Os = builtin.Os; |
| 4 | pub use switch(builtin.os) { | 4 | pub use switch(builtin.os) { |
| 5 | Os.linux => @import("linux.zig"), | 5 | Os.linux => @import("linux.zig"), |
| 6 | Os.windows => @import("windows.zig"), | 6 | Os.windows => @import("windows.zig"), |
| 7 | Os.darwin, Os.macosx, Os.ios => @import("darwin.zig"), | 7 | Os.macosx, Os.ios => @import("darwin.zig"), |
| 8 | else => empty_import, | 8 | else => empty_import, |
| 9 | }; | 9 | }; |
| 10 | const empty_import = @import("../empty.zig"); | 10 | const empty_import = @import("../empty.zig"); |
std/heap.zig+2-2| ... | @@ -49,7 +49,7 @@ pub const IncrementingAllocator = struct { | ... | @@ -49,7 +49,7 @@ pub const IncrementingAllocator = struct { |
| 49 | 49 | ||
| 50 | fn init(capacity: usize) -> %IncrementingAllocator { | 50 | fn init(capacity: usize) -> %IncrementingAllocator { |
| 51 | switch (builtin.os) { | 51 | switch (builtin.os) { |
| 52 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | 52 | Os.linux, Os.macosx, Os.ios => { |
| 53 | const p = os.posix; | 53 | const p = os.posix; |
| 54 | const addr = p.mmap(null, capacity, p.PROT_READ|p.PROT_WRITE, | 54 | const addr = p.mmap(null, capacity, p.PROT_READ|p.PROT_WRITE, |
| 55 | p.MAP_PRIVATE|p.MAP_ANONYMOUS|p.MAP_NORESERVE, -1, 0); | 55 | p.MAP_PRIVATE|p.MAP_ANONYMOUS|p.MAP_NORESERVE, -1, 0); |
| ... | @@ -87,7 +87,7 @@ pub const IncrementingAllocator = struct { | ... | @@ -87,7 +87,7 @@ pub const IncrementingAllocator = struct { |
| 87 | 87 | ||
| 88 | fn deinit(self: &IncrementingAllocator) { | 88 | fn deinit(self: &IncrementingAllocator) { |
| 89 | switch (builtin.os) { | 89 | switch (builtin.os) { |
| 90 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | 90 | Os.linux, Os.macosx, Os.ios => { |
| 91 | _ = os.posix.munmap(self.bytes.ptr, self.bytes.len); | 91 | _ = os.posix.munmap(self.bytes.ptr, self.bytes.len); |
| 92 | }, | 92 | }, |
| 93 | Os.windows => { | 93 | Os.windows => { |
std/io.zig+4-4| ... | @@ -3,7 +3,7 @@ const builtin = @import("builtin"); | ... | @@ -3,7 +3,7 @@ const builtin = @import("builtin"); |
| 3 | const Os = builtin.Os; | 3 | const Os = builtin.Os; |
| 4 | const system = switch(builtin.os) { | 4 | const system = switch(builtin.os) { |
| 5 | Os.linux => @import("os/linux.zig"), | 5 | Os.linux => @import("os/linux.zig"), |
| 6 | Os.darwin, Os.macosx, Os.ios => @import("os/darwin.zig"), | 6 | Os.macosx, Os.ios => @import("os/darwin.zig"), |
| 7 | Os.windows => @import("os/windows/index.zig"), | 7 | Os.windows => @import("os/windows/index.zig"), |
| 8 | else => @compileError("Unsupported OS"), | 8 | else => @compileError("Unsupported OS"), |
| 9 | }; | 9 | }; |
| ... | @@ -190,7 +190,7 @@ pub const File = struct { | ... | @@ -190,7 +190,7 @@ pub const File = struct { |
| 190 | 190 | ||
| 191 | pub fn seekForward(self: &File, amount: isize) -> %void { | 191 | pub fn seekForward(self: &File, amount: isize) -> %void { |
| 192 | switch (builtin.os) { | 192 | switch (builtin.os) { |
| 193 | Os.linux, Os.darwin => { | 193 | Os.linux, Os.macosx, Os.ios => { |
| 194 | const result = system.lseek(self.handle, amount, system.SEEK_CUR); | 194 | const result = system.lseek(self.handle, amount, system.SEEK_CUR); |
| 195 | const err = system.getErrno(result); | 195 | const err = system.getErrno(result); |
| 196 | if (err > 0) { | 196 | if (err > 0) { |
| ... | @@ -210,7 +210,7 @@ pub const File = struct { | ... | @@ -210,7 +210,7 @@ pub const File = struct { |
| 210 | 210 | ||
| 211 | pub fn seekTo(self: &File, pos: usize) -> %void { | 211 | pub fn seekTo(self: &File, pos: usize) -> %void { |
| 212 | switch (builtin.os) { | 212 | switch (builtin.os) { |
| 213 | Os.linux, Os.darwin => { | 213 | Os.linux, Os.macosx, Os.ios => { |
| 214 | const result = system.lseek(self.handle, @bitCast(isize, pos), system.SEEK_SET); | 214 | const result = system.lseek(self.handle, @bitCast(isize, pos), system.SEEK_SET); |
| 215 | const err = system.getErrno(result); | 215 | const err = system.getErrno(result); |
| 216 | if (err > 0) { | 216 | if (err > 0) { |
| ... | @@ -230,7 +230,7 @@ pub const File = struct { | ... | @@ -230,7 +230,7 @@ pub const File = struct { |
| 230 | 230 | ||
| 231 | pub fn getPos(self: &File) -> %usize { | 231 | pub fn getPos(self: &File) -> %usize { |
| 232 | switch (builtin.os) { | 232 | switch (builtin.os) { |
| 233 | Os.linux, Os.darwin => { | 233 | Os.linux, Os.macosx, Os.ios => { |
| 234 | const result = system.lseek(self.handle, 0, system.SEEK_CUR); | 234 | const result = system.lseek(self.handle, 0, system.SEEK_CUR); |
| 235 | const err = system.getErrno(result); | 235 | const err = system.getErrno(result); |
| 236 | if (err > 0) { | 236 | if (err > 0) { |
std/os/get_user_id.zig+1-1| ... | @@ -11,7 +11,7 @@ pub const UserInfo = struct { | ... | @@ -11,7 +11,7 @@ pub const UserInfo = struct { |
| 11 | /// POSIX function which gets a uid from username. | 11 | /// POSIX function which gets a uid from username. |
| 12 | pub fn getUserInfo(name: []const u8) -> %UserInfo { | 12 | pub fn getUserInfo(name: []const u8) -> %UserInfo { |
| 13 | return switch (builtin.os) { | 13 | return switch (builtin.os) { |
| 14 | Os.linux, Os.darwin, Os.macosx, Os.ios => posixGetUserInfo(name), | 14 | Os.linux, Os.macosx, Os.ios => posixGetUserInfo(name), |
| 15 | else => @compileError("Unsupported OS"), | 15 | else => @compileError("Unsupported OS"), |
| 16 | }; | 16 | }; |
| 17 | } | 17 | } |
std/os/index.zig+8-8| ... | @@ -9,7 +9,7 @@ pub const darwin = @import("darwin.zig"); | ... | @@ -9,7 +9,7 @@ pub const darwin = @import("darwin.zig"); |
| 9 | pub const linux = @import("linux.zig"); | 9 | pub const linux = @import("linux.zig"); |
| 10 | pub const posix = switch(builtin.os) { | 10 | pub const posix = switch(builtin.os) { |
| 11 | Os.linux => linux, | 11 | Os.linux => linux, |
| 12 | Os.darwin, Os.macosx, Os.ios => darwin, | 12 | Os.macosx, Os.ios => darwin, |
| 13 | else => @compileError("Unsupported OS"), | 13 | else => @compileError("Unsupported OS"), |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| ... | @@ -89,7 +89,7 @@ pub fn getRandomBytes(buf: []u8) -> %void { | ... | @@ -89,7 +89,7 @@ pub fn getRandomBytes(buf: []u8) -> %void { |
| 89 | } | 89 | } |
| 90 | return; | 90 | return; |
| 91 | }, | 91 | }, |
| 92 | Os.darwin, Os.macosx, Os.ios => { | 92 | Os.macosx, Os.ios => { |
| 93 | const fd = %return posixOpen("/dev/urandom", posix.O_RDONLY|posix.O_CLOEXEC, | 93 | const fd = %return posixOpen("/dev/urandom", posix.O_RDONLY|posix.O_CLOEXEC, |
| 94 | 0, null); | 94 | 0, null); |
| 95 | defer close(fd); | 95 | defer close(fd); |
| ... | @@ -130,7 +130,7 @@ pub coldcc fn abort() -> noreturn { | ... | @@ -130,7 +130,7 @@ pub coldcc fn abort() -> noreturn { |
| 130 | c.abort(); | 130 | c.abort(); |
| 131 | } | 131 | } |
| 132 | switch (builtin.os) { | 132 | switch (builtin.os) { |
| 133 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | 133 | Os.linux, Os.macosx, Os.ios => { |
| 134 | _ = posix.raise(posix.SIGABRT); | 134 | _ = posix.raise(posix.SIGABRT); |
| 135 | _ = posix.raise(posix.SIGKILL); | 135 | _ = posix.raise(posix.SIGKILL); |
| 136 | while (true) {} | 136 | while (true) {} |
| ... | @@ -151,7 +151,7 @@ pub coldcc fn exit(status: i32) -> noreturn { | ... | @@ -151,7 +151,7 @@ pub coldcc fn exit(status: i32) -> noreturn { |
| 151 | c.exit(status); | 151 | c.exit(status); |
| 152 | } | 152 | } |
| 153 | switch (builtin.os) { | 153 | switch (builtin.os) { |
| 154 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | 154 | Os.linux, Os.macosx, Os.ios => { |
| 155 | posix.exit(status); | 155 | posix.exit(status); |
| 156 | }, | 156 | }, |
| 157 | Os.windows => { | 157 | Os.windows => { |
| ... | @@ -1104,7 +1104,7 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 { | ... | @@ -1104,7 +1104,7 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 1104 | 1104 | ||
| 1105 | pub fn sleep(seconds: usize, nanoseconds: usize) { | 1105 | pub fn sleep(seconds: usize, nanoseconds: usize) { |
| 1106 | switch(builtin.os) { | 1106 | switch(builtin.os) { |
| 1107 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | 1107 | Os.linux, Os.macosx, Os.ios => { |
| 1108 | posixSleep(u63(seconds), u63(nanoseconds)); | 1108 | posixSleep(u63(seconds), u63(nanoseconds)); |
| 1109 | }, | 1109 | }, |
| 1110 | Os.windows => { | 1110 | Os.windows => { |
| ... | @@ -1537,7 +1537,7 @@ pub fn openSelfExe() -> %io.File { | ... | @@ -1537,7 +1537,7 @@ pub fn openSelfExe() -> %io.File { |
| 1537 | Os.linux => { | 1537 | Os.linux => { |
| 1538 | return io.File.openRead("/proc/self/exe", null); | 1538 | return io.File.openRead("/proc/self/exe", null); |
| 1539 | }, | 1539 | }, |
| 1540 | Os.darwin => { | 1540 | Os.macosx, Os.ios => { |
| 1541 | @panic("TODO: openSelfExe on Darwin"); | 1541 | @panic("TODO: openSelfExe on Darwin"); |
| 1542 | }, | 1542 | }, |
| 1543 | else => @compileError("Unsupported OS"), | 1543 | else => @compileError("Unsupported OS"), |
| ... | @@ -1577,7 +1577,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { | ... | @@ -1577,7 +1577,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { |
| 1577 | %return out_path.resize(new_len); | 1577 | %return out_path.resize(new_len); |
| 1578 | } | 1578 | } |
| 1579 | }, | 1579 | }, |
| 1580 | Os.darwin, Os.macosx, Os.ios => { | 1580 | Os.macosx, Os.ios => { |
| 1581 | var u32_len: u32 = 0; | 1581 | var u32_len: u32 = 0; |
| 1582 | const ret1 = c._NSGetExecutablePath(undefined, &u32_len); | 1582 | const ret1 = c._NSGetExecutablePath(undefined, &u32_len); |
| 1583 | assert(ret1 != 0); | 1583 | assert(ret1 != 0); |
| ... | @@ -1605,7 +1605,7 @@ pub fn selfExeDirPath(allocator: &mem.Allocator) -> %[]u8 { | ... | @@ -1605,7 +1605,7 @@ pub fn selfExeDirPath(allocator: &mem.Allocator) -> %[]u8 { |
| 1605 | const dir = path.dirname(full_exe_path); | 1605 | const dir = path.dirname(full_exe_path); |
| 1606 | return allocator.shrink(u8, full_exe_path, dir.len); | 1606 | return allocator.shrink(u8, full_exe_path, dir.len); |
| 1607 | }, | 1607 | }, |
| 1608 | Os.windows, Os.darwin, Os.macosx, Os.ios => { | 1608 | Os.windows, Os.macosx, Os.ios => { |
| 1609 | const self_exe_path = %return selfExePath(allocator); | 1609 | const self_exe_path = %return selfExePath(allocator); |
| 1610 | %defer allocator.free(self_exe_path); | 1610 | %defer allocator.free(self_exe_path); |
| 1611 | const dirname = os.path.dirname(self_exe_path); | 1611 | const dirname = os.path.dirname(self_exe_path); |
std/os/path.zig+1-1| ... | @@ -1137,7 +1137,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { | ... | @@ -1137,7 +1137,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 1137 | return allocator.shrink(u8, buf, final_len); | 1137 | return allocator.shrink(u8, buf, final_len); |
| 1138 | } | 1138 | } |
| 1139 | }, | 1139 | }, |
| 1140 | Os.darwin, Os.macosx, Os.ios => { | 1140 | Os.macosx, Os.ios => { |
| 1141 | // TODO instead of calling the libc function here, port the implementation | 1141 | // TODO instead of calling the libc function here, port the implementation |
| 1142 | // to Zig, and then remove the NameTooLong error possibility. | 1142 | // to Zig, and then remove the NameTooLong error possibility. |
| 1143 | const pathname_buf = %return allocator.alloc(u8, pathname.len + 1); | 1143 | const pathname_buf = %return allocator.alloc(u8, pathname.len + 1); |
test/tests.zig+1-1| ... | @@ -33,7 +33,7 @@ const test_targets = []TestTarget { | ... | @@ -33,7 +33,7 @@ const test_targets = []TestTarget { |
| 33 | .environ = builtin.Environ.gnu, | 33 | .environ = builtin.Environ.gnu, |
| 34 | }, | 34 | }, |
| 35 | TestTarget { | 35 | TestTarget { |
| 36 | .os = builtin.Os.darwin, | 36 | .os = builtin.Os.macosx, |
| 37 | .arch = builtin.Arch.x86_64, | 37 | .arch = builtin.Arch.x86_64, |
| 38 | .environ = builtin.Environ.unknown, | 38 | .environ = builtin.Environ.unknown, |
| 39 | }, | 39 | }, |