authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-12 12:56:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-12 12:56:01-04:00
logc1793d61061a112dc3d58c33ac0d3a1ebc8fb35e
treeda9b4839ee1c8bcc4d5c6dcd3423f955cfce2e5d
parented5a6d74ad980474ed46732828c7f8363dd5b80d
signaturelock-open Commit is signed but in an unrecognized format.

zig fmt on the standard library


25 files changed, 141 insertions(+), 214 deletions(-)

std/ascii.zig+11-11
...@@ -29,7 +29,7 @@ const combinedTable = init: {...@@ -29,7 +29,7 @@ const combinedTable = init: {
29 const mem = std.mem;29 const mem = std.mem;
3030
31 const alpha = []u1{31 const alpha = []u1{
32 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,1532 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -41,7 +41,7 @@ const combinedTable = init: {...@@ -41,7 +41,7 @@ const combinedTable = init: {
41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
42 };42 };
43 const lower = []u1{43 const lower = []u1{
44 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,1544 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -53,7 +53,7 @@ const combinedTable = init: {...@@ -53,7 +53,7 @@ const combinedTable = init: {
53 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,53 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
54 };54 };
55 const upper = []u1{55 const upper = []u1{
56 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,1556 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,58 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,59 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -65,7 +65,7 @@ const combinedTable = init: {...@@ -65,7 +65,7 @@ const combinedTable = init: {
65 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,65 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66 };66 };
67 const digit = []u1{67 const digit = []u1{
68 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,1568 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -77,7 +77,7 @@ const combinedTable = init: {...@@ -77,7 +77,7 @@ const combinedTable = init: {
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78 };78 };
79 const hex = []u1{79 const hex = []u1{
80 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,1580 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
82 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,82 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
83 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,83 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -89,7 +89,7 @@ const combinedTable = init: {...@@ -89,7 +89,7 @@ const combinedTable = init: {
89 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,89 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
90 };90 };
91 const space = []u1{91 const space = []u1{
92 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,1592 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,93 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,95 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -101,7 +101,7 @@ const combinedTable = init: {...@@ -101,7 +101,7 @@ const combinedTable = init: {
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 };102 };
103 const punct = []u1{103 const punct = []u1{
104 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15104 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
107 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,107 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...@@ -113,7 +113,7 @@ const combinedTable = init: {...@@ -113,7 +113,7 @@ const combinedTable = init: {
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
114 };114 };
115 const graph = []u1{115 const graph = []u1{
116 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15116 // 0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,10,11,12,13,14,15
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,119 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...@@ -129,7 +129,7 @@ const combinedTable = init: {...@@ -129,7 +129,7 @@ const combinedTable = init: {
129 inline while (i < 128) : (i += 1) {129 inline while (i < 128) : (i += 1) {
130 table[i] =130 table[i] =
131 u8(alpha[i]) << @enumToInt(tIndex.Alpha) |131 u8(alpha[i]) << @enumToInt(tIndex.Alpha) |
132 u8(hex[i]) << @enumToInt(tIndex.Hex) |132 u8(hex[i]) << @enumToInt(tIndex.Hex) |
133 u8(space[i]) << @enumToInt(tIndex.Space) |133 u8(space[i]) << @enumToInt(tIndex.Space) |
134 u8(digit[i]) << @enumToInt(tIndex.Digit) |134 u8(digit[i]) << @enumToInt(tIndex.Digit) |
135 u8(lower[i]) << @enumToInt(tIndex.Lower) |135 u8(lower[i]) << @enumToInt(tIndex.Lower) |
...@@ -146,8 +146,8 @@ fn inTable(c: u8, t: tIndex) bool {...@@ -146,8 +146,8 @@ fn inTable(c: u8, t: tIndex) bool {
146}146}
147147
148pub fn isAlNum(c: u8) bool {148pub fn isAlNum(c: u8) bool {
149 return (combinedTable[c] & ((u8(1) << @enumToInt(tIndex.Alpha)) | 149 return (combinedTable[c] & ((u8(1) << @enumToInt(tIndex.Alpha)) |
150 u8(1) << @enumToInt(tIndex.Digit))) != 0;150 u8(1) << @enumToInt(tIndex.Digit))) != 0;
151}151}
152152
153pub fn isAlpha(c: u8) bool {153pub fn isAlpha(c: u8) bool {
std/c/freebsd.zig+12
...@@ -44,16 +44,22 @@ pub const pthread_attr_t = extern struct {...@@ -44,16 +44,22 @@ pub const pthread_attr_t = extern struct {
44pub const msghdr = extern struct {44pub const msghdr = extern struct {
45 /// optional address45 /// optional address
46 msg_name: ?*sockaddr,46 msg_name: ?*sockaddr,
47
47 /// size of address48 /// size of address
48 msg_namelen: socklen_t,49 msg_namelen: socklen_t,
50
49 /// scatter/gather array51 /// scatter/gather array
50 msg_iov: [*]iovec,52 msg_iov: [*]iovec,
53
51 /// # elements in msg_iov54 /// # elements in msg_iov
52 msg_iovlen: i32,55 msg_iovlen: i32,
56
53 /// ancillary data57 /// ancillary data
54 msg_control: ?*c_void,58 msg_control: ?*c_void,
59
55 /// ancillary data buffer len60 /// ancillary data buffer len
56 msg_controllen: socklen_t,61 msg_controllen: socklen_t,
62
57 /// flags on received message63 /// flags on received message
58 msg_flags: i32,64 msg_flags: i32,
59};65};
...@@ -61,16 +67,22 @@ pub const msghdr = extern struct {...@@ -61,16 +67,22 @@ pub const msghdr = extern struct {
61pub const msghdr_const = extern struct {67pub const msghdr_const = extern struct {
62 /// optional address68 /// optional address
63 msg_name: ?*const sockaddr,69 msg_name: ?*const sockaddr,
70
64 /// size of address71 /// size of address
65 msg_namelen: socklen_t,72 msg_namelen: socklen_t,
73
66 /// scatter/gather array74 /// scatter/gather array
67 msg_iov: [*]iovec_const,75 msg_iov: [*]iovec_const,
76
68 /// # elements in msg_iov77 /// # elements in msg_iov
69 msg_iovlen: i32,78 msg_iovlen: i32,
79
70 /// ancillary data80 /// ancillary data
71 msg_control: ?*c_void,81 msg_control: ?*c_void,
82
72 /// ancillary data buffer len83 /// ancillary data buffer len
73 msg_controllen: socklen_t,84 msg_controllen: socklen_t,
85
74 /// flags on received message86 /// flags on received message
75 msg_flags: i32,87 msg_flags: i32,
76};88};
std/c/netbsd.zig+12
...@@ -44,16 +44,22 @@ pub const pthread_attr_t = extern struct {...@@ -44,16 +44,22 @@ pub const pthread_attr_t = extern struct {
44pub const msghdr = extern struct {44pub const msghdr = extern struct {
45 /// optional address45 /// optional address
46 msg_name: ?*sockaddr,46 msg_name: ?*sockaddr,
47
47 /// size of address48 /// size of address
48 msg_namelen: socklen_t,49 msg_namelen: socklen_t,
50
49 /// scatter/gather array51 /// scatter/gather array
50 msg_iov: [*]iovec,52 msg_iov: [*]iovec,
53
51 /// # elements in msg_iov54 /// # elements in msg_iov
52 msg_iovlen: i32,55 msg_iovlen: i32,
56
53 /// ancillary data57 /// ancillary data
54 msg_control: ?*c_void,58 msg_control: ?*c_void,
59
55 /// ancillary data buffer len60 /// ancillary data buffer len
56 msg_controllen: socklen_t,61 msg_controllen: socklen_t,
62
57 /// flags on received message63 /// flags on received message
58 msg_flags: i32,64 msg_flags: i32,
59};65};
...@@ -61,16 +67,22 @@ pub const msghdr = extern struct {...@@ -61,16 +67,22 @@ pub const msghdr = extern struct {
61pub const msghdr_const = extern struct {67pub const msghdr_const = extern struct {
62 /// optional address68 /// optional address
63 msg_name: ?*const sockaddr,69 msg_name: ?*const sockaddr,
70
64 /// size of address71 /// size of address
65 msg_namelen: socklen_t,72 msg_namelen: socklen_t,
73
66 /// scatter/gather array74 /// scatter/gather array
67 msg_iov: [*]iovec_const,75 msg_iov: [*]iovec_const,
76
68 /// # elements in msg_iov77 /// # elements in msg_iov
69 msg_iovlen: i32,78 msg_iovlen: i32,
79
70 /// ancillary data80 /// ancillary data
71 msg_control: ?*c_void,81 msg_control: ?*c_void,
82
72 /// ancillary data buffer len83 /// ancillary data buffer len
73 msg_controllen: socklen_t,84 msg_controllen: socklen_t,
85
74 /// flags on received message86 /// flags on received message
75 msg_flags: i32,87 msg_flags: i32,
76};88};
std/crypto/chacha20.zig+2-2
...@@ -206,8 +206,8 @@ test "crypto.chacha20 test vector sunscreen" {...@@ -206,8 +206,8 @@ test "crypto.chacha20 test vector sunscreen" {
206 const input = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";206 const input = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
207 var result: [114]u8 = undefined;207 var result: [114]u8 = undefined;
208 const key = []u8{208 const key = []u8{
209 0, 1, 2, 3, 4, 5, 6, 7,209 0, 1, 2, 3, 4, 5, 6, 7,
210 8, 9, 10, 11, 12, 13, 14, 15,210 8, 9, 10, 11, 12, 13, 14, 15,
211 16, 17, 18, 19, 20, 21, 22, 23,211 16, 17, 18, 19, 20, 21, 22, 23,
212 24, 25, 26, 27, 28, 29, 30, 31,212 24, 25, 26, 27, 28, 29, 30, 31,
213 };213 };
std/dynamic_library.zig+4-4
...@@ -71,12 +71,12 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {...@@ -71,12 +71,12 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
71 for (phdrs) |*phdr| {71 for (phdrs) |*phdr| {
72 if (phdr.p_type == elf.PT_DYNAMIC) {72 if (phdr.p_type == elf.PT_DYNAMIC) {
73 const ptr = @intToPtr([*]elf.Dyn, va_offset + phdr.p_vaddr);73 const ptr = @intToPtr([*]elf.Dyn, va_offset + phdr.p_vaddr);
74 break :init ptr[0..phdr.p_memsz / @sizeOf(elf.Dyn)];74 break :init ptr[0 .. phdr.p_memsz / @sizeOf(elf.Dyn)];
75 }75 }
76 }76 }
77 // No PT_DYNAMIC means this is either a statically-linked program or a77 // No PT_DYNAMIC means this is either a statically-linked program or a
78 // badly corrupted one78 // badly corrupted one
79 return LinkMap.Iterator{.current = null};79 return LinkMap.Iterator{ .current = null };
80 };80 };
8181
82 const link_map_ptr = init: {82 const link_map_ptr = init: {
...@@ -93,13 +93,13 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {...@@ -93,13 +93,13 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
93 // second slot93 // second slot
94 break :init @intToPtr(?*LinkMap, got_table[1]);94 break :init @intToPtr(?*LinkMap, got_table[1]);
95 },95 },
96 else => { }96 else => {},
97 }97 }
98 }98 }
99 return error.InvalidExe;99 return error.InvalidExe;
100 };100 };
101101
102 return LinkMap.Iterator{.current = link_map_ptr};102 return LinkMap.Iterator{ .current = link_map_ptr };
103}103}
104104
105pub const LinuxDynLib = struct {105pub const LinuxDynLib = struct {
std/event/locked.zig+1-1
...@@ -34,7 +34,7 @@ pub fn Locked(comptime T: type) type {...@@ -34,7 +34,7 @@ pub fn Locked(comptime T: type) type {
3434
35 pub async fn acquire(self: *Self) HeldLock {35 pub async fn acquire(self: *Self) HeldLock {
36 return HeldLock{36 return HeldLock{
37 // TODO guaranteed allocation elision37 // TODO guaranteed allocation elision
38 .held = await (async self.lock.acquire() catch unreachable),38 .held = await (async self.lock.acquire() catch unreachable),
39 .value = &self.private_data,39 .value = &self.private_data,
40 };40 };
std/fmt.zig+2-2
...@@ -183,7 +183,7 @@ pub fn formatType(...@@ -183,7 +183,7 @@ pub fn formatType(
183 }183 }
184 try output(context, @memberName(T, field_i));184 try output(context, @memberName(T, field_i));
185 try output(context, " = ");185 try output(context, " = ");
186 try formatType(@field(value, @memberName(T, field_i)), "", context, Errors, output, max_depth-1);186 try formatType(@field(value, @memberName(T, field_i)), "", context, Errors, output, max_depth - 1);
187 }187 }
188 try output(context, " }");188 try output(context, " }");
189 },189 },
...@@ -198,7 +198,7 @@ pub fn formatType(...@@ -198,7 +198,7 @@ pub fn formatType(
198 try output(context, " = ");198 try output(context, " = ");
199 inline for (info.fields) |u_field| {199 inline for (info.fields) |u_field| {
200 if (@enumToInt(UnionTagType(value)) == u_field.enum_field.?.value) {200 if (@enumToInt(UnionTagType(value)) == u_field.enum_field.?.value) {
201 try formatType(@field(value, u_field.name), "", context, Errors, output, max_depth-1);201 try formatType(@field(value, u_field.name), "", context, Errors, output, max_depth - 1);
202 }202 }
203 }203 }
204 try output(context, " }");204 try output(context, " }");
std/hash_map.zig+3-3
...@@ -155,7 +155,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3...@@ -155,7 +155,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
155 /// capacity is greater than the current capacity.155 /// capacity is greater than the current capacity.
156 /// New capacity must be a power of two.156 /// New capacity must be a power of two.
157 fn ensureCapacityExact(self: *Self, new_capacity: usize) !void {157 fn ensureCapacityExact(self: *Self, new_capacity: usize) !void {
158 const is_power_of_two = new_capacity & (new_capacity-1) == 0;158 const is_power_of_two = new_capacity & (new_capacity - 1) == 0;
159 assert(is_power_of_two);159 assert(is_power_of_two);
160160
161 if (new_capacity <= self.entries.len) {161 if (new_capacity <= self.entries.len) {
...@@ -474,9 +474,9 @@ test "ensure capacity" {...@@ -474,9 +474,9 @@ test "ensure capacity" {
474 try map.ensureCapacity(20);474 try map.ensureCapacity(20);
475 const initialCapacity = map.entries.len;475 const initialCapacity = map.entries.len;
476 testing.expect(initialCapacity >= 20);476 testing.expect(initialCapacity >= 20);
477 var i : i32 = 0;477 var i: i32 = 0;
478 while (i < 20) : (i += 1) {478 while (i < 20) : (i += 1) {
479 testing.expect(map.putAssumeCapacity(i, i+10) == null);479 testing.expect(map.putAssumeCapacity(i, i + 10) == null);
480 }480 }
481 // shouldn't resize from putAssumeCapacity481 // shouldn't resize from putAssumeCapacity
482 testing.expect(initialCapacity == map.entries.len);482 testing.expect(initialCapacity == map.entries.len);
std/os/linux/tls.zig+8-10
...@@ -86,8 +86,7 @@ const tls_dtv_offset = switch (builtin.arch) {...@@ -86,8 +86,7 @@ const tls_dtv_offset = switch (builtin.arch) {
86};86};
8787
88// Per-thread storage for Zig's use88// Per-thread storage for Zig's use
89const CustomData = packed struct {89const CustomData = packed struct {};
90};
9190
92// Dynamic Thread Vector91// Dynamic Thread Vector
93const DTV = packed struct {92const DTV = packed struct {
...@@ -109,14 +108,14 @@ pub var tls_image: ?TLSImage = null;...@@ -109,14 +108,14 @@ pub var tls_image: ?TLSImage = null;
109pub fn setThreadPointer(addr: usize) void {108pub fn setThreadPointer(addr: usize) void {
110 switch (builtin.arch) {109 switch (builtin.arch) {
111 .x86_64 => {110 .x86_64 => {
112 const rc = std.os.linux.syscall2(std.os.linux.SYS_arch_prctl,111 const rc = std.os.linux.syscall2(std.os.linux.SYS_arch_prctl, std.os.linux.ARCH_SET_FS, addr);
113 std.os.linux.ARCH_SET_FS, addr);
114 assert(rc == 0);112 assert(rc == 0);
115 },113 },
116 .aarch64 => {114 .aarch64 => {
117 asm volatile (115 asm volatile (
118 \\ msr tpidr_el0, %[addr]116 \\ msr tpidr_el0, %[addr]
119 : : [addr] "r" (addr)117 :
118 : [addr] "r" (addr)
120 );119 );
121 },120 },
122 else => @compileError("Unsupported architecture"),121 else => @compileError("Unsupported architecture"),
...@@ -137,7 +136,7 @@ pub fn initTLS() void {...@@ -137,7 +136,7 @@ pub fn initTLS() void {
137 switch (auxv[i].a_type) {136 switch (auxv[i].a_type) {
138 elf.AT_PHENT => at_phent = auxv[i].a_un.a_val,137 elf.AT_PHENT => at_phent = auxv[i].a_un.a_val,
139 elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val,138 elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val,
140 elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val,139 elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val,
141 else => continue,140 else => continue,
142 }141 }
143 }142 }
...@@ -151,7 +150,7 @@ pub fn initTLS() void {...@@ -151,7 +150,7 @@ pub fn initTLS() void {
151 for (phdrs) |*phdr| {150 for (phdrs) |*phdr| {
152 switch (phdr.p_type) {151 switch (phdr.p_type) {
153 elf.PT_PHDR => img_base = at_phdr - phdr.p_vaddr,152 elf.PT_PHDR => img_base = at_phdr - phdr.p_vaddr,
154 elf.PT_TLS => tls_phdr = phdr,153 elf.PT_TLS => tls_phdr = phdr,
155 else => continue,154 else => continue,
156 }155 }
157 }156 }
...@@ -194,7 +193,7 @@ pub fn initTLS() void {...@@ -194,7 +193,7 @@ pub fn initTLS() void {
194 dtv_offset = l;193 dtv_offset = l;
195 l += @sizeOf(DTV);194 l += @sizeOf(DTV);
196 break :blk l;195 break :blk l;
197 }196 },
198 };197 };
199198
200 tls_image = TLSImage{199 tls_image = TLSImage{
...@@ -238,8 +237,7 @@ pub fn allocateTLS(size: usize) usize {...@@ -238,8 +237,7 @@ pub fn allocateTLS(size: usize) usize {
238 return @ptrToInt(&main_thread_tls_buffer);237 return @ptrToInt(&main_thread_tls_buffer);
239 }238 }
240239
241 const addr = posix.mmap(null, size, posix.PROT_READ | posix.PROT_WRITE,240 const addr = posix.mmap(null, size, posix.PROT_READ | posix.PROT_WRITE, posix.MAP_PRIVATE | posix.MAP_ANONYMOUS, -1, 0);
242 posix.MAP_PRIVATE | posix.MAP_ANONYMOUS, -1, 0);
243241
244 if (posix.getErrno(addr) != 0) @panic("out of memory");242 if (posix.getErrno(addr) != 0) @panic("out of memory");
245243
std/os/windows/shell32.zig-1
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1use @import("../windows.zig");1use @import("../windows.zig");
22
3pub extern "shell32" stdcallcc fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) HRESULT;3pub extern "shell32" stdcallcc fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) HRESULT;
4
std/special/compiler_rt.zig+16-4
...@@ -338,7 +338,10 @@ extern fn __umoddi3(a: u64, b: u64) u64 {...@@ -338,7 +338,10 @@ extern fn __umoddi3(a: u64, b: u64) u64 {
338 return r;338 return r;
339}339}
340340
341extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct{q: u32, r: u32} {341extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct {
342 q: u32,
343 r: u32,
344} {
342 @setRuntimeSafety(is_test);345 @setRuntimeSafety(is_test);
343346
344 var result: @typeOf(__aeabi_uidivmod).ReturnType = undefined;347 var result: @typeOf(__aeabi_uidivmod).ReturnType = undefined;
...@@ -346,7 +349,10 @@ extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct{q: u32, r: u32} {...@@ -346,7 +349,10 @@ extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct{q: u32, r: u32} {
346 return result;349 return result;
347}350}
348351
349extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct{q: u64, r: u64} {352extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct {
353 q: u64,
354 r: u64,
355} {
350 @setRuntimeSafety(is_test);356 @setRuntimeSafety(is_test);
351357
352 var result: @typeOf(__aeabi_uldivmod).ReturnType = undefined;358 var result: @typeOf(__aeabi_uldivmod).ReturnType = undefined;
...@@ -354,7 +360,10 @@ extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct{q: u64, r: u64} {...@@ -354,7 +360,10 @@ extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct{q: u64, r: u64} {
354 return result;360 return result;
355}361}
356362
357extern fn __aeabi_idivmod(n: i32, d: i32) extern struct{q: i32, r: i32} {363extern fn __aeabi_idivmod(n: i32, d: i32) extern struct {
364 q: i32,
365 r: i32,
366} {
358 @setRuntimeSafety(is_test);367 @setRuntimeSafety(is_test);
359368
360 var result: @typeOf(__aeabi_idivmod).ReturnType = undefined;369 var result: @typeOf(__aeabi_idivmod).ReturnType = undefined;
...@@ -362,7 +371,10 @@ extern fn __aeabi_idivmod(n: i32, d: i32) extern struct{q: i32, r: i32} {...@@ -362,7 +371,10 @@ extern fn __aeabi_idivmod(n: i32, d: i32) extern struct{q: i32, r: i32} {
362 return result;371 return result;
363}372}
364373
365extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct{q: i64, r:i64} {374extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct {
375 q: i64,
376 r: i64,
377} {
366 @setRuntimeSafety(is_test);378 @setRuntimeSafety(is_test);
367379
368 var result: @typeOf(__aeabi_ldivmod).ReturnType = undefined;380 var result: @typeOf(__aeabi_ldivmod).ReturnType = undefined;
std/special/compiler_rt/ashrti3_test.zig+1-1
...@@ -4,7 +4,7 @@ const testing = @import("std").testing;...@@ -4,7 +4,7 @@ const testing = @import("std").testing;
4fn test__ashrti3(a: i128, b: i32, expected: i128) void {4fn test__ashrti3(a: i128, b: i32, expected: i128) void {
5 const x = __ashrti3(a, b);5 const x = __ashrti3(a, b);
6 // @import("std").debug.warn("got 0x{x}\nexp 0x{x}\n", @truncate(u64,6 // @import("std").debug.warn("got 0x{x}\nexp 0x{x}\n", @truncate(u64,
7// @bitCast(u128, x) >> 64), @truncate(u64, @bitCast(u128, expected)) >> 64);7 // @bitCast(u128, x) >> 64), @truncate(u64, @bitCast(u128, expected)) >> 64);
8 testing.expect(x == expected);8 testing.expect(x == expected);
9}9}
1010
std/special/compiler_rt/fixdfdi_test.zig-1
...@@ -12,7 +12,6 @@ fn test__fixdfdi(a: f64, expected: i64) void {...@@ -12,7 +12,6 @@ fn test__fixdfdi(a: f64, expected: i64) void {
1212
13test "fixdfdi" {13test "fixdfdi" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixdfdi(-math.f64_max, math.minInt(i64));15 test__fixdfdi(-math.f64_max, math.minInt(i64));
1716
18 test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));17 test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
std/special/compiler_rt/fixdfsi_test.zig+4-5
...@@ -12,7 +12,6 @@ fn test__fixdfsi(a: f64, expected: i32) void {...@@ -12,7 +12,6 @@ fn test__fixdfsi(a: f64, expected: i32) void {
1212
13test "fixdfsi" {13test "fixdfsi" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixdfsi(-math.f64_max, math.minInt(i32));15 test__fixdfsi(-math.f64_max, math.minInt(i32));
1716
18 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));17 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
...@@ -22,10 +21,10 @@ test "fixdfsi" {...@@ -22,10 +21,10 @@ test "fixdfsi" {
22 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);21 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
23 test__fixdfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);22 test__fixdfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
2423
25 test__fixdfsi(-0x1.0000000000001p+63, -0x80000000);24 test__fixdfsi(-0x1.0000000000001p+63, -0x80000000);
26 test__fixdfsi(-0x1.0000000000000p+63, -0x80000000);25 test__fixdfsi(-0x1.0000000000000p+63, -0x80000000);
27 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);26 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
28 test__fixdfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);27 test__fixdfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
2928
30 test__fixdfsi(-0x1.FFFFFEp+62, -0x80000000);29 test__fixdfsi(-0x1.FFFFFEp+62, -0x80000000);
31 test__fixdfsi(-0x1.FFFFFCp+62, -0x80000000);30 test__fixdfsi(-0x1.FFFFFCp+62, -0x80000000);
std/special/compiler_rt/fixdfti_test.zig-1
...@@ -12,7 +12,6 @@ fn test__fixdfti(a: f64, expected: i128) void {...@@ -12,7 +12,6 @@ fn test__fixdfti(a: f64, expected: i128) void {
1212
13test "fixdfti" {13test "fixdfti" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixdfti(-math.f64_max, math.minInt(i128));15 test__fixdfti(-math.f64_max, math.minInt(i128));
1716
18 test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));17 test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
std/special/compiler_rt/fixint_test.zig+7-7
...@@ -82,7 +82,7 @@ test "fixint.i32" {...@@ -82,7 +82,7 @@ test "fixint.i32" {
82 test__fixint(f64, i32, -math.inf_f64, math.minInt(i32));82 test__fixint(f64, i32, -math.inf_f64, math.minInt(i32));
83 test__fixint(f64, i32, -math.f64_max, math.minInt(i32));83 test__fixint(f64, i32, -math.f64_max, math.minInt(i32));
84 test__fixint(f64, i32, f64(math.minInt(i32)), math.minInt(i32));84 test__fixint(f64, i32, f64(math.minInt(i32)), math.minInt(i32));
85 test__fixint(f64, i32, f64(math.minInt(i32))+1, math.minInt(i32)+1);85 test__fixint(f64, i32, f64(math.minInt(i32)) + 1, math.minInt(i32) + 1);
86 test__fixint(f64, i32, -2.0, -2);86 test__fixint(f64, i32, -2.0, -2);
87 test__fixint(f64, i32, -1.9, -1);87 test__fixint(f64, i32, -1.9, -1);
88 test__fixint(f64, i32, -1.1, -1);88 test__fixint(f64, i32, -1.1, -1);
...@@ -96,7 +96,7 @@ test "fixint.i32" {...@@ -96,7 +96,7 @@ test "fixint.i32" {
96 test__fixint(f64, i32, 0.1, 0);96 test__fixint(f64, i32, 0.1, 0);
97 test__fixint(f64, i32, 0.9, 0);97 test__fixint(f64, i32, 0.9, 0);
98 test__fixint(f64, i32, 1.0, 1);98 test__fixint(f64, i32, 1.0, 1);
99 test__fixint(f64, i32, f64(math.maxInt(i32))-1, math.maxInt(i32)-1);99 test__fixint(f64, i32, f64(math.maxInt(i32)) - 1, math.maxInt(i32) - 1);
100 test__fixint(f64, i32, f64(math.maxInt(i32)), math.maxInt(i32));100 test__fixint(f64, i32, f64(math.maxInt(i32)), math.maxInt(i32));
101 test__fixint(f64, i32, math.f64_max, math.maxInt(i32));101 test__fixint(f64, i32, math.f64_max, math.maxInt(i32));
102 test__fixint(f64, i32, math.inf_f64, math.maxInt(i32));102 test__fixint(f64, i32, math.inf_f64, math.maxInt(i32));
...@@ -106,8 +106,8 @@ test "fixint.i64" {...@@ -106,8 +106,8 @@ test "fixint.i64" {
106 test__fixint(f64, i64, -math.inf_f64, math.minInt(i64));106 test__fixint(f64, i64, -math.inf_f64, math.minInt(i64));
107 test__fixint(f64, i64, -math.f64_max, math.minInt(i64));107 test__fixint(f64, i64, -math.f64_max, math.minInt(i64));
108 test__fixint(f64, i64, f64(math.minInt(i64)), math.minInt(i64));108 test__fixint(f64, i64, f64(math.minInt(i64)), math.minInt(i64));
109 test__fixint(f64, i64, f64(math.minInt(i64))+1, math.minInt(i64));109 test__fixint(f64, i64, f64(math.minInt(i64)) + 1, math.minInt(i64));
110 test__fixint(f64, i64, f64(math.minInt(i64)/2), math.minInt(i64)/2);110 test__fixint(f64, i64, f64(math.minInt(i64) / 2), math.minInt(i64) / 2);
111 test__fixint(f64, i64, -2.0, -2);111 test__fixint(f64, i64, -2.0, -2);
112 test__fixint(f64, i64, -1.9, -1);112 test__fixint(f64, i64, -1.9, -1);
113 test__fixint(f64, i64, -1.1, -1);113 test__fixint(f64, i64, -1.1, -1);
...@@ -121,7 +121,7 @@ test "fixint.i64" {...@@ -121,7 +121,7 @@ test "fixint.i64" {
121 test__fixint(f64, i64, 0.1, 0);121 test__fixint(f64, i64, 0.1, 0);
122 test__fixint(f64, i64, 0.9, 0);122 test__fixint(f64, i64, 0.9, 0);
123 test__fixint(f64, i64, 1.0, 1);123 test__fixint(f64, i64, 1.0, 1);
124 test__fixint(f64, i64, f64(math.maxInt(i64))-1, math.maxInt(i64));124 test__fixint(f64, i64, f64(math.maxInt(i64)) - 1, math.maxInt(i64));
125 test__fixint(f64, i64, f64(math.maxInt(i64)), math.maxInt(i64));125 test__fixint(f64, i64, f64(math.maxInt(i64)), math.maxInt(i64));
126 test__fixint(f64, i64, math.f64_max, math.maxInt(i64));126 test__fixint(f64, i64, math.f64_max, math.maxInt(i64));
127 test__fixint(f64, i64, math.inf_f64, math.maxInt(i64));127 test__fixint(f64, i64, math.inf_f64, math.maxInt(i64));
...@@ -131,7 +131,7 @@ test "fixint.i128" {...@@ -131,7 +131,7 @@ test "fixint.i128" {
131 test__fixint(f64, i128, -math.inf_f64, math.minInt(i128));131 test__fixint(f64, i128, -math.inf_f64, math.minInt(i128));
132 test__fixint(f64, i128, -math.f64_max, math.minInt(i128));132 test__fixint(f64, i128, -math.f64_max, math.minInt(i128));
133 test__fixint(f64, i128, f64(math.minInt(i128)), math.minInt(i128));133 test__fixint(f64, i128, f64(math.minInt(i128)), math.minInt(i128));
134 test__fixint(f64, i128, f64(math.minInt(i128))+1, math.minInt(i128));134 test__fixint(f64, i128, f64(math.minInt(i128)) + 1, math.minInt(i128));
135 test__fixint(f64, i128, -2.0, -2);135 test__fixint(f64, i128, -2.0, -2);
136 test__fixint(f64, i128, -1.9, -1);136 test__fixint(f64, i128, -1.9, -1);
137 test__fixint(f64, i128, -1.1, -1);137 test__fixint(f64, i128, -1.1, -1);
...@@ -145,7 +145,7 @@ test "fixint.i128" {...@@ -145,7 +145,7 @@ test "fixint.i128" {
145 test__fixint(f64, i128, 0.1, 0);145 test__fixint(f64, i128, 0.1, 0);
146 test__fixint(f64, i128, 0.9, 0);146 test__fixint(f64, i128, 0.9, 0);
147 test__fixint(f64, i128, 1.0, 1);147 test__fixint(f64, i128, 1.0, 1);
148 test__fixint(f64, i128, f64(math.maxInt(i128))-1, math.maxInt(i128));148 test__fixint(f64, i128, f64(math.maxInt(i128)) - 1, math.maxInt(i128));
149 test__fixint(f64, i128, f64(math.maxInt(i128)), math.maxInt(i128));149 test__fixint(f64, i128, f64(math.maxInt(i128)), math.maxInt(i128));
150 test__fixint(f64, i128, math.f64_max, math.maxInt(i128));150 test__fixint(f64, i128, math.f64_max, math.maxInt(i128));
151 test__fixint(f64, i128, math.inf_f64, math.maxInt(i128));151 test__fixint(f64, i128, math.inf_f64, math.maxInt(i128));
std/special/compiler_rt/fixsfdi_test.zig-1
...@@ -12,7 +12,6 @@ fn test__fixsfdi(a: f32, expected: i64) void {...@@ -12,7 +12,6 @@ fn test__fixsfdi(a: f32, expected: i64) void {
1212
13test "fixsfdi" {13test "fixsfdi" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixsfdi(-math.f32_max, math.minInt(i64));15 test__fixsfdi(-math.f32_max, math.minInt(i64));
1716
18 test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));17 test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
std/special/compiler_rt/fixsfsi_test.zig+4-5
...@@ -12,7 +12,6 @@ fn test__fixsfsi(a: f32, expected: i32) void {...@@ -12,7 +12,6 @@ fn test__fixsfsi(a: f32, expected: i32) void {
1212
13test "fixsfsi" {13test "fixsfsi" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixsfsi(-math.f32_max, math.minInt(i32));15 test__fixsfsi(-math.f32_max, math.minInt(i32));
1716
18 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));17 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
...@@ -22,10 +21,10 @@ test "fixsfsi" {...@@ -22,10 +21,10 @@ test "fixsfsi" {
22 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);21 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
23 test__fixsfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);22 test__fixsfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
2423
25 test__fixsfsi(-0x1.0000000000001p+63, -0x80000000);24 test__fixsfsi(-0x1.0000000000001p+63, -0x80000000);
26 test__fixsfsi(-0x1.0000000000000p+63, -0x80000000);25 test__fixsfsi(-0x1.0000000000000p+63, -0x80000000);
27 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);26 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
28 test__fixsfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);27 test__fixsfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
2928
30 test__fixsfsi(-0x1.FFFFFEp+62, -0x80000000);29 test__fixsfsi(-0x1.FFFFFEp+62, -0x80000000);
31 test__fixsfsi(-0x1.FFFFFCp+62, -0x80000000);30 test__fixsfsi(-0x1.FFFFFCp+62, -0x80000000);
std/special/compiler_rt/fixsfti_test.zig+1-2
...@@ -12,7 +12,6 @@ fn test__fixsfti(a: f32, expected: i128) void {...@@ -12,7 +12,6 @@ fn test__fixsfti(a: f32, expected: i128) void {
1212
13test "fixsfti" {13test "fixsfti" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixsfti(-math.f32_max, math.minInt(i128));15 test__fixsfti(-math.f32_max, math.minInt(i128));
1716
18 test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));17 test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
...@@ -30,7 +29,7 @@ test "fixsfti" {...@@ -30,7 +29,7 @@ test "fixsfti" {
30 test__fixsfti(-0x1.FFFFFFFFFFFFFp+62, -0x8000000000000000);29 test__fixsfti(-0x1.FFFFFFFFFFFFFp+62, -0x8000000000000000);
31 test__fixsfti(-0x1.FFFFFFFFFFFFEp+62, -0x8000000000000000);30 test__fixsfti(-0x1.FFFFFFFFFFFFEp+62, -0x8000000000000000);
3231
33 test__fixsfti(-0x1.FFFFFFp+62, -0x8000000000000000);32 test__fixsfti(-0x1.FFFFFFp+62, -0x8000000000000000);
34 test__fixsfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);33 test__fixsfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
35 test__fixsfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);34 test__fixsfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
3635
std/special/compiler_rt/fixtfdi_test.zig+4-5
...@@ -12,7 +12,6 @@ fn test__fixtfdi(a: f128, expected: i64) void {...@@ -12,7 +12,6 @@ fn test__fixtfdi(a: f128, expected: i64) void {
1212
13test "fixtfdi" {13test "fixtfdi" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixtfdi(-math.f128_max, math.minInt(i64));15 test__fixtfdi(-math.f128_max, math.minInt(i64));
1716
18 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));17 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
...@@ -22,10 +21,10 @@ test "fixtfdi" {...@@ -22,10 +21,10 @@ test "fixtfdi" {
22 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);21 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
23 test__fixtfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);22 test__fixtfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
2423
25 test__fixtfdi(-0x1.0000000000001p+63, -0x8000000000000000);24 test__fixtfdi(-0x1.0000000000001p+63, -0x8000000000000000);
26 test__fixtfdi(-0x1.0000000000000p+63, -0x8000000000000000);25 test__fixtfdi(-0x1.0000000000000p+63, -0x8000000000000000);
27 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);26 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
28 test__fixtfdi(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);27 test__fixtfdi(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
2928
30 test__fixtfdi(-0x1.FFFFFEp+62, -0x7FFFFF8000000000);29 test__fixtfdi(-0x1.FFFFFEp+62, -0x7FFFFF8000000000);
31 test__fixtfdi(-0x1.FFFFFCp+62, -0x7FFFFF0000000000);30 test__fixtfdi(-0x1.FFFFFCp+62, -0x7FFFFF0000000000);
std/special/compiler_rt/fixtfsi_test.zig+4-5
...@@ -12,7 +12,6 @@ fn test__fixtfsi(a: f128, expected: i32) void {...@@ -12,7 +12,6 @@ fn test__fixtfsi(a: f128, expected: i32) void {
1212
13test "fixtfsi" {13test "fixtfsi" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixtfsi(-math.f128_max, math.minInt(i32));15 test__fixtfsi(-math.f128_max, math.minInt(i32));
1716
18 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));17 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
...@@ -22,10 +21,10 @@ test "fixtfsi" {...@@ -22,10 +21,10 @@ test "fixtfsi" {
22 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);21 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
23 test__fixtfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);22 test__fixtfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
2423
25 test__fixtfsi(-0x1.0000000000001p+63, -0x80000000);24 test__fixtfsi(-0x1.0000000000001p+63, -0x80000000);
26 test__fixtfsi(-0x1.0000000000000p+63, -0x80000000);25 test__fixtfsi(-0x1.0000000000000p+63, -0x80000000);
27 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);26 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
28 test__fixtfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);27 test__fixtfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
2928
30 test__fixtfsi(-0x1.FFFFFEp+62, -0x80000000);29 test__fixtfsi(-0x1.FFFFFEp+62, -0x80000000);
31 test__fixtfsi(-0x1.FFFFFCp+62, -0x80000000);30 test__fixtfsi(-0x1.FFFFFCp+62, -0x80000000);
std/special/compiler_rt/fixtfti_test.zig-1
...@@ -12,7 +12,6 @@ fn test__fixtfti(a: f128, expected: i128) void {...@@ -12,7 +12,6 @@ fn test__fixtfti(a: f128, expected: i128) void {
1212
13test "fixtfti" {13test "fixtfti" {
14 //warn("\n");14 //warn("\n");
15
16 test__fixtfti(-math.f128_max, math.minInt(i128));15 test__fixtfti(-math.f128_max, math.minInt(i128));
1716
18 test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));17 test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
std/special/compiler_rt/stack_probe.zig+5-5
...@@ -51,7 +51,7 @@ pub nakedcc fn zig_probe_stack() void {...@@ -51,7 +51,7 @@ pub nakedcc fn zig_probe_stack() void {
51 \\ ret51 \\ ret
52 );52 );
53 },53 },
54 else => { }54 else => {},
55 }55 }
5656
57 unreachable;57 unreachable;
...@@ -103,7 +103,7 @@ fn win_probe_stack_only() void {...@@ -103,7 +103,7 @@ fn win_probe_stack_only() void {
103 \\ ret103 \\ ret
104 );104 );
105 },105 },
106 else => { }106 else => {},
107 }107 }
108108
109 unreachable;109 unreachable;
...@@ -159,9 +159,9 @@ fn win_probe_stack_adjust_sp() void {...@@ -159,9 +159,9 @@ fn win_probe_stack_adjust_sp() void {
159 \\ push (%%eax)159 \\ push (%%eax)
160 \\ sub %%esp,%%eax160 \\ sub %%esp,%%eax
161 \\ ret161 \\ ret
162 );162 );
163 },163 },
164 else => { },164 else => {},
165 }165 }
166166
167 unreachable;167 unreachable;
...@@ -189,7 +189,7 @@ pub nakedcc fn __chkstk() void {...@@ -189,7 +189,7 @@ pub nakedcc fn __chkstk() void {
189 switch (builtin.arch) {189 switch (builtin.arch) {
190 .i386 => @inlineCall(win_probe_stack_adjust_sp),190 .i386 => @inlineCall(win_probe_stack_adjust_sp),
191 .x86_64 => @inlineCall(win_probe_stack_only),191 .x86_64 => @inlineCall(win_probe_stack_only),
192 else => unreachable192 else => unreachable,
193 }193 }
194}194}
195pub nakedcc fn ___chkstk() void {195pub nakedcc fn ___chkstk() void {
std/valgrind.zig+40-136
...@@ -1,11 +1,7 @@...@@ -1,11 +1,7 @@
1const builtin = @import("builtin");1const builtin = @import("builtin");
2const math = @import("index.zig").math;2const math = @import("index.zig").math;
33
44pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
5pub fn doClientRequest(default: usize, request: usize,
6 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
7 ) usize
8{
9 if (!builtin.valgrind_support) {5 if (!builtin.valgrind_support) {
10 return default;6 return default;
11 }7 }
...@@ -16,8 +12,8 @@ pub fn doClientRequest(default: usize, request: usize,...@@ -16,8 +12,8 @@ pub fn doClientRequest(default: usize, request: usize,
16 \\ roll $3, %%edi ; roll $13, %%edi12 \\ roll $3, %%edi ; roll $13, %%edi
17 \\ roll $29, %%edi ; roll $19, %%edi13 \\ roll $29, %%edi ; roll $19, %%edi
18 \\ xchgl %%ebx,%%ebx14 \\ xchgl %%ebx,%%ebx
19 : [_] "={edx}" (-> usize)15 : [_] "={edx}" (-> usize)
20 : [_] "{eax}" (&[]usize{request, a1, a2, a3, a4, a5}),16 : [_] "{eax}" (&[]usize{ request, a1, a2, a3, a4, a5 }),
21 [_] "0" (default)17 [_] "0" (default)
22 : "cc", "memory"18 : "cc", "memory"
23 );19 );
...@@ -27,8 +23,8 @@ pub fn doClientRequest(default: usize, request: usize,...@@ -27,8 +23,8 @@ pub fn doClientRequest(default: usize, request: usize,
27 \\ rolq $3, %%rdi ; rolq $13, %%rdi23 \\ rolq $3, %%rdi ; rolq $13, %%rdi
28 \\ rolq $61, %%rdi ; rolq $51, %%rdi24 \\ rolq $61, %%rdi ; rolq $51, %%rdi
29 \\ xchgq %%rbx,%%rbx25 \\ xchgq %%rbx,%%rbx
30 : [_] "={rdx}" (-> usize)26 : [_] "={rdx}" (-> usize)
31 : [_] "{rax}" (&[]usize{request, a1, a2, a3, a4, a5}),27 : [_] "{rax}" (&[]usize{ request, a1, a2, a3, a4, a5 }),
32 [_] "0" (default)28 [_] "0" (default)
33 : "cc", "memory"29 : "cc", "memory"
34 );30 );
...@@ -42,11 +38,10 @@ pub fn doClientRequest(default: usize, request: usize,...@@ -42,11 +38,10 @@ pub fn doClientRequest(default: usize, request: usize,
42 // mips6438 // mips64
43 else => {39 else => {
44 return default;40 return default;
45 }41 },
46 }42 }
47}43}
4844
49
50pub const ClientRequest = extern enum {45pub const ClientRequest = extern enum {
51 RunningOnValgrind = 4097,46 RunningOnValgrind = 4097,
52 DiscardTranslations = 4098,47 DiscardTranslations = 4098,
...@@ -81,59 +76,39 @@ pub const ClientRequest = extern enum {...@@ -81,59 +76,39 @@ pub const ClientRequest = extern enum {
81 InnerThreads = 6402,76 InnerThreads = 6402,
82};77};
83pub fn ToolBase(base: [2]u8) u32 {78pub fn ToolBase(base: [2]u8) u32 {
84 return (u32(base[0]&0xff) << 24) | (u32(base[1]&0xff) << 16);79 return (u32(base[0] & 0xff) << 24) | (u32(base[1] & 0xff) << 16);
85}80}
86pub fn IsTool(base: [2]u8, code: usize) bool {81pub fn IsTool(base: [2]u8, code: usize) bool {
87 return ToolBase(base) == (code & 0xffff0000);82 return ToolBase(base) == (code & 0xffff0000);
88}83}
8984
90fn doClientRequestExpr(default: usize, request: ClientRequest,85fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
91 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize86 return doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
92 ) usize
93{
94 return doClientRequest(
95 default,
96 @intCast(usize, @enumToInt(request)),
97 a1, a2, a3, a4, a5);
98}87}
9988
100fn doClientRequestStmt(request: ClientRequest,89fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void {
101 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
102 ) void
103{
104 _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5);90 _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5);
105}91}
10692
107
108
109/// Returns the number of Valgrinds this code is running under. That93/// Returns the number of Valgrinds this code is running under. That
110/// is, 0 if running natively, 1 if running under Valgrind, 2 if94/// is, 0 if running natively, 1 if running under Valgrind, 2 if
111/// running under Valgrind which is running under another Valgrind,95/// running under Valgrind which is running under another Valgrind,
112/// etc.96/// etc.
113pub fn runningOnValgrind() usize {97pub fn runningOnValgrind() usize {
114 return doClientRequestExpr(0,98 return doClientRequestExpr(0, ClientRequest.RunningOnValgrind, 0, 0, 0, 0, 0);
115 ClientRequest.RunningOnValgrind,
116 0, 0, 0, 0, 0);
117}99}
118100
119
120/// Discard translation of code in the slice qzz. Useful if you are debugging101/// Discard translation of code in the slice qzz. Useful if you are debugging
121/// a JITter or some such, since it provides a way to make sure valgrind will102/// a JITter or some such, since it provides a way to make sure valgrind will
122/// retranslate the invalidated area. Returns no value.103/// retranslate the invalidated area. Returns no value.
123pub fn discardTranslations(qzz: []const u8) void {104pub fn discardTranslations(qzz: []const u8) void {
124 doClientRequestStmt(ClientRequest.DiscardTranslations,105 doClientRequestStmt(ClientRequest.DiscardTranslations, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
125 @ptrToInt(qzz.ptr), qzz.len,
126 0, 0, 0);
127}106}
128107
129
130pub fn innerThreads(qzz: [*]u8) void {108pub fn innerThreads(qzz: [*]u8) void {
131 doClientRequestStmt(ClientRequest.InnerThreads,109 doClientRequestStmt(ClientRequest.InnerThreads, qzz, 0, 0, 0, 0);
132 qzz,
133 0, 0, 0, 0);
134}110}
135111
136
137//pub fn printf(format: [*]const u8, args: ...) usize {112//pub fn printf(format: [*]const u8, args: ...) usize {
138// return doClientRequestExpr(0,113// return doClientRequestExpr(0,
139// ClientRequest.PrintfValistByRef,114// ClientRequest.PrintfValistByRef,
...@@ -141,7 +116,6 @@ pub fn innerThreads(qzz: [*]u8) void {...@@ -141,7 +116,6 @@ pub fn innerThreads(qzz: [*]u8) void {
141// 0, 0, 0);116// 0, 0, 0);
142//}117//}
143118
144
145//pub fn printfBacktrace(format: [*]const u8, args: ...) usize {119//pub fn printfBacktrace(format: [*]const u8, args: ...) usize {
146// return doClientRequestExpr(0,120// return doClientRequestExpr(0,
147// ClientRequest.PrintfBacktraceValistByRef,121// ClientRequest.PrintfBacktraceValistByRef,
...@@ -149,161 +123,105 @@ pub fn innerThreads(qzz: [*]u8) void {...@@ -149,161 +123,105 @@ pub fn innerThreads(qzz: [*]u8) void {
149// 0, 0, 0);123// 0, 0, 0);
150//}124//}
151125
152126pub fn nonSIMDCall0(func: fn (usize) usize) usize {
153pub fn nonSIMDCall0(func: fn(usize) usize) usize {127 return doClientRequestExpr(0, ClientRequest.ClientCall0, @ptrToInt(func), 0, 0, 0, 0);
154 return doClientRequestExpr(0,
155 ClientRequest.ClientCall0,
156 @ptrToInt(func),
157 0, 0, 0, 0);
158}128}
159129
160pub fn nonSIMDCall1(func: fn(usize, usize) usize, a1: usize) usize {130pub fn nonSIMDCall1(func: fn (usize, usize) usize, a1: usize) usize {
161 return doClientRequestExpr(0,131 return doClientRequestExpr(0, ClientRequest.ClientCall1, @ptrToInt(func), a1, 0, 0, 0);
162 ClientRequest.ClientCall1,
163 @ptrToInt(func), a1,
164 0, 0, 0);
165}132}
166133
167pub fn nonSIMDCall2(func: fn(usize, usize, usize) usize,134pub fn nonSIMDCall2(func: fn (usize, usize, usize) usize, a1: usize, a2: usize) usize {
168 a1: usize, a2: usize) usize135 return doClientRequestExpr(0, ClientRequest.ClientCall2, @ptrToInt(func), a1, a2, 0, 0);
169{
170 return doClientRequestExpr(0,
171 ClientRequest.ClientCall2,
172 @ptrToInt(func), a1, a2,
173 0, 0);
174}136}
175137
176pub fn nonSIMDCall3(func: fn(usize, usize, usize, usize) usize,138pub fn nonSIMDCall3(func: fn (usize, usize, usize, usize) usize, a1: usize, a2: usize, a3: usize) usize {
177 a1: usize, a2: usize, a3: usize) usize139 return doClientRequestExpr(0, ClientRequest.ClientCall3, @ptrToInt(func), a1, a2, a3, 0);
178{
179 return doClientRequestExpr(0,
180 ClientRequest.ClientCall3,
181 @ptrToInt(func), a1, a2, a3,
182 0);
183}140}
184141
185
186/// Counts the number of errors that have been recorded by a tool. Nb:142/// Counts the number of errors that have been recorded by a tool. Nb:
187/// the tool must record the errors with VG_(maybe_record_error)() or143/// the tool must record the errors with VG_(maybe_record_error)() or
188/// VG_(unique_error)() for them to be counted.144/// VG_(unique_error)() for them to be counted.
189pub fn countErrors() usize {145pub fn countErrors() usize {
190 return doClientRequestExpr(0, // default return146 return doClientRequestExpr(0, // default return
191 ClientRequest.CountErrors,147 ClientRequest.CountErrors, 0, 0, 0, 0, 0);
192 0, 0, 0, 0, 0);
193}148}
194149
195
196pub fn mallocLikeBlock(mem: []u8, rzB: usize, is_zeroed: bool) void {150pub fn mallocLikeBlock(mem: []u8, rzB: usize, is_zeroed: bool) void {
197 doClientRequestStmt(ClientRequest.MalloclikeBlock,151 doClientRequestStmt(ClientRequest.MalloclikeBlock, @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed), 0);
198 @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed),
199 0);
200}152}
201153
202
203pub fn resizeInPlaceBlock(oldmem: []u8, newsize: usize, rzB: usize) void {154pub fn resizeInPlaceBlock(oldmem: []u8, newsize: usize, rzB: usize) void {
204 doClientRequestStmt(ClientRequest.ResizeinplaceBlock,155 doClientRequestStmt(ClientRequest.ResizeinplaceBlock, @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB, 0);
205 @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB,
206 0);
207}156}
208157
209
210pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void {158pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void {
211 doClientRequestStmt(ClientRequest.FreelikeBlock,159 doClientRequestStmt(ClientRequest.FreelikeBlock, @ptrToInt(addr), rzB, 0, 0, 0);
212 @ptrToInt(addr), rzB,
213 0, 0, 0);
214}160}
215161
216
217/// Create a memory pool.162/// Create a memory pool.
218pub const MempoolFlags = extern enum {163pub const MempoolFlags = extern enum {
219 AutoFree = 1,164 AutoFree = 1,
220 MetaPool = 2,165 MetaPool = 2,
221};166};
222pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void {167pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void {
223 doClientRequestStmt(ClientRequest.CreateMempool,168 doClientRequestStmt(ClientRequest.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0);
224 @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags,
225 0);
226}169}
227170
228/// Destroy a memory pool.171/// Destroy a memory pool.
229pub fn destroyMempool(pool: [*]u8) void {172pub fn destroyMempool(pool: [*]u8) void {
230 doClientRequestStmt(ClientRequest.DestroyMempool,173 doClientRequestStmt(ClientRequest.DestroyMempool, pool, 0, 0, 0, 0);
231 pool,
232 0, 0, 0, 0);
233}174}
234175
235
236/// Associate a piece of memory with a memory pool.176/// Associate a piece of memory with a memory pool.
237pub fn mempoolAlloc(pool: [*]u8, mem: []u8) void {177pub fn mempoolAlloc(pool: [*]u8, mem: []u8) void {
238 doClientRequestStmt(ClientRequest.MempoolAlloc,178 doClientRequestStmt(ClientRequest.MempoolAlloc, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0);
239 @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len,
240 0, 0);
241}179}
242180
243/// Disassociate a piece of memory from a memory pool.181/// Disassociate a piece of memory from a memory pool.
244pub fn mempoolFree(pool: [*]u8, addr: [*]u8) void {182pub fn mempoolFree(pool: [*]u8, addr: [*]u8) void {
245 doClientRequestStmt(ClientRequest.MempoolFree,183 doClientRequestStmt(ClientRequest.MempoolFree, @ptrToInt(pool), @ptrToInt(addr), 0, 0, 0);
246 @ptrToInt(pool), @ptrToInt(addr),
247 0, 0, 0);
248}184}
249185
250/// Disassociate any pieces outside a particular range.186/// Disassociate any pieces outside a particular range.
251pub fn mempoolTrim(pool: [*]u8, mem: []u8) void {187pub fn mempoolTrim(pool: [*]u8, mem: []u8) void {
252 doClientRequestStmt(ClientRequest.MempoolTrim,188 doClientRequestStmt(ClientRequest.MempoolTrim, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0);
253 @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len,
254 0, 0);
255}189}
256190
257/// Resize and/or move a piece associated with a memory pool.191/// Resize and/or move a piece associated with a memory pool.
258pub fn moveMempool(poolA: [*]u8, poolB: [*]u8) void {192pub fn moveMempool(poolA: [*]u8, poolB: [*]u8) void {
259 doClientRequestStmt(ClientRequest.MoveMempool,193 doClientRequestStmt(ClientRequest.MoveMempool, @ptrToInt(poolA), @ptrToInt(poolB), 0, 0, 0);
260 @ptrToInt(poolA), @ptrToInt(poolB),
261 0, 0, 0);
262}194}
263195
264/// Resize and/or move a piece associated with a memory pool.196/// Resize and/or move a piece associated with a memory pool.
265pub fn mempoolChange(pool: [*]u8, addrA: [*]u8, mem: []u8) void {197pub fn mempoolChange(pool: [*]u8, addrA: [*]u8, mem: []u8) void {
266 doClientRequestStmt(ClientRequest.MempoolChange,198 doClientRequestStmt(ClientRequest.MempoolChange, @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len, 0);
267 @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len,
268 0);
269}199}
270200
271/// Return if a mempool exists.201/// Return if a mempool exists.
272pub fn mempoolExists(pool: [*]u8) bool {202pub fn mempoolExists(pool: [*]u8) bool {
273 return doClientRequestExpr(0,203 return doClientRequestExpr(0, ClientRequest.MempoolExists, @ptrToInt(pool), 0, 0, 0, 0) != 0;
274 ClientRequest.MempoolExists,
275 @ptrToInt(pool),
276 0, 0, 0, 0) != 0;
277}204}
278205
279
280/// Mark a piece of memory as being a stack. Returns a stack id.206/// Mark a piece of memory as being a stack. Returns a stack id.
281/// start is the lowest addressable stack byte, end is the highest207/// start is the lowest addressable stack byte, end is the highest
282/// addressable stack byte.208/// addressable stack byte.
283pub fn stackRegister(stack: []u8) usize {209pub fn stackRegister(stack: []u8) usize {
284 return doClientRequestExpr(0,210 return doClientRequestExpr(0, ClientRequest.StackRegister, @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len, 0, 0, 0);
285 ClientRequest.StackRegister,
286 @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len,
287 0, 0, 0);
288}211}
289212
290/// Unmark the piece of memory associated with a stack id as being a stack.213/// Unmark the piece of memory associated with a stack id as being a stack.
291pub fn stackDeregister(id: usize) void {214pub fn stackDeregister(id: usize) void {
292 doClientRequestStmt(ClientRequest.StackDeregister,215 doClientRequestStmt(ClientRequest.StackDeregister, id, 0, 0, 0, 0);
293 id,
294 0, 0, 0, 0);
295}216}
296217
297/// Change the start and end address of the stack id.218/// Change the start and end address of the stack id.
298/// start is the new lowest addressable stack byte, end is the new highest219/// start is the new lowest addressable stack byte, end is the new highest
299/// addressable stack byte.220/// addressable stack byte.
300pub fn stackChange(id: usize, newstack: []u8) void {221pub fn stackChange(id: usize, newstack: []u8) void {
301 doClientRequestStmt(ClientRequest.StackChange,222 doClientRequestStmt(ClientRequest.StackChange, id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len, 0, 0);
302 id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len,
303 0, 0);
304}223}
305224
306
307// Load PDB debug info for Wine PE image_map.225// Load PDB debug info for Wine PE image_map.
308// pub fn loadPdbDebuginfo(fd, ptr, total_size, delta) void {226// pub fn loadPdbDebuginfo(fd, ptr, total_size, delta) void {
309// doClientRequestStmt(ClientRequest.LoadPdbDebuginfo,227// doClientRequestStmt(ClientRequest.LoadPdbDebuginfo,
...@@ -311,19 +229,14 @@ pub fn stackChange(id: usize, newstack: []u8) void {...@@ -311,19 +229,14 @@ pub fn stackChange(id: usize, newstack: []u8) void {
311// 0);229// 0);
312// }230// }
313231
314
315/// Map a code address to a source file name and line number. buf64232/// Map a code address to a source file name and line number. buf64
316/// must point to a 64-byte buffer in the caller's address space. The233/// must point to a 64-byte buffer in the caller's address space. The
317/// result will be dumped in there and is guaranteed to be zero234/// result will be dumped in there and is guaranteed to be zero
318/// terminated. If no info is found, the first byte is set to zero.235/// terminated. If no info is found, the first byte is set to zero.
319pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {236pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {
320 return doClientRequestExpr(0,237 return doClientRequestExpr(0, ClientRequest.MapIpToSrcloc, @ptrToInt(addr), @ptrToInt(&buf64[0]), 0, 0, 0);
321 ClientRequest.MapIpToSrcloc,
322 @ptrToInt(addr), @ptrToInt(&buf64[0]),
323 0, 0, 0);
324}238}
325239
326
327/// Disable error reporting for this thread. Behaves in a stack like240/// Disable error reporting for this thread. Behaves in a stack like
328/// way, so you can safely call this multiple times provided that241/// way, so you can safely call this multiple times provided that
329/// enableErrorReporting() is called the same number of times242/// enableErrorReporting() is called the same number of times
...@@ -333,31 +246,22 @@ pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {...@@ -333,31 +246,22 @@ pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {
333/// reporting. Child threads do not inherit this setting from their246/// reporting. Child threads do not inherit this setting from their
334/// parents -- they are always created with reporting enabled.247/// parents -- they are always created with reporting enabled.
335pub fn disableErrorReporting() void {248pub fn disableErrorReporting() void {
336 doClientRequestStmt(ClientRequest.ChangeErrDisablement,249 doClientRequestStmt(ClientRequest.ChangeErrDisablement, 1, 0, 0, 0, 0);
337 1,
338 0, 0, 0, 0);
339}250}
340251
341/// Re-enable error reporting, (see disableErrorReporting())252/// Re-enable error reporting, (see disableErrorReporting())
342pub fn enableErrorReporting() void {253pub fn enableErrorReporting() void {
343 doClientRequestStmt(ClientRequest.ChangeErrDisablement,254 doClientRequestStmt(ClientRequest.ChangeErrDisablement, math.maxInt(usize), 0, 0, 0, 0);
344 math.maxInt(usize),
345 0, 0, 0, 0);
346}255}
347256
348
349/// Execute a monitor command from the client program.257/// Execute a monitor command from the client program.
350/// If a connection is opened with GDB, the output will be sent258/// If a connection is opened with GDB, the output will be sent
351/// according to the output mode set for vgdb.259/// according to the output mode set for vgdb.
352/// If no connection is opened, output will go to the log output.260/// If no connection is opened, output will go to the log output.
353/// Returns 1 if command not recognised, 0 otherwise.261/// Returns 1 if command not recognised, 0 otherwise.
354pub fn monitorCommand(command: [*]u8) bool {262pub fn monitorCommand(command: [*]u8) bool {
355 return doClientRequestExpr(0,263 return doClientRequestExpr(0, ClientRequest.GdbMonitorCommand, @ptrToInt(command.ptr), 0, 0, 0, 0) != 0;
356 ClientRequest.GdbMonitorCommand,
357 @ptrToInt(command.ptr),
358 0, 0, 0, 0) != 0;
359}264}
360265
361
362pub const memcheck = @import("memcheck.zig");266pub const memcheck = @import("memcheck.zig");
363pub const callgrind = @import("callgrind.zig");267pub const callgrind = @import("callgrind.zig");
std/zig.zig-1
...@@ -13,4 +13,3 @@ test "std.zig tests" {...@@ -13,4 +13,3 @@ test "std.zig tests" {
13 _ = @import("zig/tokenizer.zig");13 _ = @import("zig/tokenizer.zig");
14 _ = @import("zig/parse_string_literal.zig");14 _ = @import("zig/parse_string_literal.zig");
15}15}
16