authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-21 23:34:14-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-21 23:34:14-05:00
logb55efe5fabc5e743406d62bf5b1c2ebfcc8fc5b0
tree2786bbab71399b3ed6d581e721cfdc7aee9653a8
parent43be6ccb03e6ce32f78c69129b61d49cae2b747d

update more std library to new zig


9 files changed, 34 insertions(+), 34 deletions(-)

std/darwin.zig+3-3
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
11
2const arch = switch (@compileVar("arch")) {2const arch = switch (@compileVar("arch")) {
3 x86_64 => @import("darwin_x86_64.zig"),3 Arch.x86_64 => @import("darwin_x86_64.zig"),
4 else => @compile_err("unsupported arch"),4 else => @compileError("unsupported arch"),
5};5};
66
7const errno = @import("errno.zig");7const errno = @import("errno.zig");
...@@ -88,7 +88,7 @@ pub fn fstat(fd: i32, stat_buf: &stat) -> usize {...@@ -88,7 +88,7 @@ pub fn fstat(fd: i32, stat_buf: &stat) -> usize {
88 arch.syscall2(arch.SYS_fstat, usize(fd), usize(stat_buf))88 arch.syscall2(arch.SYS_fstat, usize(fd), usize(stat_buf))
89}89}
9090
91pub error Unexpected;91error Unexpected;
9292
93pub fn getrandom(buf: &u8, count: usize) -> usize {93pub fn getrandom(buf: &u8, count: usize) -> usize {
94 const rr = open_c(c"/dev/urandom", O_LARGEFILE | O_RDONLY, 0);94 const rr = open_c(c"/dev/urandom", O_LARGEFILE | O_RDONLY, 0);
std/darwin_x86_64.zig+4-4
...@@ -57,7 +57,7 @@ pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) ->...@@ -57,7 +57,7 @@ pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) ->
5757
5858
5959
60export struct stat {60pub const stat = extern struct {
61 dev: u32,61 dev: u32,
62 mode: u16,62 mode: u16,
63 nlink: u16,63 nlink: u16,
...@@ -78,9 +78,9 @@ export struct stat {...@@ -78,9 +78,9 @@ export struct stat {
78 lspare: i32,78 lspare: i32,
79 qspare: [2]u64,79 qspare: [2]u64,
8080
81}81};
8282
83export struct timespec {83pub const timespec = extern struct {
84 tv_sec: isize,84 tv_sec: isize,
85 tv_nsec: isize,85 tv_nsec: isize,
86}86};
std/debug.zig+7-7
...@@ -5,9 +5,9 @@ const elf = @import("elf.zig");...@@ -5,9 +5,9 @@ const elf = @import("elf.zig");
5const DW = @import("dwarf.zig");5const DW = @import("dwarf.zig");
6const List = @import("list.zig").List;6const List = @import("list.zig").List;
77
8pub error MissingDebugInfo;8error MissingDebugInfo;
9pub error InvalidDebugInfo;9error InvalidDebugInfo;
10pub error UnsupportedDebugInfo;10error UnsupportedDebugInfo;
1111
12pub fn assert(b: bool) {12pub fn assert(b: bool) {
13 if (!b) @unreachable()13 if (!b) @unreachable()
...@@ -20,7 +20,7 @@ pub fn printStackTrace() -> %void {...@@ -20,7 +20,7 @@ pub fn printStackTrace() -> %void {
2020
21pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {21pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {
22 switch (@compileVar("object_format")) {22 switch (@compileVar("object_format")) {
23 elf => {23 ObjectFormat.elf => {
24 var stack_trace = ElfStackTrace {24 var stack_trace = ElfStackTrace {
25 .self_exe_stream = undefined,25 .self_exe_stream = undefined,
26 .elf = undefined,26 .elf = undefined,
...@@ -57,13 +57,13 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {...@@ -57,13 +57,13 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void {
57 maybe_fp = *(&const ?&const u8)(fp);57 maybe_fp = *(&const ?&const u8)(fp);
58 }58 }
59 },59 },
60 coff => {60 ObjectFormat.coff => {
61 out_stream.write("(stack trace unavailable for COFF object format)\n");61 out_stream.write("(stack trace unavailable for COFF object format)\n");
62 },62 },
63 macho => {63 ObjectFormat.macho => {
64 %return out_stream.write("(stack trace unavailable for Mach-O object format)\n");64 %return out_stream.write("(stack trace unavailable for Mach-O object format)\n");
65 },65 },
66 unknown => {66 ObjectFormat.unknown => {
67 out_stream.write("(stack trace unavailable for unknown object format)\n");67 out_stream.write("(stack trace unavailable for unknown object format)\n");
68 },68 },
69 }69 }
std/elf.zig+1-1
...@@ -4,7 +4,7 @@ const math = @import("math.zig");...@@ -4,7 +4,7 @@ const math = @import("math.zig");
4const mem = @import("mem.zig");4const mem = @import("mem.zig");
5const debug = @import("debug.zig");5const debug = @import("debug.zig");
66
7pub error InvalidFormat;7error InvalidFormat;
88
9pub const SHT_NULL = 0;9pub const SHT_NULL = 0;
10pub const SHT_PROGBITS = 1;10pub const SHT_PROGBITS = 1;
std/index.zig+2-2
...@@ -10,11 +10,11 @@ pub const hash_map = @import("hash_map.zig");...@@ -10,11 +10,11 @@ pub const hash_map = @import("hash_map.zig");
10pub const mem = @import("mem.zig");10pub const mem = @import("mem.zig");
11pub const debug = @import("debug.zig");11pub const debug = @import("debug.zig");
12pub const linux = switch(@compileVar("os")) {12pub const linux = switch(@compileVar("os")) {
13 linux => @import("linux.zig"),13 Os.linux => @import("linux.zig"),
14 else => null_import,14 else => null_import,
15};15};
16pub const darwin = switch(@compileVar("os")) {16pub const darwin = switch(@compileVar("os")) {
17 darwin => @import("darwin.zig"),17 Os.darwin => @import("darwin.zig"),
18 else => null_import,18 else => null_import,
19};19};
20const null_import = @import("empty.zig");20const null_import = @import("empty.zig");
std/linux.zig+3-3
...@@ -456,9 +456,9 @@ pub fn accept4(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t, flags:...@@ -456,9 +456,9 @@ pub fn accept4(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t, flags:
456 arch.syscall4(arch.SYS_accept4, usize(fd), usize(addr), usize(len), flags)456 arch.syscall4(arch.SYS_accept4, usize(fd), usize(addr), usize(len), flags)
457}457}
458458
459// pub error NameTooLong;459// error NameTooLong;
460// pub error SystemResources;460// error SystemResources;
461// pub error Io;461// error Io;
462// 462//
463// pub fn if_nametoindex(name: []u8) -> %u32 {463// pub fn if_nametoindex(name: []u8) -> %u32 {
464// var ifr: ifreq = undefined;464// var ifr: ifreq = undefined;
std/mem.zig+1-1
...@@ -5,7 +5,7 @@ const io = @import("io.zig");...@@ -5,7 +5,7 @@ const io = @import("io.zig");
55
6pub const Cmp = math.Cmp;6pub const Cmp = math.Cmp;
77
8pub error NoMem;8error NoMem;
99
10pub type Context = u8;10pub type Context = u8;
11pub const Allocator = struct {11pub const Allocator = struct {
std/net.zig+10-10
...@@ -3,15 +3,15 @@ const errno = @import("errno.zig");...@@ -3,15 +3,15 @@ const errno = @import("errno.zig");
3const assert = @import("debug.zig").assert;3const assert = @import("debug.zig").assert;
4const endian = @import("endian.zig");4const endian = @import("endian.zig");
55
6pub error SigInterrupt;6error SigInterrupt;
7pub error Unexpected;7error Unexpected;
8pub error Io;8error Io;
9pub error TimedOut;9error TimedOut;
10pub error ConnectionReset;10error ConnectionReset;
11pub error ConnectionRefused;11error ConnectionRefused;
12pub error NoMem;12error NoMem;
13pub error NotSocket;13error NotSocket;
14pub error BadFd;14error BadFd;
1515
16const Connection = struct {16const Connection = struct {
17 socket_fd: i32,17 socket_fd: i32,
...@@ -139,7 +139,7 @@ pub fn connect(hostname: []const u8, port: u16) -> %Connection {...@@ -139,7 +139,7 @@ pub fn connect(hostname: []const u8, port: u16) -> %Connection {
139 return connectAddr(main_addr, port);139 return connectAddr(main_addr, port);
140}140}
141141
142pub error InvalidIpLiteral;142error InvalidIpLiteral;
143143
144pub fn parseIpLiteral(buf: []const u8) -> %Address {144pub fn parseIpLiteral(buf: []const u8) -> %Address {
145 switch (parseIp4(buf)) {145 switch (parseIp4(buf)) {
std/os.zig+3-3
...@@ -1,11 +1,11 @@...@@ -1,11 +1,11 @@
1const system = switch(@compileVar("os")) {1const system = switch(@compileVar("os")) {
2 linux => @import("linux.zig"),2 Os.linux => @import("linux.zig"),
3 darwin => @import("darwin.zig"),3 Os.darwin => @import("darwin.zig"),
4 else => @compileError("Unsupported OS"),4 else => @compileError("Unsupported OS"),
5};5};
6const errno = @import("errno.zig");6const errno = @import("errno.zig");
77
8pub error Unexpected;8error Unexpected;
99
10pub fn getRandomBytes(buf: []u8) -> %void {10pub fn getRandomBytes(buf: []u8) -> %void {
11 while (true) {11 while (true) {