diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-07-03 18:49:28 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-07-03 18:49:28 -0400 |
commit | 8dd389a5f7db1c8ef9e60d900104fef99f25645f (patch) | |
tree | 74e07d438e3c30fed3cdb7eec50b37936c4cfc7f /std/mem.toc | |
parent | 119950ebde3c9f096d1866ba6448d6bd9b22d063 (diff) |
io is working but slow
Diffstat (limited to 'std/mem.toc')
-rw-r--r-- | std/mem.toc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/std/mem.toc b/std/mem.toc index 9ea9b12..b6af0fe 100644 --- a/std/mem.toc +++ b/std/mem.toc @@ -1,6 +1,6 @@ #include "std/base.toc", base; -// TODO: check for failed calloc +// @TODO: check for failed calloc calloc ::= #foreign("calloc", base.libc) fn(#C size_t, #C size_t) #C &"void"; free ::= #foreign("free", base.libc) fn(#C &"void"); @@ -15,7 +15,6 @@ news ::= fn(t :: Type, n : int) []t { return s; } -// TODO(eventually): use type information to make this just one function del ::= fn(t::=, x: &t) { free(x); } @@ -23,3 +22,15 @@ del ::= fn(t::=, x: &t) { dels ::= fn(t::=, x: []t) { free(x.data); } + + +// @OPTIM @OPTIM @OPTIM +mem_copy ::= fn(out: &void, in: &void, n : int) { + out_u8 : &u8 = out; + in_u8 : &u8 = in; + for i := 0..n-1 { + *out_u8 = *in_u8; + out_u8 += 1; + in_u8 += 1; + } +} |