authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-06-02 22:02:45-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-16 13:44:09-07:00
log259315606827620daaabf82b479e59ee710097cd
tree16c797e4cc15479a27e64b4414517d9334f52250
parent22c6b6c9a9378aaca75c83c2182a6d94298f6bc2

migration: std.math.{min, min3, max, max3} -> `@min` & `@max`


58 files changed, 173 insertions(+), 264 deletions(-)

doc/docgen.zig+1-1
......@@ -276,7 +276,7 @@ fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, arg
276276 }
277277 }
278278 {
279 const caret_count = std.math.min(token.end, loc.line_end) - token.start;
279 const caret_count = @min(token.end, loc.line_end) - token.start;
280280 var i: usize = 0;
281281 while (i < caret_count) : (i += 1) {
282282 print("~", .{});
lib/compiler_rt/divc3.zig+1-2
......@@ -3,7 +3,6 @@ const isNan = std.math.isNan;
33const isInf = std.math.isInf;
44const scalbn = std.math.scalbn;
55const ilogb = std.math.ilogb;
6const max = std.math.max;
76const fabs = std.math.fabs;
87const maxInt = std.math.maxInt;
98const minInt = std.math.minInt;
......@@ -17,7 +16,7 @@ pub inline fn divc3(comptime T: type, a: T, b: T, c_in: T, d_in: T) Complex(T) {
1716 var d = d_in;
1817
1918 // logbw used to prevent under/over-flow
20 const logbw = ilogb(max(fabs(c), fabs(d)));
19 const logbw = ilogb(@max(fabs(c), fabs(d)));
2120 const logbw_finite = logbw != maxInt(i32) and logbw != minInt(i32);
2221 const ilogbw = if (logbw_finite) b: {
2322 c = scalbn(c, -logbw);
lib/compiler_rt/emutls.zig+2-2
......@@ -49,7 +49,7 @@ const simple_allocator = struct {
4949
5050 /// Allocate a memory chunk.
5151 pub fn advancedAlloc(alignment: u29, size: usize) [*]u8 {
52 const minimal_alignment = std.math.max(@alignOf(usize), alignment);
52 const minimal_alignment = @max(@alignOf(usize), alignment);
5353
5454 var aligned_ptr: ?*anyopaque = undefined;
5555 if (std.c.posix_memalign(&aligned_ptr, minimal_alignment, size) != 0) {
......@@ -170,7 +170,7 @@ const current_thread_storage = struct {
170170
171171 // make it to contains at least 16 objects (to avoid too much
172172 // reallocation at startup).
173 const size = std.math.max(16, index);
173 const size = @max(16, index);
174174
175175 // create a new array and store it.
176176 var array: *ObjectArray = ObjectArray.init(size);
lib/std/Build/Cache/DepTokenizer.zig+1-1
......@@ -983,7 +983,7 @@ fn hexDump(out: anytype, bytes: []const u8) !void {
983983 try printDecValue(out, offset, 8);
984984 try out.writeAll(":");
985985 try out.writeAll(" ");
986 var end1 = std.math.min(offset + n, offset + 8);
986 var end1 = @min(offset + n, offset + 8);
987987 for (bytes[offset..end1]) |b| {
988988 try out.writeAll(" ");
989989 try printHexValue(out, b, 2);
lib/std/Thread.zig+3-3
......@@ -541,7 +541,7 @@ const WindowsThreadImpl = struct {
541541 // Going lower makes it default to that specified in the executable (~1mb).
542542 // Its also fine if the limit here is incorrect as stack size is only a hint.
543543 var stack_size = std.math.cast(u32, config.stack_size) orelse std.math.maxInt(u32);
544 stack_size = std.math.max(64 * 1024, stack_size);
544 stack_size = @max(64 * 1024, stack_size);
545545
546546 instance.thread.thread_handle = windows.kernel32.CreateThread(
547547 null,
......@@ -690,7 +690,7 @@ const PosixThreadImpl = struct {
690690 defer assert(c.pthread_attr_destroy(&attr) == .SUCCESS);
691691
692692 // Use the same set of parameters used by the libc-less impl.
693 const stack_size = std.math.max(config.stack_size, c.PTHREAD_STACK_MIN);
693 const stack_size = @max(config.stack_size, c.PTHREAD_STACK_MIN);
694694 assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS);
695695 assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS);
696696
......@@ -930,7 +930,7 @@ const LinuxThreadImpl = struct {
930930 var bytes: usize = page_size;
931931 guard_offset = bytes;
932932
933 bytes += std.math.max(page_size, config.stack_size);
933 bytes += @max(page_size, config.stack_size);
934934 bytes = std.mem.alignForward(bytes, page_size);
935935 stack_offset = bytes;
936936
lib/std/Uri.zig+2-2
......@@ -177,13 +177,13 @@ pub fn parseWithoutScheme(text: []const u8) ParseError!Uri {
177177
178178 if (std.mem.lastIndexOf(u8, authority, ":")) |index| {
179179 if (index >= end_of_host) { // if not part of the V6 address field
180 end_of_host = std.math.min(end_of_host, index);
180 end_of_host = @min(end_of_host, index);
181181 uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;
182182 }
183183 }
184184 } else if (std.mem.lastIndexOf(u8, authority, ":")) |index| {
185185 if (index >= start_of_host) { // if not part of the userinfo field
186 end_of_host = std.math.min(end_of_host, index);
186 end_of_host = @min(end_of_host, index);
187187 uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort;
188188 }
189189 }
lib/std/array_hash_map.zig+3-3
......@@ -815,9 +815,9 @@ pub fn ArrayHashMapUnmanaged(
815815 /// no longer guaranteed that no allocations will be performed.
816816 pub fn capacity(self: Self) usize {
817817 const entry_cap = self.entries.capacity;
818 const header = self.index_header orelse return math.min(linear_scan_max, entry_cap);
818 const header = self.index_header orelse return @min(linear_scan_max, entry_cap);
819819 const indexes_cap = header.capacity();
820 return math.min(entry_cap, indexes_cap);
820 return @min(entry_cap, indexes_cap);
821821 }
822822
823823 /// Clobbers any existing data. To detect if a put would clobber
......@@ -1821,7 +1821,7 @@ fn Index(comptime I: type) type {
18211821/// length * the size of an Index(u32). The index is 8 bytes (3 bits repr)
18221822/// and max_usize + 1 is not representable, so we need to subtract out 4 bits.
18231823const max_representable_index_len = @bitSizeOf(usize) - 4;
1824const max_bit_index = math.min(32, max_representable_index_len);
1824const max_bit_index = @min(32, max_representable_index_len);
18251825const min_bit_index = 5;
18261826const max_capacity = (1 << max_bit_index) - 1;
18271827const index_capacities = blk: {
lib/std/ascii.zig+1-1
......@@ -422,7 +422,7 @@ test "indexOfIgnoreCase" {
422422
423423/// Returns the lexicographical order of two slices. O(n).
424424pub fn orderIgnoreCase(lhs: []const u8, rhs: []const u8) std.math.Order {
425 const n = std.math.min(lhs.len, rhs.len);
425 const n = @min(lhs.len, rhs.len);
426426 var i: usize = 0;
427427 while (i < n) : (i += 1) {
428428 switch (std.math.order(toLower(lhs[i]), toLower(rhs[i]))) {
lib/std/compress/lzma/decode.zig+1-1
......@@ -59,7 +59,7 @@ pub const Params = struct {
5959 const pb = @intCast(u3, props);
6060
6161 const dict_size_provided = try reader.readIntLittle(u32);
62 const dict_size = math.max(0x1000, dict_size_provided);
62 const dict_size = @max(0x1000, dict_size_provided);
6363
6464 const unpacked_size = switch (options.unpacked_size) {
6565 .read_from_header => blk: {
lib/std/crypto/blake3.zig+4-4
......@@ -20,7 +20,7 @@ const ChunkIterator = struct {
2020 }
2121
2222 fn next(self: *ChunkIterator) ?[]u8 {
23 const next_chunk = self.slice[0..math.min(self.chunk_len, self.slice.len)];
23 const next_chunk = self.slice[0..@min(self.chunk_len, self.slice.len)];
2424 self.slice = self.slice[next_chunk.len..];
2525 return if (next_chunk.len > 0) next_chunk else null;
2626 }
......@@ -283,7 +283,7 @@ const ChunkState = struct {
283283
284284 fn fillBlockBuf(self: *ChunkState, input: []const u8) []const u8 {
285285 const want = BLOCK_LEN - self.block_len;
286 const take = math.min(want, input.len);
286 const take = @min(want, input.len);
287287 @memcpy(self.block[self.block_len..][0..take], input[0..take]);
288288 self.block_len += @truncate(u8, take);
289289 return input[take..];
......@@ -450,7 +450,7 @@ pub const Blake3 = struct {
450450
451451 // Compress input bytes into the current chunk state.
452452 const want = CHUNK_LEN - self.chunk_state.len();
453 const take = math.min(want, input.len);
453 const take = @min(want, input.len);
454454 self.chunk_state.update(input[0..take]);
455455 input = input[take..];
456456 }
......@@ -663,7 +663,7 @@ fn testBlake3(hasher: *Blake3, input_len: usize, expected_hex: [262]u8) !void {
663663 // Write repeating input pattern to hasher
664664 var input_counter = input_len;
665665 while (input_counter > 0) {
666 const update_len = math.min(input_counter, input_pattern.len);
666 const update_len = @min(input_counter, input_pattern.len);
667667 hasher.update(input_pattern[0..update_len]);
668668 input_counter -= update_len;
669669 }
lib/std/crypto/ff.zig+1-1
......@@ -570,7 +570,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
570570 var out = self.zero;
571571 var i = x.limbs_count() - 1;
572572 if (self.limbs_count() >= 2) {
573 const start = math.min(i, self.limbs_count() - 2);
573 const start = @min(i, self.limbs_count() - 2);
574574 var j = start;
575575 while (true) : (j -= 1) {
576576 out.v.limbs.set(j, x.limbs.get(i));
lib/std/crypto/ghash_polyval.zig+1-1
......@@ -363,7 +363,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
363363 var mb = m;
364364
365365 if (st.leftover > 0) {
366 const want = math.min(block_length - st.leftover, mb.len);
366 const want = @min(block_length - st.leftover, mb.len);
367367 const mc = mb[0..want];
368368 for (mc, 0..) |x, i| {
369369 st.buf[st.leftover + i] = x;
lib/std/crypto/keccak_p.zig+2-2
......@@ -214,7 +214,7 @@ pub fn State(comptime f: u11, comptime capacity: u11, comptime delim: u8, compti
214214 pub fn absorb(self: *Self, bytes_: []const u8) void {
215215 var bytes = bytes_;
216216 if (self.offset > 0) {
217 const left = math.min(rate - self.offset, bytes.len);
217 const left = @min(rate - self.offset, bytes.len);
218218 @memcpy(self.buf[self.offset..][0..left], bytes[0..left]);
219219 self.offset += left;
220220 if (self.offset == rate) {
......@@ -249,7 +249,7 @@ pub fn State(comptime f: u11, comptime capacity: u11, comptime delim: u8, compti
249249 pub fn squeeze(self: *Self, out: []u8) void {
250250 var i: usize = 0;
251251 while (i < out.len) : (i += rate) {
252 const left = math.min(rate, out.len - i);
252 const left = @min(rate, out.len - i);
253253 self.st.extractBytes(out[i..][0..left]);
254254 self.st.permuteR(rounds);
255255 }
lib/std/crypto/poly1305.zig+1-1
......@@ -112,7 +112,7 @@ pub const Poly1305 = struct {
112112
113113 // handle leftover
114114 if (st.leftover > 0) {
115 const want = std.math.min(block_length - st.leftover, mb.len);
115 const want = @min(block_length - st.leftover, mb.len);
116116 const mc = mb[0..want];
117117 for (mc, 0..) |x, i| {
118118 st.buf[st.leftover + i] = x;
lib/std/crypto/salsa20.zig+1-1
......@@ -404,7 +404,7 @@ pub const XSalsa20Poly1305 = struct {
404404 debug.assert(c.len == m.len);
405405 const extended = extend(rounds, k, npub);
406406 var block0 = [_]u8{0} ** 64;
407 const mlen0 = math.min(32, c.len);
407 const mlen0 = @min(32, c.len);
408408 @memcpy(block0[32..][0..mlen0], c[0..mlen0]);
409409 Salsa20.xor(block0[0..], block0[0..], 0, extended.key, extended.nonce);
410410 var mac = Poly1305.init(block0[0..32]);
lib/std/crypto/scrypt.zig+2-2
......@@ -143,7 +143,7 @@ pub const Params = struct {
143143
144144 /// Create parameters from ops and mem limits, where mem_limit given in bytes
145145 pub fn fromLimits(ops_limit: u64, mem_limit: usize) Self {
146 const ops = math.max(32768, ops_limit);
146 const ops = @max(32768, ops_limit);
147147 const r: u30 = 8;
148148 if (ops < mem_limit / 32) {
149149 const max_n = ops / (r * 4);
......@@ -151,7 +151,7 @@ pub const Params = struct {
151151 } else {
152152 const max_n = mem_limit / (@intCast(usize, r) * 128);
153153 const ln = @intCast(u6, math.log2(max_n));
154 const max_rp = math.min(0x3fffffff, (ops / 4) / (@as(u64, 1) << ln));
154 const max_rp = @min(0x3fffffff, (ops / 4) / (@as(u64, 1) << ln));
155155 return Self{ .r = r, .p = @intCast(u30, max_rp / @as(u64, r)), .ln = ln };
156156 }
157157 }
lib/std/crypto/sha3.zig+1-1
......@@ -148,7 +148,7 @@ fn ShakeLike(comptime security_level: u11, comptime delim: u8, comptime rounds:
148148 if (self.offset > 0) {
149149 const left = self.buf.len - self.offset;
150150 if (left > 0) {
151 const n = math.min(left, out.len);
151 const n = @min(left, out.len);
152152 @memcpy(out[0..n], self.buf[self.offset..][0..n]);
153153 out = out[n..];
154154 self.offset += n;
lib/std/crypto/siphash.zig+1-1
......@@ -433,7 +433,7 @@ test "iterative non-divisible update" {
433433 var siphash = Siphash.init(key);
434434 var i: usize = 0;
435435 while (i < end) : (i += 7) {
436 siphash.update(buf[i..std.math.min(i + 7, end)]);
436 siphash.update(buf[i..@min(i + 7, end)]);
437437 }
438438 const iterative_hash = siphash.finalInt();
439439
lib/std/debug.zig+2-2
......@@ -198,7 +198,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackT
198198 stack_trace.index = 0;
199199 return;
200200 };
201 const end_index = math.min(first_index + addrs.len, n);
201 const end_index = @min(first_index + addrs.len, n);
202202 const slice = addr_buf[first_index..end_index];
203203 // We use a for loop here because slice and addrs may alias.
204204 for (slice, 0..) |addr, i| {
......@@ -380,7 +380,7 @@ pub fn writeStackTrace(
380380 _ = allocator;
381381 if (builtin.strip_debug_info) return error.MissingDebugInfo;
382382 var frame_index: usize = 0;
383 var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);
383 var frames_left: usize = @min(stack_trace.index, stack_trace.instruction_addresses.len);
384384
385385 while (frames_left != 0) : ({
386386 frames_left -= 1;
lib/std/dynamic_library.zig+1-2
......@@ -8,7 +8,6 @@ const elf = std.elf;
88const windows = std.os.windows;
99const system = std.os.system;
1010const maxInt = std.math.maxInt;
11const max = std.math.max;
1211
1312pub const DynLib = switch (builtin.os.tag) {
1413 .linux => if (builtin.link_libc) DlDynlib else ElfDynLib,
......@@ -152,7 +151,7 @@ pub const ElfDynLib = struct {
152151 }) {
153152 const ph = @intToPtr(*elf.Phdr, ph_addr);
154153 switch (ph.p_type) {
155 elf.PT_LOAD => virt_addr_end = max(virt_addr_end, ph.p_vaddr + ph.p_memsz),
154 elf.PT_LOAD => virt_addr_end = @max(virt_addr_end, ph.p_vaddr + ph.p_memsz),
156155 elf.PT_DYNAMIC => maybe_dynv = @intToPtr([*]usize, elf_addr + ph.p_offset),
157156 else => {},
158157 }
lib/std/event/loop.zig+1-1
......@@ -179,7 +179,7 @@ pub const Loop = struct {
179179
180180 // We need at least one of these in case the fs thread wants to use onNextTick
181181 const extra_thread_count = thread_count - 1;
182 const resume_node_count = std.math.max(extra_thread_count, 1);
182 const resume_node_count = @max(extra_thread_count, 1);
183183 self.eventfd_resume_nodes = try self.arena.allocator().alloc(
184184 std.atomic.Stack(ResumeNode.EventFd).Node,
185185 resume_node_count,
lib/std/fifo.zig+1-1
......@@ -150,7 +150,7 @@ pub fn LinearFifo(
150150 start -= self.buf.len;
151151 return self.buf[start .. start + (self.count - offset)];
152152 } else {
153 const end = math.min(self.head + self.count, self.buf.len);
153 const end = @min(self.head + self.count, self.buf.len);
154154 return self.buf[start..end];
155155 }
156156 }
lib/std/fmt.zig+9-9
......@@ -921,8 +921,8 @@ fn formatSizeImpl(comptime base: comptime_int) type {
921921
922922 const log2 = math.log2(value);
923923 const magnitude = switch (base) {
924 1000 => math.min(log2 / comptime math.log2(1000), mags_si.len - 1),
925 1024 => math.min(log2 / 10, mags_iec.len - 1),
924 1000 => @min(log2 / comptime math.log2(1000), mags_si.len - 1),
925 1024 => @min(log2 / 10, mags_iec.len - 1),
926926 else => unreachable,
927927 };
928928 const new_value = lossyCast(f64, value) / math.pow(f64, lossyCast(f64, base), lossyCast(f64, magnitude));
......@@ -1103,7 +1103,7 @@ pub fn formatFloatScientific(
11031103
11041104 var printed: usize = 0;
11051105 if (float_decimal.digits.len > 1) {
1106 const num_digits = math.min(float_decimal.digits.len, precision + 1);
1106 const num_digits = @min(float_decimal.digits.len, precision + 1);
11071107 try writer.writeAll(float_decimal.digits[1..num_digits]);
11081108 printed += num_digits - 1;
11091109 }
......@@ -1116,7 +1116,7 @@ pub fn formatFloatScientific(
11161116 try writer.writeAll(float_decimal.digits[0..1]);
11171117 try writer.writeAll(".");
11181118 if (float_decimal.digits.len > 1) {
1119 const num_digits = if (@TypeOf(value) == f32) math.min(@as(usize, 9), float_decimal.digits.len) else float_decimal.digits.len;
1119 const num_digits = if (@TypeOf(value) == f32) @min(@as(usize, 9), float_decimal.digits.len) else float_decimal.digits.len;
11201120
11211121 try writer.writeAll(float_decimal.digits[1..num_digits]);
11221122 } else {
......@@ -1299,7 +1299,7 @@ pub fn formatFloatDecimal(
12991299 var num_digits_whole = if (float_decimal.exp > 0) @intCast(usize, float_decimal.exp) else 0;
13001300
13011301 // the actual slice into the buffer, we may need to zero-pad between num_digits_whole and this.
1302 var num_digits_whole_no_pad = math.min(num_digits_whole, float_decimal.digits.len);
1302 var num_digits_whole_no_pad = @min(num_digits_whole, float_decimal.digits.len);
13031303
13041304 if (num_digits_whole > 0) {
13051305 // We may have to zero pad, for instance 1e4 requires zero padding.
......@@ -1326,7 +1326,7 @@ pub fn formatFloatDecimal(
13261326 // Zero-fill until we reach significant digits or run out of precision.
13271327 if (float_decimal.exp <= 0) {
13281328 const zero_digit_count = @intCast(usize, -float_decimal.exp);
1329 const zeros_to_print = math.min(zero_digit_count, precision);
1329 const zeros_to_print = @min(zero_digit_count, precision);
13301330
13311331 var i: usize = 0;
13321332 while (i < zeros_to_print) : (i += 1) {
......@@ -1357,7 +1357,7 @@ pub fn formatFloatDecimal(
13571357 var num_digits_whole = if (float_decimal.exp > 0) @intCast(usize, float_decimal.exp) else 0;
13581358
13591359 // the actual slice into the buffer, we may need to zero-pad between num_digits_whole and this.
1360 var num_digits_whole_no_pad = math.min(num_digits_whole, float_decimal.digits.len);
1360 var num_digits_whole_no_pad = @min(num_digits_whole, float_decimal.digits.len);
13611361
13621362 if (num_digits_whole > 0) {
13631363 // We may have to zero pad, for instance 1e4 requires zero padding.
......@@ -1410,12 +1410,12 @@ pub fn formatInt(
14101410
14111411 // The type must have the same size as `base` or be wider in order for the
14121412 // division to work
1413 const min_int_bits = comptime math.max(value_info.bits, 8);
1413 const min_int_bits = comptime @max(value_info.bits, 8);
14141414 const MinInt = std.meta.Int(.unsigned, min_int_bits);
14151415
14161416 const abs_value = math.absCast(int_value);
14171417 // The worst case in terms of space needed is base 2, plus 1 for the sign
1418 var buf: [1 + math.max(value_info.bits, 1)]u8 = undefined;
1418 var buf: [1 + @max(@as(comptime_int, value_info.bits), 1)]u8 = undefined;
14191419
14201420 var a: MinInt = abs_value;
14211421 var index: usize = buf.len;
lib/std/hash/wyhash.zig+1-1
......@@ -252,7 +252,7 @@ test "iterative non-divisible update" {
252252 var wy = Wyhash.init(seed);
253253 var i: usize = 0;
254254 while (i < end) : (i += 33) {
255 wy.update(buf[i..std.math.min(i + 33, end)]);
255 wy.update(buf[i..@min(i + 33, end)]);
256256 }
257257 const iterative_hash = wy.final();
258258
lib/std/hash_map.zig+3-3
......@@ -1507,7 +1507,7 @@ pub fn HashMapUnmanaged(
15071507
15081508 fn grow(self: *Self, allocator: Allocator, new_capacity: Size, ctx: Context) Allocator.Error!void {
15091509 @setCold(true);
1510 const new_cap = std.math.max(new_capacity, minimal_capacity);
1510 const new_cap = @max(new_capacity, minimal_capacity);
15111511 assert(new_cap > self.capacity());
15121512 assert(std.math.isPowerOfTwo(new_cap));
15131513
......@@ -1540,7 +1540,7 @@ pub fn HashMapUnmanaged(
15401540 const header_align = @alignOf(Header);
15411541 const key_align = if (@sizeOf(K) == 0) 1 else @alignOf(K);
15421542 const val_align = if (@sizeOf(V) == 0) 1 else @alignOf(V);
1543 const max_align = comptime math.max3(header_align, key_align, val_align);
1543 const max_align = comptime @max(header_align, key_align, val_align);
15441544
15451545 const meta_size = @sizeOf(Header) + new_capacity * @sizeOf(Metadata);
15461546 comptime assert(@alignOf(Metadata) == 1);
......@@ -1575,7 +1575,7 @@ pub fn HashMapUnmanaged(
15751575 const header_align = @alignOf(Header);
15761576 const key_align = if (@sizeOf(K) == 0) 1 else @alignOf(K);
15771577 const val_align = if (@sizeOf(V) == 0) 1 else @alignOf(V);
1578 const max_align = comptime math.max3(header_align, key_align, val_align);
1578 const max_align = comptime @max(header_align, key_align, val_align);
15791579
15801580 const cap = self.capacity();
15811581 const meta_size = @sizeOf(Header) + cap * @sizeOf(Metadata);
lib/std/heap/arena_allocator.zig+1-1
......@@ -110,7 +110,7 @@ pub const ArenaAllocator = struct {
110110 // value.
111111 const requested_capacity = switch (mode) {
112112 .retain_capacity => self.queryCapacity(),
113 .retain_with_limit => |limit| std.math.min(limit, self.queryCapacity()),
113 .retain_with_limit => |limit| @min(limit, self.queryCapacity()),
114114 .free_all => 0,
115115 };
116116 if (requested_capacity == 0) {
lib/std/heap/memory_pool.zig+2-2
......@@ -40,11 +40,11 @@ pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type
4040
4141 /// Size of the memory pool items. This is not necessarily the same
4242 /// as `@sizeOf(Item)` as the pool also uses the items for internal means.
43 pub const item_size = std.math.max(@sizeOf(Node), @sizeOf(Item));
43 pub const item_size = @max(@sizeOf(Node), @sizeOf(Item));
4444
4545 /// Alignment of the memory pool items. This is not necessarily the same
4646 /// as `@alignOf(Item)` as the pool also uses the items for internal means.
47 pub const item_alignment = std.math.max(@alignOf(Node), pool_options.alignment orelse 0);
47 pub const item_alignment = @max(@alignOf(Node), pool_options.alignment orelse 0);
4848
4949 const Node = struct {
5050 next: ?*@This(),
lib/std/http/protocol.zig+1-1
......@@ -82,7 +82,7 @@ pub const HeadersParser = struct {
8282 /// If the amount returned is less than `bytes.len`, you may assume that the parser is in a content state and the
8383 /// first byte of content is located at `bytes[result]`.
8484 pub fn findHeadersEnd(r: *HeadersParser, bytes: []const u8) u32 {
85 const vector_len: comptime_int = comptime std.math.max(std.simd.suggestVectorSize(u8) orelse 1, 8);
85 const vector_len: comptime_int = comptime @max(std.simd.suggestVectorSize(u8) orelse 1, 8);
8686 const len = @intCast(u32, bytes.len);
8787 var index: u32 = 0;
8888
lib/std/io/fixed_buffer_stream.zig+2-2
......@@ -76,7 +76,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
7676 }
7777
7878 pub fn seekTo(self: *Self, pos: u64) SeekError!void {
79 self.pos = if (std.math.cast(usize, pos)) |x| std.math.min(self.buffer.len, x) else self.buffer.len;
79 self.pos = if (std.math.cast(usize, pos)) |x| @min(self.buffer.len, x) else self.buffer.len;
8080 }
8181
8282 pub fn seekBy(self: *Self, amt: i64) SeekError!void {
......@@ -91,7 +91,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
9191 } else {
9292 const amt_usize = std.math.cast(usize, amt) orelse std.math.maxInt(usize);
9393 const new_pos = std.math.add(usize, self.pos, amt_usize) catch std.math.maxInt(usize);
94 self.pos = std.math.min(self.buffer.len, new_pos);
94 self.pos = @min(self.buffer.len, new_pos);
9595 }
9696 }
9797
lib/std/io/limited_reader.zig+1-1
......@@ -14,7 +14,7 @@ pub fn LimitedReader(comptime ReaderType: type) type {
1414 const Self = @This();
1515
1616 pub fn read(self: *Self, dest: []u8) Error!usize {
17 const max_read = std.math.min(self.bytes_left, dest.len);
17 const max_read = @min(self.bytes_left, dest.len);
1818 const n = try self.inner_reader.read(dest[0..max_read]);
1919 self.bytes_left -= n;
2020 return n;
lib/std/io/reader.zig+1-1
......@@ -325,7 +325,7 @@ pub fn Reader(
325325 var remaining = num_bytes;
326326
327327 while (remaining > 0) {
328 const amt = std.math.min(remaining, options.buf_size);
328 const amt = @min(remaining, options.buf_size);
329329 try self.readNoEof(buf[0..amt]);
330330 remaining -= amt;
331331 }
lib/std/io/writer.zig+1-1
......@@ -39,7 +39,7 @@ pub fn Writer(
3939
4040 var remaining: usize = n;
4141 while (remaining > 0) {
42 const to_write = std.math.min(remaining, bytes.len);
42 const to_write = @min(remaining, bytes.len);
4343 try self.writeAll(bytes[0..to_write]);
4444 remaining -= to_write;
4545 }
lib/std/math.zig+7-96
......@@ -165,7 +165,7 @@ pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool {
165165 if (isNan(x) or isNan(y))
166166 return false;
167167
168 return @fabs(x - y) <= max(@fabs(x), @fabs(y)) * tolerance;
168 return @fabs(x - y) <= @max(@fabs(x), @fabs(y)) * tolerance;
169169}
170170
171171test "approxEqAbs and approxEqRel" {
......@@ -434,104 +434,15 @@ pub fn Min(comptime A: type, comptime B: type) type {
434434 return @TypeOf(@as(A, 0) + @as(B, 0));
435435}
436436
437/// Returns the smaller number. When one parameter's type's full range
438/// fits in the other, the return type is the smaller type.
439pub fn min(x: anytype, y: anytype) Min(@TypeOf(x), @TypeOf(y)) {
440 const Result = Min(@TypeOf(x), @TypeOf(y));
441 if (x < y) {
442 // TODO Zig should allow this as an implicit cast because x is
443 // immutable and in this scope it is known to fit in the
444 // return type.
445 switch (@typeInfo(Result)) {
446 .Int => return @intCast(Result, x),
447 else => return x,
448 }
449 } else {
450 // TODO Zig should allow this as an implicit cast because y is
451 // immutable and in this scope it is known to fit in the
452 // return type.
453 switch (@typeInfo(Result)) {
454 .Int => return @intCast(Result, y),
455 else => return y,
456 }
457 }
458}
459
460test "min" {
461 try testing.expect(min(@as(i32, -1), @as(i32, 2)) == -1);
462 {
463 var a: u16 = 999;
464 var b: u32 = 10;
465 var result = min(a, b);
466 try testing.expect(@TypeOf(result) == u16);
467 try testing.expect(result == 10);
468 }
469 {
470 var a: f64 = 10.34;
471 var b: f32 = 999.12;
472 var result = min(a, b);
473 try testing.expect(@TypeOf(result) == f64);
474 try testing.expect(result == 10.34);
475 }
476 {
477 var a: i8 = -127;
478 var b: i16 = -200;
479 var result = min(a, b);
480 try testing.expect(@TypeOf(result) == i16);
481 try testing.expect(result == -200);
482 }
483 {
484 const a = 10.34;
485 var b: f32 = 999.12;
486 var result = min(a, b);
487 try testing.expect(@TypeOf(result) == f32);
488 try testing.expect(result == 10.34);
489 }
490}
491
492/// Finds the minimum of three numbers.
493pub fn min3(x: anytype, y: anytype, z: anytype) @TypeOf(x, y, z) {
494 return min(x, min(y, z));
495}
496
497test "min3" {
498 try testing.expect(min3(@as(i32, 0), @as(i32, 1), @as(i32, 2)) == 0);
499 try testing.expect(min3(@as(i32, 0), @as(i32, 2), @as(i32, 1)) == 0);
500 try testing.expect(min3(@as(i32, 1), @as(i32, 0), @as(i32, 2)) == 0);
501 try testing.expect(min3(@as(i32, 1), @as(i32, 2), @as(i32, 0)) == 0);
502 try testing.expect(min3(@as(i32, 2), @as(i32, 0), @as(i32, 1)) == 0);
503 try testing.expect(min3(@as(i32, 2), @as(i32, 1), @as(i32, 0)) == 0);
504}
505
506/// Returns the maximum of two numbers. Return type is the one with the
507/// larger range.
508pub fn max(x: anytype, y: anytype) @TypeOf(x, y) {
509 return if (x > y) x else y;
510}
511
512test "max" {
513 try testing.expect(max(@as(i32, -1), @as(i32, 2)) == 2);
514 try testing.expect(max(@as(i32, 2), @as(i32, -1)) == 2);
515}
516
517/// Finds the maximum of three numbers.
518pub fn max3(x: anytype, y: anytype, z: anytype) @TypeOf(x, y, z) {
519 return max(x, max(y, z));
520}
521
522test "max3" {
523 try testing.expect(max3(@as(i32, 0), @as(i32, 1), @as(i32, 2)) == 2);
524 try testing.expect(max3(@as(i32, 0), @as(i32, 2), @as(i32, 1)) == 2);
525 try testing.expect(max3(@as(i32, 1), @as(i32, 0), @as(i32, 2)) == 2);
526 try testing.expect(max3(@as(i32, 1), @as(i32, 2), @as(i32, 0)) == 2);
527 try testing.expect(max3(@as(i32, 2), @as(i32, 0), @as(i32, 1)) == 2);
528 try testing.expect(max3(@as(i32, 2), @as(i32, 1), @as(i32, 0)) == 2);
529}
437pub const min = @compileError("deprecated; use @min instead");
438pub const max = @compileError("deprecated; use @max instead");
439pub const min3 = @compileError("deprecated; use @min instead");
440pub const max3 = @compileError("deprecated; use @max instead");
530441
531442/// Limit val to the inclusive range [lower, upper].
532443pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {
533444 assert(lower <= upper);
534 return max(lower, min(val, upper));
445 return @max(lower, @min(val, upper));
535446}
536447test "clamp" {
537448 // Within range
......@@ -795,7 +706,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
795706 return u0;
796707 }
797708 const signedness: std.builtin.Signedness = if (from < 0) .signed else .unsigned;
798 const largest_positive_integer = max(if (from < 0) (-from) - 1 else from, to); // two's complement
709 const largest_positive_integer = @max(if (from < 0) (-from) - 1 else from, to); // two's complement
799710 const base = log2(largest_positive_integer);
800711 const upper = (1 << base) - 1;
801712 var magnitude_bits = if (upper >= largest_positive_integer) base else base + 1;
lib/std/math/big/int.zig+48-48
......@@ -44,12 +44,12 @@ pub fn calcDivLimbsBufferLen(a_len: usize, b_len: usize) usize {
4444}
4545
4646pub fn calcMulLimbsBufferLen(a_len: usize, b_len: usize, aliases: usize) usize {
47 return aliases * math.max(a_len, b_len);
47 return aliases * @max(a_len, b_len);
4848}
4949
5050pub fn calcMulWrapLimbsBufferLen(bit_count: usize, a_len: usize, b_len: usize, aliases: usize) usize {
5151 const req_limbs = calcTwosCompLimbCount(bit_count);
52 return aliases * math.min(req_limbs, math.max(a_len, b_len));
52 return aliases * @min(req_limbs, @max(a_len, b_len));
5353}
5454
5555pub fn calcSetStringLimbsBufferLen(base: u8, string_len: usize) usize {
......@@ -396,7 +396,7 @@ pub const Mutable = struct {
396396 /// scalar is a primitive integer type.
397397 ///
398398 /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by
399 /// r is `math.max(a.limbs.len, calcLimbLen(scalar)) + 1`.
399 /// r is `@max(a.limbs.len, calcLimbLen(scalar)) + 1`.
400400 pub fn addScalar(r: *Mutable, a: Const, scalar: anytype) void {
401401 // Normally we could just determine the number of limbs needed with calcLimbLen,
402402 // but that is not comptime-known when scalar is not a comptime_int. Instead, we
......@@ -414,11 +414,11 @@ pub const Mutable = struct {
414414 return add(r, a, operand);
415415 }
416416
417 /// Base implementation for addition. Adds `max(a.limbs.len, b.limbs.len)` elements from a and b,
417 /// Base implementation for addition. Adds `@max(a.limbs.len, b.limbs.len)` elements from a and b,
418418 /// and returns whether any overflow occurred.
419419 /// r, a and b may be aliases.
420420 ///
421 /// Asserts r has enough elements to hold the result. The upper bound is `max(a.limbs.len, b.limbs.len)`.
421 /// Asserts r has enough elements to hold the result. The upper bound is `@max(a.limbs.len, b.limbs.len)`.
422422 fn addCarry(r: *Mutable, a: Const, b: Const) bool {
423423 if (a.eqZero()) {
424424 r.copy(b);
......@@ -452,12 +452,12 @@ pub const Mutable = struct {
452452 /// r, a and b may be aliases.
453453 ///
454454 /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by
455 /// r is `math.max(a.limbs.len, b.limbs.len) + 1`.
455 /// r is `@max(a.limbs.len, b.limbs.len) + 1`.
456456 pub fn add(r: *Mutable, a: Const, b: Const) void {
457457 if (r.addCarry(a, b)) {
458458 // Fix up the result. Note that addCarry normalizes by a.limbs.len or b.limbs.len,
459459 // so we need to set the length here.
460 const msl = math.max(a.limbs.len, b.limbs.len);
460 const msl = @max(a.limbs.len, b.limbs.len);
461461 // `[add|sub]Carry` normalizes by `msl`, so we need to fix up the result manually here.
462462 // Note, the fact that it normalized means that the intermediary limbs are zero here.
463463 r.len = msl + 1;
......@@ -477,12 +477,12 @@ pub const Mutable = struct {
477477 // if an overflow occurred.
478478 const x = Const{
479479 .positive = a.positive,
480 .limbs = a.limbs[0..math.min(req_limbs, a.limbs.len)],
480 .limbs = a.limbs[0..@min(req_limbs, a.limbs.len)],
481481 };
482482
483483 const y = Const{
484484 .positive = b.positive,
485 .limbs = b.limbs[0..math.min(req_limbs, b.limbs.len)],
485 .limbs = b.limbs[0..@min(req_limbs, b.limbs.len)],
486486 };
487487
488488 var carry_truncated = false;
......@@ -492,7 +492,7 @@ pub const Mutable = struct {
492492 // truncate anyway.
493493 // - a and b had less elements than req_limbs, and those were overflowed. This case needs to be handled.
494494 // Note: after this we still might need to wrap.
495 const msl = math.max(a.limbs.len, b.limbs.len);
495 const msl = @max(a.limbs.len, b.limbs.len);
496496 if (msl < req_limbs) {
497497 r.limbs[msl] = 1;
498498 r.len = req_limbs;
......@@ -522,12 +522,12 @@ pub const Mutable = struct {
522522 // if an overflow occurred.
523523 const x = Const{
524524 .positive = a.positive,
525 .limbs = a.limbs[0..math.min(req_limbs, a.limbs.len)],
525 .limbs = a.limbs[0..@min(req_limbs, a.limbs.len)],
526526 };
527527
528528 const y = Const{
529529 .positive = b.positive,
530 .limbs = b.limbs[0..math.min(req_limbs, b.limbs.len)],
530 .limbs = b.limbs[0..@min(req_limbs, b.limbs.len)],
531531 };
532532
533533 if (r.addCarry(x, y)) {
......@@ -535,7 +535,7 @@ pub const Mutable = struct {
535535 // - We overflowed req_limbs, in which case we need to saturate.
536536 // - a and b had less elements than req_limbs, and those were overflowed.
537537 // Note: In this case, might _also_ need to saturate.
538 const msl = math.max(a.limbs.len, b.limbs.len);
538 const msl = @max(a.limbs.len, b.limbs.len);
539539 if (msl < req_limbs) {
540540 r.limbs[msl] = 1;
541541 r.len = req_limbs;
......@@ -550,11 +550,11 @@ pub const Mutable = struct {
550550 r.saturate(r.toConst(), signedness, bit_count);
551551 }
552552
553 /// Base implementation for subtraction. Subtracts `max(a.limbs.len, b.limbs.len)` elements from a and b,
553 /// Base implementation for subtraction. Subtracts `@max(a.limbs.len, b.limbs.len)` elements from a and b,
554554 /// and returns whether any overflow occurred.
555555 /// r, a and b may be aliases.
556556 ///
557 /// Asserts r has enough elements to hold the result. The upper bound is `max(a.limbs.len, b.limbs.len)`.
557 /// Asserts r has enough elements to hold the result. The upper bound is `@max(a.limbs.len, b.limbs.len)`.
558558 fn subCarry(r: *Mutable, a: Const, b: Const) bool {
559559 if (a.eqZero()) {
560560 r.copy(b);
......@@ -607,7 +607,7 @@ pub const Mutable = struct {
607607 /// r, a and b may be aliases.
608608 ///
609609 /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by
610 /// r is `math.max(a.limbs.len, b.limbs.len) + 1`. The +1 is not needed if both operands are positive.
610 /// r is `@max(a.limbs.len, b.limbs.len) + 1`. The +1 is not needed if both operands are positive.
611611 pub fn sub(r: *Mutable, a: Const, b: Const) void {
612612 r.add(a, b.negate());
613613 }
......@@ -714,7 +714,7 @@ pub const Mutable = struct {
714714
715715 const a_copy = if (rma.limbs.ptr == a.limbs.ptr) blk: {
716716 const start = buf_index;
717 const a_len = math.min(req_limbs, a.limbs.len);
717 const a_len = @min(req_limbs, a.limbs.len);
718718 @memcpy(limbs_buffer[buf_index..][0..a_len], a.limbs[0..a_len]);
719719 buf_index += a_len;
720720 break :blk a.toMutable(limbs_buffer[start..buf_index]).toConst();
......@@ -722,7 +722,7 @@ pub const Mutable = struct {
722722
723723 const b_copy = if (rma.limbs.ptr == b.limbs.ptr) blk: {
724724 const start = buf_index;
725 const b_len = math.min(req_limbs, b.limbs.len);
725 const b_len = @min(req_limbs, b.limbs.len);
726726 @memcpy(limbs_buffer[buf_index..][0..b_len], b.limbs[0..b_len]);
727727 buf_index += b_len;
728728 break :blk a.toMutable(limbs_buffer[start..buf_index]).toConst();
......@@ -755,13 +755,13 @@ pub const Mutable = struct {
755755 const req_limbs = calcTwosCompLimbCount(bit_count);
756756
757757 // We can ignore the upper bits here, those results will be discarded anyway.
758 const a_limbs = a.limbs[0..math.min(req_limbs, a.limbs.len)];
759 const b_limbs = b.limbs[0..math.min(req_limbs, b.limbs.len)];
758 const a_limbs = a.limbs[0..@min(req_limbs, a.limbs.len)];
759 const b_limbs = b.limbs[0..@min(req_limbs, b.limbs.len)];
760760
761761 @memset(rma.limbs[0..req_limbs], 0);
762762
763763 llmulacc(.add, allocator, rma.limbs, a_limbs, b_limbs);
764 rma.normalize(math.min(req_limbs, a.limbs.len + b.limbs.len));
764 rma.normalize(@min(req_limbs, a.limbs.len + b.limbs.len));
765765 rma.positive = (a.positive == b.positive);
766766 rma.truncate(rma.toConst(), signedness, bit_count);
767767 }
......@@ -1211,7 +1211,7 @@ pub const Mutable = struct {
12111211 ///
12121212 /// a and b are zero-extended to the longer of a or b.
12131213 ///
1214 /// Asserts that r has enough limbs to store the result. Upper bound is `math.max(a.limbs.len, b.limbs.len)`.
1214 /// Asserts that r has enough limbs to store the result. Upper bound is `@max(a.limbs.len, b.limbs.len)`.
12151215 pub fn bitOr(r: *Mutable, a: Const, b: Const) void {
12161216 // Trivial cases, llsignedor does not support zero.
12171217 if (a.eqZero()) {
......@@ -1235,8 +1235,8 @@ pub const Mutable = struct {
12351235 /// r may alias with a or b.
12361236 ///
12371237 /// Asserts that r has enough limbs to store the result.
1238 /// If a or b is positive, the upper bound is `math.min(a.limbs.len, b.limbs.len)`.
1239 /// If a and b are negative, the upper bound is `math.max(a.limbs.len, b.limbs.len) + 1`.
1238 /// If a or b is positive, the upper bound is `@min(a.limbs.len, b.limbs.len)`.
1239 /// If a and b are negative, the upper bound is `@max(a.limbs.len, b.limbs.len) + 1`.
12401240 pub fn bitAnd(r: *Mutable, a: Const, b: Const) void {
12411241 // Trivial cases, llsignedand does not support zero.
12421242 if (a.eqZero()) {
......@@ -1260,8 +1260,8 @@ pub const Mutable = struct {
12601260 /// r may alias with a or b.
12611261 ///
12621262 /// Asserts that r has enough limbs to store the result. If a and b share the same signedness, the
1263 /// upper bound is `math.max(a.limbs.len, b.limbs.len)`. Otherwise, if either a or b is negative
1264 /// but not both, the upper bound is `math.max(a.limbs.len, b.limbs.len) + 1`.
1263 /// upper bound is `@max(a.limbs.len, b.limbs.len)`. Otherwise, if either a or b is negative
1264 /// but not both, the upper bound is `@max(a.limbs.len, b.limbs.len) + 1`.
12651265 pub fn bitXor(r: *Mutable, a: Const, b: Const) void {
12661266 // Trivial cases, because llsignedxor does not support negative zero.
12671267 if (a.eqZero()) {
......@@ -1284,7 +1284,7 @@ pub const Mutable = struct {
12841284 /// rma may alias x or y.
12851285 /// x and y may alias each other.
12861286 /// Asserts that `rma` has enough limbs to store the result. Upper bound is
1287 /// `math.min(x.limbs.len, y.limbs.len)`.
1287 /// `@min(x.limbs.len, y.limbs.len)`.
12881288 ///
12891289 /// `limbs_buffer` is used for temporary storage during the operation. When this function returns,
12901290 /// it will have the same length as it had when the function was called.
......@@ -1546,7 +1546,7 @@ pub const Mutable = struct {
15461546 if (yi != 0) break i;
15471547 } else unreachable;
15481548
1549 const xy_trailing = math.min(x_trailing, y_trailing);
1549 const xy_trailing = @min(x_trailing, y_trailing);
15501550
15511551 if (y.len - xy_trailing == 1) {
15521552 const divisor = y.limbs[y.len - 1];
......@@ -2589,7 +2589,7 @@ pub const Managed = struct {
25892589 .allocator = allocator,
25902590 .metadata = 1,
25912591 .limbs = block: {
2592 const limbs = try allocator.alloc(Limb, math.max(default_capacity, capacity));
2592 const limbs = try allocator.alloc(Limb, @max(default_capacity, capacity));
25932593 limbs[0] = 0;
25942594 break :block limbs;
25952595 },
......@@ -2918,7 +2918,7 @@ pub const Managed = struct {
29182918 ///
29192919 /// Returns an error if memory could not be allocated.
29202920 pub fn sub(r: *Managed, a: *const Managed, b: *const Managed) !void {
2921 try r.ensureCapacity(math.max(a.len(), b.len()) + 1);
2921 try r.ensureCapacity(@max(a.len(), b.len()) + 1);
29222922 var m = r.toMutable();
29232923 m.sub(a.toConst(), b.toConst());
29242924 r.setMetadata(m.positive, m.len);
......@@ -3025,11 +3025,11 @@ pub const Managed = struct {
30253025 }
30263026
30273027 pub fn ensureAddScalarCapacity(r: *Managed, a: Const, scalar: anytype) !void {
3028 try r.ensureCapacity(math.max(a.limbs.len, calcLimbLen(scalar)) + 1);
3028 try r.ensureCapacity(@max(a.limbs.len, calcLimbLen(scalar)) + 1);
30293029 }
30303030
30313031 pub fn ensureAddCapacity(r: *Managed, a: Const, b: Const) !void {
3032 try r.ensureCapacity(math.max(a.limbs.len, b.limbs.len) + 1);
3032 try r.ensureCapacity(@max(a.limbs.len, b.limbs.len) + 1);
30333033 }
30343034
30353035 pub fn ensureMulCapacity(rma: *Managed, a: Const, b: Const) !void {
......@@ -3123,7 +3123,7 @@ pub const Managed = struct {
31233123 ///
31243124 /// a and b are zero-extended to the longer of a or b.
31253125 pub fn bitOr(r: *Managed, a: *const Managed, b: *const Managed) !void {
3126 try r.ensureCapacity(math.max(a.len(), b.len()));
3126 try r.ensureCapacity(@max(a.len(), b.len()));
31273127 var m = r.toMutable();
31283128 m.bitOr(a.toConst(), b.toConst());
31293129 r.setMetadata(m.positive, m.len);
......@@ -3132,9 +3132,9 @@ pub const Managed = struct {
31323132 /// r = a & b
31333133 pub fn bitAnd(r: *Managed, a: *const Managed, b: *const Managed) !void {
31343134 const cap = if (a.isPositive() or b.isPositive())
3135 math.min(a.len(), b.len())
3135 @min(a.len(), b.len())
31363136 else
3137 math.max(a.len(), b.len()) + 1;
3137 @max(a.len(), b.len()) + 1;
31383138 try r.ensureCapacity(cap);
31393139 var m = r.toMutable();
31403140 m.bitAnd(a.toConst(), b.toConst());
......@@ -3143,7 +3143,7 @@ pub const Managed = struct {
31433143
31443144 /// r = a ^ b
31453145 pub fn bitXor(r: *Managed, a: *const Managed, b: *const Managed) !void {
3146 var cap = math.max(a.len(), b.len()) + @boolToInt(a.isPositive() != b.isPositive());
3146 var cap = @max(a.len(), b.len()) + @boolToInt(a.isPositive() != b.isPositive());
31473147 try r.ensureCapacity(cap);
31483148
31493149 var m = r.toMutable();
......@@ -3156,7 +3156,7 @@ pub const Managed = struct {
31563156 ///
31573157 /// rma's allocator is used for temporary storage to boost multiplication performance.
31583158 pub fn gcd(rma: *Managed, x: *const Managed, y: *const Managed) !void {
3159 try rma.ensureCapacity(math.min(x.len(), y.len()));
3159 try rma.ensureCapacity(@min(x.len(), y.len()));
31603160 var m = rma.toMutable();
31613161 var limbs_buffer = std.ArrayList(Limb).init(rma.allocator);
31623162 defer limbs_buffer.deinit();
......@@ -3356,13 +3356,13 @@ fn llmulaccKaratsuba(
33563356 // For a1 and b1 we only need `limbs_after_split` limbs.
33573357 const a1 = blk: {
33583358 var a1 = a[split..];
3359 a1.len = math.min(llnormalize(a1), limbs_after_split);
3359 a1.len = @min(llnormalize(a1), limbs_after_split);
33603360 break :blk a1;
33613361 };
33623362
33633363 const b1 = blk: {
33643364 var b1 = b[split..];
3365 b1.len = math.min(llnormalize(b1), limbs_after_split);
3365 b1.len = @min(llnormalize(b1), limbs_after_split);
33663366 break :blk b1;
33673367 };
33683368
......@@ -3381,10 +3381,10 @@ fn llmulaccKaratsuba(
33813381
33823382 // Compute p2.
33833383 // Note, we don't need to compute all of p2, just enough limbs to satisfy r.
3384 const p2_limbs = math.min(limbs_after_split, a1.len + b1.len);
3384 const p2_limbs = @min(limbs_after_split, a1.len + b1.len);
33853385
33863386 @memset(tmp[0..p2_limbs], 0);
3387 llmulacc(.add, allocator, tmp[0..p2_limbs], a1[0..math.min(a1.len, p2_limbs)], b1[0..math.min(b1.len, p2_limbs)]);
3387 llmulacc(.add, allocator, tmp[0..p2_limbs], a1[0..@min(a1.len, p2_limbs)], b1[0..@min(b1.len, p2_limbs)]);
33883388 const p2 = tmp[0..llnormalize(tmp[0..p2_limbs])];
33893389
33903390 // Add p2 * B to the result.
......@@ -3392,7 +3392,7 @@ fn llmulaccKaratsuba(
33923392
33933393 // Add p2 * B^2 to the result if required.
33943394 if (limbs_after_split2 > 0) {
3395 llaccum(op, r[split * 2 ..], p2[0..math.min(p2.len, limbs_after_split2)]);
3395 llaccum(op, r[split * 2 ..], p2[0..@min(p2.len, limbs_after_split2)]);
33963396 }
33973397
33983398 // Compute p0.
......@@ -3406,13 +3406,13 @@ fn llmulaccKaratsuba(
34063406 llaccum(op, r, p0);
34073407
34083408 // Add p0 * B to the result. In this case, we may not need all of it.
3409 llaccum(op, r[split..], p0[0..math.min(limbs_after_split, p0.len)]);
3409 llaccum(op, r[split..], p0[0..@min(limbs_after_split, p0.len)]);
34103410
34113411 // Finally, compute and add p1.
34123412 // From now on we only need `limbs_after_split` limbs for a0 and b0, since the result of the
34133413 // following computation will be added * B.
3414 const a0x = a0[0..std.math.min(a0.len, limbs_after_split)];
3415 const b0x = b0[0..std.math.min(b0.len, limbs_after_split)];
3414 const a0x = a0[0..@min(a0.len, limbs_after_split)];
3415 const b0x = b0[0..@min(b0.len, limbs_after_split)];
34163416
34173417 const j0_sign = llcmp(a0x, a1);
34183418 const j1_sign = llcmp(b1, b0x);
......@@ -3544,7 +3544,7 @@ fn llmulLimb(comptime op: AccOp, acc: []Limb, y: []const Limb, xi: Limb) bool {
35443544 return false;
35453545 }
35463546
3547 const split = std.math.min(y.len, acc.len);
3547 const split = @min(y.len, acc.len);
35483548 var a_lo = acc[0..split];
35493549 var a_hi = acc[split..];
35503550
......@@ -4023,8 +4023,8 @@ fn llsignedand(r: []Limb, a: []const Limb, a_positive: bool, b: []const Limb, b_
40234023// r may alias.
40244024// a and b must not be -0.
40254025// Returns `true` when the result is positive.
4026// If the sign of a and b is equal, then r requires at least `max(a.len, b.len)` limbs are required.
4027// Otherwise, r requires at least `max(a.len, b.len) + 1` limbs.
4026// If the sign of a and b is equal, then r requires at least `@max(a.len, b.len)` limbs are required.
4027// Otherwise, r requires at least `@max(a.len, b.len) + 1` limbs.
40284028fn llsignedxor(r: []Limb, a: []const Limb, a_positive: bool, b: []const Limb, b_positive: bool) bool {
40294029 @setRuntimeSafety(debug_safety);
40304030 assert(a.len != 0 and b.len != 0);
lib/std/math/ldexp.zig+1-1
......@@ -48,7 +48,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) {
4848 return @bitCast(T, sign_bit); // Severe underflow. Return +/- 0
4949
5050 // Result underflowed, we need to shift and round
51 const shift = @intCast(Log2Int(TBits), math.min(-n, -(exponent + n) + 1));
51 const shift = @intCast(Log2Int(TBits), @min(-n, -(exponent + n) + 1));
5252 const exact_tie: bool = @ctz(repr) == shift - 1;
5353 var result = repr & mantissa_mask;
5454
lib/std/mem.zig+6-6
......@@ -596,7 +596,7 @@ pub fn sortUnstableContext(a: usize, b: usize, context: anytype) void {
596596
597597/// Compares two slices of numbers lexicographically. O(n).
598598pub fn order(comptime T: type, lhs: []const T, rhs: []const T) math.Order {
599 const n = math.min(lhs.len, rhs.len);
599 const n = @min(lhs.len, rhs.len);
600600 var i: usize = 0;
601601 while (i < n) : (i += 1) {
602602 switch (math.order(lhs[i], rhs[i])) {
......@@ -642,7 +642,7 @@ pub fn eql(comptime T: type, a: []const T, b: []const T) bool {
642642/// Compares two slices and returns the index of the first inequality.
643643/// Returns null if the slices are equal.
644644pub fn indexOfDiff(comptime T: type, a: []const T, b: []const T) ?usize {
645 const shortest = math.min(a.len, b.len);
645 const shortest = @min(a.len, b.len);
646646 if (a.ptr == b.ptr)
647647 return if (a.len == b.len) null else shortest;
648648 var index: usize = 0;
......@@ -3296,7 +3296,7 @@ pub fn min(comptime T: type, slice: []const T) T {
32963296 assert(slice.len > 0);
32973297 var best = slice[0];
32983298 for (slice[1..]) |item| {
3299 best = math.min(best, item);
3299 best = @min(best, item);
33003300 }
33013301 return best;
33023302}
......@@ -3313,7 +3313,7 @@ pub fn max(comptime T: type, slice: []const T) T {
33133313 assert(slice.len > 0);
33143314 var best = slice[0];
33153315 for (slice[1..]) |item| {
3316 best = math.max(best, item);
3316 best = @max(best, item);
33173317 }
33183318 return best;
33193319}
......@@ -3332,8 +3332,8 @@ pub fn minMax(comptime T: type, slice: []const T) struct { min: T, max: T } {
33323332 var minVal = slice[0];
33333333 var maxVal = slice[0];
33343334 for (slice[1..]) |item| {
3335 minVal = math.min(minVal, item);
3336 maxVal = math.max(maxVal, item);
3335 minVal = @min(minVal, item);
3336 maxVal = @max(maxVal, item);
33373337 }
33383338 return .{ .min = minVal, .max = maxVal };
33393339}
lib/std/net.zig+4-4
......@@ -1482,11 +1482,11 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
14821482 error.InvalidCharacter => continue,
14831483 };
14841484 if (mem.eql(u8, name, "ndots")) {
1485 rc.ndots = std.math.min(value, 15);
1485 rc.ndots = @min(value, 15);
14861486 } else if (mem.eql(u8, name, "attempts")) {
1487 rc.attempts = std.math.min(value, 10);
1487 rc.attempts = @min(value, 10);
14881488 } else if (mem.eql(u8, name, "timeout")) {
1489 rc.timeout = std.math.min(value, 60);
1489 rc.timeout = @min(value, 60);
14901490 }
14911491 }
14921492 } else if (mem.eql(u8, token, "nameserver")) {
......@@ -1615,7 +1615,7 @@ fn resMSendRc(
16151615 }
16161616
16171617 // Wait for a response, or until time to retry
1618 const clamped_timeout = std.math.min(@as(u31, std.math.maxInt(u31)), t1 + retry_interval - t2);
1618 const clamped_timeout = @min(@as(u31, std.math.maxInt(u31)), t1 + retry_interval - t2);
16191619 const nevents = os.poll(&pfd, clamped_timeout) catch 0;
16201620 if (nevents == 0) continue;
16211621
lib/std/os/linux.zig+2-2
......@@ -317,7 +317,7 @@ pub fn getdents(fd: i32, dirp: [*]u8, len: usize) usize {
317317 .getdents,
318318 @bitCast(usize, @as(isize, fd)),
319319 @ptrToInt(dirp),
320 std.math.min(len, maxInt(c_int)),
320 @min(len, maxInt(c_int)),
321321 );
322322}
323323
......@@ -326,7 +326,7 @@ pub fn getdents64(fd: i32, dirp: [*]u8, len: usize) usize {
326326 .getdents64,
327327 @bitCast(usize, @as(isize, fd)),
328328 @ptrToInt(dirp),
329 std.math.min(len, maxInt(c_int)),
329 @min(len, maxInt(c_int)),
330330 );
331331}
332332
lib/std/os/linux/io_uring.zig+2-2
......@@ -277,7 +277,7 @@ pub const IO_Uring = struct {
277277 fn copy_cqes_ready(self: *IO_Uring, cqes: []linux.io_uring_cqe, wait_nr: u32) u32 {
278278 _ = wait_nr;
279279 const ready = self.cq_ready();
280 const count = std.math.min(cqes.len, ready);
280 const count = @min(cqes.len, ready);
281281 var head = self.cq.head.*;
282282 var tail = head +% count;
283283 // TODO Optimize this by using 1 or 2 memcpy's (if the tail wraps) rather than a loop.
......@@ -1093,7 +1093,7 @@ pub const SubmissionQueue = struct {
10931093 pub fn init(fd: os.fd_t, p: linux.io_uring_params) !SubmissionQueue {
10941094 assert(fd >= 0);
10951095 assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0);
1096 const size = std.math.max(
1096 const size = @max(
10971097 p.sq_off.array + p.sq_entries * @sizeOf(u32),
10981098 p.cq_off.cqes + p.cq_entries * @sizeOf(linux.io_uring_cqe),
10991099 );
lib/std/os/windows.zig+2-2
......@@ -272,7 +272,7 @@ pub fn RtlGenRandom(output: []u8) RtlGenRandomError!void {
272272 const max_read_size: ULONG = maxInt(ULONG);
273273
274274 while (total_read < output.len) {
275 const to_read: ULONG = math.min(buff.len, max_read_size);
275 const to_read: ULONG = @min(buff.len, max_read_size);
276276
277277 if (advapi32.RtlGenRandom(buff.ptr, to_read) == 0) {
278278 return unexpectedError(kernel32.GetLastError());
......@@ -501,7 +501,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo
501501 return @as(usize, bytes_transferred);
502502 } else {
503503 while (true) {
504 const want_read_count = @intCast(DWORD, math.min(@as(DWORD, maxInt(DWORD)), buffer.len));
504 const want_read_count: DWORD = @min(@as(DWORD, maxInt(DWORD)), buffer.len);
505505 var amt_read: DWORD = undefined;
506506 var overlapped_data: OVERLAPPED = undefined;
507507 const overlapped: ?*OVERLAPPED = if (offset) |off| blk: {
lib/std/pdb.zig+1-1
......@@ -1049,7 +1049,7 @@ const MsfStream = struct {
10491049 var size: usize = 0;
10501050 var rem_buffer = buffer;
10511051 while (size < buffer.len) {
1052 const size_to_read = math.min(self.block_size - offset, rem_buffer.len);
1052 const size_to_read = @min(self.block_size - offset, rem_buffer.len);
10531053 size += try in.read(rem_buffer[0..size_to_read]);
10541054 rem_buffer = buffer[size..];
10551055 offset += size_to_read;
lib/std/rand.zig+1-1
......@@ -410,7 +410,7 @@ pub const Random = struct {
410410 r.uintLessThan(T, sum)
411411 else if (comptime std.meta.trait.isFloat(T))
412412 // take care that imprecision doesn't lead to a value slightly greater than sum
413 std.math.min(r.float(T) * sum, sum - std.math.floatEps(T))
413 @min(r.float(T) * sum, sum - std.math.floatEps(T))
414414 else
415415 @compileError("weightedIndex does not support proportions of type " ++ @typeName(T));
416416
lib/std/sort/block.zig+5-5
......@@ -590,7 +590,7 @@ pub fn block(
590590 // whenever we leave an A block behind, we'll need to merge the previous A block with any B blocks that follow it, so track that information as well
591591 var lastA = firstA;
592592 var lastB = Range.init(0, 0);
593 var blockB = Range.init(B.start, B.start + math.min(block_size, B.length()));
593 var blockB = Range.init(B.start, B.start + @min(block_size, B.length()));
594594 blockA.start += firstA.length();
595595 indexA = buffer1.start;
596596
......@@ -849,7 +849,7 @@ fn findFirstForward(
849849 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
850850) usize {
851851 if (range.length() == 0) return range.start;
852 const skip = math.max(range.length() / unique, @as(usize, 1));
852 const skip = @max(range.length() / unique, @as(usize, 1));
853853
854854 var index = range.start + skip;
855855 while (lessThan(context, items[index - 1], value)) : (index += skip) {
......@@ -871,7 +871,7 @@ fn findFirstBackward(
871871 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
872872) usize {
873873 if (range.length() == 0) return range.start;
874 const skip = math.max(range.length() / unique, @as(usize, 1));
874 const skip = @max(range.length() / unique, @as(usize, 1));
875875
876876 var index = range.end - skip;
877877 while (index > range.start and !lessThan(context, items[index - 1], value)) : (index -= skip) {
......@@ -893,7 +893,7 @@ fn findLastForward(
893893 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
894894) usize {
895895 if (range.length() == 0) return range.start;
896 const skip = math.max(range.length() / unique, @as(usize, 1));
896 const skip = @max(range.length() / unique, @as(usize, 1));
897897
898898 var index = range.start + skip;
899899 while (!lessThan(context, value, items[index - 1])) : (index += skip) {
......@@ -915,7 +915,7 @@ fn findLastBackward(
915915 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
916916) usize {
917917 if (range.length() == 0) return range.start;
918 const skip = math.max(range.length() / unique, @as(usize, 1));
918 const skip = @max(range.length() / unique, @as(usize, 1));
919919
920920 var index = range.end - skip;
921921 while (index > range.start and lessThan(context, value, items[index - 1])) : (index -= skip) {
lib/std/zig/render.zig+2-2
......@@ -1960,7 +1960,7 @@ fn renderArrayInit(
19601960
19611961 if (!this_contains_newline) {
19621962 const column = column_counter % row_size;
1963 column_widths[column] = std.math.max(column_widths[column], width);
1963 column_widths[column] = @max(column_widths[column], width);
19641964
19651965 const expr_last_token = tree.lastToken(expr) + 1;
19661966 const next_expr = section_exprs[i + 1];
......@@ -1980,7 +1980,7 @@ fn renderArrayInit(
19801980
19811981 if (!contains_newline) {
19821982 const column = column_counter % row_size;
1983 column_widths[column] = std.math.max(column_widths[column], width);
1983 column_widths[column] = @max(column_widths[column], width);
19841984 }
19851985 }
19861986 }
lib/std/zig/system/NativeTargetInfo.zig+3-3
......@@ -503,7 +503,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.builtin.Version {
503503 const shstrtab_off = elfInt(is_64, need_bswap, shstr32.sh_offset, shstr64.sh_offset);
504504 const shstrtab_size = elfInt(is_64, need_bswap, shstr32.sh_size, shstr64.sh_size);
505505 var strtab_buf: [4096:0]u8 = undefined;
506 const shstrtab_len = std.math.min(shstrtab_size, strtab_buf.len);
506 const shstrtab_len = @min(shstrtab_size, strtab_buf.len);
507507 const shstrtab_read_len = try preadMin(file, &strtab_buf, shstrtab_off, shstrtab_len);
508508 const shstrtab = strtab_buf[0..shstrtab_read_len];
509509 const shnum = elfInt(is_64, need_bswap, hdr32.e_shnum, hdr64.e_shnum);
......@@ -757,7 +757,7 @@ pub fn abiAndDynamicLinkerFromFile(
757757 const shstrtab_off = elfInt(is_64, need_bswap, shstr32.sh_offset, shstr64.sh_offset);
758758 const shstrtab_size = elfInt(is_64, need_bswap, shstr32.sh_size, shstr64.sh_size);
759759 var strtab_buf: [4096:0]u8 = undefined;
760 const shstrtab_len = std.math.min(shstrtab_size, strtab_buf.len);
760 const shstrtab_len = @min(shstrtab_size, strtab_buf.len);
761761 const shstrtab_read_len = try preadMin(file, &strtab_buf, shstrtab_off, shstrtab_len);
762762 const shstrtab = strtab_buf[0..shstrtab_read_len];
763763
......@@ -806,7 +806,7 @@ pub fn abiAndDynamicLinkerFromFile(
806806 const rpoff_file = ds.offset + rpoff_usize;
807807 const rp_max_size = ds.size - rpoff_usize;
808808
809 const strtab_len = std.math.min(rp_max_size, strtab_buf.len);
809 const strtab_len = @min(rp_max_size, strtab_buf.len);
810810 const strtab_read_len = try preadMin(file, &strtab_buf, rpoff_file, strtab_len);
811811 const strtab = strtab_buf[0..strtab_read_len];
812812
src/Sema.zig+5-5
......@@ -22367,9 +22367,9 @@ fn analyzeShuffle(
2236722367 // to it up to the length of the longer vector. This recursion terminates
2236822368 // in 1 call because these calls to analyzeShuffle guarantee a_len == b_len.
2236922369 if (a_len != b_len) {
22370 const min_len = std.math.min(a_len, b_len);
22370 const min_len = @min(a_len, b_len);
2237122371 const max_src = if (a_len > b_len) a_src else b_src;
22372 const max_len = try sema.usizeCast(block, max_src, std.math.max(a_len, b_len));
22372 const max_len = try sema.usizeCast(block, max_src, @max(a_len, b_len));
2237322373
2237422374 const expand_mask_values = try sema.arena.alloc(InternPool.Index, max_len);
2237522375 for (@intCast(usize, 0)..@intCast(usize, min_len)) |i| {
......@@ -31301,7 +31301,7 @@ fn cmpNumeric(
3130131301 }
3130231302
3130331303 const dest_ty = if (dest_float_type) |ft| ft else blk: {
31304 const max_bits = std.math.max(lhs_bits, rhs_bits);
31304 const max_bits = @max(lhs_bits, rhs_bits);
3130531305 const casted_bits = std.math.cast(u16, max_bits) orelse return sema.fail(block, src, "{d} exceeds maximum integer bit count", .{max_bits});
3130631306 const signedness: std.builtin.Signedness = if (dest_int_is_signed) .signed else .unsigned;
3130731307 break :blk try mod.intType(signedness, casted_bits);
......@@ -35828,7 +35828,7 @@ fn intAddScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) !Value {
3582835828 const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema);
3582935829 const limbs = try sema.arena.alloc(
3583035830 std.math.big.Limb,
35831 std.math.max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
35831 @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
3583235832 );
3583335833 var result_bigint = std.math.big.int.Mutable{ .limbs = limbs, .positive = undefined, .len = undefined };
3583435834 result_bigint.add(lhs_bigint, rhs_bigint);
......@@ -35918,7 +35918,7 @@ fn intSubScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) !Value {
3591835918 const rhs_bigint = try rhs.toBigIntAdvanced(&rhs_space, mod, sema);
3591935919 const limbs = try sema.arena.alloc(
3592035920 std.math.big.Limb,
35921 std.math.max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
35921 @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
3592235922 );
3592335923 var result_bigint = std.math.big.int.Mutable{ .limbs = limbs, .positive = undefined, .len = undefined };
3592435924 result_bigint.sub(lhs_bigint, rhs_bigint);
src/TypedValue.zig+5-5
......@@ -111,7 +111,7 @@ pub fn print(
111111 .val = val.castTag(.repeated).?.data,
112112 };
113113 const len = ty.arrayLen(mod);
114 const max_len = std.math.min(len, max_aggregate_items);
114 const max_len = @min(len, max_aggregate_items);
115115 while (i < max_len) : (i += 1) {
116116 if (i != 0) try writer.writeAll(", ");
117117 try print(elem_tv, writer, level - 1, mod);
......@@ -130,7 +130,7 @@ pub fn print(
130130 const len = payload.len.toUnsignedInt(mod);
131131
132132 if (elem_ty.eql(Type.u8, mod)) str: {
133 const max_len = @intCast(usize, std.math.min(len, max_string_len));
133 const max_len: usize = @min(len, max_string_len);
134134 var buf: [max_string_len]u8 = undefined;
135135
136136 var i: u32 = 0;
......@@ -149,7 +149,7 @@ pub fn print(
149149
150150 try writer.writeAll(".{ ");
151151
152 const max_len = std.math.min(len, max_aggregate_items);
152 const max_len = @min(len, max_aggregate_items);
153153 var i: u32 = 0;
154154 while (i < max_len) : (i += 1) {
155155 if (i != 0) try writer.writeAll(", ");
......@@ -455,7 +455,7 @@ fn printAggregate(
455455 const len = ty.arrayLen(mod);
456456
457457 if (elem_ty.eql(Type.u8, mod)) str: {
458 const max_len = @intCast(usize, std.math.min(len, max_string_len));
458 const max_len: usize = @min(len, max_string_len);
459459 var buf: [max_string_len]u8 = undefined;
460460
461461 var i: u32 = 0;
......@@ -471,7 +471,7 @@ fn printAggregate(
471471
472472 try writer.writeAll(".{ ");
473473
474 const max_len = std.math.min(len, max_aggregate_items);
474 const max_len = @min(len, max_aggregate_items);
475475 var i: u32 = 0;
476476 while (i < max_len) : (i += 1) {
477477 if (i != 0) try writer.writeAll(", ");
src/arch/x86_64/CodeGen.zig+2-2
......@@ -2907,7 +2907,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
29072907 const dst_info = dst_ty.intInfo(mod);
29082908 const src_ty = try mod.intType(dst_info.signedness, switch (tag) {
29092909 else => unreachable,
2910 .mul, .mulwrap => math.max3(
2910 .mul, .mulwrap => @max(
29112911 self.activeIntBits(bin_op.lhs),
29122912 self.activeIntBits(bin_op.rhs),
29132913 dst_info.bits / 2,
......@@ -3349,7 +3349,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
33493349
33503350 const lhs_active_bits = self.activeIntBits(bin_op.lhs);
33513351 const rhs_active_bits = self.activeIntBits(bin_op.rhs);
3352 const src_bits = math.max3(lhs_active_bits, rhs_active_bits, dst_info.bits / 2);
3352 const src_bits = @max(lhs_active_bits, rhs_active_bits, dst_info.bits / 2);
33533353 const src_ty = try mod.intType(dst_info.signedness, src_bits);
33543354
33553355 const lhs = try self.resolveInst(bin_op.lhs);
src/link/Elf.zig+1-1
......@@ -2326,7 +2326,7 @@ fn allocateAtom(self: *Elf, atom_index: Atom.Index, new_block_size: u64, alignme
23262326 self.debug_aranges_section_dirty = true;
23272327 }
23282328 }
2329 shdr.sh_addralign = math.max(shdr.sh_addralign, alignment);
2329 shdr.sh_addralign = @max(shdr.sh_addralign, alignment);
23302330
23312331 // This function can also reallocate an atom.
23322332 // In this case we need to "unplug" it from its previous location before
src/link/MachO/CodeSignature.zig+3-3
......@@ -99,7 +99,7 @@ const CodeDirectory = struct {
9999
100100 fn addSpecialHash(self: *CodeDirectory, index: u32, hash: [hash_size]u8) void {
101101 assert(index > 0);
102 self.inner.nSpecialSlots = std.math.max(self.inner.nSpecialSlots, index);
102 self.inner.nSpecialSlots = @max(self.inner.nSpecialSlots, index);
103103 self.special_slots[index - 1] = hash;
104104 }
105105
......@@ -426,11 +426,11 @@ pub fn estimateSize(self: CodeSignature, file_size: u64) u32 {
426426 var n_special_slots: u32 = 0;
427427 if (self.requirements) |req| {
428428 ssize += @sizeOf(macho.BlobIndex) + req.size();
429 n_special_slots = std.math.max(n_special_slots, req.slotType());
429 n_special_slots = @max(n_special_slots, req.slotType());
430430 }
431431 if (self.entitlements) |ent| {
432432 ssize += @sizeOf(macho.BlobIndex) + ent.size() + hash_size;
433 n_special_slots = std.math.max(n_special_slots, ent.slotType());
433 n_special_slots = @max(n_special_slots, ent.slotType());
434434 }
435435 if (self.signature) |sig| {
436436 ssize += @sizeOf(macho.BlobIndex) + sig.size();
src/link/MachO/Object.zig+1-1
......@@ -530,7 +530,7 @@ pub fn splitRegularSections(self: *Object, zld: *Zld, object_id: u32) !void {
530530 sect.addr + sect.size - addr;
531531
532532 const atom_align = if (addr > 0)
533 math.min(@ctz(addr), sect.@"align")
533 @min(@ctz(addr), sect.@"align")
534534 else
535535 sect.@"align";
536536
src/link/Wasm.zig+1-1
......@@ -2027,7 +2027,7 @@ fn parseAtom(wasm: *Wasm, atom_index: Atom.Index, kind: Kind) !void {
20272027 };
20282028
20292029 const segment: *Segment = &wasm.segments.items[final_index];
2030 segment.alignment = std.math.max(segment.alignment, atom.alignment);
2030 segment.alignment = @max(segment.alignment, atom.alignment);
20312031
20322032 try wasm.appendAtomAtIndex(final_index, atom_index);
20332033}
src/link/Wasm/Object.zig+1-1
......@@ -979,7 +979,7 @@ pub fn parseIntoAtoms(object: *Object, gpa: Allocator, object_index: u16, wasm_b
979979
980980 const segment: *Wasm.Segment = &wasm_bin.segments.items[final_index];
981981 if (relocatable_data.type == .data) { //code section and debug sections are 1-byte aligned
982 segment.alignment = std.math.max(segment.alignment, atom.alignment);
982 segment.alignment = @max(segment.alignment, atom.alignment);
983983 }
984984
985985 try wasm_bin.appendAtomAtIndex(final_index, atom_index);
src/main.zig+1-1
......@@ -5391,7 +5391,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
53915391 // setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
53925392 // It no longer accepts "rlim_cur = RLIM.INFINITY" for RLIM.NOFILE.
53935393 // Use "rlim_cur = min(OPEN_MAX, rlim_max)".
5394 lim.max = std.math.min(std.os.darwin.OPEN_MAX, lim.max);
5394 lim.max = @min(std.os.darwin.OPEN_MAX, lim.max);
53955395 }
53965396 if (lim.cur == lim.max) return;
53975397
src/translate_c.zig+1-1
......@@ -2400,7 +2400,7 @@ fn transStringLiteralInitializer(
24002400
24012401 if (array_size == 0) return Tag.empty_array.create(c.arena, elem_type);
24022402
2403 const num_inits = math.min(str_length, array_size);
2403 const num_inits = @min(str_length, array_size);
24042404 const init_node = if (num_inits > 0) blk: {
24052405 if (is_narrow) {
24062406 // "string literal".* or string literal"[0..num_inits].*
src/translate_c/ast.zig+7-7
......@@ -1824,7 +1824,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
18241824 },
18251825 .switch_prong => {
18261826 const payload = node.castTag(.switch_prong).?.data;
1827 var items = try c.gpa.alloc(NodeIndex, std.math.max(payload.cases.len, 1));
1827 var items = try c.gpa.alloc(NodeIndex, @max(payload.cases.len, 1));
18281828 defer c.gpa.free(items);
18291829 items[0] = 0;
18301830 for (payload.cases, 0..) |item, i| {
......@@ -1973,7 +1973,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
19731973 const payload = node.castTag(.tuple).?.data;
19741974 _ = try c.addToken(.period, ".");
19751975 const l_brace = try c.addToken(.l_brace, "{");
1976 var inits = try c.gpa.alloc(NodeIndex, std.math.max(payload.len, 2));
1976 var inits = try c.gpa.alloc(NodeIndex, @max(payload.len, 2));
19771977 defer c.gpa.free(inits);
19781978 inits[0] = 0;
19791979 inits[1] = 0;
......@@ -2007,7 +2007,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
20072007 const payload = node.castTag(.container_init_dot).?.data;
20082008 _ = try c.addToken(.period, ".");
20092009 const l_brace = try c.addToken(.l_brace, "{");
2010 var inits = try c.gpa.alloc(NodeIndex, std.math.max(payload.len, 2));
2010 var inits = try c.gpa.alloc(NodeIndex, @max(payload.len, 2));
20112011 defer c.gpa.free(inits);
20122012 inits[0] = 0;
20132013 inits[1] = 0;
......@@ -2046,7 +2046,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
20462046 const lhs = try renderNode(c, payload.lhs);
20472047
20482048 const l_brace = try c.addToken(.l_brace, "{");
2049 var inits = try c.gpa.alloc(NodeIndex, std.math.max(payload.inits.len, 1));
2049 var inits = try c.gpa.alloc(NodeIndex, @max(payload.inits.len, 1));
20502050 defer c.gpa.free(inits);
20512051 inits[0] = 0;
20522052 for (payload.inits, 0..) |init, i| {
......@@ -2102,7 +2102,7 @@ fn renderRecord(c: *Context, node: Node) !NodeIndex {
21022102 const num_vars = payload.variables.len;
21032103 const num_funcs = payload.functions.len;
21042104 const total_members = payload.fields.len + num_vars + num_funcs;
2105 const members = try c.gpa.alloc(NodeIndex, std.math.max(total_members, 2));
2105 const members = try c.gpa.alloc(NodeIndex, @max(total_members, 2));
21062106 defer c.gpa.free(members);
21072107 members[0] = 0;
21082108 members[1] = 0;
......@@ -2195,7 +2195,7 @@ fn renderFieldAccess(c: *Context, lhs: NodeIndex, field_name: []const u8) !NodeI
21952195
21962196fn renderArrayInit(c: *Context, lhs: NodeIndex, inits: []const Node) !NodeIndex {
21972197 const l_brace = try c.addToken(.l_brace, "{");
2198 var rendered = try c.gpa.alloc(NodeIndex, std.math.max(inits.len, 1));
2198 var rendered = try c.gpa.alloc(NodeIndex, @max(inits.len, 1));
21992199 defer c.gpa.free(rendered);
22002200 rendered[0] = 0;
22012201 for (inits, 0..) |init, i| {
......@@ -2904,7 +2904,7 @@ fn renderMacroFunc(c: *Context, node: Node) !NodeIndex {
29042904
29052905fn renderParams(c: *Context, params: []Payload.Param, is_var_args: bool) !std.ArrayList(NodeIndex) {
29062906 _ = try c.addToken(.l_paren, "(");
2907 var rendered = try std.ArrayList(NodeIndex).initCapacity(c.gpa, std.math.max(params.len, 1));
2907 var rendered = try std.ArrayList(NodeIndex).initCapacity(c.gpa, @max(params.len, 1));
29082908 errdefer rendered.deinit();
29092909
29102910 for (params, 0..) |param, i| {
src/type.zig+1-1
......@@ -1633,7 +1633,7 @@ pub const Type = struct {
16331633 const len = array_type.len + @boolToInt(array_type.sentinel != .none);
16341634 if (len == 0) return 0;
16351635 const elem_ty = array_type.child.toType();
1636 const elem_size = std.math.max(elem_ty.abiAlignment(mod), elem_ty.abiSize(mod));
1636 const elem_size = @max(elem_ty.abiAlignment(mod), elem_ty.abiSize(mod));
16371637 if (elem_size == 0) return 0;
16381638 const elem_bit_size = try bitSizeAdvanced(elem_ty, mod, opt_sema);
16391639 return (len - 1) * 8 * elem_size + elem_bit_size;
src/value.zig+4-4
......@@ -2458,7 +2458,7 @@ pub const Value = struct {
24582458 const rhs_bigint = rhs.toBigInt(&rhs_space, mod);
24592459 const limbs = try arena.alloc(
24602460 std.math.big.Limb,
2461 std.math.max(
2461 @max(
24622462 // For the saturate
24632463 std.math.big.int.calcTwosCompLimbCount(info.bits),
24642464 lhs_bigint.limbs.len + rhs_bigint.limbs.len,
......@@ -2572,7 +2572,7 @@ pub const Value = struct {
25722572 const limbs = try arena.alloc(
25732573 std.math.big.Limb,
25742574 // + 1 for negatives
2575 std.math.max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
2575 @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
25762576 );
25772577 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
25782578 result_bigint.bitAnd(lhs_bigint, rhs_bigint);
......@@ -2638,7 +2638,7 @@ pub const Value = struct {
26382638 const rhs_bigint = rhs.toBigInt(&rhs_space, mod);
26392639 const limbs = try arena.alloc(
26402640 std.math.big.Limb,
2641 std.math.max(lhs_bigint.limbs.len, rhs_bigint.limbs.len),
2641 @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len),
26422642 );
26432643 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
26442644 result_bigint.bitOr(lhs_bigint, rhs_bigint);
......@@ -2677,7 +2677,7 @@ pub const Value = struct {
26772677 const limbs = try arena.alloc(
26782678 std.math.big.Limb,
26792679 // + 1 for negatives
2680 std.math.max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
2680 @max(lhs_bigint.limbs.len, rhs_bigint.limbs.len) + 1,
26812681 );
26822682 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
26832683 result_bigint.bitXor(lhs_bigint, rhs_bigint);