hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit bec30775e3ed2c933a3b026c794536070a3f6848
parent a3926af6d3582f1ea30ca02fc46d9ff930f75f35
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 28 Apr 2021 10:10:11 -0400

rt: add memmove

Diffstat:
Art/memmove.ha | 16++++++++++++++++
Mscripts/gen-stdlib | 1+
Mstdlib.mk | 2++
3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/rt/memmove.ha b/rt/memmove.ha @@ -0,0 +1,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]; + }; + }; +}; diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib @@ -34,6 +34,7 @@ gensrcs_rt() { jmp.ha \ malloc.ha \ memcpy.ha \ + memmove.ha \ memset.ha \ strcmp.ha \ $* diff --git a/stdlib.mk b/stdlib.mk @@ -21,6 +21,7 @@ stdlib_rt_srcs= \ $(STDLIB)/rt/jmp.ha \ $(STDLIB)/rt/malloc.ha \ $(STDLIB)/rt/memcpy.ha \ + $(STDLIB)/rt/memmove.ha \ $(STDLIB)/rt/memset.ha \ $(STDLIB)/rt/strcmp.ha \ $(STDLIB)/rt/abort.ha \ @@ -930,6 +931,7 @@ testlib_rt_srcs= \ $(STDLIB)/rt/jmp.ha \ $(STDLIB)/rt/malloc.ha \ $(STDLIB)/rt/memcpy.ha \ + $(STDLIB)/rt/memmove.ha \ $(STDLIB)/rt/memset.ha \ $(STDLIB)/rt/strcmp.ha \ $(STDLIB)/rt/start+test.ha \