Fix a type error in std.os.linux.getpid() (#1326)

syscall0() returns usize, but we were trying to @bitCast to i32.
master
Matthew D. Steele 2018-08-03 11:45:23 -04:00 committed by Andrew Kelley
parent c2a08d7c51
commit dcaaa241df
2 changed files with 5 additions and 1 deletions

View File

@ -944,7 +944,7 @@ pub fn setgroups(size: usize, list: *const u32) usize {
} }
pub fn getpid() i32 { pub fn getpid() i32 {
return @bitCast(i32, u32(syscall0(SYS_getpid))); return @bitCast(i32, @truncate(u32, syscall0(SYS_getpid)));
} }
pub fn sigprocmask(flags: u32, noalias set: *const sigset_t, noalias oldset: ?*sigset_t) usize { pub fn sigprocmask(flags: u32, noalias set: *const sigset_t, noalias oldset: ?*sigset_t) usize {

View File

@ -3,6 +3,10 @@ const builtin = @import("builtin");
const linux = std.os.linux; const linux = std.os.linux;
const assert = std.debug.assert; const assert = std.debug.assert;
test "getpid" {
assert(linux.getpid() != 0);
}
test "timer" { test "timer" {
const epoll_fd = linux.epoll_create(); const epoll_fd = linux.epoll_create();
var err = linux.getErrno(epoll_fd); var err = linux.getErrno(epoll_fd);