authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-04 20:35:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-07 10:04:52-07:00
log3837862e5217ebe3056a4628d78b6808e33a1b4f
tree1b74c8cd2afc161314613a060dcc03ce57df120f
parentabd76938cb8455891c5a69c33edb7060f42001a3

fix 32-bit builds


3 files changed, 33 insertions(+), 33 deletions(-)

lib/std/crypto/tls/Client.zig+2-2
......@@ -910,7 +910,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
910910}
911911
912912fn drain(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize {
913 const c: *Client = @fieldParentPtr("writer", w);
913 const c: *Client = @alignCast(@fieldParentPtr("writer", w));
914914 if (true) @panic("update to use the buffer and flush");
915915 const sliced_data = if (splat == 0) data[0..data.len -| 1] else data;
916916 const output = c.output;
......@@ -1046,7 +1046,7 @@ pub fn eof(c: Client) bool {
10461046}
10471047
10481048fn stream(r: *Reader, w: *Writer, limit: std.io.Limit) Reader.StreamError!usize {
1049 const c: *Client = @fieldParentPtr("reader", r);
1049 const c: *Client = @alignCast(@fieldParentPtr("reader", r));
10501050 if (c.eof()) return error.EndOfStream;
10511051 const input = c.input;
10521052 // If at least one full encrypted record is not buffered, read once.
lib/std/http.zig+19-19
......@@ -519,33 +519,33 @@ pub const Reader = struct {
519519 w: *Writer,
520520 limit: std.Io.Limit,
521521 ) std.Io.Reader.StreamError!usize {
522 const reader: *Reader = @fieldParentPtr("interface", io_r);
522 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
523523 const remaining_content_length = &reader.state.body_remaining_content_length;
524524 const remaining = remaining_content_length.*;
525525 if (remaining == 0) {
526526 reader.state = .ready;
527527 return error.EndOfStream;
528528 }
529 const n = try reader.in.stream(w, limit.min(.limited(remaining)));
529 const n = try reader.in.stream(w, limit.min(.limited64(remaining)));
530530 remaining_content_length.* = remaining - n;
531531 return n;
532532 }
533533
534534 fn contentLengthDiscard(io_r: *std.Io.Reader, limit: std.Io.Limit) std.Io.Reader.Error!usize {
535 const reader: *Reader = @fieldParentPtr("interface", io_r);
535 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
536536 const remaining_content_length = &reader.state.body_remaining_content_length;
537537 const remaining = remaining_content_length.*;
538538 if (remaining == 0) {
539539 reader.state = .ready;
540540 return error.EndOfStream;
541541 }
542 const n = try reader.in.discard(limit.min(.limited(remaining)));
542 const n = try reader.in.discard(limit.min(.limited64(remaining)));
543543 remaining_content_length.* = remaining - n;
544544 return n;
545545 }
546546
547547 fn chunkedStream(io_r: *std.Io.Reader, w: *Writer, limit: std.Io.Limit) std.Io.Reader.StreamError!usize {
548 const reader: *Reader = @fieldParentPtr("interface", io_r);
548 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
549549 const chunk_len_ptr = switch (reader.state) {
550550 .ready => return error.EndOfStream,
551551 .body_remaining_chunk_len => |*x| x,
......@@ -591,7 +591,7 @@ pub const Reader = struct {
591591 }
592592 }
593593 if (cp.chunk_len == 0) return parseTrailers(reader, 0);
594 const n = try in.stream(w, limit.min(.limited(cp.chunk_len)));
594 const n = try in.stream(w, limit.min(.limited64(cp.chunk_len)));
595595 chunk_len_ptr.* = .init(cp.chunk_len + 2 - n);
596596 return n;
597597 },
......@@ -607,7 +607,7 @@ pub const Reader = struct {
607607 continue :len .head;
608608 },
609609 else => |remaining_chunk_len| {
610 const n = try in.stream(w, limit.min(.limited(@intFromEnum(remaining_chunk_len) - 2)));
610 const n = try in.stream(w, limit.min(.limited64(@intFromEnum(remaining_chunk_len) - 2)));
611611 chunk_len_ptr.* = .init(@intFromEnum(remaining_chunk_len) - n);
612612 return n;
613613 },
......@@ -615,7 +615,7 @@ pub const Reader = struct {
615615 }
616616
617617 fn chunkedDiscard(io_r: *std.Io.Reader, limit: std.Io.Limit) std.Io.Reader.Error!usize {
618 const reader: *Reader = @fieldParentPtr("interface", io_r);
618 const reader: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
619619 const chunk_len_ptr = switch (reader.state) {
620620 .ready => return error.EndOfStream,
621621 .body_remaining_chunk_len => |*x| x,
......@@ -659,7 +659,7 @@ pub const Reader = struct {
659659 }
660660 }
661661 if (cp.chunk_len == 0) return parseTrailers(reader, 0);
662 const n = try in.discard(limit.min(.limited(cp.chunk_len)));
662 const n = try in.discard(limit.min(.limited64(cp.chunk_len)));
663663 chunk_len_ptr.* = .init(cp.chunk_len + 2 - n);
664664 return n;
665665 },
......@@ -675,7 +675,7 @@ pub const Reader = struct {
675675 continue :len .head;
676676 },
677677 else => |remaining_chunk_len| {
678 const n = try in.discard(limit.min(.limited(remaining_chunk_len.int() - 2)));
678 const n = try in.discard(limit.min(.limited64(remaining_chunk_len.int() - 2)));
679679 chunk_len_ptr.* = .init(remaining_chunk_len.int() - n);
680680 return n;
681681 },
......@@ -758,7 +758,7 @@ pub const BodyWriter = struct {
758758
759759 /// How many zeroes to reserve for hex-encoded chunk length.
760760 const chunk_len_digits = 8;
761 const max_chunk_len: usize = std.math.pow(usize, 16, chunk_len_digits) - 1;
761 const max_chunk_len: usize = std.math.pow(u64, 16, chunk_len_digits) - 1;
762762 const chunk_header_template = ("0" ** chunk_len_digits) ++ "\r\n";
763763
764764 comptime {
......@@ -918,7 +918,7 @@ pub const BodyWriter = struct {
918918 }
919919
920920 pub fn contentLengthDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
921 const bw: *BodyWriter = @fieldParentPtr("writer", w);
921 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
922922 assert(!bw.isEliding());
923923 const out = bw.http_protocol_output;
924924 const n = try out.writeSplatHeader(w.buffered(), data, splat);
......@@ -927,7 +927,7 @@ pub const BodyWriter = struct {
927927 }
928928
929929 pub fn noneDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
930 const bw: *BodyWriter = @fieldParentPtr("writer", w);
930 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
931931 assert(!bw.isEliding());
932932 const out = bw.http_protocol_output;
933933 const n = try out.writeSplatHeader(w.buffered(), data, splat);
......@@ -935,7 +935,7 @@ pub const BodyWriter = struct {
935935 }
936936
937937 pub fn elidingDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
938 const bw: *BodyWriter = @fieldParentPtr("writer", w);
938 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
939939 const slice = data[0 .. data.len - 1];
940940 const pattern = data[slice.len];
941941 var written: usize = pattern.len * splat;
......@@ -949,7 +949,7 @@ pub const BodyWriter = struct {
949949 }
950950
951951 pub fn elidingSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
952 const bw: *BodyWriter = @fieldParentPtr("writer", w);
952 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
953953 if (File.Handle == void) return error.Unimplemented;
954954 if (builtin.zig_backend == .stage2_aarch64) return error.Unimplemented;
955955 switch (bw.state) {
......@@ -976,7 +976,7 @@ pub const BodyWriter = struct {
976976
977977 /// Returns `null` if size cannot be computed without making any syscalls.
978978 pub fn noneSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
979 const bw: *BodyWriter = @fieldParentPtr("writer", w);
979 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
980980 assert(!bw.isEliding());
981981 const out = bw.http_protocol_output;
982982 const n = try out.sendFileHeader(w.buffered(), file_reader, limit);
......@@ -984,7 +984,7 @@ pub const BodyWriter = struct {
984984 }
985985
986986 pub fn contentLengthSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
987 const bw: *BodyWriter = @fieldParentPtr("writer", w);
987 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
988988 assert(!bw.isEliding());
989989 const out = bw.http_protocol_output;
990990 const n = try out.sendFileHeader(w.buffered(), file_reader, limit);
......@@ -993,7 +993,7 @@ pub const BodyWriter = struct {
993993 }
994994
995995 pub fn chunkedSendFile(w: *Writer, file_reader: *File.Reader, limit: std.Io.Limit) Writer.FileError!usize {
996 const bw: *BodyWriter = @fieldParentPtr("writer", w);
996 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
997997 assert(!bw.isEliding());
998998 const data_len = Writer.countSendFileLowerBound(w.end, file_reader, limit) orelse {
999999 // If the file size is unknown, we cannot lower to a `sendFile` since we would
......@@ -1041,7 +1041,7 @@ pub const BodyWriter = struct {
10411041 }
10421042
10431043 pub fn chunkedDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
1044 const bw: *BodyWriter = @fieldParentPtr("writer", w);
1044 const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
10451045 assert(!bw.isEliding());
10461046 const out = bw.http_protocol_output;
10471047 const data_len = w.end + Writer.countSplat(data, splat);
lib/std/http/Client.zig+12-12
......@@ -82,7 +82,7 @@ pub const ConnectionPool = struct {
8282
8383 var next = pool.free.last;
8484 while (next) |node| : (next = node.prev) {
85 const connection: *Connection = @fieldParentPtr("pool_node", node);
85 const connection: *Connection = @alignCast(@fieldParentPtr("pool_node", node));
8686 if (connection.protocol != criteria.protocol) continue;
8787 if (connection.port != criteria.port) continue;
8888
......@@ -127,7 +127,7 @@ pub const ConnectionPool = struct {
127127 if (connection.closing or pool.free_size == 0) return connection.destroy();
128128
129129 if (pool.free_len >= pool.free_size) {
130 const popped: *Connection = @fieldParentPtr("pool_node", pool.free.popFirst().?);
130 const popped: *Connection = @alignCast(@fieldParentPtr("pool_node", pool.free.popFirst().?));
131131 pool.free_len -= 1;
132132
133133 popped.destroy();
......@@ -183,14 +183,14 @@ pub const ConnectionPool = struct {
183183
184184 var next = pool.free.first;
185185 while (next) |node| {
186 const connection: *Connection = @fieldParentPtr("pool_node", node);
186 const connection: *Connection = @alignCast(@fieldParentPtr("pool_node", node));
187187 next = node.next;
188188 connection.destroy();
189189 }
190190
191191 next = pool.used.first;
192192 while (next) |node| {
193 const connection: *Connection = @fieldParentPtr("pool_node", node);
193 const connection: *Connection = @alignCast(@fieldParentPtr("pool_node", node));
194194 next = node.next;
195195 connection.destroy();
196196 }
......@@ -366,11 +366,11 @@ pub const Connection = struct {
366366 return switch (c.protocol) {
367367 .tls => {
368368 if (disable_tls) unreachable;
369 const tls: *Tls = @fieldParentPtr("connection", c);
369 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
370370 return tls.host();
371371 },
372372 .plain => {
373 const plain: *Plain = @fieldParentPtr("connection", c);
373 const plain: *Plain = @alignCast(@fieldParentPtr("connection", c));
374374 return plain.host();
375375 },
376376 };
......@@ -383,11 +383,11 @@ pub const Connection = struct {
383383 switch (c.protocol) {
384384 .tls => {
385385 if (disable_tls) unreachable;
386 const tls: *Tls = @fieldParentPtr("connection", c);
386 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
387387 tls.destroy();
388388 },
389389 .plain => {
390 const plain: *Plain = @fieldParentPtr("connection", c);
390 const plain: *Plain = @alignCast(@fieldParentPtr("connection", c));
391391 plain.destroy();
392392 },
393393 }
......@@ -399,7 +399,7 @@ pub const Connection = struct {
399399 return switch (c.protocol) {
400400 .tls => {
401401 if (disable_tls) unreachable;
402 const tls: *Tls = @fieldParentPtr("connection", c);
402 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
403403 return &tls.client.writer;
404404 },
405405 .plain => &c.stream_writer.interface,
......@@ -412,7 +412,7 @@ pub const Connection = struct {
412412 return switch (c.protocol) {
413413 .tls => {
414414 if (disable_tls) unreachable;
415 const tls: *Tls = @fieldParentPtr("connection", c);
415 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
416416 return &tls.client.reader;
417417 },
418418 .plain => c.stream_reader.interface(),
......@@ -422,7 +422,7 @@ pub const Connection = struct {
422422 pub fn flush(c: *Connection) Writer.Error!void {
423423 if (c.protocol == .tls) {
424424 if (disable_tls) unreachable;
425 const tls: *Tls = @fieldParentPtr("connection", c);
425 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
426426 try tls.client.writer.flush();
427427 }
428428 try c.stream_writer.interface.flush();
......@@ -434,7 +434,7 @@ pub const Connection = struct {
434434 pub fn end(c: *Connection) Writer.Error!void {
435435 if (c.protocol == .tls) {
436436 if (disable_tls) unreachable;
437 const tls: *Tls = @fieldParentPtr("connection", c);
437 const tls: *Tls = @alignCast(@fieldParentPtr("connection", c));
438438 try tls.client.end();
439439 try tls.client.writer.flush();
440440 }