authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-04 23:04:07-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-02-04 23:04:07-05:00
loge56f903522c07c959d22e81e7b4dedef9d0bd5cf
tree45215f4c1a1e0b0c28528c447728a1a222b784b8
parent64a0510205b4d224413de52fd87632fbe6bfe083

memset and memcpy implementations need not return dest


1 files changed, 8 insertions(+), 8 deletions(-)

std/builtin.zig+8-8
...@@ -1,31 +1,31 @@...@@ -1,31 +1,31 @@
1// These functions are provided when not linking against libc because LLVM1// These functions are provided when not linking against libc because LLVM
2// sometimes generates code that calls them.2// sometimes generates code that calls them.
33
4export fn memset(dest: ?&u8, c: u8, n: usize) -> ?&u8 {4// Note that these functions do not return `dest`, like the libc API.
5// The semantics of these functions is dictated by the corresponding
6// LLVM intrinsics, not by the libc API.
7
8export fn memset(dest: ?&u8, c: u8, n: usize) {
5 @setDebugSafety(this, false);9 @setDebugSafety(this, false);
610
7 if (n == 0)11 if (n == 0)
8 return dest;12 return;
913
10 const d = ??dest;14 const d = ??dest;
11 var index: usize = 0;15 var index: usize = 0;
12 while (index != n; index += 1)16 while (index != n; index += 1)
13 d[index] = c;17 d[index] = c;
14
15 return dest;
16}18}
1719
18export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) -> ?&u8 {20export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) {
19 @setDebugSafety(this, false);21 @setDebugSafety(this, false);
2022
21 if (n == 0)23 if (n == 0)
22 return dest;24 return;
2325
24 const d = ??dest;26 const d = ??dest;
25 const s = ??src;27 const s = ??src;
26 var index: usize = 0;28 var index: usize = 0;
27 while (index != n; index += 1)29 while (index != n; index += 1)
28 d[index] = s[index];30 d[index] = s[index];
29
30 return dest;
31}31}