2016-01-06 21:40:25 +08:00
|
|
|
// These functions are provided when not linking against libc because LLVM
|
|
|
|
// sometimes generates code that calls them.
|
|
|
|
|
2017-02-05 12:04:07 +08:00
|
|
|
// 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) {
|
2016-09-28 14:33:32 +08:00
|
|
|
@setDebugSafety(this, false);
|
|
|
|
|
2016-11-19 12:52:42 +08:00
|
|
|
if (n == 0)
|
2017-02-05 12:04:07 +08:00
|
|
|
return;
|
2016-11-19 12:52:42 +08:00
|
|
|
|
|
|
|
const d = ??dest;
|
2016-07-27 11:40:11 +08:00
|
|
|
var index: usize = 0;
|
2016-11-19 11:24:41 +08:00
|
|
|
while (index != n; index += 1)
|
2016-11-19 12:52:42 +08:00
|
|
|
d[index] = c;
|
2016-01-06 21:40:25 +08:00
|
|
|
}
|
|
|
|
|
2017-02-05 12:04:07 +08:00
|
|
|
export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
|
2016-09-28 14:33:32 +08:00
|
|
|
@setDebugSafety(this, false);
|
|
|
|
|
2016-11-19 12:52:42 +08:00
|
|
|
if (n == 0)
|
2017-02-05 12:04:07 +08:00
|
|
|
return;
|
2016-11-19 12:52:42 +08:00
|
|
|
|
|
|
|
const d = ??dest;
|
|
|
|
const s = ??src;
|
2016-07-27 11:40:11 +08:00
|
|
|
var index: usize = 0;
|
2016-11-19 11:24:41 +08:00
|
|
|
while (index != n; index += 1)
|
2016-11-19 12:52:42 +08:00
|
|
|
d[index] = s[index];
|
2016-01-06 21:40:25 +08:00
|
|
|
}
|
2017-02-09 15:50:03 +08:00
|
|
|
|
|
|
|
// Avoid dragging in the debug safety mechanisms into this .o file.
|
|
|
|
pub fn panic(message: []const u8) -> unreachable {
|
|
|
|
@unreachable();
|
|
|
|
}
|