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 {
5858 return self.items[0..self.len];
5959 }
6060
61 /// Safely access index i of the list.
61 /// Safely access index i of the list.
6262 pub fn at(self: Self, i: usize) T {
6363 return self.toSliceConst()[i];
6464 }
lib/std/builtin.zig+2
......@@ -144,6 +144,7 @@ pub const TypeInfo = union(enum) {
144144 alignment: comptime_int,
145145 child: type,
146146 is_allowzero: bool,
147
147148 /// The type of the sentinel is the element type of the pointer, which is
148149 /// the value of the `child` field in this struct. However there is no way
149150 /// to refer to that type here, so we use `var`.
......@@ -164,6 +165,7 @@ pub const TypeInfo = union(enum) {
164165 pub const Array = struct {
165166 len: comptime_int,
166167 child: type,
168
167169 /// The type of the sentinel is the element type of the array, which is
168170 /// the value of the `child` field in this struct. However there is no way
169171 /// 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 {
259259 }
260260
261261 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
263263 var term = self.cleanupAfterWait(status);
264264 self.term = term;
265265 }
lib/std/debug/failing_allocator.zig+2-2
......@@ -5,10 +5,10 @@ const mem = std.mem;
55/// memory conditions are handled correctly.
66///
77/// To use this, first initialize it and get an allocator with
8///
8///
99/// `const failing_allocator = &FailingAllocator.init(<allocator>,
1010/// <fail_index>).allocator;`
11///
11///
1212/// Then use `failing_allocator` anywhere you would have used a
1313/// different allocator.
1414pub const FailingAllocator = struct {
lib/std/event/fs.zig+1-1
......@@ -1266,7 +1266,7 @@ pub fn Watch(comptime V: type) type {
12661266 if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) {
12671267 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);
12681268 // `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];
12701270 const user_value = blk: {
12711271 const held = self.os_data.table_lock.acquire();
12721272 defer held.release();
lib/std/fifo.zig+1-1
......@@ -148,7 +148,7 @@ pub fn LinearFifo(
148148 var start = self.head + offset;
149149 if (start >= self.buf.len) {
150150 start -= self.buf.len;
151 return self.buf[start..self.count - offset];
151 return self.buf[start .. self.count - offset];
152152 } else {
153153 const end = math.min(self.head + self.count, self.buf.len);
154154 return self.buf[start..end];
lib/std/mutex.zig+2-2
......@@ -74,7 +74,7 @@ else
7474 pub fn release(self: Held) void {
7575 switch (@atomicRmw(State, &self.mutex.state, .Xchg, .Unlocked, .Release)) {
7676 .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)),
7878 .Unlocked => unreachable, // unlocking an unlocked mutex
7979 else => unreachable, // should never be anything else
8080 }
......@@ -112,7 +112,7 @@ else
112112 if (@atomicRmw(State, &self.state, .Xchg, .Sleeping, .Acquire) == .Unlocked)
113113 return Held{ .mutex = self };
114114 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));
116116 }
117117 }
118118 };
lib/std/net.zig+1-1
......@@ -1362,7 +1362,7 @@ pub const StreamServer = struct {
13621362
13631363 pub const Connection = struct {
13641364 file: fs.File,
1365 address: Address
1365 address: Address,
13661366 };
13671367
13681368 /// 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 {
27532753
27542754/// Used to convert a slice to a null terminated slice on the stack.
27552755/// TODO https://github.com/ziglang/zig/issues/287
2756pub fn toPosixPath(file_path: []const u8) ![PATH_MAX-1:0]u8 {
2757 var path_with_null: [PATH_MAX-1:0]u8 = undefined;
2756pub fn toPosixPath(file_path: []const u8) ![PATH_MAX - 1:0]u8 {
2757 var path_with_null: [PATH_MAX - 1:0]u8 = undefined;
27582758 // >= rather than > to make room for the null byte
27592759 if (file_path.len >= PATH_MAX) return error.NameTooLong;
27602760 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 {
11241124
11251125pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
11261126
1127
11281127// io_uring_params.flags
11291128
11301129/// io_context is polled
lib/std/os/uefi/protocols/hii.zig+1
......@@ -26,6 +26,7 @@ pub const HIIPackageHeader = packed struct {
2626/// The header found at the start of each package list.
2727pub const HIIPackageList = extern struct {
2828 package_list_guid: Guid,
29
2930 /// The size of the package list (in bytes), including the header.
3031 package_list_length: u32,
3132
lib/std/os/uefi/status.zig+38
......@@ -5,82 +5,120 @@ pub const success: usize = 0;
55
66/// The image failed to load.
77pub const load_error: usize = high_bit | 1;
8
89/// A parameter was incorrect.
910pub const invalid_parameter: usize = high_bit | 2;
11
1012/// The operation is not supported.
1113pub const unsupported: usize = high_bit | 3;
14
1215/// The buffer was not the proper size for the request.
1316pub const bad_buffer_size: usize = high_bit | 4;
17
1418/// 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.
1519pub const buffer_too_small: usize = high_bit | 5;
20
1621/// There is no data pending upon return.
1722pub const not_ready: usize = high_bit | 6;
23
1824/// The physical device reported an error while attempting the operation.
1925pub const device_error: usize = high_bit | 7;
26
2027/// The device cannot be written to.
2128pub const write_protected: usize = high_bit | 8;
29
2230/// A resource has run out.
2331pub const out_of_resources: usize = high_bit | 9;
32
2433/// An inconstancy was detected on the file system causing the operating to fail.
2534pub const volume_corrupted: usize = high_bit | 10;
35
2636/// There is no more space on the file system.
2737pub const volume_full: usize = high_bit | 11;
38
2839/// The device does not contain any medium to perform the operation.
2940pub const no_media: usize = high_bit | 12;
41
3042/// The medium in the device has changed since the last access.
3143pub const media_changed: usize = high_bit | 13;
44
3245/// The item was not found.
3346pub const not_found: usize = high_bit | 14;
47
3448/// Access was denied.
3549pub const access_denied: usize = high_bit | 15;
50
3651/// The server was not found or did not respond to the request.
3752pub const no_response: usize = high_bit | 16;
53
3854/// A mapping to a device does not exist.
3955pub const no_mapping: usize = high_bit | 17;
56
4057/// The timeout time expired.
4158pub const timeout: usize = high_bit | 18;
59
4260/// The protocol has not been started.
4361pub const not_started: usize = high_bit | 19;
62
4463/// The protocol has already been started.
4564pub const already_started: usize = high_bit | 20;
65
4666/// The operation was aborted.
4767pub const aborted: usize = high_bit | 21;
68
4869/// An ICMP error occurred during the network operation.
4970pub const icmp_error: usize = high_bit | 22;
71
5072/// A TFTP error occurred during the network operation.
5173pub const tftp_error: usize = high_bit | 23;
74
5275/// A protocol error occurred during the network operation.
5376pub const protocol_error: usize = high_bit | 24;
77
5478/// The function encountered an internal version that was incompatible with a version requested by the caller.
5579pub const incompatible_version: usize = high_bit | 25;
80
5681/// The function was not performed due to a security violation.
5782pub const security_violation: usize = high_bit | 26;
83
5884/// A CRC error was detected.
5985pub const crc_error: usize = high_bit | 27;
86
6087/// Beginning or end of media was reached
6188pub const end_of_media: usize = high_bit | 28;
89
6290/// The end of the file was reached.
6391pub const end_of_file: usize = high_bit | 31;
92
6493/// The language specified was invalid.
6594pub const invalid_language: usize = high_bit | 32;
95
6696/// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
6797pub const compromised_data: usize = high_bit | 33;
98
6899/// There is an address conflict address allocation
69100pub const ip_address_conflict: usize = high_bit | 34;
101
70102/// A HTTP error occurred during the network operation.
71103pub const http_error: usize = high_bit | 35;
72104
73105/// The string contained one or more characters that the device could not render and were skipped.
74106pub const warn_unknown_glyph: usize = 1;
107
75108/// The handle was closed, but the file was not deleted.
76109pub const warn_delete_failure: usize = 2;
110
77111/// The handle was closed, but the data to the file was not flushed properly.
78112pub const warn_write_failure: usize = 3;
113
79114/// The resulting buffer was too small, and the data was truncated to the buffer size.
80115pub const warn_buffer_too_small: usize = 4;
116
81117/// The data has not been updated within the timeframe set by localpolicy for this type of data.
82118pub const warn_stale_data: usize = 5;
119
83120/// The resulting buffer contains UEFI-compliant file system.
84121pub const warn_file_system: usize = 6;
122
85123/// The operation will be processed across a system reset.
86124pub const warn_reset_required: usize = 7;
lib/std/os/uefi/tables/table_header.zig+1
......@@ -1,6 +1,7 @@
11pub const TableHeader = extern struct {
22 signature: u64,
33 revision: u32,
4
45 /// The size, in bytes, of the entire table including the TableHeader
56 header_size: u32,
67 crc32: u32,
lib/std/os/windows.zig+2-3
......@@ -192,7 +192,7 @@ pub const FindFirstFileError = error{
192192};
193193
194194pub 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{ '\\', '*' });
196196 const handle = kernel32.FindFirstFileW(&dir_path_w, find_file_data);
197197
198198 if (handle == INVALID_HANDLE_VALUE) {
......@@ -932,7 +932,7 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
932932 // TODO https://github.com/ziglang/zig/issues/2765
933933 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: {
936936 const prefix = [_]u16{ '\\', '?', '?', '\\' };
937937 mem.copy(u16, result[0..], prefix);
938938 break :blk prefix.len;
......@@ -942,7 +942,6 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
942942 mem.copy(u16, result[start_index..], s);
943943 result[end_index] = 0;
944944 return result;
945
946945}
947946
948947pub 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 {
106106 hEvent: ?WSAEVENT,
107107};
108108
109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (
110 dwError: DWORD,
111 cbTransferred: DWORD,
112 lpOverlapped: *WSAOVERLAPPED,
113 dwFlags: DWORD
114) void;
109pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void;
115110
116111pub const WSA_INVALID_HANDLE = 6;
117112pub const WSA_NOT_ENOUGH_MEMORY = 8;
......@@ -209,11 +204,12 @@ pub const WSA_QOS_ESDMODEOBJ = 11029;
209204pub const WSA_QOS_ESHAPERATEOBJ = 11030;
210205pub const WSA_QOS_RESERVED_PETYPE = 11031;
211206
212
213207/// no parameters
214208const IOC_VOID = 0x80000000;
209
215210/// copy out parameters
216211const IOC_OUT = 0x40000000;
212
217213/// copy in parameters
218214const IOC_IN = 0x80000000;
219215