~sircmpwn/hare

hare/rt/memmove.ha -rw-r--r-- 328 bytes
ea90e6dfEyal Sawady unix::umask: don't return an error 9 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export fn memmove(dest: *void, src: *void, n: size) void = {
	let d = dest: *[*]u8, s = src: *[*]u8;
	if (d: uintptr == s: uintptr) {
		return;
	};

	if (d: uintptr < s: uintptr) {
		for (let i = 0z; i < n; i += 1) {
			d[i] = s[i];
		};
	} else {
		for (let i = 0z; i < n; i += 1) {
			d[n - i - 1] = s[n - i - 1];
		};
	};
};