rename syscall.zig to linux.zig

This commit is contained in:
Andrew Kelley 2016-03-01 14:11:38 -07:00
parent 1d08ab087e
commit 9c3d7b628c
5 changed files with 19 additions and 19 deletions

View File

@ -139,7 +139,7 @@ set(ZIG_STD_SRC
"${CMAKE_SOURCE_DIR}/std/test_runner_nolibc.zig"
"${CMAKE_SOURCE_DIR}/std/io.zig"
"${CMAKE_SOURCE_DIR}/std/os.zig"
"${CMAKE_SOURCE_DIR}/std/syscall.zig"
"${CMAKE_SOURCE_DIR}/std/linux.zig"
"${CMAKE_SOURCE_DIR}/std/errno.zig"
"${CMAKE_SOURCE_DIR}/std/rand.zig"
"${CMAKE_SOURCE_DIR}/std/math.zig"

View File

@ -1,7 +1,7 @@
// This file is in a package which has the root source file exposed as "@root".
const root = @import("@root");
const syscall = @import("syscall.zig");
const linux = @import("linux.zig");
const want_start_symbol = switch(@compile_var("os")) {
linux => true,
@ -47,8 +47,8 @@ fn call_main() -> %void {
}
fn call_main_and_exit() -> unreachable {
call_main() %% syscall.exit(1);
syscall.exit(0);
call_main() %% linux.exit(1);
linux.exit(0);
}
#condition(want_main_symbol)

View File

@ -1,4 +1,4 @@
const syscall = @import("syscall.zig");
const linux = @import("linux.zig");
const errno = @import("errno.zig");
const math = @import("math.zig");
@ -105,7 +105,7 @@ pub struct OutStream {
}
pub fn flush(os: &OutStream) -> %void {
const amt_written = syscall.write(os.fd, &os.buffer[0], os.index);
const amt_written = linux.write(os.fd, &os.buffer[0], os.index);
os.index = 0;
if (amt_written < 0) {
return switch (-amt_written) {
@ -123,12 +123,12 @@ pub struct OutStream {
}
pub fn close(os: &OutStream) -> %void {
const closed = close(os.fd);
const closed = linux.close(os.fd);
if (closed < 0) {
return switch (-closed) {
EIO => error.Io,
EBADF => error.BadFd,
EINTR => error.SigInterrupt,
errno.EIO => error.Io,
errno.EBADF => error.BadFd,
errno.EINTR => error.SigInterrupt,
else => error.Unexpected,
}
}
@ -139,7 +139,7 @@ pub struct InStream {
fd: isize,
pub fn read(is: &InStream, buf: []u8) -> %isize {
const amt_read = syscall.read(is.fd, &buf[0], buf.len);
const amt_read = linux.read(is.fd, &buf[0], buf.len);
if (amt_read < 0) {
return switch (-amt_read) {
errno.EINVAL => unreachable{},
@ -154,12 +154,12 @@ pub struct InStream {
}
pub fn close(is: &InStream) -> %void {
const closed = close(is.fd);
const closed = linux.close(is.fd);
if (closed < 0) {
return switch (-closed) {
EIO => error.Io,
EBADF => error.BadFd,
EINTR => error.SigInterrupt,
errno.EIO => error.Io,
errno.EBADF => error.BadFd,
errno.EINTR => error.SigInterrupt,
else => error.Unexpected,
}
}
@ -168,8 +168,8 @@ pub struct InStream {
#attribute("cold")
pub fn abort() -> unreachable {
syscall.raise(syscall.SIGABRT);
syscall.raise(syscall.SIGKILL);
linux.raise(linux.SIGABRT);
linux.raise(linux.SIGKILL);
while (true) {}
}

View File

@ -1,4 +1,4 @@
const syscall = @import("syscall.zig");
const linux = @import("linux.zig");
const errno = @import("errno.zig");
pub error SigInterrupt;
@ -7,7 +7,7 @@ pub error Unexpected;
pub fn get_random_bytes(buf: []u8) -> %void {
switch (@compile_var("os")) {
linux => {
const amt_got = syscall.getrandom(buf.ptr, buf.len, 0);
const amt_got = linux.getrandom(buf.ptr, buf.len, 0);
if (amt_got < 0) {
return switch (-amt_got) {
errno.EINVAL => unreachable{},