| 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 | 38 | |
| 39 | 39 | pub fn isDarwin(self: &const Target) -> bool { |
| 40 | 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 | 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 | 32 | // failed semantic analysis, which isn't supposed to happen |
| 33 | 33 | ErrorMsg *err = add_node_error(g, node->owner->c_import_node, |
| 34 | 34 | buf_sprintf("compiler bug: @cImport generated invalid zig code")); |
| 35 | ||
| 35 | ||
| 36 | 36 | add_error_note(g, err, node, msg); |
| 37 | 37 | |
| 38 | 38 | g->errors.append(err); |
| ... | ... | @@ -2425,7 +2425,7 @@ static void resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) { |
| 2425 | 2425 | qual_str = "extern"; |
| 2426 | 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 | 2429 | decl_node->data.container_decl.init_arg_expr : decl_node; |
| 2430 | 2430 | add_node_error(g, source_node, |
| 2431 | 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 | 2599 | g->windows_subsystem_windows = false; |
| 2600 | 2600 | g->windows_subsystem_console = true; |
| 2601 | 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 | 2604 | g->have_winmain = true; |
| 2605 | 2605 | g->windows_subsystem_windows = true; |
| 2606 | 2606 | g->windows_subsystem_console = false; |
| 2607 | 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 | 2610 | g->have_winmain_crt_startup = true; |
| 2611 | 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 | 2614 | g->have_dllmain_crt_startup = true; |
| 2615 | 2615 | } |
| ... | ... | @@ -3994,7 +3994,7 @@ void find_libc_include_path(CodeGen *g) { |
| 3994 | 3994 | if (!g->libc_include_dir || buf_len(g->libc_include_dir) == 0) { |
| 3995 | 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 | 3998 | if (os_get_win32_ucrt_include_path(sdk, g->libc_include_dir)) { |
| 3999 | 3999 | zig_panic("Unable to determine libc include path."); |
| 4000 | 4000 | } |
| ... | ... | @@ -4010,9 +4010,9 @@ void find_libc_include_path(CodeGen *g) { |
| 4010 | 4010 | void find_libc_lib_path(CodeGen *g) { |
| 4011 | 4011 | // later we can handle this better by reporting an error via the normal mechanism |
| 4012 | 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 | 4016 | ZigWindowsSDK *sdk = get_windows_sdk(g); |
| 4017 | 4017 | |
| 4018 | 4018 | Buf* vc_lib_dir = buf_alloc(); |
| ... | ... | @@ -4039,7 +4039,7 @@ void find_libc_lib_path(CodeGen *g) { |
| 4039 | 4039 | } |
| 4040 | 4040 | |
| 4041 | 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 | 4043 | return; |
| 4044 | 4044 | } |
| 4045 | 4045 | else { |
src/codegen.cpp+13-15| ... | ... | @@ -42,7 +42,7 @@ static void init_darwin_native(CodeGen *g) { |
| 42 | 42 | g->mmacosx_version_min = buf_create_from_str(osx_target); |
| 43 | 43 | } else if (ios_target) { |
| 44 | 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 | 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 | 136 | g->each_lib_rpath = true; |
| 137 | 137 | #endif |
| 138 | 138 | |
| 139 | if (g->zig_target.os == ZigLLVM_Darwin || | |
| 140 | g->zig_target.os == ZigLLVM_MacOSX || | |
| 141 | g->zig_target.os == ZigLLVM_IOS) | |
| 139 | if (g->zig_target.os == OsMacOSX || | |
| 140 | g->zig_target.os == OsIOS) | |
| 142 | 141 | { |
| 143 | 142 | init_darwin_native(g); |
| 144 | 143 | } |
| ... | ... | @@ -146,9 +145,8 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 146 | 145 | } |
| 147 | 146 | |
| 148 | 147 | // On Darwin/MacOS/iOS, we always link libSystem which contains libc. |
| 149 | if (g->zig_target.os == ZigLLVM_Darwin || | |
| 150 | g->zig_target.os == ZigLLVM_MacOSX || | |
| 151 | g->zig_target.os == ZigLLVM_IOS) | |
| 148 | if (g->zig_target.os == OsMacOSX || | |
| 149 | g->zig_target.os == OsIOS) | |
| 152 | 150 | { |
| 153 | 151 | g->libc_link_lib = create_link_lib(buf_create_from_str("c")); |
| 154 | 152 | g->link_libs_list.append(g->libc_link_lib); |
| ... | ... | @@ -363,7 +361,7 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 363 | 361 | g->zig_target.arch.arch == ZigLLVM_x86_64) |
| 364 | 362 | { |
| 365 | 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 | 365 | return LLVMCCallConv; |
| 368 | 366 | } else { |
| 369 | 367 | return LLVMColdCallConv; |
| ... | ... | @@ -386,7 +384,7 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 386 | 384 | } |
| 387 | 385 | |
| 388 | 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 | 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 | 557 | } |
| 560 | 558 | // Note: byval is disabled on windows due to an LLVM bug: |
| 561 | 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 | 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 | 2369 | FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i]; |
| 2372 | 2370 | // Note: byval is disabled on windows due to an LLVM bug: |
| 2373 | 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 | 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 | 5092 | buf_appendf(contents, "pub const Os = enum {\n"); |
| 5095 | 5093 | uint32_t field_count = (uint32_t)target_os_count(); |
| 5096 | 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 | 5096 | const char *name = get_target_os_name(os_type); |
| 5099 | 5097 | buf_appendf(contents, " %s,\n", name); |
| 5100 | 5098 | |
| ... | ... | @@ -5304,7 +5302,7 @@ static void init(CodeGen *g) { |
| 5304 | 5302 | // LLVM creates invalid binaries on Windows sometimes. |
| 5305 | 5303 | // See https://github.com/zig-lang/zig/issues/508 |
| 5306 | 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 | 5306 | target_specific_cpu_args = ""; |
| 5309 | 5307 | target_specific_features = ""; |
| 5310 | 5308 | } else { |
| ... | ... | @@ -5524,13 +5522,13 @@ static void gen_root_source(CodeGen *g) { |
| 5524 | 5522 | } |
| 5525 | 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 | 5526 | !g->have_c_main && !g->have_winmain && !g->have_winmain_crt_startup && |
| 5529 | 5527 | ((g->have_pub_main && g->out_type == OutTypeObj) || g->out_type == OutTypeExe)) |
| 5530 | 5528 | { |
| 5531 | 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 | 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 | 644 | platform->kind = MacOS; |
| 645 | 645 | } else if (g->mios_version_min) { |
| 646 | 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 | 648 | platform->kind = MacOS; |
| 649 | 649 | g->mmacosx_version_min = buf_create_from_str("10.10"); |
| 650 | 650 | } else { |
src/main.cpp+1-1| ... | ... | @@ -120,7 +120,7 @@ static int print_target_list(FILE *f) { |
| 120 | 120 | fprintf(f, "\nOperating Systems:\n"); |
| 121 | 121 | size_t os_count = target_os_count(); |
| 122 | 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 | 124 | const char *native_str = (native.os == os_type) ? " (native)" : ""; |
| 125 | 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 | 105 | ZigLLVM_SUSE, |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | static const ZigLLVM_OSType os_list[] = { | |
| 109 | ZigLLVM_UnknownOS, | |
| 110 | ZigLLVM_Ananas, | |
| 111 | ZigLLVM_CloudABI, | |
| 112 | ZigLLVM_Darwin, | |
| 113 | ZigLLVM_DragonFly, | |
| 114 | ZigLLVM_FreeBSD, | |
| 115 | ZigLLVM_Fuchsia, | |
| 116 | ZigLLVM_IOS, | |
| 117 | ZigLLVM_KFreeBSD, | |
| 118 | ZigLLVM_Linux, | |
| 119 | ZigLLVM_Lv2, | |
| 120 | ZigLLVM_MacOSX, | |
| 121 | ZigLLVM_NetBSD, | |
| 122 | ZigLLVM_OpenBSD, | |
| 123 | ZigLLVM_Solaris, | |
| 124 | ZigLLVM_Win32, | |
| 125 | ZigLLVM_Haiku, | |
| 126 | ZigLLVM_Minix, | |
| 127 | ZigLLVM_RTEMS, | |
| 128 | ZigLLVM_NaCl, | |
| 129 | ZigLLVM_CNK, | |
| 130 | ZigLLVM_Bitrig, | |
| 131 | ZigLLVM_AIX, | |
| 132 | ZigLLVM_CUDA, | |
| 133 | ZigLLVM_NVCL, | |
| 134 | ZigLLVM_AMDHSA, | |
| 135 | ZigLLVM_PS4, | |
| 136 | ZigLLVM_ELFIAMCU, | |
| 137 | ZigLLVM_TvOS, | |
| 138 | ZigLLVM_WatchOS, | |
| 139 | ZigLLVM_Mesa3D, | |
| 140 | ZigLLVM_Contiki, | |
| 108 | static const Os os_list[] = { | |
| 109 | OsFreestanding, | |
| 110 | OsAnanas, | |
| 111 | OsCloudABI, | |
| 112 | OsDragonFly, | |
| 113 | OsFreeBSD, | |
| 114 | OsFuchsia, | |
| 115 | OsIOS, | |
| 116 | OsKFreeBSD, | |
| 117 | OsLinux, | |
| 118 | OsLv2, // PS3 | |
| 119 | OsMacOSX, | |
| 120 | OsNetBSD, | |
| 121 | OsOpenBSD, | |
| 122 | OsSolaris, | |
| 123 | OsWindows, | |
| 124 | OsHaiku, | |
| 125 | OsMinix, | |
| 126 | OsRTEMS, | |
| 127 | OsNaCl, // Native Client | |
| 128 | OsCNK, // BG/P Compute-Node Kernel | |
| 129 | OsBitrig, | |
| 130 | OsAIX, | |
| 131 | OsCUDA, // NVIDIA CUDA | |
| 132 | OsNVCL, // NVIDIA OpenCL | |
| 133 | OsAMDHSA, // AMD HSA Runtime | |
| 134 | OsPS4, | |
| 135 | OsELFIAMCU, | |
| 136 | OsTvOS, // Apple tvOS | |
| 137 | OsWatchOS, // Apple watchOS | |
| 138 | OsMesa3D, | |
| 139 | OsContiki, | |
| 140 | OsZen, | |
| 141 | 141 | }; |
| 142 | 142 | |
| 143 | 143 | static const ZigLLVM_EnvironmentType environ_list[] = { |
| ... | ... | @@ -209,12 +209,187 @@ ZigLLVM_VendorType get_target_vendor(size_t index) { |
| 209 | 209 | size_t target_os_count(void) { |
| 210 | 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 | 213 | return os_list[index]; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | const char *get_target_os_name(ZigLLVM_OSType os_type) { | |
| 217 | return (os_type == ZigLLVM_UnknownOS) ? "freestanding" : ZigLLVMGetOSTypeName(os_type); | |
| 216 | static ZigLLVM_OSType get_llvm_os_type(Os 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 | 395 | size_t target_environ_count(void) { |
| ... | ... | @@ -225,20 +400,22 @@ ZigLLVM_EnvironmentType get_target_environ(size_t index) { |
| 225 | 400 | } |
| 226 | 401 | |
| 227 | 402 | void get_native_target(ZigTarget *target) { |
| 403 | ZigLLVM_OSType os_type; | |
| 228 | 404 | ZigLLVMGetNativeTarget( |
| 229 | 405 | &target->arch.arch, |
| 230 | 406 | &target->arch.sub_arch, |
| 231 | 407 | &target->vendor, |
| 232 | &target->os, | |
| 408 | &os_type, | |
| 233 | 409 | &target->env_type, |
| 234 | 410 | &target->oformat); |
| 411 | target->os = get_zig_os_type(os_type); | |
| 235 | 412 | } |
| 236 | 413 | |
| 237 | 414 | void get_unknown_target(ZigTarget *target) { |
| 238 | 415 | target->arch.arch = ZigLLVM_UnknownArch; |
| 239 | 416 | target->arch.sub_arch = ZigLLVM_NoSubArch; |
| 240 | 417 | target->vendor = ZigLLVM_UnknownVendor; |
| 241 | target->os = ZigLLVM_UnknownOS; | |
| 418 | target->os = OsFreestanding; | |
| 242 | 419 | target->env_type = ZigLLVM_UnknownEnvironment; |
| 243 | 420 | target->oformat = ZigLLVM_UnknownObjectFormat; |
| 244 | 421 | } |
| ... | ... | @@ -265,9 +442,9 @@ int parse_target_arch(const char *str, ArchType *out_arch) { |
| 265 | 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 | 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 | 448 | const char *os_name = get_target_os_name(os); |
| 272 | 449 | if (strcmp(os_name, str) == 0) { |
| 273 | 450 | *out_os = os; |
| ... | ... | @@ -304,15 +481,14 @@ void get_target_triple(Buf *triple, const ZigTarget *target) { |
| 304 | 481 | buf_resize(triple, 0); |
| 305 | 482 | buf_appendf(triple, "%s-%s-%s-%s", arch_name, |
| 306 | 483 | ZigLLVMGetVendorTypeName(target->vendor), |
| 307 | ZigLLVMGetOSTypeName(target->os), | |
| 484 | ZigLLVMGetOSTypeName(get_llvm_os_type(target->os)), | |
| 308 | 485 | ZigLLVMGetEnvironmentTypeName(target->env_type)); |
| 309 | 486 | } |
| 310 | 487 | |
| 311 | 488 | static bool is_os_darwin(ZigTarget *target) { |
| 312 | 489 | switch (target->os) { |
| 313 | case ZigLLVM_Darwin: | |
| 314 | case ZigLLVM_IOS: | |
| 315 | case ZigLLVM_MacOSX: | |
| 490 | case OsMacOSX: | |
| 491 | case OsIOS: | |
| 316 | 492 | return true; |
| 317 | 493 | default: |
| 318 | 494 | return false; |
| ... | ... | @@ -333,7 +509,7 @@ void resolve_target_object_format(ZigTarget *target) { |
| 333 | 509 | case ZigLLVM_x86_64: |
| 334 | 510 | if (is_os_darwin(target)) { |
| 335 | 511 | target->oformat = ZigLLVM_MachO; |
| 336 | } else if (target->os == ZigLLVM_Win32) { | |
| 512 | } else if (target->os == OsWindows) { | |
| 337 | 513 | target->oformat = ZigLLVM_COFF; |
| 338 | 514 | } else { |
| 339 | 515 | target->oformat = ZigLLVM_ELF; |
| ... | ... | @@ -463,7 +639,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) { |
| 463 | 639 | |
| 464 | 640 | uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 465 | 641 | switch (target->os) { |
| 466 | case ZigLLVM_UnknownOS: | |
| 642 | case OsFreestanding: | |
| 467 | 643 | switch (id) { |
| 468 | 644 | case CIntTypeShort: |
| 469 | 645 | case CIntTypeUShort: |
| ... | ... | @@ -480,9 +656,9 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 480 | 656 | case CIntTypeCount: |
| 481 | 657 | zig_unreachable(); |
| 482 | 658 | } |
| 483 | case ZigLLVM_Linux: | |
| 484 | case ZigLLVM_Darwin: | |
| 485 | case ZigLLVM_MacOSX: | |
| 659 | case OsLinux: | |
| 660 | case OsMacOSX: | |
| 661 | case OsZen: | |
| 486 | 662 | switch (id) { |
| 487 | 663 | case CIntTypeShort: |
| 488 | 664 | case CIntTypeUShort: |
| ... | ... | @@ -499,7 +675,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 499 | 675 | case CIntTypeCount: |
| 500 | 676 | zig_unreachable(); |
| 501 | 677 | } |
| 502 | case ZigLLVM_Win32: | |
| 678 | case OsWindows: | |
| 503 | 679 | switch (id) { |
| 504 | 680 | case CIntTypeShort: |
| 505 | 681 | case CIntTypeUShort: |
| ... | ... | @@ -515,40 +691,40 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 515 | 691 | case CIntTypeCount: |
| 516 | 692 | zig_unreachable(); |
| 517 | 693 | } |
| 518 | case ZigLLVM_Ananas: | |
| 519 | case ZigLLVM_CloudABI: | |
| 520 | case ZigLLVM_DragonFly: | |
| 521 | case ZigLLVM_FreeBSD: | |
| 522 | case ZigLLVM_IOS: | |
| 523 | case ZigLLVM_KFreeBSD: | |
| 524 | case ZigLLVM_Lv2: | |
| 525 | case ZigLLVM_NetBSD: | |
| 526 | case ZigLLVM_OpenBSD: | |
| 527 | case ZigLLVM_Solaris: | |
| 528 | case ZigLLVM_Haiku: | |
| 529 | case ZigLLVM_Minix: | |
| 530 | case ZigLLVM_RTEMS: | |
| 531 | case ZigLLVM_NaCl: | |
| 532 | case ZigLLVM_CNK: | |
| 533 | case ZigLLVM_Bitrig: | |
| 534 | case ZigLLVM_AIX: | |
| 535 | case ZigLLVM_CUDA: | |
| 536 | case ZigLLVM_NVCL: | |
| 537 | case ZigLLVM_AMDHSA: | |
| 538 | case ZigLLVM_PS4: | |
| 539 | case ZigLLVM_ELFIAMCU: | |
| 540 | case ZigLLVM_TvOS: | |
| 541 | case ZigLLVM_WatchOS: | |
| 542 | case ZigLLVM_Mesa3D: | |
| 543 | case ZigLLVM_Fuchsia: | |
| 544 | case ZigLLVM_Contiki: | |
| 694 | case OsAnanas: | |
| 695 | case OsCloudABI: | |
| 696 | case OsDragonFly: | |
| 697 | case OsFreeBSD: | |
| 698 | case OsIOS: | |
| 699 | case OsKFreeBSD: | |
| 700 | case OsLv2: | |
| 701 | case OsNetBSD: | |
| 702 | case OsOpenBSD: | |
| 703 | case OsSolaris: | |
| 704 | case OsHaiku: | |
| 705 | case OsMinix: | |
| 706 | case OsRTEMS: | |
| 707 | case OsNaCl: | |
| 708 | case OsCNK: | |
| 709 | case OsBitrig: | |
| 710 | case OsAIX: | |
| 711 | case OsCUDA: | |
| 712 | case OsNVCL: | |
| 713 | case OsAMDHSA: | |
| 714 | case OsPS4: | |
| 715 | case OsELFIAMCU: | |
| 716 | case OsTvOS: | |
| 717 | case OsWatchOS: | |
| 718 | case OsMesa3D: | |
| 719 | case OsFuchsia: | |
| 720 | case OsContiki: | |
| 545 | 721 | zig_panic("TODO c type size in bits for this target"); |
| 546 | 722 | } |
| 547 | 723 | zig_unreachable(); |
| 548 | 724 | } |
| 549 | 725 | |
| 550 | 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 | 728 | return ".obj"; |
| 553 | 729 | } else { |
| 554 | 730 | return ".o"; |
| ... | ... | @@ -564,7 +740,7 @@ const char *target_llvm_ir_file_ext(ZigTarget *target) { |
| 564 | 740 | } |
| 565 | 741 | |
| 566 | 742 | const char *target_exe_file_ext(ZigTarget *target) { |
| 567 | if (target->os == ZigLLVM_Win32) { | |
| 743 | if (target->os == OsWindows) { | |
| 568 | 744 | return ".exe"; |
| 569 | 745 | } else { |
| 570 | 746 | return ""; |
| ... | ... | @@ -664,12 +840,12 @@ bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target |
| 664 | 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 | 844 | host_target->arch.arch == ZigLLVM_x86_64 && guest_target->arch.arch == ZigLLVM_x86) |
| 669 | 845 | { |
| 670 | 846 | // 64-bit windows can run 32-bit programs |
| 671 | 847 | return true; |
| 672 | 848 | } |
| 673 | ||
| 849 | ||
| 674 | 850 | return false; |
| 675 | 851 | } |
src/target.hpp+39-4| ... | ... | @@ -17,10 +17,45 @@ struct ArchType { |
| 17 | 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 | 55 | struct ZigTarget { |
| 21 | 56 | ArchType arch; |
| 22 | 57 | ZigLLVM_VendorType vendor; |
| 23 | ZigLLVM_OSType os; | |
| 58 | Os os; | |
| 24 | 59 | ZigLLVM_EnvironmentType env_type; |
| 25 | 60 | ZigLLVM_ObjectFormatType oformat; |
| 26 | 61 | }; |
| ... | ... | @@ -46,8 +81,8 @@ size_t target_vendor_count(void); |
| 46 | 81 | ZigLLVM_VendorType get_target_vendor(size_t index); |
| 47 | 82 | |
| 48 | 83 | size_t target_os_count(void); |
| 49 | ZigLLVM_OSType get_target_os(size_t index); | |
| 50 | const char *get_target_os_name(ZigLLVM_OSType os_type); | |
| 84 | Os get_target_os(size_t index); | |
| 85 | const char *get_target_os_name(Os os_type); | |
| 51 | 86 | |
| 52 | 87 | size_t target_environ_count(void); |
| 53 | 88 | ZigLLVM_EnvironmentType get_target_environ(size_t index); |
| ... | ... | @@ -61,7 +96,7 @@ void get_native_target(ZigTarget *target); |
| 61 | 96 | void get_unknown_target(ZigTarget *target); |
| 62 | 97 | |
| 63 | 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 | 100 | int parse_target_environ(const char *str, ZigLLVM_EnvironmentType *env_type); |
| 66 | 101 | |
| 67 | 102 | void init_all_targets(void); |
std/build.zig+2-2| ... | ... | @@ -800,7 +800,7 @@ const Target = union(enum) { |
| 800 | 800 | |
| 801 | 801 | pub fn isDarwin(self: &const Target) -> bool { |
| 802 | 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 | 804 | else => false, |
| 805 | 805 | }; |
| 806 | 806 | } |
| ... | ... | @@ -1011,7 +1011,7 @@ pub const LibExeObjStep = struct { |
| 1011 | 1011 | self.out_filename = self.builder.fmt("lib{}.a", self.name); |
| 1012 | 1012 | } else { |
| 1013 | 1013 | switch (self.target.getOs()) { |
| 1014 | builtin.Os.darwin, builtin.Os.ios, builtin.Os.macosx => { | |
| 1014 | builtin.Os.ios, builtin.Os.macosx => { | |
| 1015 | 1015 | self.out_filename = self.builder.fmt("lib{}.{d}.{d}.{d}.dylib", |
| 1016 | 1016 | self.name, self.version.major, self.version.minor, self.version.patch); |
| 1017 | 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 | 4 | pub use switch(builtin.os) { |
| 5 | 5 | Os.linux => @import("linux.zig"), |
| 6 | 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 | 8 | else => empty_import, |
| 9 | 9 | }; |
| 10 | 10 | const empty_import = @import("../empty.zig"); |
std/heap.zig+2-2| ... | ... | @@ -49,7 +49,7 @@ pub const IncrementingAllocator = struct { |
| 49 | 49 | |
| 50 | 50 | fn init(capacity: usize) -> %IncrementingAllocator { |
| 51 | 51 | switch (builtin.os) { |
| 52 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | |
| 52 | Os.linux, Os.macosx, Os.ios => { | |
| 53 | 53 | const p = os.posix; |
| 54 | 54 | const addr = p.mmap(null, capacity, p.PROT_READ|p.PROT_WRITE, |
| 55 | 55 | p.MAP_PRIVATE|p.MAP_ANONYMOUS|p.MAP_NORESERVE, -1, 0); |
| ... | ... | @@ -87,7 +87,7 @@ pub const IncrementingAllocator = struct { |
| 87 | 87 | |
| 88 | 88 | fn deinit(self: &IncrementingAllocator) { |
| 89 | 89 | switch (builtin.os) { |
| 90 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | |
| 90 | Os.linux, Os.macosx, Os.ios => { | |
| 91 | 91 | _ = os.posix.munmap(self.bytes.ptr, self.bytes.len); |
| 92 | 92 | }, |
| 93 | 93 | Os.windows => { |
std/io.zig+4-4| ... | ... | @@ -3,7 +3,7 @@ const builtin = @import("builtin"); |
| 3 | 3 | const Os = builtin.Os; |
| 4 | 4 | const system = switch(builtin.os) { |
| 5 | 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 | 7 | Os.windows => @import("os/windows/index.zig"), |
| 8 | 8 | else => @compileError("Unsupported OS"), |
| 9 | 9 | }; |
| ... | ... | @@ -190,7 +190,7 @@ pub const File = struct { |
| 190 | 190 | |
| 191 | 191 | pub fn seekForward(self: &File, amount: isize) -> %void { |
| 192 | 192 | switch (builtin.os) { |
| 193 | Os.linux, Os.darwin => { | |
| 193 | Os.linux, Os.macosx, Os.ios => { | |
| 194 | 194 | const result = system.lseek(self.handle, amount, system.SEEK_CUR); |
| 195 | 195 | const err = system.getErrno(result); |
| 196 | 196 | if (err > 0) { |
| ... | ... | @@ -210,7 +210,7 @@ pub const File = struct { |
| 210 | 210 | |
| 211 | 211 | pub fn seekTo(self: &File, pos: usize) -> %void { |
| 212 | 212 | switch (builtin.os) { |
| 213 | Os.linux, Os.darwin => { | |
| 213 | Os.linux, Os.macosx, Os.ios => { | |
| 214 | 214 | const result = system.lseek(self.handle, @bitCast(isize, pos), system.SEEK_SET); |
| 215 | 215 | const err = system.getErrno(result); |
| 216 | 216 | if (err > 0) { |
| ... | ... | @@ -230,7 +230,7 @@ pub const File = struct { |
| 230 | 230 | |
| 231 | 231 | pub fn getPos(self: &File) -> %usize { |
| 232 | 232 | switch (builtin.os) { |
| 233 | Os.linux, Os.darwin => { | |
| 233 | Os.linux, Os.macosx, Os.ios => { | |
| 234 | 234 | const result = system.lseek(self.handle, 0, system.SEEK_CUR); |
| 235 | 235 | const err = system.getErrno(result); |
| 236 | 236 | if (err > 0) { |
std/os/get_user_id.zig+1-1| ... | ... | @@ -11,7 +11,7 @@ pub const UserInfo = struct { |
| 11 | 11 | /// POSIX function which gets a uid from username. |
| 12 | 12 | pub fn getUserInfo(name: []const u8) -> %UserInfo { |
| 13 | 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 | 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 | 9 | pub const linux = @import("linux.zig"); |
| 10 | 10 | pub const posix = switch(builtin.os) { |
| 11 | 11 | Os.linux => linux, |
| 12 | Os.darwin, Os.macosx, Os.ios => darwin, | |
| 12 | Os.macosx, Os.ios => darwin, | |
| 13 | 13 | else => @compileError("Unsupported OS"), |
| 14 | 14 | }; |
| 15 | 15 | |
| ... | ... | @@ -89,7 +89,7 @@ pub fn getRandomBytes(buf: []u8) -> %void { |
| 89 | 89 | } |
| 90 | 90 | return; |
| 91 | 91 | }, |
| 92 | Os.darwin, Os.macosx, Os.ios => { | |
| 92 | Os.macosx, Os.ios => { | |
| 93 | 93 | const fd = %return posixOpen("/dev/urandom", posix.O_RDONLY|posix.O_CLOEXEC, |
| 94 | 94 | 0, null); |
| 95 | 95 | defer close(fd); |
| ... | ... | @@ -130,7 +130,7 @@ pub coldcc fn abort() -> noreturn { |
| 130 | 130 | c.abort(); |
| 131 | 131 | } |
| 132 | 132 | switch (builtin.os) { |
| 133 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | |
| 133 | Os.linux, Os.macosx, Os.ios => { | |
| 134 | 134 | _ = posix.raise(posix.SIGABRT); |
| 135 | 135 | _ = posix.raise(posix.SIGKILL); |
| 136 | 136 | while (true) {} |
| ... | ... | @@ -151,7 +151,7 @@ pub coldcc fn exit(status: i32) -> noreturn { |
| 151 | 151 | c.exit(status); |
| 152 | 152 | } |
| 153 | 153 | switch (builtin.os) { |
| 154 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | |
| 154 | Os.linux, Os.macosx, Os.ios => { | |
| 155 | 155 | posix.exit(status); |
| 156 | 156 | }, |
| 157 | 157 | Os.windows => { |
| ... | ... | @@ -1104,7 +1104,7 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 1104 | 1104 | |
| 1105 | 1105 | pub fn sleep(seconds: usize, nanoseconds: usize) { |
| 1106 | 1106 | switch(builtin.os) { |
| 1107 | Os.linux, Os.darwin, Os.macosx, Os.ios => { | |
| 1107 | Os.linux, Os.macosx, Os.ios => { | |
| 1108 | 1108 | posixSleep(u63(seconds), u63(nanoseconds)); |
| 1109 | 1109 | }, |
| 1110 | 1110 | Os.windows => { |
| ... | ... | @@ -1537,7 +1537,7 @@ pub fn openSelfExe() -> %io.File { |
| 1537 | 1537 | Os.linux => { |
| 1538 | 1538 | return io.File.openRead("/proc/self/exe", null); |
| 1539 | 1539 | }, |
| 1540 | Os.darwin => { | |
| 1540 | Os.macosx, Os.ios => { | |
| 1541 | 1541 | @panic("TODO: openSelfExe on Darwin"); |
| 1542 | 1542 | }, |
| 1543 | 1543 | else => @compileError("Unsupported OS"), |
| ... | ... | @@ -1577,7 +1577,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { |
| 1577 | 1577 | %return out_path.resize(new_len); |
| 1578 | 1578 | } |
| 1579 | 1579 | }, |
| 1580 | Os.darwin, Os.macosx, Os.ios => { | |
| 1580 | Os.macosx, Os.ios => { | |
| 1581 | 1581 | var u32_len: u32 = 0; |
| 1582 | 1582 | const ret1 = c._NSGetExecutablePath(undefined, &u32_len); |
| 1583 | 1583 | assert(ret1 != 0); |
| ... | ... | @@ -1605,7 +1605,7 @@ pub fn selfExeDirPath(allocator: &mem.Allocator) -> %[]u8 { |
| 1605 | 1605 | const dir = path.dirname(full_exe_path); |
| 1606 | 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 | 1609 | const self_exe_path = %return selfExePath(allocator); |
| 1610 | 1610 | %defer allocator.free(self_exe_path); |
| 1611 | 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 | 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 | 1141 | // TODO instead of calling the libc function here, port the implementation |
| 1142 | 1142 | // to Zig, and then remove the NameTooLong error possibility. |
| 1143 | 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 | 33 | .environ = builtin.Environ.gnu, |
| 34 | 34 | }, |
| 35 | 35 | TestTarget { |
| 36 | .os = builtin.Os.darwin, | |
| 36 | .os = builtin.Os.macosx, | |
| 37 | 37 | .arch = builtin.Arch.x86_64, |
| 38 | 38 | .environ = builtin.Environ.unknown, |
| 39 | 39 | }, |