Skip to content

Commit c4a5a98

Browse files
committed
all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
1 parent 7363bb6 commit c4a5a98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+572
-573
lines changed

lib/std/Build/Step/ConfigHeader.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty
144144
.pointer => |ptr| {
145145
switch (@typeInfo(ptr.child)) {
146146
.array => |array| {
147-
if (ptr.size == .One and array.child == u8) {
147+
if (ptr.size == .one and array.child == u8) {
148148
try config_header.values.put(field_name, .{ .string = v });
149149
return;
150150
}
151151
},
152152
.int => {
153-
if (ptr.size == .Slice and ptr.child == u8) {
153+
if (ptr.size == .slice and ptr.child == u8) {
154154
try config_header.values.put(field_name, .{ .string = v });
155155
return;
156156
}

lib/std/Build/Step/Options.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
172172
return;
173173
},
174174
.pointer => |p| {
175-
if (p.size != .Slice) {
175+
if (p.size != .slice) {
176176
@compileError("Non-slice pointers are not yet supported in build options");
177177
}
178178

lib/std/Progress.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void {
13661366
}
13671367
}
13681368

1369-
fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {
1369+
fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
13701370
_ = info;
13711371
_ = ctx_ptr;
13721372
assert(sig == posix.SIG.WINCH);

lib/std/Random.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
3535
pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
3636
const Ptr = @TypeOf(pointer);
3737
assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
38-
assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer
38+
assert(@typeInfo(Ptr).pointer.size == .one); // Must be a single-item pointer
3939
assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
4040
const gen = struct {
4141
fn fill(ptr: *anyopaque, buf: []u8) void {

lib/std/c.zig

+31-31
Original file line numberDiff line numberDiff line change
@@ -2733,48 +2733,48 @@ pub const Sigaction = switch (native_os) {
27332733
=> if (builtin.target.isMusl())
27342734
linux.Sigaction
27352735
else if (builtin.target.ptrBitWidth() == 64) extern struct {
2736-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2737-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2736+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2737+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27382738

27392739
flags: c_uint,
27402740
handler: extern union {
27412741
handler: ?handler_fn,
27422742
sigaction: ?sigaction_fn,
27432743
},
27442744
mask: sigset_t,
2745-
restorer: ?*const fn () callconv(.C) void = null,
2745+
restorer: ?*const fn () callconv(.c) void = null,
27462746
} else extern struct {
2747-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2748-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2747+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2748+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27492749

27502750
flags: c_uint,
27512751
handler: extern union {
27522752
handler: ?handler_fn,
27532753
sigaction: ?sigaction_fn,
27542754
},
27552755
mask: sigset_t,
2756-
restorer: ?*const fn () callconv(.C) void = null,
2756+
restorer: ?*const fn () callconv(.c) void = null,
27572757
__resv: [1]c_int = .{0},
27582758
},
27592759
.s390x => if (builtin.abi == .gnu) extern struct {
2760-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2761-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2760+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2761+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27622762

27632763
handler: extern union {
27642764
handler: ?handler_fn,
27652765
sigaction: ?sigaction_fn,
27662766
},
27672767
__glibc_reserved0: c_int = 0,
27682768
flags: c_uint,
2769-
restorer: ?*const fn () callconv(.C) void = null,
2769+
restorer: ?*const fn () callconv(.c) void = null,
27702770
mask: sigset_t,
27712771
} else linux.Sigaction,
27722772
else => linux.Sigaction,
27732773
},
27742774
.emscripten => emscripten.Sigaction,
27752775
.netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
2776-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2777-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2776+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2777+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27782778

27792779
handler: extern union {
27802780
handler: ?handler_fn,
@@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {
27842784
flags: c_uint,
27852785
},
27862786
.dragonfly, .freebsd => extern struct {
2787-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2788-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2787+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2788+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27892789

27902790
/// signal handler
27912791
handler: extern union {
@@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {
27982798
mask: sigset_t,
27992799
},
28002800
.solaris, .illumos => extern struct {
2801-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2802-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2801+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2802+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
28032803

28042804
/// signal options
28052805
flags: c_uint,
@@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {
28122812
mask: sigset_t,
28132813
},
28142814
.haiku => extern struct {
2815-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2816-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2815+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2816+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
28172817

28182818
/// signal handler
28192819
handler: extern union {
@@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {
28312831
userdata: *allowzero anyopaque = undefined,
28322832
},
28332833
.openbsd => extern struct {
2834-
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2835-
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2834+
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2835+
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
28362836

28372837
/// signal handler
28382838
handler: extern union {
@@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {
64106410
else => void,
64116411
};
64126412

6413-
pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
6413+
pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int;
64146414

64156415
pub const Stat = switch (native_os) {
64166416
.linux => switch (native_arch) {
@@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
93969396
pub extern "c" fn pthread_create(
93979397
noalias newthread: *pthread_t,
93989398
noalias attr: ?*const pthread_attr_t,
9399-
start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque,
9399+
start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque,
94009400
noalias arg: ?*anyopaque,
94019401
) E;
94029402
pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
@@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t;
94089408
pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
94099409
pub extern "c" fn pthread_detach(thread: pthread_t) E;
94109410
pub extern "c" fn pthread_atfork(
9411-
prepare: ?*const fn () callconv(.C) void,
9412-
parent: ?*const fn () callconv(.C) void,
9413-
child: ?*const fn () callconv(.C) void,
9411+
prepare: ?*const fn () callconv(.c) void,
9412+
parent: ?*const fn () callconv(.c) void,
9413+
child: ?*const fn () callconv(.c) void,
94149414
) c_int;
94159415
pub extern "c" fn pthread_key_create(
94169416
key: *pthread_key_t,
9417-
destructor: ?*const fn (value: *anyopaque) callconv(.C) void,
9417+
destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
94189418
) E;
94199419
pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
94209420
pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque;
@@ -9530,12 +9530,12 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
95309530
pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
95319531
pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
95329532

9533-
pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;
9534-
pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
9535-
pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
9536-
pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
9537-
pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
9538-
pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;
9533+
pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E;
9534+
pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9535+
pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9536+
pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9537+
pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9538+
pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E;
95399539

95409540
pub const pthread_t = *opaque {};
95419541
pub const FILE = opaque {};

lib/std/c/darwin.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) {
379379
};
380380

381381
extern "c" var mach_task_self_: mach_port_t;
382-
pub fn mach_task_self() callconv(.C) mach_port_t {
382+
pub fn mach_task_self() callconv(.c) mach_port_t {
383383
return mach_task_self_;
384384
}
385385

@@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0);
873873
pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;
874874

875875
const dispatch_once_t = usize;
876-
const dispatch_function_t = fn (?*anyopaque) callconv(.C) void;
876+
const dispatch_function_t = fn (?*anyopaque) callconv(.c) void;
877877
pub extern fn dispatch_once_f(
878878
predicate: *dispatch_once_t,
879879
context: ?*anyopaque,

lib/std/c/dragonfly.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub const E = enum(u16) {
156156

157157
pub const BADSIG = SIG.ERR;
158158

159-
pub const sig_t = *const fn (i32) callconv(.C) void;
159+
pub const sig_t = *const fn (i32) callconv(.c) void;
160160

161161
pub const cmsghdr = extern struct {
162162
len: socklen_t,

lib/std/crypto/tlcsprng.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
133133
return initAndFill(buffer);
134134
}
135135

136-
fn childAtForkHandler() callconv(.C) void {
136+
fn childAtForkHandler() callconv(.c) void {
137137
// The atfork handler is global, this function may be called after
138138
// fork()-ing threads that never initialized the CSPRNG context.
139139
if (wipe_mem.len == 0) return;

lib/std/debug.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void {
12691269
updateSegfaultHandler(&act);
12701270
}
12711271

1272-
fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn {
1272+
fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
12731273
// Reset to the default handler so that if a segfault happens in this handler it will crash
12741274
// the process. Also when this handler returns, the original instruction will be repeated
12751275
// and the resulting segfault will crash the process rather than continually dump stack traces.

lib/std/fmt.zig

+7-7
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
434434
switch (@typeInfo(T)) {
435435
.pointer => |info| {
436436
try writer.writeAll(@typeName(info.child) ++ "@");
437-
if (info.size == .Slice)
437+
if (info.size == .slice)
438438
try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
439439
else
440440
try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
@@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {
460460
switch (@typeInfo(T)) {
461461
.array, .vector => return ANY,
462462
.pointer => |ptr_info| switch (ptr_info.size) {
463-
.One => switch (@typeInfo(ptr_info.child)) {
463+
.one => switch (@typeInfo(ptr_info.child)) {
464464
.array => return ANY,
465465
else => {},
466466
},
467-
.Many, .C => return "*",
468-
.Slice => return ANY,
467+
.many, .c => return "*",
468+
.slice => return ANY,
469469
},
470470
.optional => |info| return "?" ++ defaultSpec(info.child),
471471
.error_union => |info| return "!" ++ defaultSpec(info.payload),
@@ -624,13 +624,13 @@ pub fn formatType(
624624
try writer.writeAll(" }");
625625
},
626626
.pointer => |ptr_info| switch (ptr_info.size) {
627-
.One => switch (@typeInfo(ptr_info.child)) {
627+
.one => switch (@typeInfo(ptr_info.child)) {
628628
.array, .@"enum", .@"union", .@"struct" => {
629629
return formatType(value.*, actual_fmt, options, writer, max_depth);
630630
},
631631
else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
632632
},
633-
.Many, .C => {
633+
.many, .c => {
634634
if (actual_fmt.len == 0)
635635
@compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
636636
if (ptr_info.sentinel() != null) {
@@ -641,7 +641,7 @@ pub fn formatType(
641641
}
642642
invalidFmtError(fmt, value);
643643
},
644-
.Slice => {
644+
.slice => {
645645
if (actual_fmt.len == 0)
646646
@compileError("cannot format slice without a specifier (i.e. {s} or {any})");
647647
if (max_depth == 0) {

lib/std/hash/auto_hash.zig

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
2323
const info = @typeInfo(@TypeOf(key));
2424

2525
switch (info.pointer.size) {
26-
.One => switch (strat) {
26+
.one => switch (strat) {
2727
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
2828
.Deep => hash(hasher, key.*, .Shallow),
2929
.DeepRecursive => hash(hasher, key.*, .DeepRecursive),
3030
},
3131

32-
.Slice => {
32+
.slice => {
3333
switch (strat) {
3434
.Shallow => {
3535
hashPointer(hasher, key.ptr, .Shallow);
@@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
4040
hash(hasher, key.len, .Shallow);
4141
},
4242

43-
.Many,
44-
.C,
43+
.many,
44+
.c,
4545
=> switch (strat) {
4646
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
4747
else => @compileError(
@@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
167167

168168
inline fn typeContainsSlice(comptime K: type) bool {
169169
return switch (@typeInfo(K)) {
170-
.pointer => |info| info.size == .Slice,
170+
.pointer => |info| info.size == .slice,
171171

172172
inline .@"struct", .@"union" => |info| {
173173
inline for (info.fields) |field| {

lib/std/io/fixed_buffer_stream.zig

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ fn Slice(comptime T: type) type {
118118
.pointer => |ptr_info| {
119119
var new_ptr_info = ptr_info;
120120
switch (ptr_info.size) {
121-
.Slice => {},
122-
.One => switch (@typeInfo(ptr_info.child)) {
121+
.slice => {},
122+
.one => switch (@typeInfo(ptr_info.child)) {
123123
.array => |info| new_ptr_info.child = info.child,
124124
else => @compileError("invalid type given to fixedBufferStream"),
125125
},
126126
else => @compileError("invalid type given to fixedBufferStream"),
127127
}
128-
new_ptr_info.size = .Slice;
128+
new_ptr_info.size = .slice;
129129
return @Type(.{ .pointer = new_ptr_info });
130130
},
131131
else => @compileError("invalid type given to fixedBufferStream"),

lib/std/json/static.zig

+4-4
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,12 @@ pub fn innerParse(
451451

452452
.pointer => |ptrInfo| {
453453
switch (ptrInfo.size) {
454-
.One => {
454+
.one => {
455455
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
456456
r.* = try innerParse(ptrInfo.child, allocator, source, options);
457457
return r;
458458
},
459-
.Slice => {
459+
.slice => {
460460
switch (try source.peekNextTokenType()) {
461461
.array_begin => {
462462
_ = try source.next();
@@ -705,12 +705,12 @@ pub fn innerParseFromValue(
705705

706706
.pointer => |ptrInfo| {
707707
switch (ptrInfo.size) {
708-
.One => {
708+
.one => {
709709
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
710710
r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options);
711711
return r;
712712
},
713-
.Slice => {
713+
.slice => {
714714
switch (source) {
715715
.array => |array| {
716716
const r = if (ptrInfo.sentinel()) |sentinel|

0 commit comments

Comments
 (0)