1const builtin = @import("builtin"); 2 3// TODO delete these after releasing 0.9.0 4 5pub const zig_version = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 6pub const zig_is_stage2 = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 7pub const output_mode = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 8pub const link_mode = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 9pub const is_test = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 10pub const single_threaded = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 11pub const abi = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 12pub const cpu = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 13pub const os = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 14pub const target = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 15pub const object_format = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 16pub const mode = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 17pub const link_libc = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 18pub const link_libcpp = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 19pub const have_error_return_tracing = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 20pub const valgrind_support = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 21pub const position_independent_code = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 22pub const position_independent_executable = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 23pub const strip_debug_info = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 24pub const code_model = @compileError("get this from @import(\"builtin\") instead of std.builtin"); 25 26/// `explicit_subsystem` is missing when the subsystem is automatically detected, 27/// so Zig standard library has the subsystem detection logic here. This should generally be 28/// used rather than `explicit_subsystem`. 29/// On non-Windows targets, this is `null`. 30pub const subsystem: ?std.Target.SubSystem = blk: { 31 if (@hasDecl(builtin, "explicit_subsystem")) break :blk builtin.explicit_subsystem; 32 switch (os.tag) { 33 .windows => { 34 if (is_test) { 35 break :blk std.Target.SubSystem.Console; 36 } 37 if (@hasDecl(root, "main") or 38 @hasDecl(root, "WinMain") or 39 @hasDecl(root, "wWinMain") or 40 @hasDecl(root, "WinMainCRTStartup") or 41 @hasDecl(root, "wWinMainCRTStartup")) 42 { 43 break :blk std.Target.SubSystem.Windows; 44 } else { 45 break :blk std.Target.SubSystem.Console; 46 } 47 }, 48 else => break :blk null, 49 } 50}; 51 52/// This data structure is used by the Zig language code generation and 53/// therefore must be kept in sync with the compiler implementation. 54pub const StackTrace = struct { 55 index: usize, 56 instruction_addresses: []usize, 57 58 pub fn format( 59 self: StackTrace, 60 comptime fmt: []const u8, 61 options: std.fmt.FormatOptions, 62 writer: anytype, 63 ) !void { 64 // TODO: re-evaluate whether to use format() methods at all. 65 // Until then, avoid an error when using GeneralPurposeAllocator with WebAssembly 66 // where it tries to call detectTTYConfig here. 67 if (builtin.os.tag == .freestanding) return; 68 69 _ = fmt; 70 _ = options; 71 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 72 defer arena.deinit(); 73 const debug_info = std.debug.getSelfDebugInfo() catch |err| { 74 return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}); 75 }; 76 const tty_config = std.debug.detectTTYConfig(); 77 try writer.writeAll("\n"); 78 std.debug.writeStackTrace(self, writer, arena.allocator(), debug_info, tty_config) catch |err| { 79 try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)}); 80 }; 81 try writer.writeAll("\n"); 82 } 83}; 84 85/// This data structure is used by the Zig language code generation and 86/// therefore must be kept in sync with the compiler implementation. 87pub const GlobalLinkage = enum { 88 Internal, 89 Strong, 90 Weak, 91 LinkOnce, 92}; 93 94/// This data structure is used by the Zig language code generation and 95/// therefore must be kept in sync with the compiler implementation. 96pub const AtomicOrder = enum { 97 Unordered, 98 Monotonic, 99 Acquire, 100 Release, 101 AcqRel, 102 SeqCst, 103}; 104 105/// This data structure is used by the Zig language code generation and 106/// therefore must be kept in sync with the compiler implementation. 107pub const ReduceOp = enum { 108 And, 109 Or, 110 Xor, 111 Min, 112 Max, 113 Add, 114 Mul, 115}; 116 117/// This data structure is used by the Zig language code generation and 118/// therefore must be kept in sync with the compiler implementation. 119pub const AtomicRmwOp = enum { 120 Xchg, 121 Add, 122 Sub, 123 And, 124 Nand, 125 Or, 126 Xor, 127 Max, 128 Min, 129}; 130 131/// The code model puts constraints on the location of symbols and the size of code and data. 132/// The selection of a code model is a trade off on speed and restrictions that needs to be selected on a per application basis to meet its requirements. 133/// A slightly more detailed explanation can be found in (for example) the [System V Application Binary Interface (x86_64)](https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf) 3.5.1. 134/// 135/// This data structure is used by the Zig language code generation and 136/// therefore must be kept in sync with the compiler implementation. 137pub const CodeModel = enum { 138 default, 139 tiny, 140 small, 141 kernel, 142 medium, 143 large, 144}; 145 146/// This data structure is used by the Zig language code generation and 147/// therefore must be kept in sync with the compiler implementation. 148pub const Mode = enum { 149 Debug, 150 ReleaseSafe, 151 ReleaseFast, 152 ReleaseSmall, 153}; 154 155/// This data structure is used by the Zig language code generation and 156/// therefore must be kept in sync with the compiler implementation. 157pub const CallingConvention = enum { 158 Unspecified, 159 C, 160 Naked, 161 Async, 162 Inline, 163 Interrupt, 164 Signal, 165 Stdcall, 166 Fastcall, 167 Vectorcall, 168 Thiscall, 169 APCS, 170 AAPCS, 171 AAPCSVFP, 172 SysV, 173}; 174 175/// This data structure is used by the Zig language code generation and 176/// therefore must be kept in sync with the compiler implementation. 177pub const AddressSpace = enum { 178 generic, 179 gs, 180 fs, 181 ss, 182}; 183 184/// This data structure is used by the Zig language code generation and 185/// therefore must be kept in sync with the compiler implementation. 186pub const SourceLocation = struct { 187 file: [:0]const u8, 188 fn_name: [:0]const u8, 189 line: u32, 190 column: u32, 191}; 192 193pub const TypeId = std.meta.Tag(TypeInfo); 194 195/// This data structure is used by the Zig language code generation and 196/// therefore must be kept in sync with the compiler implementation. 197pub const TypeInfo = union(enum) { 198 Type: void, 199 Void: void, 200 Bool: void, 201 NoReturn: void, 202 Int: Int, 203 Float: Float, 204 Pointer: Pointer, 205 Array: Array, 206 Struct: Struct, 207 ComptimeFloat: void, 208 ComptimeInt: void, 209 Undefined: void, 210 Null: void, 211 Optional: Optional, 212 ErrorUnion: ErrorUnion, 213 ErrorSet: ErrorSet, 214 Enum: Enum, 215 Union: Union, 216 Fn: Fn, 217 BoundFn: Fn, 218 Opaque: Opaque, 219 Frame: Frame, 220 AnyFrame: AnyFrame, 221 Vector: Vector, 222 EnumLiteral: void, 223 224 /// This data structure is used by the Zig language code generation and 225 /// therefore must be kept in sync with the compiler implementation. 226 pub const Int = struct { 227 signedness: Signedness, 228 bits: comptime_int, 229 }; 230 231 /// This data structure is used by the Zig language code generation and 232 /// therefore must be kept in sync with the compiler implementation. 233 pub const Float = struct { 234 bits: comptime_int, 235 }; 236 237 /// This data structure is used by the Zig language code generation and 238 /// therefore must be kept in sync with the compiler implementation. 239 pub const Pointer = struct { 240 size: Size, 241 is_const: bool, 242 is_volatile: bool, 243 alignment: comptime_int, 244 address_space: AddressSpace, 245 child: type, 246 is_allowzero: bool, 247 248 /// This field is an optional type. 249 /// The type of the sentinel is the element type of the pointer, which is 250 /// the value of the `child` field in this struct. However there is no way 251 /// to refer to that type here, so we use `anytype`. 252 sentinel: anytype, 253 254 /// This data structure is used by the Zig language code generation and 255 /// therefore must be kept in sync with the compiler implementation. 256 pub const Size = enum { 257 One, 258 Many, 259 Slice, 260 C, 261 }; 262 }; 263 264 /// This data structure is used by the Zig language code generation and 265 /// therefore must be kept in sync with the compiler implementation. 266 pub const Array = struct { 267 len: comptime_int, 268 child: type, 269 270 /// This field is an optional type. 271 /// The type of the sentinel is the element type of the array, which is 272 /// the value of the `child` field in this struct. However there is no way 273 /// to refer to that type here, so we use `anytype`. 274 sentinel: anytype, 275 }; 276 277 /// This data structure is used by the Zig language code generation and 278 /// therefore must be kept in sync with the compiler implementation. 279 pub const ContainerLayout = enum(u2) { 280 Auto, 281 Extern, 282 Packed, 283 }; 284 285 /// This data structure is used by the Zig language code generation and 286 /// therefore must be kept in sync with the compiler implementation. 287 pub const StructField = struct { 288 name: []const u8, 289 field_type: type, 290 default_value: anytype, 291 is_comptime: bool, 292 alignment: comptime_int, 293 }; 294 295 /// This data structure is used by the Zig language code generation and 296 /// therefore must be kept in sync with the compiler implementation. 297 pub const Struct = struct { 298 layout: ContainerLayout, 299 fields: []const StructField, 300 decls: []const Declaration, 301 is_tuple: bool, 302 }; 303 304 /// This data structure is used by the Zig language code generation and 305 /// therefore must be kept in sync with the compiler implementation. 306 pub const Optional = struct { 307 child: type, 308 }; 309 310 /// This data structure is used by the Zig language code generation and 311 /// therefore must be kept in sync with the compiler implementation. 312 pub const ErrorUnion = struct { 313 error_set: type, 314 payload: type, 315 }; 316 317 /// This data structure is used by the Zig language code generation and 318 /// therefore must be kept in sync with the compiler implementation. 319 pub const Error = struct { 320 name: []const u8, 321 }; 322 323 /// This data structure is used by the Zig language code generation and 324 /// therefore must be kept in sync with the compiler implementation. 325 pub const ErrorSet = ?[]const Error; 326 327 /// This data structure is used by the Zig language code generation and 328 /// therefore must be kept in sync with the compiler implementation. 329 pub const EnumField = struct { 330 name: []const u8, 331 value: comptime_int, 332 }; 333 334 /// This data structure is used by the Zig language code generation and 335 /// therefore must be kept in sync with the compiler implementation. 336 pub const Enum = struct { 337 layout: ContainerLayout, 338 tag_type: type, 339 fields: []const EnumField, 340 decls: []const Declaration, 341 is_exhaustive: bool, 342 }; 343 344 /// This data structure is used by the Zig language code generation and 345 /// therefore must be kept in sync with the compiler implementation. 346 pub const UnionField = struct { 347 name: []const u8, 348 field_type: type, 349 alignment: comptime_int, 350 }; 351 352 /// This data structure is used by the Zig language code generation and 353 /// therefore must be kept in sync with the compiler implementation. 354 pub const Union = struct { 355 layout: ContainerLayout, 356 tag_type: ?type, 357 fields: []const UnionField, 358 decls: []const Declaration, 359 }; 360 361 /// This data structure is used by the Zig language code generation and 362 /// therefore must be kept in sync with the compiler implementation. 363 pub const FnArg = struct { 364 is_generic: bool, 365 is_noalias: bool, 366 arg_type: ?type, 367 }; 368 369 /// This data structure is used by the Zig language code generation and 370 /// therefore must be kept in sync with the compiler implementation. 371 pub const Fn = struct { 372 calling_convention: CallingConvention, 373 alignment: comptime_int, 374 is_generic: bool, 375 is_var_args: bool, 376 return_type: ?type, 377 args: []const FnArg, 378 }; 379 380 /// This data structure is used by the Zig language code generation and 381 /// therefore must be kept in sync with the compiler implementation. 382 pub const Opaque = struct { 383 decls: []const Declaration, 384 }; 385 386 /// This data structure is used by the Zig language code generation and 387 /// therefore must be kept in sync with the compiler implementation. 388 pub const Frame = struct { 389 function: anytype, 390 }; 391 392 /// This data structure is used by the Zig language code generation and 393 /// therefore must be kept in sync with the compiler implementation. 394 pub const AnyFrame = struct { 395 child: ?type, 396 }; 397 398 /// This data structure is used by the Zig language code generation and 399 /// therefore must be kept in sync with the compiler implementation. 400 pub const Vector = struct { 401 len: comptime_int, 402 child: type, 403 }; 404 405 /// This data structure is used by the Zig language code generation and 406 /// therefore must be kept in sync with the compiler implementation. 407 pub const Declaration = struct { 408 name: []const u8, 409 is_pub: bool, 410 data: Data, 411 412 /// This data structure is used by the Zig language code generation and 413 /// therefore must be kept in sync with the compiler implementation. 414 pub const Data = union(enum) { 415 Type: type, 416 Var: type, 417 Fn: FnDecl, 418 419 /// This data structure is used by the Zig language code generation and 420 /// therefore must be kept in sync with the compiler implementation. 421 pub const FnDecl = struct { 422 fn_type: type, 423 is_noinline: bool, 424 is_var_args: bool, 425 is_extern: bool, 426 is_export: bool, 427 lib_name: ?[]const u8, 428 return_type: type, 429 arg_names: []const []const u8, 430 }; 431 }; 432 }; 433}; 434 435/// This data structure is used by the Zig language code generation and 436/// therefore must be kept in sync with the compiler implementation. 437pub const FloatMode = enum { 438 Strict, 439 Optimized, 440}; 441 442/// This data structure is used by the Zig language code generation and 443/// therefore must be kept in sync with the compiler implementation. 444pub const Endian = enum { 445 Big, 446 Little, 447}; 448 449/// This data structure is used by the Zig language code generation and 450/// therefore must be kept in sync with the compiler implementation. 451pub const Signedness = enum { 452 signed, 453 unsigned, 454}; 455 456/// This data structure is used by the Zig language code generation and 457/// therefore must be kept in sync with the compiler implementation. 458pub const OutputMode = enum { 459 Exe, 460 Lib, 461 Obj, 462}; 463 464/// This data structure is used by the Zig language code generation and 465/// therefore must be kept in sync with the compiler implementation. 466pub const LinkMode = enum { 467 Static, 468 Dynamic, 469}; 470 471/// This data structure is used by the Zig language code generation and 472/// therefore must be kept in sync with the compiler implementation. 473pub const WasiExecModel = enum { 474 command, 475 reactor, 476}; 477 478/// This data structure is used by the Zig language code generation and 479/// therefore must be kept in sync with the compiler implementation. 480pub const Version = struct { 481 major: u32, 482 minor: u32, 483 patch: u32 = 0, 484 485 pub const Range = struct { 486 min: Version, 487 max: Version, 488 489 pub fn includesVersion(self: Range, ver: Version) bool { 490 if (self.min.order(ver) == .gt) return false; 491 if (self.max.order(ver) == .lt) return false; 492 return true; 493 } 494 495 /// Checks if system is guaranteed to be at least `version` or older than `version`. 496 /// Returns `null` if a runtime check is required. 497 pub fn isAtLeast(self: Range, ver: Version) ?bool { 498 if (self.min.order(ver) != .lt) return true; 499 if (self.max.order(ver) == .lt) return false; 500 return null; 501 } 502 }; 503 504 pub fn order(lhs: Version, rhs: Version) std.math.Order { 505 if (lhs.major < rhs.major) return .lt; 506 if (lhs.major > rhs.major) return .gt; 507 if (lhs.minor < rhs.minor) return .lt; 508 if (lhs.minor > rhs.minor) return .gt; 509 if (lhs.patch < rhs.patch) return .lt; 510 if (lhs.patch > rhs.patch) return .gt; 511 return .eq; 512 } 513 514 pub fn parse(text: []const u8) !Version { 515 var end: usize = 0; 516 while (end < text.len) : (end += 1) { 517 const c = text[end]; 518 if (!std.ascii.isDigit(c) and c != '.') break; 519 } 520 // found no digits or '.' before unexpected character 521 if (end == 0) return error.InvalidVersion; 522 523 var it = std.mem.split(u8, text[0..end], "."); 524 // substring is not empty, first call will succeed 525 const major = it.next().?; 526 if (major.len == 0) return error.InvalidVersion; 527 const minor = it.next() orelse "0"; 528 // ignore 'patch' if 'minor' is invalid 529 const patch = if (minor.len == 0) "0" else (it.next() orelse "0"); 530 531 return Version{ 532 .major = try std.fmt.parseUnsigned(u32, major, 10), 533 .minor = try std.fmt.parseUnsigned(u32, if (minor.len == 0) "0" else minor, 10), 534 .patch = try std.fmt.parseUnsigned(u32, if (patch.len == 0) "0" else patch, 10), 535 }; 536 } 537 538 pub fn format( 539 self: Version, 540 comptime fmt: []const u8, 541 options: std.fmt.FormatOptions, 542 out_stream: anytype, 543 ) !void { 544 _ = options; 545 if (fmt.len == 0) { 546 if (self.patch == 0) { 547 if (self.minor == 0) { 548 return std.fmt.format(out_stream, "{d}", .{self.major}); 549 } else { 550 return std.fmt.format(out_stream, "{d}.{d}", .{ self.major, self.minor }); 551 } 552 } else { 553 return std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); 554 } 555 } else { 556 @compileError("Unknown format string: '" ++ fmt ++ "'"); 557 } 558 } 559}; 560 561test "Version.parse" { 562 @setEvalBranchQuota(3000); 563 try testVersionParse(); 564 comptime (try testVersionParse()); 565} 566 567pub fn testVersionParse() !void { 568 const f = struct { 569 fn eql(text: []const u8, v1: u32, v2: u32, v3: u32) !void { 570 const v = try Version.parse(text); 571 try std.testing.expect(v.major == v1 and v.minor == v2 and v.patch == v3); 572 } 573 574 fn err(text: []const u8, expected_err: anyerror) !void { 575 _ = Version.parse(text) catch |actual_err| { 576 if (actual_err == expected_err) return; 577 return actual_err; 578 }; 579 return error.Unreachable; 580 } 581 }; 582 583 try f.eql("2.6.32.11-svn21605", 2, 6, 32); // Debian PPC 584 try f.eql("2.11.2(0.329/5/3)", 2, 11, 2); // MinGW 585 try f.eql("5.4.0-1018-raspi", 5, 4, 0); // Ubuntu 586 try f.eql("5.7.12_3", 5, 7, 12); // Void 587 try f.eql("2.13-DEVELOPMENT", 2, 13, 0); // DragonFly 588 try f.eql("2.3-35", 2, 3, 0); 589 try f.eql("1a.4", 1, 0, 0); 590 try f.eql("3.b1.0", 3, 0, 0); 591 try f.eql("1.4beta", 1, 4, 0); 592 try f.eql("2.7.pre", 2, 7, 0); 593 try f.eql("0..3", 0, 0, 0); 594 try f.eql("8.008.", 8, 8, 0); 595 try f.eql("01...", 1, 0, 0); 596 try f.eql("55", 55, 0, 0); 597 try f.eql("4294967295.0.1", 4294967295, 0, 1); 598 try f.eql("429496729_6", 429496729, 0, 0); 599 600 try f.err("foobar", error.InvalidVersion); 601 try f.err("", error.InvalidVersion); 602 try f.err("-1", error.InvalidVersion); 603 try f.err("+4", error.InvalidVersion); 604 try f.err(".", error.InvalidVersion); 605 try f.err("....3", error.InvalidVersion); 606 try f.err("4294967296", error.Overflow); 607 try f.err("5000877755", error.Overflow); 608 // error.InvalidCharacter is not possible anymore 609} 610 611/// This data structure is used by the Zig language code generation and 612/// therefore must be kept in sync with the compiler implementation. 613pub const CallOptions = struct { 614 modifier: Modifier = .auto, 615 616 /// Only valid when `Modifier` is `Modifier.async_kw`. 617 stack: ?[]align(std.Target.stack_align) u8 = null, 618 619 pub const Modifier = enum { 620 /// Equivalent to function call syntax. 621 auto, 622 623 /// Equivalent to async keyword used with function call syntax. 624 async_kw, 625 626 /// Prevents tail call optimization. This guarantees that the return 627 /// address will point to the callsite, as opposed to the callsite's 628 /// callsite. If the call is otherwise required to be tail-called 629 /// or inlined, a compile error is emitted instead. 630 never_tail, 631 632 /// Guarantees that the call will not be inlined. If the call is 633 /// otherwise required to be inlined, a compile error is emitted instead. 634 never_inline, 635 636 /// Asserts that the function call will not suspend. This allows a 637 /// non-async function to call an async function. 638 no_async, 639 640 /// Guarantees that the call will be generated with tail call optimization. 641 /// If this is not possible, a compile error is emitted instead. 642 always_tail, 643 644 /// Guarantees that the call will inlined at the callsite. 645 /// If this is not possible, a compile error is emitted instead. 646 always_inline, 647 648 /// Evaluates the call at compile-time. If the call cannot be completed at 649 /// compile-time, a compile error is emitted instead. 650 compile_time, 651 }; 652}; 653 654/// This data structure is used by the Zig language code generation and 655/// therefore must be kept in sync with the compiler implementation. 656pub const PrefetchOptions = struct { 657 /// Whether the prefetch should prepare for a read or a write. 658 rw: Rw = .read, 659 /// 0 means no temporal locality. That is, the data can be immediately 660 /// dropped from the cache after it is accessed. 661 /// 662 /// 3 means high temporal locality. That is, the data should be kept in 663 /// the cache as it is likely to be accessed again soon. 664 locality: u2 = 3, 665 /// The cache that the prefetch should be preformed on. 666 cache: Cache = .data, 667 668 pub const Rw = enum { 669 read, 670 write, 671 }; 672 673 pub const Cache = enum { 674 instruction, 675 data, 676 }; 677}; 678 679/// This data structure is used by the Zig language code generation and 680/// therefore must be kept in sync with the compiler implementation. 681pub const ExportOptions = struct { 682 name: []const u8, 683 linkage: GlobalLinkage = .Strong, 684 section: ?[]const u8 = null, 685}; 686 687/// This data structure is used by the Zig language code generation and 688/// therefore must be kept in sync with the compiler implementation. 689pub const ExternOptions = struct { 690 name: []const u8, 691 library_name: ?[]const u8 = null, 692 linkage: GlobalLinkage = .Strong, 693 is_thread_local: bool = false, 694}; 695 696/// This function type is used by the Zig language code generation and 697/// therefore must be kept in sync with the compiler implementation. 698pub const TestFn = struct { 699 name: []const u8, 700 func: fn () anyerror!void, 701 async_frame_size: ?usize, 702}; 703 704/// This function type is used by the Zig language code generation and 705/// therefore must be kept in sync with the compiler implementation. 706pub const PanicFn = fn ([]const u8, ?*StackTrace) noreturn; 707 708/// This function is used by the Zig language code generation and 709/// therefore must be kept in sync with the compiler implementation. 710pub const panic: PanicFn = if (@hasDecl(root, "panic")) 711 root.panic 712else if (@hasDecl(root, "os") and @hasDecl(root.os, "panic")) 713 root.os.panic 714else 715 default_panic; 716 717/// This function is used by the Zig language code generation and 718/// therefore must be kept in sync with the compiler implementation. 719pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn { 720 @setCold(true); 721 // Until self-hosted catches up with stage1 language features, we have a simpler 722 // default panic function: 723 if (builtin.zig_is_stage2) { 724 while (true) { 725 @breakpoint(); 726 } 727 } 728 switch (builtin.os.tag) { 729 .freestanding => { 730 while (true) { 731 @breakpoint(); 732 } 733 }, 734 .wasi => { 735 std.debug.print("{s}", .{msg}); 736 std.os.abort(); 737 }, 738 .uefi => { 739 // TODO look into using the debug info and logging helpful messages 740 std.os.abort(); 741 }, 742 else => { 743 const first_trace_addr = @returnAddress(); 744 std.debug.panicImpl(error_return_trace, first_trace_addr, msg); 745 }, 746 } 747} 748 749const std = @import("std.zig"); 750const root = @import("root"); 751