Commit 7828456b30
Changed files (5)
doc/targets.md
@@ -12,10 +12,4 @@ Write the target-specific code in std.zig.
Update the C integer types to be the correct size for the target.
-Add the conditional compilation code for the page size global. It is hardcoded
-for each target.
-
-Make sure that parseh sends the correct command line parameters to libclang for
-the given target.
-
Make sure that `c_long_double` codegens the correct floating point value.
std/mem.zig
@@ -1,22 +0,0 @@
-import "syscall.zig";
-import "std.zig";
-import "errno.zig";
-
-pub fn malloc(bytes: isize) -> ?&u8 {
- if (bytes > 4096) {
- %%stderr.printf("TODO alloc sizes > 4096B\n");
- return null;
- }
-
- const result = mmap(isize(0), 4096, MMAP_PROT_READ|MMAP_PROT_WRITE, MMAP_MAP_ANON|MMAP_MAP_SHARED, -1, 0);
-
- if (-4096 < result && result <= 0) {
- null
- } else {
- (&u8)(result)
- }
-}
-
-pub fn free(ptr: &u8) {
- munmap(isize(ptr), 4096);
-}
std/syscall.zig
@@ -250,12 +250,14 @@ fn i386_syscall6(number: isize, arg1: isize, arg2: isize, arg3: isize, arg4: isi
[arg6] "{ebp}" (arg6))
}
-pub fn mmap(address: isize, length: isize, prot: isize, flags: isize, fd: isize, offset: isize) -> isize {
- syscall6(SYS_mmap, address, length, prot, flags, fd, offset)
+pub fn mmap(address: ?&u8, length: isize, prot: isize, flags: isize, fd: isize, offset: isize) -> isize {
+ // TODO ability to cast maybe pointer to isize
+ const addr = if (const unwrapped ?= address) isize(unwrapped) else 0;
+ syscall6(SYS_mmap, addr, length, prot, flags, fd, offset)
}
-pub fn munmap(address: isize, length: isize) -> isize {
- syscall2(SYS_munmap, address, length)
+pub fn munmap(address: &u8, length: isize) -> isize {
+ syscall2(SYS_munmap, isize(address), length)
}
pub fn read(fd: isize, buf: &u8, count: isize) -> isize {
test/run_tests.cpp
@@ -1023,25 +1023,6 @@ pub fn main(args: [][]u8) -> %void {
}
)SOURCE", "OK\n");
- add_simple_case("malloc and free", R"SOURCE(
-import "mem.zig";
-import "std.zig";
-
-pub fn main(args: [][]u8) -> %void {
- var ptr = malloc(1) ?? unreachable{};
-
- *ptr = 6;
-
- if (*ptr != 6) {
- %%stdout.printf("BAD\n");
- }
-
- free(ptr);
-
- %%stdout.printf("OK\n");
-}
- )SOURCE", "OK\n");
-
add_simple_case("store member function in variable", R"SOURCE(
import "std.zig";
struct Foo {
CMakeLists.txt
@@ -140,7 +140,6 @@ set(ZIG_STD_SRC
"${CMAKE_SOURCE_DIR}/std/syscall.zig"
"${CMAKE_SOURCE_DIR}/std/errno.zig"
"${CMAKE_SOURCE_DIR}/std/rand.zig"
- "${CMAKE_SOURCE_DIR}/std/mem.zig"
"${CMAKE_SOURCE_DIR}/std/math.zig"
)