zig/std/special/builtin.zig

37 lines
939 B
Zig
Raw Normal View History

// 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.
export fn memset(dest: ?&u8, c: u8, n: usize) {
@setDebugSafety(this, false);
2016-11-18 20:52:42 -08:00
if (n == 0)
return;
2016-11-18 20:52:42 -08:00
const d = ??dest;
var index: usize = 0;
while (index != n; index += 1)
2016-11-18 20:52:42 -08:00
d[index] = c;
}
export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
@setDebugSafety(this, false);
2016-11-18 20:52:42 -08:00
if (n == 0)
return;
2016-11-18 20:52:42 -08:00
const d = ??dest;
const s = ??src;
var index: usize = 0;
while (index != n; index += 1)
2016-11-18 20:52:42 -08:00
d[index] = s[index];
}
// Avoid dragging in the debug safety mechanisms into this .o file.
pub fn panic(message: []const u8) -> noreturn {
unreachable;
}