diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-28 04:09:09 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-28 04:09:09 -0400 |
| commit | d7a539906d2dd49872abb161f3d3364c9641ccd2 (patch) | |
| tree | 0d9c04fdc537326431a34ca2e7797c976fa4b91b /std/c | |
| parent | 2a49c876be76dc98996a3251310728ad32b22363 (diff) | |
| parent | 1525e2c0561bb598b1e94ad9cdced5dd22e7d66d (diff) | |
| download | zig-d7a539906d2dd49872abb161f3d3364c9641ccd2.tar.gz zig-d7a539906d2dd49872abb161f3d3364c9641ccd2.zip | |
Merge branch 'embed-lld'
Zig now depends on LLVM 5.0.0.
For the latest version that supports LLVM 4.0.1, use
2a49c876be76dc98996a3251310728ad32b22363.
Unfortunately we had to embed LLD into Zig due to some
MACH-O related LLD bugs. One of them is already upstream
and another is awaiting feedback on the llvm-dev mailing
list.
You can use cmake option -DZIG_FORCE_EXTERNAL_LLD=ON to
still use external LLD if you want to live with the MACH-O
bugs or if your system LLD is patched.
Closes #273
Diffstat (limited to 'std/c')
| -rw-r--r-- | std/c/darwin.zig | 34 | ||||
| -rw-r--r-- | std/c/index.zig | 32 | ||||
| -rw-r--r-- | std/c/linux.zig | 2 |
3 files changed, 63 insertions, 5 deletions
diff --git a/std/c/darwin.zig b/std/c/darwin.zig index 9d4961fe00..8ea491fce0 100644 --- a/std/c/darwin.zig +++ b/std/c/darwin.zig @@ -1,4 +1,34 @@ -pub extern "c" fn getrandom(buf_ptr: &u8, buf_len: usize) -> c_int; -fn extern "c" __error() -> &c_int; +extern "c" fn __error() -> &c_int; + +pub use @import("../os/darwin_errno.zig"); pub const _errno = __error; + +/// Renamed to Stat to not conflict with the stat function. +pub const Stat = extern struct { + dev: u32, + mode: u16, + nlink: u16, + ino: u64, + uid: u32, + gid: u32, + rdev: u64, + + atim: timespec, + mtim: timespec, + ctim: timespec, + + size: u64, + blocks: u64, + blksize: u32, + flags: u32, + gen: u32, + lspare: i32, + qspare: [2]u64, + +}; + +pub const timespec = extern struct { + tv_sec: isize, + tv_nsec: isize, +}; diff --git a/std/c/index.zig b/std/c/index.zig index 091458d789..820324ff34 100644 --- a/std/c/index.zig +++ b/std/c/index.zig @@ -1,4 +1,3 @@ -pub use @import("../os/errno.zig"); const builtin = @import("builtin"); const Os = builtin.Os; @@ -8,7 +7,34 @@ pub use switch(builtin.os) { Os.darwin, Os.macosx, Os.ios => @import("darwin.zig"), else => empty_import, }; +const empty_import = @import("../empty.zig"); pub extern "c" fn abort() -> noreturn; - -const empty_import = @import("../empty.zig"); +pub extern "c" fn exit(code: c_int) -> noreturn; +pub extern "c" fn isatty(fd: c_int) -> c_int; +pub extern "c" fn close(fd: c_int) -> c_int; +pub extern "c" fn fstat(fd: c_int, buf: &stat) -> c_int; +pub extern "c" fn lseek(fd: c_int, offset: isize, whence: c_int) -> isize; +pub extern "c" fn open(path: &const u8, oflag: c_int, ...) -> c_int; +pub extern "c" fn raise(sig: c_int) -> c_int; +pub extern "c" fn read(fd: c_int, buf: &c_void, nbyte: usize) -> isize; +pub extern "c" fn stat(noalias path: &const u8, noalias buf: &Stat) -> c_int; +pub extern "c" fn write(fd: c_int, buf: &const c_void, nbyte: usize) -> c_int; +pub extern "c" fn mmap(addr: ?&c_void, len: usize, prot: c_int, flags: c_int, + fd: c_int, offset: isize) -> ?&c_void; +pub extern "c" fn munmap(addr: &c_void, len: usize) -> c_int; +pub extern "c" fn unlink(path: &const u8) -> c_int; +pub extern "c" fn getcwd(buf: &u8, size: usize) -> ?&u8; +pub extern "c" fn waitpid(pid: c_int, stat_loc: &c_int, options: c_int) -> c_int; +pub extern "c" fn fork() -> c_int; +pub extern "c" fn pipe(fds: &c_int) -> c_int; +pub extern "c" fn mkdir(path: &const u8, mode: c_uint) -> c_int; +pub extern "c" fn symlink(existing: &const u8, new: &const u8) -> c_int; +pub extern "c" fn rename(old: &const u8, new: &const u8) -> c_int; +pub extern "c" fn chdir(path: &const u8) -> c_int; +pub extern "c" fn execve(path: &const u8, argv: &const ?&const u8, + envp: &const ?&const u8) -> c_int; +pub extern "c" fn dup(fd: c_int) -> c_int; +pub extern "c" fn dup2(old_fd: c_int, new_fd: c_int) -> c_int; +pub extern "c" fn readlink(noalias path: &const u8, noalias buf: &u8, bufsize: usize) -> isize; +pub extern "c" fn realpath(noalias file_name: &const u8, noalias resolved_name: &u8) -> ?&u8; diff --git a/std/c/linux.zig b/std/c/linux.zig index 2a18ce46bd..48ba90351b 100644 --- a/std/c/linux.zig +++ b/std/c/linux.zig @@ -1,3 +1,5 @@ +pub use @import("../os/linux_errno.zig"); + pub extern "c" fn getrandom(buf_ptr: &u8, buf_len: usize, flags: c_uint) -> c_int; extern "c" fn __errno_location() -> &c_int; pub const _errno = __errno_location; |
