| author | |
| committer | |
| log | 5f35dc0c0d0530d5a1d028c56a763def3d1fd250 |
| tree | 75a0872005d2f0e5a1c12c31072a471e9ea185d8 |
| parent | d7049fc8e0709619b8aa6766b37abeae946703b2 |
20 files changed, 176 insertions(+), 139 deletions(-)
lib/std/Thread.zig+7-16| ... | @@ -70,16 +70,8 @@ else switch (std.Target.current.os.tag) { | ... | @@ -70,16 +70,8 @@ else switch (std.Target.current.os.tag) { |
| 70 | /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock"). | 70 | /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock"). |
| 71 | pub fn spinLoopHint() void { | 71 | pub fn spinLoopHint() void { |
| 72 | switch (std.Target.current.cpu.arch) { | 72 | switch (std.Target.current.cpu.arch) { |
| 73 | .i386, .x86_64 => asm volatile ("pause" | 73 | .i386, .x86_64 => asm volatile ("pause" ::: "memory"), |
| 74 | : | 74 | .arm, .aarch64 => asm volatile ("yield" ::: "memory"), |
| 75 | : | ||
| 76 | : "memory" | ||
| 77 | ), | ||
| 78 | .arm, .aarch64 => asm volatile ("yield" | ||
| 79 | : | ||
| 80 | : | ||
| 81 | : "memory" | ||
| 82 | ), | ||
| 83 | else => {}, | 75 | else => {}, |
| 84 | } | 76 | } |
| 85 | } | 77 | } |
| ... | @@ -90,12 +82,11 @@ pub fn spinLoopHint() void { | ... | @@ -90,12 +82,11 @@ pub fn spinLoopHint() void { |
| 90 | pub fn getCurrentId() Id { | 82 | pub fn getCurrentId() Id { |
| 91 | if (use_pthreads) { | 83 | if (use_pthreads) { |
| 92 | return c.pthread_self(); | 84 | return c.pthread_self(); |
| 93 | } else | 85 | } else return switch (std.Target.current.os.tag) { |
| 94 | return switch (std.Target.current.os.tag) { | 86 | .linux => os.linux.gettid(), |
| 95 | .linux => os.linux.gettid(), | 87 | .windows => windows.kernel32.GetCurrentThreadId(), |
| 96 | .windows => windows.kernel32.GetCurrentThreadId(), | 88 | else => @compileError("Unsupported OS"), |
| 97 | else => @compileError("Unsupported OS"), | 89 | }; |
| 98 | }; | ||
| 99 | } | 90 | } |
| 100 | 91 | ||
| 101 | /// Returns the handle of this thread. | 92 | /// Returns the handle of this thread. |
lib/std/Thread/Semaphore.zig+1-1| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | ||
| 11 | mutex: Mutex = .{}, | 11 | mutex: Mutex = .{}, |
| 12 | cond: Condition = .{}, | 12 | cond: Condition = .{}, |
| 13 | //! It is OK to initialize this field to any value. | 13 | /// It is OK to initialize this field to any value. |
| 14 | permits: usize = 0, | 14 | permits: usize = 0, |
| 15 | 15 | ||
| 16 | const Semaphore = @This(); | 16 | const Semaphore = @This(); |
lib/std/array_hash_map.zig+2-4| ... | @@ -1237,8 +1237,7 @@ test "shrink" { | ... | @@ -1237,8 +1237,7 @@ test "shrink" { |
| 1237 | if (i < 17) { | 1237 | if (i < 17) { |
| 1238 | testing.expect(gop.found_existing == true); | 1238 | testing.expect(gop.found_existing == true); |
| 1239 | testing.expect(gop.entry.value == i * 10); | 1239 | testing.expect(gop.entry.value == i * 10); |
| 1240 | } else | 1240 | } else testing.expect(gop.found_existing == false); |
| 1241 | testing.expect(gop.found_existing == false); | ||
| 1242 | } | 1241 | } |
| 1243 | 1242 | ||
| 1244 | // Test `shrinkAndFree`. | 1243 | // Test `shrinkAndFree`. |
| ... | @@ -1251,8 +1250,7 @@ test "shrink" { | ... | @@ -1251,8 +1250,7 @@ test "shrink" { |
| 1251 | if (i < 15) { | 1250 | if (i < 15) { |
| 1252 | testing.expect(gop.found_existing == true); | 1251 | testing.expect(gop.found_existing == true); |
| 1253 | testing.expect(gop.entry.value == i * 10); | 1252 | testing.expect(gop.entry.value == i * 10); |
| 1254 | } else | 1253 | } else testing.expect(gop.found_existing == false); |
| 1255 | testing.expect(gop.found_existing == false); | ||
| 1256 | } | 1254 | } |
| 1257 | } | 1255 | } |
| 1258 | 1256 |
lib/std/base64.zig+2-4| ... | @@ -222,12 +222,10 @@ pub const Base64DecoderWithIgnore = struct { | ... | @@ -222,12 +222,10 @@ pub const Base64DecoderWithIgnore = struct { |
| 222 | } else if (decoder_with_ignore.char_is_ignored[c]) { | 222 | } else if (decoder_with_ignore.char_is_ignored[c]) { |
| 223 | // we can even ignore chars during the padding | 223 | // we can even ignore chars during the padding |
| 224 | continue; | 224 | continue; |
| 225 | } else | 225 | } else return error.InvalidCharacter; |
| 226 | return error.InvalidCharacter; | ||
| 227 | } | 226 | } |
| 228 | break; | 227 | break; |
| 229 | } else | 228 | } else return error.InvalidCharacter; |
| 230 | return error.InvalidCharacter; | ||
| 231 | } | 229 | } |
| 232 | 230 | ||
| 233 | switch (available_chars) { | 231 | switch (available_chars) { |
lib/std/build.zig+3-1| ... | @@ -2763,7 +2763,9 @@ pub const InstallDirectoryOptions = struct { | ... | @@ -2763,7 +2763,9 @@ pub const InstallDirectoryOptions = struct { |
| 2763 | .install_dir = self.install_dir.dupe(b), | 2763 | .install_dir = self.install_dir.dupe(b), |
| 2764 | .install_subdir = b.dupe(self.install_subdir), | 2764 | .install_subdir = b.dupe(self.install_subdir), |
| 2765 | .exclude_extensions = if (self.exclude_extensions) |extensions| | 2765 | .exclude_extensions = if (self.exclude_extensions) |extensions| |
| 2766 | b.dupeStrings(extensions) else null, | 2766 | b.dupeStrings(extensions) |
| 2767 | else | ||
| 2768 | null, | ||
| 2767 | }; | 2769 | }; |
| 2768 | } | 2770 | } |
| 2769 | }; | 2771 | }; |
lib/std/c/builtins.zig+101-35| ... | @@ -6,12 +6,22 @@ | ... | @@ -6,12 +6,22 @@ |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | 8 | ||
| 9 | pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { return @byteSwap(u16, val); } | 9 | pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { |
| 10 | pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { return @byteSwap(u32, val); } | 10 | return @byteSwap(u16, val); |
| 11 | pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { return @byteSwap(u64, val); } | 11 | } |
| 12 | pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { | ||
| 13 | return @byteSwap(u32, val); | ||
| 14 | } | ||
| 15 | pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { | ||
| 16 | return @byteSwap(u64, val); | ||
| 17 | } | ||
| 12 | 18 | ||
| 13 | pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int { return @boolToInt(std.math.signbit(val)); } | 19 | pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int { |
| 14 | pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int { return @boolToInt(std.math.signbit(val)); } | 20 | return @boolToInt(std.math.signbit(val)); |
| 21 | } | ||
| 22 | pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int { | ||
| 23 | return @boolToInt(std.math.signbit(val)); | ||
| 24 | } | ||
| 15 | 25 | ||
| 16 | pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int { | 26 | pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int { |
| 17 | // popcount of a c_uint will never exceed the capacity of a c_int | 27 | // popcount of a c_uint will never exceed the capacity of a c_int |
| ... | @@ -31,40 +41,96 @@ pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int { | ... | @@ -31,40 +41,96 @@ pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int { |
| 31 | return @bitCast(c_int, @as(c_uint, @clz(c_uint, val))); | 41 | return @bitCast(c_int, @as(c_uint, @clz(c_uint, val))); |
| 32 | } | 42 | } |
| 33 | 43 | ||
| 34 | pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { return @sqrt(val); } | 44 | pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { |
| 35 | pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { return @sqrt(val); } | 45 | return @sqrt(val); |
| 46 | } | ||
| 47 | pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { | ||
| 48 | return @sqrt(val); | ||
| 49 | } | ||
| 36 | 50 | ||
| 37 | pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { return @sin(val); } | 51 | pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { |
| 38 | pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { return @sin(val); } | 52 | return @sin(val); |
| 39 | pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { return @cos(val); } | 53 | } |
| 40 | pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { return @cos(val); } | 54 | pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { |
| 55 | return @sin(val); | ||
| 56 | } | ||
| 57 | pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { | ||
| 58 | return @cos(val); | ||
| 59 | } | ||
| 60 | pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { | ||
| 61 | return @cos(val); | ||
| 62 | } | ||
| 41 | 63 | ||
| 42 | pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { return @exp(val); } | 64 | pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { |
| 43 | pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { return @exp(val); } | 65 | return @exp(val); |
| 44 | pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { return @exp2(val); } | 66 | } |
| 45 | pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { return @exp2(val); } | 67 | pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { |
| 46 | pub fn __builtin_log(val: f64) callconv(.Inline) f64 { return @log(val); } | 68 | return @exp(val); |
| 47 | pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { return @log(val); } | 69 | } |
| 48 | pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { return @log2(val); } | 70 | pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { |
| 49 | pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { return @log2(val); } | 71 | return @exp2(val); |
| 50 | pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { return @log10(val); } | 72 | } |
| 51 | pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { return @log10(val); } | 73 | pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { |
| 74 | return @exp2(val); | ||
| 75 | } | ||
| 76 | pub fn __builtin_log(val: f64) callconv(.Inline) f64 { | ||
| 77 | return @log(val); | ||
| 78 | } | ||
| 79 | pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { | ||
| 80 | return @log(val); | ||
| 81 | } | ||
| 82 | pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { | ||
| 83 | return @log2(val); | ||
| 84 | } | ||
| 85 | pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { | ||
| 86 | return @log2(val); | ||
| 87 | } | ||
| 88 | pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { | ||
| 89 | return @log10(val); | ||
| 90 | } | ||
| 91 | pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { | ||
| 92 | return @log10(val); | ||
| 93 | } | ||
| 52 | 94 | ||
| 53 | // Standard C Library bug: The absolute value of the most negative integer remains negative. | 95 | // Standard C Library bug: The absolute value of the most negative integer remains negative. |
| 54 | pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int { return std.math.absInt(val) catch std.math.minInt(c_int); } | 96 | pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int { |
| 55 | pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { return @fabs(val); } | 97 | return std.math.absInt(val) catch std.math.minInt(c_int); |
| 56 | pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { return @fabs(val); } | 98 | } |
| 57 | 99 | pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { | |
| 58 | pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { return @floor(val); } | 100 | return @fabs(val); |
| 59 | pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { return @floor(val); } | 101 | } |
| 60 | pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { return @ceil(val); } | 102 | pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { |
| 61 | pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { return @ceil(val); } | 103 | return @fabs(val); |
| 62 | pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { return @trunc(val); } | 104 | } |
| 63 | pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { return @trunc(val); } | 105 | |
| 64 | pub fn __builtin_round(val: f64) callconv(.Inline) f64 { return @round(val); } | 106 | pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { |
| 65 | pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { return @round(val); } | 107 | return @floor(val); |
| 66 | 108 | } | |
| 67 | pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { return std.mem.lenZ(s); } | 109 | pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { |
| 110 | return @floor(val); | ||
| 111 | } | ||
| 112 | pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { | ||
| 113 | return @ceil(val); | ||
| 114 | } | ||
| 115 | pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { | ||
| 116 | return @ceil(val); | ||
| 117 | } | ||
| 118 | pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { | ||
| 119 | return @trunc(val); | ||
| 120 | } | ||
| 121 | pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { | ||
| 122 | return @trunc(val); | ||
| 123 | } | ||
| 124 | pub fn __builtin_round(val: f64) callconv(.Inline) f64 { | ||
| 125 | return @round(val); | ||
| 126 | } | ||
| 127 | pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { | ||
| 128 | return @round(val); | ||
| 129 | } | ||
| 130 | |||
| 131 | pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { | ||
| 132 | return std.mem.lenZ(s); | ||
| 133 | } | ||
| 68 | pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int { | 134 | pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int { |
| 69 | return @as(c_int, std.cstr.cmp(s1, s2)); | 135 | return @as(c_int, std.cstr.cmp(s1, s2)); |
| 70 | } | 136 | } |
lib/std/c/parse.zig+1-2| ... | @@ -300,8 +300,7 @@ const Parser = struct { | ... | @@ -300,8 +300,7 @@ const Parser = struct { |
| 300 | try node.initializers.push((try parser.initializer(dr)) orelse return parser.err(.{ | 300 | try node.initializers.push((try parser.initializer(dr)) orelse return parser.err(.{ |
| 301 | .ExpectedInitializer = .{ .token = parser.it.index }, | 301 | .ExpectedInitializer = .{ .token = parser.it.index }, |
| 302 | })); | 302 | })); |
| 303 | } else | 303 | } else try node.initializers.push(&dr.base); |
| 304 | try node.initializers.push(&dr.base); | ||
| 305 | if (parser.eatToken(.Comma) != null) break; | 304 | if (parser.eatToken(.Comma) != null) break; |
| 306 | dr = @fieldParentPtr(Node.Declarator, "base", (try parser.declarator(.Must)) orelse return parser.err(.{ | 305 | dr = @fieldParentPtr(Node.Declarator, "base", (try parser.declarator(.Must)) orelse return parser.err(.{ |
| 307 | .ExpectedDeclarator = .{ .token = parser.it.index }, | 306 | .ExpectedDeclarator = .{ .token = parser.it.index }, |
lib/std/coff.zig+1-2| ... | @@ -173,8 +173,7 @@ pub const Coff = struct { | ... | @@ -173,8 +173,7 @@ pub const Coff = struct { |
| 173 | skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 18 * @sizeOf(u32); | 173 | skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 18 * @sizeOf(u32); |
| 174 | } else if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { | 174 | } else if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { |
| 175 | skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 12 * @sizeOf(u32) + 5 * @sizeOf(u64); | 175 | skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 12 * @sizeOf(u32) + 5 * @sizeOf(u64); |
| 176 | } else | 176 | } else return error.InvalidPEMagic; |
| 177 | return error.InvalidPEMagic; | ||
| 178 | 177 | ||
| 179 | try self.in_file.seekBy(skip_size); | 178 | try self.in_file.seekBy(skip_size); |
| 180 | 179 |
lib/std/crypto/aegis.zig+4-4| ... | @@ -81,8 +81,8 @@ const State128L = struct { | ... | @@ -81,8 +81,8 @@ const State128L = struct { |
| 81 | while (i < 7) : (i += 1) { | 81 | while (i < 7) : (i += 1) { |
| 82 | state.update(tmp, tmp); | 82 | state.update(tmp, tmp); |
| 83 | } | 83 | } |
| 84 | return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]). | 84 | return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]) |
| 85 | xorBlocks(blocks[5]).xorBlocks(blocks[6]).toBytes(); | 85 | .xorBlocks(blocks[5]).xorBlocks(blocks[6]).toBytes(); |
| 86 | } | 86 | } |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| ... | @@ -244,8 +244,8 @@ const State256 = struct { | ... | @@ -244,8 +244,8 @@ const State256 = struct { |
| 244 | while (i < 7) : (i += 1) { | 244 | while (i < 7) : (i += 1) { |
| 245 | state.update(tmp); | 245 | state.update(tmp); |
| 246 | } | 246 | } |
| 247 | return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]). | 247 | return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]) |
| 248 | xorBlocks(blocks[5]).toBytes(); | 248 | .xorBlocks(blocks[5]).toBytes(); |
| 249 | } | 249 | } |
| 250 | }; | 250 | }; |
| 251 | 251 |
lib/std/crypto/bcrypt.zig+1-3| ... | @@ -109,9 +109,7 @@ const State = struct { | ... | @@ -109,9 +109,7 @@ const State = struct { |
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | const Halves = struct { | 112 | const Halves = struct { l: u32, r: u32 }; |
| 113 | l: u32, r: u32 | ||
| 114 | }; | ||
| 115 | 113 | ||
| 116 | fn feistelF(state: State, x: u32) u32 { | 114 | fn feistelF(state: State, x: u32) u32 { |
| 117 | var r = state.sboxes[0][@truncate(u8, x >> 24)]; | 115 | var r = state.sboxes[0][@truncate(u8, x >> 24)]; |
lib/std/dwarf.zig+2-4| ... | @@ -213,13 +213,11 @@ const LineNumberProgram = struct { | ... | @@ -213,13 +213,11 @@ const LineNumberProgram = struct { |
| 213 | return error.MissingDebugInfo; | 213 | return error.MissingDebugInfo; |
| 214 | } else if (self.prev_file - 1 >= self.file_entries.items.len) { | 214 | } else if (self.prev_file - 1 >= self.file_entries.items.len) { |
| 215 | return error.InvalidDebugInfo; | 215 | return error.InvalidDebugInfo; |
| 216 | } else | 216 | } else &self.file_entries.items[self.prev_file - 1]; |
| 217 | &self.file_entries.items[self.prev_file - 1]; | ||
| 218 | 217 | ||
| 219 | const dir_name = if (file_entry.dir_index >= self.include_dirs.len) { | 218 | const dir_name = if (file_entry.dir_index >= self.include_dirs.len) { |
| 220 | return error.InvalidDebugInfo; | 219 | return error.InvalidDebugInfo; |
| 221 | } else | 220 | } else self.include_dirs[file_entry.dir_index]; |
| 222 | self.include_dirs[file_entry.dir_index]; | ||
| 223 | const file_name = try fs.path.join(self.file_entries.allocator, &[_][]const u8{ dir_name, file_entry.file_name }); | 221 | const file_name = try fs.path.join(self.file_entries.allocator, &[_][]const u8{ dir_name, file_entry.file_name }); |
| 224 | errdefer self.file_entries.allocator.free(file_name); | 222 | errdefer self.file_entries.allocator.free(file_name); |
| 225 | return debug.LineInfo{ | 223 | return debug.LineInfo{ |
lib/std/event/batch.zig+10-9| ... | @@ -98,15 +98,16 @@ pub fn Batch( | ... | @@ -98,15 +98,16 @@ pub fn Batch( |
| 98 | /// This function is *not* thread-safe. It must be called from one thread at | 98 | /// This function is *not* thread-safe. It must be called from one thread at |
| 99 | /// a time, however, it need not be the same thread. | 99 | /// a time, however, it need not be the same thread. |
| 100 | pub fn wait(self: *Self) CollectedResult { | 100 | pub fn wait(self: *Self) CollectedResult { |
| 101 | for (self.jobs) |*job| if (job.frame) |f| { | 101 | for (self.jobs) |*job| |
| 102 | job.result = if (async_ok) await f else nosuspend await f; | 102 | if (job.frame) |f| { |
| 103 | if (CollectedResult != void) { | 103 | job.result = if (async_ok) await f else nosuspend await f; |
| 104 | job.result catch |err| { | 104 | if (CollectedResult != void) { |
| 105 | self.collected_result = err; | 105 | job.result catch |err| { |
| 106 | }; | 106 | self.collected_result = err; |
| 107 | } | 107 | }; |
| 108 | job.frame = null; | 108 | } |
| 109 | }; | 109 | job.frame = null; |
| 110 | }; | ||
| 110 | return self.collected_result; | 111 | return self.collected_result; |
| 111 | } | 112 | } |
| 112 | }; | 113 | }; |
lib/std/fmt.zig+2-4| ... | @@ -646,8 +646,7 @@ pub fn formatIntValue( | ... | @@ -646,8 +646,7 @@ pub fn formatIntValue( |
| 646 | const int_value = if (@TypeOf(value) == comptime_int) blk: { | 646 | const int_value = if (@TypeOf(value) == comptime_int) blk: { |
| 647 | const Int = math.IntFittingRange(value, value); | 647 | const Int = math.IntFittingRange(value, value); |
| 648 | break :blk @as(Int, value); | 648 | break :blk @as(Int, value); |
| 649 | } else | 649 | } else value; |
| 650 | value; | ||
| 651 | 650 | ||
| 652 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "d")) { | 651 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "d")) { |
| 653 | radix = 10; | 652 | radix = 10; |
| ... | @@ -1087,8 +1086,7 @@ pub fn formatInt( | ... | @@ -1087,8 +1086,7 @@ pub fn formatInt( |
| 1087 | const int_value = if (@TypeOf(value) == comptime_int) blk: { | 1086 | const int_value = if (@TypeOf(value) == comptime_int) blk: { |
| 1088 | const Int = math.IntFittingRange(value, value); | 1087 | const Int = math.IntFittingRange(value, value); |
| 1089 | break :blk @as(Int, value); | 1088 | break :blk @as(Int, value); |
| 1090 | } else | 1089 | } else value; |
| 1091 | value; | ||
| 1092 | 1090 | ||
| 1093 | const value_info = @typeInfo(@TypeOf(int_value)).Int; | 1091 | const value_info = @typeInfo(@TypeOf(int_value)).Int; |
| 1094 | 1092 |
lib/std/log.zig+4-3| ... | @@ -3,9 +3,6 @@ | ... | @@ -3,9 +3,6 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | ||
| 7 | const builtin = std.builtin; | ||
| 8 | const root = @import("root"); | ||
| 9 | 6 | ||
| 10 | //! std.log is a standardized interface for logging which allows for the logging | 7 | //! std.log is a standardized interface for logging which allows for the logging |
| 11 | //! of programs and libraries using this interface to be formatted and filtered | 8 | //! of programs and libraries using this interface to be formatted and filtered |
| ... | @@ -77,6 +74,10 @@ const root = @import("root"); | ... | @@ -77,6 +74,10 @@ const root = @import("root"); |
| 77 | //! [err] (nice_library): Something went very wrong, sorry | 74 | //! [err] (nice_library): Something went very wrong, sorry |
| 78 | //! ``` | 75 | //! ``` |
| 79 | 76 | ||
| 77 | const std = @import("std.zig"); | ||
| 78 | const builtin = std.builtin; | ||
| 79 | const root = @import("root"); | ||
| 80 | |||
| 80 | pub const Level = enum { | 81 | pub const Level = enum { |
| 81 | /// Emergency: a condition that cannot be handled, usually followed by a | 82 | /// Emergency: a condition that cannot be handled, usually followed by a |
| 82 | /// panic. | 83 | /// panic. |
lib/std/meta.zig+10-11| ... | @@ -534,9 +534,7 @@ pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { | ... | @@ -534,9 +534,7 @@ pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { |
| 534 | } | 534 | } |
| 535 | 535 | ||
| 536 | test "std.meta.fieldNames" { | 536 | test "std.meta.fieldNames" { |
| 537 | const E1 = enum { | 537 | const E1 = enum { A, B }; |
| 538 | A, B | ||
| 539 | }; | ||
| 540 | const E2 = error{A}; | 538 | const E2 = error{A}; |
| 541 | const S1 = struct { | 539 | const S1 = struct { |
| 542 | a: u8, | 540 | a: u8, |
| ... | @@ -1002,19 +1000,19 @@ pub fn sizeof(target: anytype) usize { | ... | @@ -1002,19 +1000,19 @@ pub fn sizeof(target: anytype) usize { |
| 1002 | // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. | 1000 | // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. |
| 1003 | return 1; | 1001 | return 1; |
| 1004 | } else { | 1002 | } else { |
| 1005 | @compileError("Cannot use C sizeof on opaque type "++@typeName(T)); | 1003 | @compileError("Cannot use C sizeof on opaque type " ++ @typeName(T)); |
| 1006 | } | 1004 | } |
| 1007 | }, | 1005 | }, |
| 1008 | .Optional => |opt| { | 1006 | .Optional => |opt| { |
| 1009 | if (@typeInfo(opt.child) == .Pointer) { | 1007 | if (@typeInfo(opt.child) == .Pointer) { |
| 1010 | return sizeof(opt.child); | 1008 | return sizeof(opt.child); |
| 1011 | } else { | 1009 | } else { |
| 1012 | @compileError("Cannot use C sizeof on non-pointer optional "++@typeName(T)); | 1010 | @compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T)); |
| 1013 | } | 1011 | } |
| 1014 | }, | 1012 | }, |
| 1015 | .Pointer => |ptr| { | 1013 | .Pointer => |ptr| { |
| 1016 | if (ptr.size == .Slice) { | 1014 | if (ptr.size == .Slice) { |
| 1017 | @compileError("Cannot use C sizeof on slice type "++@typeName(T)); | 1015 | @compileError("Cannot use C sizeof on slice type " ++ @typeName(T)); |
| 1018 | } | 1016 | } |
| 1019 | // for strings, sizeof("a") returns 2. | 1017 | // for strings, sizeof("a") returns 2. |
| 1020 | // normal pointer decay scenarios from C are handled | 1018 | // normal pointer decay scenarios from C are handled |
| ... | @@ -1024,8 +1022,9 @@ pub fn sizeof(target: anytype) usize { | ... | @@ -1024,8 +1022,9 @@ pub fn sizeof(target: anytype) usize { |
| 1024 | if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) { | 1022 | if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) { |
| 1025 | const array_info = @typeInfo(ptr.child).Array; | 1023 | const array_info = @typeInfo(ptr.child).Array; |
| 1026 | if ((array_info.child == u8 or array_info.child == u16) and | 1024 | if ((array_info.child == u8 or array_info.child == u16) and |
| 1027 | array_info.sentinel != null and | 1025 | array_info.sentinel != null and |
| 1028 | array_info.sentinel.? == 0) { | 1026 | array_info.sentinel.? == 0) |
| 1027 | { | ||
| 1029 | // length of the string plus one for the null terminator. | 1028 | // length of the string plus one for the null terminator. |
| 1030 | return (array_info.len + 1) * @sizeOf(array_info.child); | 1029 | return (array_info.len + 1) * @sizeOf(array_info.child); |
| 1031 | } | 1030 | } |
| ... | @@ -1067,10 +1066,10 @@ test "sizeof" { | ... | @@ -1067,10 +1066,10 @@ test "sizeof" { |
| 1067 | 1066 | ||
| 1068 | testing.expect(sizeof(S) == 4); | 1067 | testing.expect(sizeof(S) == 4); |
| 1069 | 1068 | ||
| 1070 | testing.expect(sizeof([_]u32{4, 5, 6}) == 12); | 1069 | testing.expect(sizeof([_]u32{ 4, 5, 6 }) == 12); |
| 1071 | testing.expect(sizeof([3]u32) == 12); | 1070 | testing.expect(sizeof([3]u32) == 12); |
| 1072 | testing.expect(sizeof([3:0]u32) == 16); | 1071 | testing.expect(sizeof([3:0]u32) == 16); |
| 1073 | testing.expect(sizeof(&[_]u32{4, 5, 6}) == ptr_size); | 1072 | testing.expect(sizeof(&[_]u32{ 4, 5, 6 }) == ptr_size); |
| 1074 | 1073 | ||
| 1075 | testing.expect(sizeof(*u32) == ptr_size); | 1074 | testing.expect(sizeof(*u32) == ptr_size); |
| 1076 | testing.expect(sizeof([*]u32) == ptr_size); | 1075 | testing.expect(sizeof([*]u32) == ptr_size); |
| ... | @@ -1082,7 +1081,7 @@ test "sizeof" { | ... | @@ -1082,7 +1081,7 @@ test "sizeof" { |
| 1082 | testing.expect(sizeof(null) == ptr_size); | 1081 | testing.expect(sizeof(null) == ptr_size); |
| 1083 | 1082 | ||
| 1084 | testing.expect(sizeof("foobar") == 7); | 1083 | testing.expect(sizeof("foobar") == 7); |
| 1085 | testing.expect(sizeof(&[_:0]u16{'f','o','o','b','a','r'}) == 14); | 1084 | testing.expect(sizeof(&[_:0]u16{ 'f', 'o', 'o', 'b', 'a', 'r' }) == 14); |
| 1086 | testing.expect(sizeof(*const [4:0]u8) == 5); | 1085 | testing.expect(sizeof(*const [4:0]u8) == 5); |
| 1087 | testing.expect(sizeof(*[4:0]u8) == ptr_size); | 1086 | testing.expect(sizeof(*[4:0]u8) == ptr_size); |
| 1088 | testing.expect(sizeof([*]const [4:0]u8) == ptr_size); | 1087 | testing.expect(sizeof([*]const [4:0]u8) == ptr_size); |
lib/std/meta/trait.zig+2-6| ... | @@ -544,15 +544,11 @@ test "std.meta.trait.hasUniqueRepresentation" { | ... | @@ -544,15 +544,11 @@ test "std.meta.trait.hasUniqueRepresentation" { |
| 544 | 544 | ||
| 545 | testing.expect(hasUniqueRepresentation(TestStruct3)); | 545 | testing.expect(hasUniqueRepresentation(TestStruct3)); |
| 546 | 546 | ||
| 547 | const TestStruct4 = struct { | 547 | const TestStruct4 = struct { a: []const u8 }; |
| 548 | a: []const u8 | ||
| 549 | }; | ||
| 550 | 548 | ||
| 551 | testing.expect(!hasUniqueRepresentation(TestStruct4)); | 549 | testing.expect(!hasUniqueRepresentation(TestStruct4)); |
| 552 | 550 | ||
| 553 | const TestStruct5 = struct { | 551 | const TestStruct5 = struct { a: TestStruct4 }; |
| 554 | a: TestStruct4 | ||
| 555 | }; | ||
| 556 | 552 | ||
| 557 | testing.expect(!hasUniqueRepresentation(TestStruct5)); | 553 | testing.expect(!hasUniqueRepresentation(TestStruct5)); |
| 558 | 554 |
lib/std/os.zig+3-2| ... | @@ -3263,8 +3263,9 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne | ... | @@ -3263,8 +3263,9 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 3263 | .WSAEADDRNOTAVAIL => return error.AddressNotAvailable, | 3263 | .WSAEADDRNOTAVAIL => return error.AddressNotAvailable, |
| 3264 | .WSAECONNREFUSED => return error.ConnectionRefused, | 3264 | .WSAECONNREFUSED => return error.ConnectionRefused, |
| 3265 | .WSAETIMEDOUT => return error.ConnectionTimedOut, | 3265 | .WSAETIMEDOUT => return error.ConnectionTimedOut, |
| 3266 | .WSAEHOSTUNREACH // TODO: should we return NetworkUnreachable in this case as well? | 3266 | .WSAEHOSTUNREACH, // TODO: should we return NetworkUnreachable in this case as well? |
| 3267 | , .WSAENETUNREACH => return error.NetworkUnreachable, | 3267 | .WSAENETUNREACH, |
| 3268 | => return error.NetworkUnreachable, | ||
| 3268 | .WSAEFAULT => unreachable, | 3269 | .WSAEFAULT => unreachable, |
| 3269 | .WSAEINVAL => unreachable, | 3270 | .WSAEINVAL => unreachable, |
| 3270 | .WSAEISCONN => unreachable, | 3271 | .WSAEISCONN => unreachable, |
lib/std/os/bits/netbsd.zig+9-7| ... | @@ -836,13 +836,15 @@ pub const ucontext_t = extern struct { | ... | @@ -836,13 +836,15 @@ pub const ucontext_t = extern struct { |
| 836 | sigmask: sigset_t, | 836 | sigmask: sigset_t, |
| 837 | stack: stack_t, | 837 | stack: stack_t, |
| 838 | mcontext: mcontext_t, | 838 | mcontext: mcontext_t, |
| 839 | __pad: [switch (builtin.arch) { | 839 | __pad: [ |
| 840 | .i386 => 4, | 840 | switch (builtin.arch) { |
| 841 | .mips, .mipsel, .mips64, .mips64el => 14, | 841 | .i386 => 4, |
| 842 | .arm, .armeb, .thumb, .thumbeb => 1, | 842 | .mips, .mipsel, .mips64, .mips64el => 14, |
| 843 | .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, | 843 | .arm, .armeb, .thumb, .thumbeb => 1, |
| 844 | else => 0, | 844 | .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, |
| 845 | }]u32, | 845 | else => 0, |
| 846 | } | ||
| 847 | ]u32, | ||
| 846 | }; | 848 | }; |
| 847 | 849 | ||
| 848 | pub const EPERM = 1; // Operation not permitted | 850 | pub const EPERM = 1; // Operation not permitted |
lib/std/os/windows/bits.zig+7-5| ... | @@ -1315,11 +1315,13 @@ pub const PEB = extern struct { | ... | @@ -1315,11 +1315,13 @@ pub const PEB = extern struct { |
| 1315 | ImageSubSystemMinorVersion: ULONG, | 1315 | ImageSubSystemMinorVersion: ULONG, |
| 1316 | // note: there is padding here on 64 bit | 1316 | // note: there is padding here on 64 bit |
| 1317 | ActiveProcessAffinityMask: KAFFINITY, | 1317 | ActiveProcessAffinityMask: KAFFINITY, |
| 1318 | GdiHandleBuffer: [switch (@sizeOf(usize)) { | 1318 | GdiHandleBuffer: [ |
| 1319 | 4 => 0x22, | 1319 | switch (@sizeOf(usize)) { |
| 1320 | 8 => 0x3C, | 1320 | 4 => 0x22, |
| 1321 | else => unreachable, | 1321 | 8 => 0x3C, |
| 1322 | }]ULONG, | 1322 | else => unreachable, |
| 1323 | } | ||
| 1324 | ]ULONG, | ||
| 1323 | 1325 | ||
| 1324 | // Fields appended in 5.0 (Windows 2000): | 1326 | // Fields appended in 5.0 (Windows 2000): |
| 1325 | PostProcessInitRoutine: PVOID, | 1327 | PostProcessInitRoutine: PVOID, |
lib/std/special/compiler_rt/arm.zig+4-16| ... | @@ -66,10 +66,7 @@ pub fn __aeabi_uidivmod() callconv(.Naked) void { | ... | @@ -66,10 +66,7 @@ pub fn __aeabi_uidivmod() callconv(.Naked) void { |
| 66 | \\ ldr r1, [sp] | 66 | \\ ldr r1, [sp] |
| 67 | \\ add sp, #4 | 67 | \\ add sp, #4 |
| 68 | \\ pop {pc} | 68 | \\ pop {pc} |
| 69 | : | 69 | ::: "memory"); |
| 70 | : | ||
| 71 | : "memory" | ||
| 72 | ); | ||
| 73 | unreachable; | 70 | unreachable; |
| 74 | } | 71 | } |
| 75 | 72 | ||
| ... | @@ -86,10 +83,7 @@ pub fn __aeabi_uldivmod() callconv(.Naked) void { | ... | @@ -86,10 +83,7 @@ pub fn __aeabi_uldivmod() callconv(.Naked) void { |
| 86 | \\ ldr r3, [sp, #12] | 83 | \\ ldr r3, [sp, #12] |
| 87 | \\ add sp, #16 | 84 | \\ add sp, #16 |
| 88 | \\ pop {r4, pc} | 85 | \\ pop {r4, pc} |
| 89 | : | 86 | ::: "memory"); |
| 90 | : | ||
| 91 | : "memory" | ||
| 92 | ); | ||
| 93 | unreachable; | 87 | unreachable; |
| 94 | } | 88 | } |
| 95 | 89 | ||
| ... | @@ -104,10 +98,7 @@ pub fn __aeabi_idivmod() callconv(.Naked) void { | ... | @@ -104,10 +98,7 @@ pub fn __aeabi_idivmod() callconv(.Naked) void { |
| 104 | \\ ldr r1, [sp] | 98 | \\ ldr r1, [sp] |
| 105 | \\ add sp, #4 | 99 | \\ add sp, #4 |
| 106 | \\ pop {pc} | 100 | \\ pop {pc} |
| 107 | : | 101 | ::: "memory"); |
| 108 | : | ||
| 109 | : "memory" | ||
| 110 | ); | ||
| 111 | unreachable; | 102 | unreachable; |
| 112 | } | 103 | } |
| 113 | 104 | ||
| ... | @@ -124,9 +115,6 @@ pub fn __aeabi_ldivmod() callconv(.Naked) void { | ... | @@ -124,9 +115,6 @@ pub fn __aeabi_ldivmod() callconv(.Naked) void { |
| 124 | \\ ldr r3, [sp, #12] | 115 | \\ ldr r3, [sp, #12] |
| 125 | \\ add sp, #16 | 116 | \\ add sp, #16 |
| 126 | \\ pop {r4, pc} | 117 | \\ pop {r4, pc} |
| 127 | : | 118 | ::: "memory"); |
| 128 | : | ||
| 129 | : "memory" | ||
| 130 | ); | ||
| 131 | unreachable; | 119 | unreachable; |
| 132 | } | 120 | } |