aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-09-30 18:58:41 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-09-30 20:21:57 -0400
commitc6295fe9abf5508d522ab4000b577a6f30a98a88 (patch)
treede5ff247f235fbf8f9cfe6f8ad2267c897c4d022 /std
parent6db589fff5be05e3e782a34443a1133ebc6ef17d (diff)
downloadzig-c6295fe9abf5508d522ab4000b577a6f30a98a88.tar.gz
zig-c6295fe9abf5508d522ab4000b577a6f30a98a88.zip
remove zigrt
adds test case for #394 partially reverts a32b5929ccf8cbf79396d8924097a1a911985dac
Diffstat (limited to 'std')
-rw-r--r--std/special/builtin.zig19
-rw-r--r--std/special/compiler_rt/index.zig10
-rw-r--r--std/special/panic.zig14
-rw-r--r--std/special/zigrt.zig18
4 files changed, 40 insertions, 21 deletions
diff --git a/std/special/builtin.zig b/std/special/builtin.zig
index 17839a51d5..51e6646574 100644
--- a/std/special/builtin.zig
+++ b/std/special/builtin.zig
@@ -1,11 +1,21 @@
// These functions are provided when not linking against libc because LLVM
// sometimes generates code that calls them.
-// Note that these functions do not return `dest`, like the libc API.
-// The semantics of these functions is dictated by the corresponding
-// LLVM intrinsics, not by the libc API.
const builtin = @import("builtin");
+// Avoid dragging in the debug safety mechanisms into this .o file,
+// unless we're trying to test this file.
+pub coldcc fn panic(msg: []const u8) -> noreturn {
+ if (builtin.is_test) {
+ @import("std").debug.panic("{}", msg);
+ } else {
+ unreachable;
+ }
+}
+
+// Note that memset does not return `dest`, like the libc API.
+// The semantics of memset is dictated by the corresponding
+// LLVM intrinsics, not by the libc API.
export fn memset(dest: ?&u8, c: u8, n: usize) {
@setDebugSafety(this, false);
@@ -14,6 +24,9 @@ export fn memset(dest: ?&u8, c: u8, n: usize) {
(??dest)[index] = c;
}
+// Note that memcpy does not return `dest`, like the libc API.
+// The semantics of memcpy is dictated by the corresponding
+// LLVM intrinsics, not by the libc API.
export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
@setDebugSafety(this, false);
diff --git a/std/special/compiler_rt/index.zig b/std/special/compiler_rt/index.zig
index a19eac4c2c..d005c92ba1 100644
--- a/std/special/compiler_rt/index.zig
+++ b/std/special/compiler_rt/index.zig
@@ -23,6 +23,16 @@ const assert = @import("../../debug.zig").assert;
const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
+// Avoid dragging in the debug safety mechanisms into this .o file,
+// unless we're trying to test this file.
+pub coldcc fn panic(msg: []const u8) -> noreturn {
+ if (is_test) {
+ @import("std").debug.panic("{}", msg);
+ } else {
+ unreachable;
+ }
+}
+
export fn __udivdi3(a: u64, b: u64) -> u64 {
@setDebugSafety(this, is_test);
@setGlobalLinkage(__udivdi3, builtin.GlobalLinkage.LinkOnce);
diff --git a/std/special/panic.zig b/std/special/panic.zig
new file mode 100644
index 0000000000..78117a5366
--- /dev/null
+++ b/std/special/panic.zig
@@ -0,0 +1,14 @@
+// This file is the default panic handler if the root source file does not
+// have a `pub fn panic`.
+// If this file wants to import other files *by name*, support for that would
+// have to be added in the compiler.
+
+const builtin = @import("builtin");
+
+pub coldcc fn panic(msg: []const u8) -> noreturn {
+ if (builtin.os == builtin.Os.freestanding) {
+ while (true) {}
+ } else {
+ @import("std").debug.panic("{}", msg);
+ }
+}
diff --git a/std/special/zigrt.zig b/std/special/zigrt.zig
deleted file mode 100644
index 26d5a161c7..0000000000
--- a/std/special/zigrt.zig
+++ /dev/null
@@ -1,18 +0,0 @@
-// This file contains functions that zig depends on to coordinate between
-// multiple .o files. The symbols are defined LinkOnce so that multiple
-// instances of zig_rt.zig do not conflict with each other.
-
-const builtin = @import("builtin");
-
-export coldcc fn __zig_panic(message_ptr: &const u8, message_len: usize) -> noreturn {
- @setGlobalLinkage(__zig_panic, builtin.GlobalLinkage.LinkOnce);
- @setDebugSafety(this, false);
-
- if (builtin.__zig_panic_implementation_provided) {
- @import("@root").panic(message_ptr[0..message_len]);
- } else if (builtin.os == builtin.Os.freestanding) {
- while (true) {}
- } else {
- @import("std").debug.panic("{}", message_ptr[0..message_len]);
- }
-}