Commit 62c817420d

Raul Leal <raulgrell@gmail.com>
2019-12-17 21:43:49
[#3844 + #3767] update std.c and std.os.linux to use null-terminated pointer types (#3900)
* #3844 update std.c functions to use null-terminated pointer types * check linux functions * fix callsites * fix io test * Add allocPrintCstr function to remove other cast
1 parent b242c2a
Changed files (4)
lib/std/os/linux.zig
@@ -65,18 +65,15 @@ pub fn dup3(old: i32, new: i32, flags: u32) usize {
     return syscall3(SYS_dup3, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)), flags);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn chdir(path: [*]const u8) usize {
+pub fn chdir(path: [*:0]const u8) usize {
     return syscall1(SYS_chdir, @ptrToInt(path));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn chroot(path: [*]const u8) usize {
+pub fn chroot(path: [*:0]const u8) usize {
     return syscall1(SYS_chroot, @ptrToInt(path));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn execve(path: [*]const u8, argv: [*]const ?[*]const u8, envp: [*]const ?[*]const u8) usize {
+pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize {
     return syscall3(SYS_execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp));
 }
 
@@ -101,8 +98,7 @@ pub fn futimens(fd: i32, times: *const [2]timespec) usize {
     return utimensat(fd, null, times, 0);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn utimensat(dirfd: i32, path: ?[*]const u8, times: *const [2]timespec, flags: u32) usize {
+pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, flags: u32) usize {
     return syscall4(SYS_utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);
 }
 
@@ -140,7 +136,7 @@ pub fn inotify_init1(flags: u32) usize {
     return syscall1(SYS_inotify_init1, flags);
 }
 
-pub fn inotify_add_watch(fd: i32, pathname: [*]const u8, mask: u32) usize {
+pub fn inotify_add_watch(fd: i32, pathname: [*:0]const u8, mask: u32) usize {
     return syscall3(SYS_inotify_add_watch, @bitCast(usize, @as(isize, fd)), @ptrToInt(pathname), mask);
 }
 
@@ -148,8 +144,7 @@ pub fn inotify_rm_watch(fd: i32, wd: i32) usize {
     return syscall2(SYS_inotify_rm_watch, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, wd)));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
+pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
     if (@hasDecl(@This(), "SYS_readlink")) {
         return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
     } else {
@@ -157,13 +152,11 @@ pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usiz
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn readlinkat(dirfd: i32, noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
+pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
     return syscall4(SYS_readlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn mkdir(path: [*]const u8, mode: u32) usize {
+pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
     if (@hasDecl(@This(), "SYS_mkdir")) {
         return syscall2(SYS_mkdir, @ptrToInt(path), mode);
     } else {
@@ -171,23 +164,19 @@ pub fn mkdir(path: [*]const u8, mode: u32) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn mkdirat(dirfd: i32, path: [*]const u8, mode: u32) usize {
+pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: u32) usize {
     return syscall3(SYS_mkdirat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn mount(special: [*]const u8, dir: [*]const u8, fstype: [*]const u8, flags: u32, data: usize) usize {
+pub fn mount(special: [*:0]const u8, dir: [*:0]const u8, fstype: [*:0]const u8, flags: u32, data: usize) usize {
     return syscall5(SYS_mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn umount(special: [*]const u8) usize {
+pub fn umount(special: [*:0]const u8) usize {
     return syscall2(SYS_umount2, @ptrToInt(special), 0);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn umount2(special: [*]const u8, flags: u32) usize {
+pub fn umount2(special: [*:0]const u8, flags: u32) usize {
     return syscall2(SYS_umount2, @ptrToInt(special), flags);
 }
 
@@ -307,8 +296,7 @@ pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, f
     );
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn rmdir(path: [*]const u8) usize {
+pub fn rmdir(path: [*:0]const u8) usize {
     if (@hasDecl(@This(), "SYS_rmdir")) {
         return syscall1(SYS_rmdir, @ptrToInt(path));
     } else {
@@ -316,8 +304,7 @@ pub fn rmdir(path: [*]const u8) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn symlink(existing: [*]const u8, new: [*]const u8) usize {
+pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
     if (@hasDecl(@This(), "SYS_symlink")) {
         return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new));
     } else {
@@ -325,18 +312,15 @@ pub fn symlink(existing: [*]const u8, new: [*]const u8) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn symlinkat(existing: [*]const u8, newfd: i32, newpath: [*]const u8) usize {
+pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) usize {
     return syscall3(SYS_symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, newfd)), @ptrToInt(newpath));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
 pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize {
     return syscall4(SYS_pread, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count, offset);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn access(path: [*]const u8, mode: u32) usize {
+pub fn access(path: [*:0]const u8, mode: u32) usize {
     if (@hasDecl(@This(), "SYS_access")) {
         return syscall2(SYS_access, @ptrToInt(path), mode);
     } else {
@@ -344,8 +328,7 @@ pub fn access(path: [*]const u8, mode: u32) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32, flags: u32) usize {
+pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {
     return syscall4(SYS_faccessat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, flags);
 }
 
@@ -371,8 +354,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize {
     return syscall4(SYS_pwrite, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count, offset);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn rename(old: [*]const u8, new: [*]const u8) usize {
+pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
     if (@hasDecl(@This(), "SYS_rename")) {
         return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new));
     } else if (@hasDecl(@This(), "SYS_renameat")) {
@@ -403,8 +385,7 @@ pub fn renameat(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn renameat2(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const u8, flags: u32) usize {
+pub fn renameat2(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]const u8, flags: u32) usize {
     return syscall5(
         SYS_renameat2,
         @bitCast(usize, @as(isize, oldfd)),
@@ -415,8 +396,7 @@ pub fn renameat2(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const
     );
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn open(path: [*]const u8, flags: u32, perm: usize) usize {
+pub fn open(path: [*:0]const u8, flags: u32, perm: usize) usize {
     if (@hasDecl(@This(), "SYS_open")) {
         return syscall3(SYS_open, @ptrToInt(path), flags, perm);
     } else {
@@ -430,13 +410,11 @@ pub fn open(path: [*]const u8, flags: u32, perm: usize) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn create(path: [*]const u8, perm: usize) usize {
+pub fn create(path: [*:0]const u8, perm: usize) usize {
     return syscall2(SYS_creat, @ptrToInt(path), perm);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn openat(dirfd: i32, path: [*]const u8, flags: u32, mode: usize) usize {
+pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: usize) usize {
     // dirfd could be negative, for example AT_FDCWD is -100
     return syscall4(SYS_openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
 }
@@ -490,8 +468,7 @@ pub fn kill(pid: i32, sig: i32) usize {
     return syscall2(SYS_kill, @bitCast(usize, @as(isize, pid)), @bitCast(usize, @as(isize, sig)));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn unlink(path: [*]const u8) usize {
+pub fn unlink(path: [*:0]const u8) usize {
     if (@hasDecl(@This(), "SYS_unlink")) {
         return syscall1(SYS_unlink, @ptrToInt(path));
     } else {
@@ -499,8 +476,7 @@ pub fn unlink(path: [*]const u8) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn unlinkat(dirfd: i32, path: [*]const u8, flags: u32) usize {
+pub fn unlinkat(dirfd: i32, path: [*:0]const u8, flags: u32) usize {
     return syscall3(SYS_unlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags);
 }
 
@@ -903,8 +879,7 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn stat(pathname: [*]const u8, statbuf: *Stat) usize {
+pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
     if (@hasDecl(@This(), "SYS_stat64")) {
         return syscall2(SYS_stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
     } else {
@@ -912,8 +887,7 @@ pub fn stat(pathname: [*]const u8, statbuf: *Stat) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn lstat(pathname: [*]const u8, statbuf: *Stat) usize {
+pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
     if (@hasDecl(@This(), "SYS_lstat64")) {
         return syscall2(SYS_lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
     } else {
@@ -921,8 +895,7 @@ pub fn lstat(pathname: [*]const u8, statbuf: *Stat) usize {
     }
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn fstatat(dirfd: i32, path: [*]const u8, stat_buf: *Stat, flags: u32) usize {
+pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {
     if (@hasDecl(@This(), "SYS_fstatat64")) {
         return syscall4(SYS_fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
     } else {
@@ -944,13 +917,11 @@ pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *S
     return @bitCast(usize, @as(isize, -ENOSYS));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn listxattr(path: [*]const u8, list: [*]u8, size: usize) usize {
+pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
     return syscall3(SYS_listxattr, @ptrToInt(path), @ptrToInt(list), size);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn llistxattr(path: [*]const u8, list: [*]u8, size: usize) usize {
+pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
     return syscall3(SYS_llistxattr, @ptrToInt(path), @ptrToInt(list), size);
 }
 
@@ -958,48 +929,39 @@ pub fn flistxattr(fd: usize, list: [*]u8, size: usize) usize {
     return syscall3(SYS_flistxattr, fd, @ptrToInt(list), size);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn getxattr(path: [*]const u8, name: [*]const u8, value: [*]u8, size: usize) usize {
+pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
     return syscall4(SYS_getxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn lgetxattr(path: [*]const u8, name: [*]const u8, value: [*]u8, size: usize) usize {
+pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
     return syscall4(SYS_lgetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn fgetxattr(fd: usize, name: [*]const u8, value: [*]u8, size: usize) usize {
+pub fn fgetxattr(fd: usize, name: [*:0]const u8, value: [*]u8, size: usize) usize {
     return syscall4(SYS_lgetxattr, fd, @ptrToInt(name), @ptrToInt(value), size);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn setxattr(path: [*]const u8, name: [*]const u8, value: *const void, size: usize, flags: usize) usize {
+pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
     return syscall5(SYS_setxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn lsetxattr(path: [*]const u8, name: [*]const u8, value: *const void, size: usize, flags: usize) usize {
+pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
     return syscall5(SYS_lsetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn fsetxattr(fd: usize, name: [*]const u8, value: *const void, size: usize, flags: usize) usize {
+pub fn fsetxattr(fd: usize, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
     return syscall5(SYS_fsetxattr, fd, @ptrToInt(name), @ptrToInt(value), size, flags);
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn removexattr(path: [*]const u8, name: [*]const u8) usize {
+pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
     return syscall2(SYS_removexattr, @ptrToInt(path), @ptrToInt(name));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn lremovexattr(path: [*]const u8, name: [*]const u8) usize {
+pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
     return syscall2(SYS_lremovexattr, @ptrToInt(path), @ptrToInt(name));
 }
 
-// TODO https://github.com/ziglang/zig/issues/265
-pub fn fremovexattr(fd: usize, name: [*]const u8) usize {
+pub fn fremovexattr(fd: usize, name: [*:0]const u8) usize {
     return syscall2(SYS_fremovexattr, fd, @ptrToInt(name));
 }
 
lib/std/c.zig
@@ -56,9 +56,7 @@ pub fn versionCheck(glibc_version: builtin.Version) type {
     };
 }
 
-// TODO https://github.com/ziglang/zig/issues/265 on this whole file
-
-pub extern "c" fn fopen(filename: [*]const u8, modes: [*]const u8) ?*FILE;
+pub extern "c" fn fopen(filename: [*:0]const u8, modes: [*:0]const u8) ?*FILE;
 pub extern "c" fn fclose(stream: *FILE) c_int;
 pub extern "c" fn fwrite(ptr: [*]const u8, size_of_type: usize, item_count: usize, stream: *FILE) usize;
 pub extern "c" fn fread(ptr: [*]u8, size_of_type: usize, item_count: usize, stream: *FILE) usize;
@@ -71,8 +69,8 @@ pub extern "c" fn close(fd: fd_t) c_int;
 pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
 pub extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int;
 pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t;
-pub extern "c" fn open(path: [*]const u8, oflag: c_uint, ...) c_int;
-pub extern "c" fn openat(fd: c_int, path: [*]const u8, oflag: c_uint, ...) c_int;
+pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int;
+pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int;
 pub extern "c" fn raise(sig: c_int) c_int;
 pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
 pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
@@ -80,40 +78,40 @@ pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize;
 pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: u64) isize;
 pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
 pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: u64) isize;
-pub extern "c" fn stat(noalias path: [*]const u8, noalias buf: *Stat) c_int;
+pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
 pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
 pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) isize;
 pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: u64) *c_void;
 pub extern "c" fn munmap(addr: *align(page_size) c_void, len: usize) c_int;
 pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
-pub extern "c" fn unlink(path: [*]const u8) c_int;
-pub extern "c" fn unlinkat(dirfd: fd_t, path: [*]const u8, flags: c_uint) c_int;
+pub extern "c" fn unlink(path: [*:0]const u8) c_int;
+pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int;
 pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;
 pub extern "c" fn waitpid(pid: c_int, stat_loc: *c_uint, options: c_uint) c_int;
 pub extern "c" fn fork() c_int;
-pub extern "c" fn access(path: [*]const u8, mode: c_uint) c_int;
+pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
 pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
 pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) 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 mkdir(path: [*:0]const u8, mode: c_uint) c_int;
+pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
+pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
+pub extern "c" fn chdir(path: [*:0]const u8) c_int;
+pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;
 pub extern "c" fn dup(fd: fd_t) c_int;
 pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) 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) ?[*:0]u8;
+pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
+pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
 pub extern "c" fn sigprocmask(how: c_int, noalias set: *const sigset_t, noalias oset: ?*sigset_t) c_int;
 pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
 pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int;
 pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
 pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int;
 pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int;
-pub extern "c" fn rmdir(path: [*]const u8) c_int;
+pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
 pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
 pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
-pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
-pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
+pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
+pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
 
 pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;
 pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int;
@@ -158,9 +156,9 @@ pub extern "c" fn posix_memalign(memptr: **c_void, alignment: usize, size: usize
 
 // Deprecated
 pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int;
-pub extern "c" fn utimes(path: [*]const u8, times: *[2]timeval) c_int;
+pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
 
-pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*]const u8, times: *[2]timespec, flags: u32) c_int;
+pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;
 pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
 
 pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: extern fn (?*c_void) ?*c_void, noalias arg: ?*c_void) c_int;
@@ -181,8 +179,8 @@ pub extern "c" fn kevent(
 ) c_int;
 
 pub extern "c" fn getaddrinfo(
-    noalias node: [*]const u8,
-    noalias service: [*]const u8,
+    noalias node: [*:0]const u8,
+    noalias service: [*:0]const u8,
     noalias hints: *const addrinfo,
     noalias res: **addrinfo,
 ) c_int;
@@ -199,15 +197,15 @@ pub extern "c" fn getnameinfo(
     flags: u32,
 ) c_int;
 
-pub extern "c" fn gai_strerror(errcode: c_int) [*]const u8;
+pub extern "c" fn gai_strerror(errcode: c_int) [*:0]const u8;
 
 pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int;
 
 pub extern "c" fn dn_expand(
-    msg: [*]const u8,
-    eomorig: [*]const u8,
-    comp_dn: [*]const u8,
-    exp_dn: [*]u8,
+    msg: [*:0]const u8,
+    eomorig: [*:0]const u8,
+    comp_dn: [*:0]const u8,
+    exp_dn: [*:0]u8,
     length: c_int,
 ) c_int;
 
lib/std/cstr.zig
@@ -9,7 +9,7 @@ pub const line_sep = switch (builtin.os) {
     else => "\n",
 };
 
-pub fn cmp(a: [*]const u8, b: [*]const u8) i8 {
+pub fn cmp(a: [*:0]const u8, b: [*:0]const u8) i8 {
     var index: usize = 0;
     while (a[index] == b[index] and a[index] != 0) : (index += 1) {}
     if (a[index] > b[index]) {
@@ -33,7 +33,7 @@ fn testCStrFnsImpl() void {
 
 /// Returns a mutable slice with 1 more byte of length which is a null byte.
 /// Caller owns the returned memory.
-pub fn addNullByte(allocator: *mem.Allocator, slice: []const u8) ![]u8 {
+pub fn addNullByte(allocator: *mem.Allocator, slice: []const u8) ![:0]u8 {
     const result = try allocator.alloc(u8, slice.len + 1);
     mem.copy(u8, result, slice);
     result[slice.len] = 0;
@@ -43,7 +43,7 @@ pub fn addNullByte(allocator: *mem.Allocator, slice: []const u8) ![]u8 {
 pub const NullTerminated2DArray = struct {
     allocator: *mem.Allocator,
     byte_count: usize,
-    ptr: ?[*]?[*]u8,
+    ptr: ?[*:null]?[*:0]u8,
 
     /// Takes N lists of strings, concatenates the lists together, and adds a null terminator
     /// Caller must deinit result
@@ -83,7 +83,7 @@ pub const NullTerminated2DArray = struct {
         return NullTerminated2DArray{
             .allocator = allocator,
             .byte_count = byte_count,
-            .ptr = @ptrCast(?[*]?[*]u8, buf.ptr),
+            .ptr = @ptrCast(?[*:null]?[*:0]u8, buf.ptr),
         };
     }
 
lib/std/net.zig
@@ -451,7 +451,11 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
             .next = null,
         };
         var res: *os.addrinfo = undefined;
-        switch (os.system.getaddrinfo(name_c.ptr, port_c.ptr, &hints, &res)) {
+        switch (os.system.getaddrinfo(
+                name_c.ptr,
+                @ptrCast([*:0]const u8, port_c.ptr),
+                &hints,
+                &res)) {
             0 => {},
             c.EAI_ADDRFAMILY => return error.HostLacksNetworkAddresses,
             c.EAI_AGAIN => return error.TemporaryNameServerFailure,