authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 13:51:09-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 13:53:13-05:00
logbdf3680be1b39f4a92370817ef0a7e8a9fdaa373
treeaf5df2c88b930db263f3b20ce5f4fdae42f0a10c
parent8a4c2d3b07751507830416e29d6f7d6a023cd483
signaturelock-open Commit is signed but in an unrecognized format.

zig fmt


15 files changed, 58 insertions(+), 22 deletions(-)

lib/std/array_list.zig+1-1
...@@ -58,7 +58,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -58,7 +58,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
58 return self.items[0..self.len];58 return self.items[0..self.len];
59 }59 }
6060
61 /// Safely access index i of the list. 61 /// Safely access index i of the list.
62 pub fn at(self: Self, i: usize) T {62 pub fn at(self: Self, i: usize) T {
63 return self.toSliceConst()[i];63 return self.toSliceConst()[i];
64 }64 }
lib/std/builtin.zig+2
...@@ -144,6 +144,7 @@ pub const TypeInfo = union(enum) {...@@ -144,6 +144,7 @@ pub const TypeInfo = union(enum) {
144 alignment: comptime_int,144 alignment: comptime_int,
145 child: type,145 child: type,
146 is_allowzero: bool,146 is_allowzero: bool,
147
147 /// The type of the sentinel is the element type of the pointer, which is148 /// The type of the sentinel is the element type of the pointer, which is
148 /// the value of the `child` field in this struct. However there is no way149 /// the value of the `child` field in this struct. However there is no way
149 /// to refer to that type here, so we use `var`.150 /// to refer to that type here, so we use `var`.
...@@ -164,6 +165,7 @@ pub const TypeInfo = union(enum) {...@@ -164,6 +165,7 @@ pub const TypeInfo = union(enum) {
164 pub const Array = struct {165 pub const Array = struct {
165 len: comptime_int,166 len: comptime_int,
166 child: type,167 child: type,
168
167 /// The type of the sentinel is the element type of the array, which is169 /// The type of the sentinel is the element type of the array, which is
168 /// the value of the `child` field in this struct. However there is no way170 /// the value of the `child` field in this struct. However there is no way
169 /// to refer to that type here, so we use `var`.171 /// to refer to that type here, so we use `var`.
lib/std/child_process.zig+1-1
...@@ -259,7 +259,7 @@ pub const ChildProcess = struct {...@@ -259,7 +259,7 @@ pub const ChildProcess = struct {
259 }259 }
260260
261 fn handleWaitResult(self: *ChildProcess, status: u32) void {261 fn handleWaitResult(self: *ChildProcess, status: u32) void {
262 // TODO https://github.com/ziglang/zig/issues/3190 262 // TODO https://github.com/ziglang/zig/issues/3190
263 var term = self.cleanupAfterWait(status);263 var term = self.cleanupAfterWait(status);
264 self.term = term;264 self.term = term;
265 }265 }
lib/std/debug/failing_allocator.zig+2-2
...@@ -5,10 +5,10 @@ const mem = std.mem;...@@ -5,10 +5,10 @@ const mem = std.mem;
5/// memory conditions are handled correctly.5/// memory conditions are handled correctly.
6///6///
7/// To use this, first initialize it and get an allocator with7/// To use this, first initialize it and get an allocator with
8/// 8///
9/// `const failing_allocator = &FailingAllocator.init(<allocator>,9/// `const failing_allocator = &FailingAllocator.init(<allocator>,
10/// <fail_index>).allocator;`10/// <fail_index>).allocator;`
11/// 11///
12/// Then use `failing_allocator` anywhere you would have used a12/// Then use `failing_allocator` anywhere you would have used a
13/// different allocator.13/// different allocator.
14pub const FailingAllocator = struct {14pub const FailingAllocator = struct {
lib/std/event/fs.zig+1-1
...@@ -1266,7 +1266,7 @@ pub fn Watch(comptime V: type) type {...@@ -1266,7 +1266,7 @@ pub fn Watch(comptime V: type) type {
1266 if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) {1266 if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) {
1267 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);1267 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);
1268 // `ev.len` counts all bytes in `ev.name` including terminating null byte.1268 // `ev.len` counts all bytes in `ev.name` including terminating null byte.
1269 const basename_with_null = basename_ptr[0 .. ev.len];1269 const basename_with_null = basename_ptr[0..ev.len];
1270 const user_value = blk: {1270 const user_value = blk: {
1271 const held = self.os_data.table_lock.acquire();1271 const held = self.os_data.table_lock.acquire();
1272 defer held.release();1272 defer held.release();
lib/std/fifo.zig+1-1
...@@ -148,7 +148,7 @@ pub fn LinearFifo(...@@ -148,7 +148,7 @@ pub fn LinearFifo(
148 var start = self.head + offset;148 var start = self.head + offset;
149 if (start >= self.buf.len) {149 if (start >= self.buf.len) {
150 start -= self.buf.len;150 start -= self.buf.len;
151 return self.buf[start..self.count - offset];151 return self.buf[start .. self.count - offset];
152 } else {152 } else {
153 const end = math.min(self.head + self.count, self.buf.len);153 const end = math.min(self.head + self.count, self.buf.len);
154 return self.buf[start..end];154 return self.buf[start..end];
lib/std/mutex.zig+2-2
...@@ -74,7 +74,7 @@ else...@@ -74,7 +74,7 @@ else
74 pub fn release(self: Held) void {74 pub fn release(self: Held) void {
75 switch (@atomicRmw(State, &self.mutex.state, .Xchg, .Unlocked, .Release)) {75 switch (@atomicRmw(State, &self.mutex.state, .Xchg, .Unlocked, .Release)) {
76 .Locked => {},76 .Locked => {},
77 .Sleeping => self.mutex.parker.unpark(@ptrCast(*const u32, &self.mutex.state)),77 .Sleeping => self.mutex.parker.unpark(@ptrCast(*const u32, &self.mutex.state)),
78 .Unlocked => unreachable, // unlocking an unlocked mutex78 .Unlocked => unreachable, // unlocking an unlocked mutex
79 else => unreachable, // should never be anything else79 else => unreachable, // should never be anything else
80 }80 }
...@@ -112,7 +112,7 @@ else...@@ -112,7 +112,7 @@ else
112 if (@atomicRmw(State, &self.state, .Xchg, .Sleeping, .Acquire) == .Unlocked)112 if (@atomicRmw(State, &self.state, .Xchg, .Sleeping, .Acquire) == .Unlocked)
113 return Held{ .mutex = self };113 return Held{ .mutex = self };
114 state = .Sleeping;114 state = .Sleeping;
115 self.parker.park(@ptrCast(*const u32, &self.state), @enumToInt(State.Sleeping));115 self.parker.park(@ptrCast(*const u32, &self.state), @enumToInt(State.Sleeping));
116 }116 }
117 }117 }
118 };118 };
lib/std/net.zig+1-1
...@@ -1362,7 +1362,7 @@ pub const StreamServer = struct {...@@ -1362,7 +1362,7 @@ pub const StreamServer = struct {
13621362
1363 pub const Connection = struct {1363 pub const Connection = struct {
1364 file: fs.File,1364 file: fs.File,
1365 address: Address1365 address: Address,
1366 };1366 };
13671367
1368 /// If this function succeeds, the returned `Connection` is a caller-managed resource.1368 /// If this function succeeds, the returned `Connection` is a caller-managed resource.
lib/std/os.zig+2-2
...@@ -2753,8 +2753,8 @@ pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {...@@ -2753,8 +2753,8 @@ pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {
27532753
2754/// Used to convert a slice to a null terminated slice on the stack.2754/// Used to convert a slice to a null terminated slice on the stack.
2755/// TODO https://github.com/ziglang/zig/issues/2872755/// TODO https://github.com/ziglang/zig/issues/287
2756pub fn toPosixPath(file_path: []const u8) ![PATH_MAX-1:0]u8 {2756pub fn toPosixPath(file_path: []const u8) ![PATH_MAX - 1:0]u8 {
2757 var path_with_null: [PATH_MAX-1:0]u8 = undefined;2757 var path_with_null: [PATH_MAX - 1:0]u8 = undefined;
2758 // >= rather than > to make room for the null byte2758 // >= rather than > to make room for the null byte
2759 if (file_path.len >= PATH_MAX) return error.NameTooLong;2759 if (file_path.len >= PATH_MAX) return error.NameTooLong;
2760 mem.copy(u8, &path_with_null, file_path);2760 mem.copy(u8, &path_with_null, file_path);
lib/std/os/bits/linux.zig-1
...@@ -1124,7 +1124,6 @@ pub const io_uring_params = extern struct {...@@ -1124,7 +1124,6 @@ pub const io_uring_params = extern struct {
11241124
1125pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;1125pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
11261126
1127
1128// io_uring_params.flags1127// io_uring_params.flags
11291128
1130/// io_context is polled1129/// io_context is polled
lib/std/os/uefi/protocols/hii.zig+1
...@@ -26,6 +26,7 @@ pub const HIIPackageHeader = packed struct {...@@ -26,6 +26,7 @@ pub const HIIPackageHeader = packed struct {
26/// The header found at the start of each package list.26/// The header found at the start of each package list.
27pub const HIIPackageList = extern struct {27pub const HIIPackageList = extern struct {
28 package_list_guid: Guid,28 package_list_guid: Guid,
29
29 /// The size of the package list (in bytes), including the header.30 /// The size of the package list (in bytes), including the header.
30 package_list_length: u32,31 package_list_length: u32,
3132
lib/std/os/uefi/status.zig+38
...@@ -5,82 +5,120 @@ pub const success: usize = 0;...@@ -5,82 +5,120 @@ pub const success: usize = 0;
55
6/// The image failed to load.6/// The image failed to load.
7pub const load_error: usize = high_bit | 1;7pub const load_error: usize = high_bit | 1;
8
8/// A parameter was incorrect.9/// A parameter was incorrect.
9pub const invalid_parameter: usize = high_bit | 2;10pub const invalid_parameter: usize = high_bit | 2;
11
10/// The operation is not supported.12/// The operation is not supported.
11pub const unsupported: usize = high_bit | 3;13pub const unsupported: usize = high_bit | 3;
14
12/// The buffer was not the proper size for the request.15/// The buffer was not the proper size for the request.
13pub const bad_buffer_size: usize = high_bit | 4;16pub const bad_buffer_size: usize = high_bit | 4;
17
14/// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.18/// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.
15pub const buffer_too_small: usize = high_bit | 5;19pub const buffer_too_small: usize = high_bit | 5;
20
16/// There is no data pending upon return.21/// There is no data pending upon return.
17pub const not_ready: usize = high_bit | 6;22pub const not_ready: usize = high_bit | 6;
23
18/// The physical device reported an error while attempting the operation.24/// The physical device reported an error while attempting the operation.
19pub const device_error: usize = high_bit | 7;25pub const device_error: usize = high_bit | 7;
26
20/// The device cannot be written to.27/// The device cannot be written to.
21pub const write_protected: usize = high_bit | 8;28pub const write_protected: usize = high_bit | 8;
29
22/// A resource has run out.30/// A resource has run out.
23pub const out_of_resources: usize = high_bit | 9;31pub const out_of_resources: usize = high_bit | 9;
32
24/// An inconstancy was detected on the file system causing the operating to fail.33/// An inconstancy was detected on the file system causing the operating to fail.
25pub const volume_corrupted: usize = high_bit | 10;34pub const volume_corrupted: usize = high_bit | 10;
35
26/// There is no more space on the file system.36/// There is no more space on the file system.
27pub const volume_full: usize = high_bit | 11;37pub const volume_full: usize = high_bit | 11;
38
28/// The device does not contain any medium to perform the operation.39/// The device does not contain any medium to perform the operation.
29pub const no_media: usize = high_bit | 12;40pub const no_media: usize = high_bit | 12;
41
30/// The medium in the device has changed since the last access.42/// The medium in the device has changed since the last access.
31pub const media_changed: usize = high_bit | 13;43pub const media_changed: usize = high_bit | 13;
44
32/// The item was not found.45/// The item was not found.
33pub const not_found: usize = high_bit | 14;46pub const not_found: usize = high_bit | 14;
47
34/// Access was denied.48/// Access was denied.
35pub const access_denied: usize = high_bit | 15;49pub const access_denied: usize = high_bit | 15;
50
36/// The server was not found or did not respond to the request.51/// The server was not found or did not respond to the request.
37pub const no_response: usize = high_bit | 16;52pub const no_response: usize = high_bit | 16;
53
38/// A mapping to a device does not exist.54/// A mapping to a device does not exist.
39pub const no_mapping: usize = high_bit | 17;55pub const no_mapping: usize = high_bit | 17;
56
40/// The timeout time expired.57/// The timeout time expired.
41pub const timeout: usize = high_bit | 18;58pub const timeout: usize = high_bit | 18;
59
42/// The protocol has not been started.60/// The protocol has not been started.
43pub const not_started: usize = high_bit | 19;61pub const not_started: usize = high_bit | 19;
62
44/// The protocol has already been started.63/// The protocol has already been started.
45pub const already_started: usize = high_bit | 20;64pub const already_started: usize = high_bit | 20;
65
46/// The operation was aborted.66/// The operation was aborted.
47pub const aborted: usize = high_bit | 21;67pub const aborted: usize = high_bit | 21;
68
48/// An ICMP error occurred during the network operation.69/// An ICMP error occurred during the network operation.
49pub const icmp_error: usize = high_bit | 22;70pub const icmp_error: usize = high_bit | 22;
71
50/// A TFTP error occurred during the network operation.72/// A TFTP error occurred during the network operation.
51pub const tftp_error: usize = high_bit | 23;73pub const tftp_error: usize = high_bit | 23;
74
52/// A protocol error occurred during the network operation.75/// A protocol error occurred during the network operation.
53pub const protocol_error: usize = high_bit | 24;76pub const protocol_error: usize = high_bit | 24;
77
54/// The function encountered an internal version that was incompatible with a version requested by the caller.78/// The function encountered an internal version that was incompatible with a version requested by the caller.
55pub const incompatible_version: usize = high_bit | 25;79pub const incompatible_version: usize = high_bit | 25;
80
56/// The function was not performed due to a security violation.81/// The function was not performed due to a security violation.
57pub const security_violation: usize = high_bit | 26;82pub const security_violation: usize = high_bit | 26;
83
58/// A CRC error was detected.84/// A CRC error was detected.
59pub const crc_error: usize = high_bit | 27;85pub const crc_error: usize = high_bit | 27;
86
60/// Beginning or end of media was reached87/// Beginning or end of media was reached
61pub const end_of_media: usize = high_bit | 28;88pub const end_of_media: usize = high_bit | 28;
89
62/// The end of the file was reached.90/// The end of the file was reached.
63pub const end_of_file: usize = high_bit | 31;91pub const end_of_file: usize = high_bit | 31;
92
64/// The language specified was invalid.93/// The language specified was invalid.
65pub const invalid_language: usize = high_bit | 32;94pub const invalid_language: usize = high_bit | 32;
95
66/// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.96/// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
67pub const compromised_data: usize = high_bit | 33;97pub const compromised_data: usize = high_bit | 33;
98
68/// There is an address conflict address allocation99/// There is an address conflict address allocation
69pub const ip_address_conflict: usize = high_bit | 34;100pub const ip_address_conflict: usize = high_bit | 34;
101
70/// A HTTP error occurred during the network operation.102/// A HTTP error occurred during the network operation.
71pub const http_error: usize = high_bit | 35;103pub const http_error: usize = high_bit | 35;
72104
73/// The string contained one or more characters that the device could not render and were skipped.105/// The string contained one or more characters that the device could not render and were skipped.
74pub const warn_unknown_glyph: usize = 1;106pub const warn_unknown_glyph: usize = 1;
107
75/// The handle was closed, but the file was not deleted.108/// The handle was closed, but the file was not deleted.
76pub const warn_delete_failure: usize = 2;109pub const warn_delete_failure: usize = 2;
110
77/// The handle was closed, but the data to the file was not flushed properly.111/// The handle was closed, but the data to the file was not flushed properly.
78pub const warn_write_failure: usize = 3;112pub const warn_write_failure: usize = 3;
113
79/// The resulting buffer was too small, and the data was truncated to the buffer size.114/// The resulting buffer was too small, and the data was truncated to the buffer size.
80pub const warn_buffer_too_small: usize = 4;115pub const warn_buffer_too_small: usize = 4;
116
81/// The data has not been updated within the timeframe set by localpolicy for this type of data.117/// The data has not been updated within the timeframe set by localpolicy for this type of data.
82pub const warn_stale_data: usize = 5;118pub const warn_stale_data: usize = 5;
119
83/// The resulting buffer contains UEFI-compliant file system.120/// The resulting buffer contains UEFI-compliant file system.
84pub const warn_file_system: usize = 6;121pub const warn_file_system: usize = 6;
122
85/// The operation will be processed across a system reset.123/// The operation will be processed across a system reset.
86pub const warn_reset_required: usize = 7;124pub const warn_reset_required: usize = 7;
lib/std/os/uefi/tables/table_header.zig+1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1pub const TableHeader = extern struct {1pub const TableHeader = extern struct {
2 signature: u64,2 signature: u64,
3 revision: u32,3 revision: u32,
4
4 /// The size, in bytes, of the entire table including the TableHeader5 /// The size, in bytes, of the entire table including the TableHeader
5 header_size: u32,6 header_size: u32,
6 crc32: u32,7 crc32: u32,
lib/std/os/windows.zig+2-3
...@@ -192,7 +192,7 @@ pub const FindFirstFileError = error{...@@ -192,7 +192,7 @@ pub const FindFirstFileError = error{
192};192};
193193
194pub fn FindFirstFile(dir_path: []const u8, find_file_data: *WIN32_FIND_DATAW) FindFirstFileError!HANDLE {194pub fn FindFirstFile(dir_path: []const u8, find_file_data: *WIN32_FIND_DATAW) FindFirstFileError!HANDLE {
195 const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, [_]u16{ '\\', '*'});195 const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, [_]u16{ '\\', '*' });
196 const handle = kernel32.FindFirstFileW(&dir_path_w, find_file_data);196 const handle = kernel32.FindFirstFileW(&dir_path_w, find_file_data);
197197
198 if (handle == INVALID_HANDLE_VALUE) {198 if (handle == INVALID_HANDLE_VALUE) {
...@@ -932,7 +932,7 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {...@@ -932,7 +932,7 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
932 // TODO https://github.com/ziglang/zig/issues/2765932 // TODO https://github.com/ziglang/zig/issues/2765
933 var result: [PATH_MAX_WIDE:0]u16 = undefined;933 var result: [PATH_MAX_WIDE:0]u16 = undefined;
934934
935 const start_index = if (mem.startsWith(u16, s, [_]u16{'\\', '?'})) 0 else blk: {935 const start_index = if (mem.startsWith(u16, s, [_]u16{ '\\', '?' })) 0 else blk: {
936 const prefix = [_]u16{ '\\', '?', '?', '\\' };936 const prefix = [_]u16{ '\\', '?', '?', '\\' };
937 mem.copy(u16, result[0..], prefix);937 mem.copy(u16, result[0..], prefix);
938 break :blk prefix.len;938 break :blk prefix.len;
...@@ -942,7 +942,6 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {...@@ -942,7 +942,6 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
942 mem.copy(u16, result[start_index..], s);942 mem.copy(u16, result[start_index..], s);
943 result[end_index] = 0;943 result[end_index] = 0;
944 return result;944 return result;
945
946}945}
947946
948pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16) ![PATH_MAX_WIDE + suffix.len:0]u16 {947pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16) ![PATH_MAX_WIDE + suffix.len:0]u16 {
lib/std/os/windows/ws2_32.zig+3-7
...@@ -106,12 +106,7 @@ pub const WSAOVERLAPPED = extern struct {...@@ -106,12 +106,7 @@ pub const WSAOVERLAPPED = extern struct {
106 hEvent: ?WSAEVENT,106 hEvent: ?WSAEVENT,
107};107};
108108
109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void;
110 dwError: DWORD,
111 cbTransferred: DWORD,
112 lpOverlapped: *WSAOVERLAPPED,
113 dwFlags: DWORD
114) void;
115110
116pub const WSA_INVALID_HANDLE = 6;111pub const WSA_INVALID_HANDLE = 6;
117pub const WSA_NOT_ENOUGH_MEMORY = 8;112pub const WSA_NOT_ENOUGH_MEMORY = 8;
...@@ -209,11 +204,12 @@ pub const WSA_QOS_ESDMODEOBJ = 11029;...@@ -209,11 +204,12 @@ pub const WSA_QOS_ESDMODEOBJ = 11029;
209pub const WSA_QOS_ESHAPERATEOBJ = 11030;204pub const WSA_QOS_ESHAPERATEOBJ = 11030;
210pub const WSA_QOS_RESERVED_PETYPE = 11031;205pub const WSA_QOS_RESERVED_PETYPE = 11031;
211206
212
213/// no parameters207/// no parameters
214const IOC_VOID = 0x80000000;208const IOC_VOID = 0x80000000;
209
215/// copy out parameters210/// copy out parameters
216const IOC_OUT = 0x40000000;211const IOC_OUT = 0x40000000;
212
217/// copy in parameters213/// copy in parameters
218const IOC_IN = 0x80000000;214const IOC_IN = 0x80000000;
219215