mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
memset and memcpy implementations need not return dest
This commit is contained in:
parent
64a0510205
commit
e56f903522
@ -1,31 +1,31 @@
|
|||||||
// These functions are provided when not linking against libc because LLVM
|
// These functions are provided when not linking against libc because LLVM
|
||||||
// sometimes generates code that calls them.
|
// sometimes generates code that calls them.
|
||||||
|
|
||||||
export fn memset(dest: ?&u8, c: u8, n: usize) -> ?&u8 {
|
// 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);
|
@setDebugSafety(this, false);
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return dest;
|
return;
|
||||||
|
|
||||||
const d = ??dest;
|
const d = ??dest;
|
||||||
var index: usize = 0;
|
var index: usize = 0;
|
||||||
while (index != n; index += 1)
|
while (index != n; index += 1)
|
||||||
d[index] = c;
|
d[index] = c;
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) -> ?&u8 {
|
export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
|
||||||
@setDebugSafety(this, false);
|
@setDebugSafety(this, false);
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return dest;
|
return;
|
||||||
|
|
||||||
const d = ??dest;
|
const d = ??dest;
|
||||||
const s = ??src;
|
const s = ??src;
|
||||||
var index: usize = 0;
|
var index: usize = 0;
|
||||||
while (index != n; index += 1)
|
while (index != n; index += 1)
|
||||||
d[index] = s[index];
|
d[index] = s[index];
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user