diff options
| author | Matthew D. Steele <mdsteele@alum.mit.edu> | 2018-08-03 11:45:23 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-08-03 11:45:23 -0400 |
| commit | dcaaa241dfb7ce77b7070df8d6a939a9f0749e2c (patch) | |
| tree | 64041d0e295206b5dd9653e8fdb3ad472bdab2a6 /std/os | |
| parent | c2a08d7c516899b4c794bd6c3fc07ddb22d5876a (diff) | |
| download | zig-dcaaa241dfb7ce77b7070df8d6a939a9f0749e2c.tar.gz zig-dcaaa241dfb7ce77b7070df8d6a939a9f0749e2c.zip | |
Fix a type error in std.os.linux.getpid() (#1326)
syscall0() returns usize, but we were trying to @bitCast to i32.
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/linux/index.zig | 2 | ||||
| -rw-r--r-- | std/os/linux/test.zig | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/std/os/linux/index.zig b/std/os/linux/index.zig index 69bc30bad0..15607ea6c0 100644 --- a/std/os/linux/index.zig +++ b/std/os/linux/index.zig @@ -944,7 +944,7 @@ pub fn setgroups(size: usize, list: *const u32) usize { } 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 { diff --git a/std/os/linux/test.zig b/std/os/linux/test.zig index e7dae3a584..4de26012c7 100644 --- a/std/os/linux/test.zig +++ b/std/os/linux/test.zig @@ -3,6 +3,10 @@ const builtin = @import("builtin"); const linux = std.os.linux; const assert = std.debug.assert; +test "getpid" { + assert(linux.getpid() != 0); +} + test "timer" { const epoll_fd = linux.epoll_create(); var err = linux.getErrno(epoll_fd); |
