update more std library to new zig

This commit is contained in:
Andrew Kelley 2016-12-21 23:34:14 -05:00
parent 43be6ccb03
commit b55efe5fab
9 changed files with 34 additions and 34 deletions

View File

@ -1,7 +1,7 @@
const arch = switch (@compileVar("arch")) {
x86_64 => @import("darwin_x86_64.zig"),
else => @compile_err("unsupported arch"),
Arch.x86_64 => @import("darwin_x86_64.zig"),
else => @compileError("unsupported arch"),
};
const errno = @import("errno.zig");
@ -88,7 +88,7 @@ pub fn fstat(fd: i32, stat_buf: &stat) -> usize {
arch.syscall2(arch.SYS_fstat, usize(fd), usize(stat_buf))
}
pub error Unexpected;
error Unexpected;
pub fn getrandom(buf: &u8, count: usize) -> usize {
const rr = open_c(c"/dev/urandom", O_LARGEFILE | O_RDONLY, 0);

View File

@ -57,7 +57,7 @@ pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) ->
export struct stat {
pub const stat = extern struct {
dev: u32,
mode: u16,
nlink: u16,
@ -78,9 +78,9 @@ export struct stat {
lspare: i32,
qspare: [2]u64,
}
};
export struct timespec {
pub const timespec = extern struct {
tv_sec: isize,
tv_nsec: isize,
}
};

View File

@ -5,9 +5,9 @@ const elf = @import("elf.zig");
const DW = @import("dwarf.zig");
const List = @import("list.zig").List;
pub error MissingDebugInfo;
pub error InvalidDebugInfo;
pub error UnsupportedDebugInfo;
error MissingDebugInfo;
error InvalidDebugInfo;
error UnsupportedDebugInfo;
pub fn assert(b: bool) {
if (!b) @unreachable()
@ -20,7 +20,7 @@ pub fn printStackTrace() -> %void {
pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {
switch (@compileVar("object_format")) {
elf => {
ObjectFormat.elf => {
var stack_trace = ElfStackTrace {
.self_exe_stream = undefined,
.elf = undefined,
@ -57,13 +57,13 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {
maybe_fp = *(&const ?&const u8)(fp);
}
},
coff => {
ObjectFormat.coff => {
out_stream.write("(stack trace unavailable for COFF object format)\n");
},
macho => {
ObjectFormat.macho => {
%return out_stream.write("(stack trace unavailable for Mach-O object format)\n");
},
unknown => {
ObjectFormat.unknown => {
out_stream.write("(stack trace unavailable for unknown object format)\n");
},
}

View File

@ -4,7 +4,7 @@ const math = @import("math.zig");
const mem = @import("mem.zig");
const debug = @import("debug.zig");
pub error InvalidFormat;
error InvalidFormat;
pub const SHT_NULL = 0;
pub const SHT_PROGBITS = 1;

View File

@ -10,11 +10,11 @@ pub const hash_map = @import("hash_map.zig");
pub const mem = @import("mem.zig");
pub const debug = @import("debug.zig");
pub const linux = switch(@compileVar("os")) {
linux => @import("linux.zig"),
Os.linux => @import("linux.zig"),
else => null_import,
};
pub const darwin = switch(@compileVar("os")) {
darwin => @import("darwin.zig"),
Os.darwin => @import("darwin.zig"),
else => null_import,
};
const null_import = @import("empty.zig");

View File

@ -456,9 +456,9 @@ pub fn accept4(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t, flags:
arch.syscall4(arch.SYS_accept4, usize(fd), usize(addr), usize(len), flags)
}
// pub error NameTooLong;
// pub error SystemResources;
// pub error Io;
// error NameTooLong;
// error SystemResources;
// error Io;
//
// pub fn if_nametoindex(name: []u8) -> %u32 {
// var ifr: ifreq = undefined;

View File

@ -5,7 +5,7 @@ const io = @import("io.zig");
pub const Cmp = math.Cmp;
pub error NoMem;
error NoMem;
pub type Context = u8;
pub const Allocator = struct {

View File

@ -3,15 +3,15 @@ const errno = @import("errno.zig");
const assert = @import("debug.zig").assert;
const endian = @import("endian.zig");
pub error SigInterrupt;
pub error Unexpected;
pub error Io;
pub error TimedOut;
pub error ConnectionReset;
pub error ConnectionRefused;
pub error NoMem;
pub error NotSocket;
pub error BadFd;
error SigInterrupt;
error Unexpected;
error Io;
error TimedOut;
error ConnectionReset;
error ConnectionRefused;
error NoMem;
error NotSocket;
error BadFd;
const Connection = struct {
socket_fd: i32,
@ -139,7 +139,7 @@ pub fn connect(hostname: []const u8, port: u16) -> %Connection {
return connectAddr(main_addr, port);
}
pub error InvalidIpLiteral;
error InvalidIpLiteral;
pub fn parseIpLiteral(buf: []const u8) -> %Address {
switch (parseIp4(buf)) {

View File

@ -1,11 +1,11 @@
const system = switch(@compileVar("os")) {
linux => @import("linux.zig"),
darwin => @import("darwin.zig"),
Os.linux => @import("linux.zig"),
Os.darwin => @import("darwin.zig"),
else => @compileError("Unsupported OS"),
};
const errno = @import("errno.zig");
pub error Unexpected;
error Unexpected;
pub fn getRandomBytes(buf: []u8) -> %void {
while (true) {