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!
This commit is contained in:
mlugg 2025-01-15 17:53:05 +00:00
parent af6bad46cd
commit d00e05f186
No known key found for this signature in database
GPG key ID: 3F5B7DCCBF4AF02E
74 changed files with 576 additions and 581 deletions

View file

@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty
.pointer => |ptr| {
switch (@typeInfo(ptr.child)) {
.array => |array| {
if (ptr.size == .One and array.child == u8) {
if (ptr.size == .one and array.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
}
},
.int => {
if (ptr.size == .Slice and ptr.child == u8) {
if (ptr.size == .slice and ptr.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
}

View file

@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
return;
},
.pointer => |p| {
if (p.size != .Slice) {
if (p.size != .slice) {
@compileError("Non-slice pointers are not yet supported in build options");
}

View file

@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void {
}
}
fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {
fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
_ = info;
_ = ctx_ptr;
assert(sig == posix.SIG.WINCH);

View file

@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
const Ptr = @TypeOf(pointer);
assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer
assert(@typeInfo(Ptr).pointer.size == .one); // Must be a single-item pointer
assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
const gen = struct {
fn fill(ptr: *anyopaque, buf: []u8) void {

View file

@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) {
=> if (builtin.target.isMusl())
linux.Sigaction
else if (builtin.target.ptrBitWidth() == 64) extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
flags: c_uint,
handler: extern union {
@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) {
sigaction: ?sigaction_fn,
},
mask: sigset_t,
restorer: ?*const fn () callconv(.C) void = null,
restorer: ?*const fn () callconv(.c) void = null,
} else extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
flags: c_uint,
handler: extern union {
@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) {
sigaction: ?sigaction_fn,
},
mask: sigset_t,
restorer: ?*const fn () callconv(.C) void = null,
restorer: ?*const fn () callconv(.c) void = null,
__resv: [1]c_int = .{0},
},
.s390x => if (builtin.abi == .gnu) extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) {
},
__glibc_reserved0: c_int = 0,
flags: c_uint,
restorer: ?*const fn () callconv(.C) void = null,
restorer: ?*const fn () callconv(.c) void = null,
mask: sigset_t,
} else linux.Sigaction,
else => linux.Sigaction,
},
.emscripten => emscripten.Sigaction,
.netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {
flags: c_uint,
},
.dragonfly, .freebsd => extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler
handler: extern union {
@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {
mask: sigset_t,
},
.solaris, .illumos => extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal options
flags: c_uint,
@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {
mask: sigset_t,
},
.haiku => extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler
handler: extern union {
@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {
userdata: *allowzero anyopaque = undefined,
},
.openbsd => extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler
handler: extern union {
@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {
else => void,
};
pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int;
pub const Stat = switch (native_os) {
.linux => switch (native_arch) {
@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
pub extern "c" fn pthread_create(
noalias newthread: *pthread_t,
noalias attr: ?*const pthread_attr_t,
start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque,
start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque,
noalias arg: ?*anyopaque,
) E;
pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t;
pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
pub extern "c" fn pthread_detach(thread: pthread_t) E;
pub extern "c" fn pthread_atfork(
prepare: ?*const fn () callconv(.C) void,
parent: ?*const fn () callconv(.C) void,
child: ?*const fn () callconv(.C) void,
prepare: ?*const fn () callconv(.c) void,
parent: ?*const fn () callconv(.c) void,
child: ?*const fn () callconv(.c) void,
) c_int;
pub extern "c" fn pthread_key_create(
key: *pthread_key_t,
destructor: ?*const fn (value: *anyopaque) callconv(.C) void,
destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
) E;
pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
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;
pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;
pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;
pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E;
pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub const pthread_t = *opaque {};
pub const FILE = opaque {};

View file

@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) {
};
extern "c" var mach_task_self_: mach_port_t;
pub fn mach_task_self() callconv(.C) mach_port_t {
pub fn mach_task_self() callconv(.c) mach_port_t {
return mach_task_self_;
}
@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0);
pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;
const dispatch_once_t = usize;
const dispatch_function_t = fn (?*anyopaque) callconv(.C) void;
const dispatch_function_t = fn (?*anyopaque) callconv(.c) void;
pub extern fn dispatch_once_f(
predicate: *dispatch_once_t,
context: ?*anyopaque,

View file

@ -156,7 +156,7 @@ pub const E = enum(u16) {
pub const BADSIG = SIG.ERR;
pub const sig_t = *const fn (i32) callconv(.C) void;
pub const sig_t = *const fn (i32) callconv(.c) void;
pub const cmsghdr = extern struct {
len: socklen_t,

View file

@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
return initAndFill(buffer);
}
fn childAtForkHandler() callconv(.C) void {
fn childAtForkHandler() callconv(.c) void {
// The atfork handler is global, this function may be called after
// fork()-ing threads that never initialized the CSPRNG context.
if (wipe_mem.len == 0) return;

View file

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

View file

@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
switch (@typeInfo(T)) {
.pointer => |info| {
try writer.writeAll(@typeName(info.child) ++ "@");
if (info.size == .Slice)
if (info.size == .slice)
try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
else
try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {
switch (@typeInfo(T)) {
.array, .vector => return ANY,
.pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.one => switch (@typeInfo(ptr_info.child)) {
.array => return ANY,
else => {},
},
.Many, .C => return "*",
.Slice => return ANY,
.many, .c => return "*",
.slice => return ANY,
},
.optional => |info| return "?" ++ defaultSpec(info.child),
.error_union => |info| return "!" ++ defaultSpec(info.payload),
@ -624,13 +624,13 @@ pub fn formatType(
try writer.writeAll(" }");
},
.pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.one => switch (@typeInfo(ptr_info.child)) {
.array, .@"enum", .@"union", .@"struct" => {
return formatType(value.*, actual_fmt, options, writer, max_depth);
},
else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
},
.Many, .C => {
.many, .c => {
if (actual_fmt.len == 0)
@compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
if (ptr_info.sentinel) |_| {
@ -641,7 +641,7 @@ pub fn formatType(
}
invalidFmtError(fmt, value);
},
.Slice => {
.slice => {
if (actual_fmt.len == 0)
@compileError("cannot format slice without a specifier (i.e. {s} or {any})");
if (max_depth == 0) {

View file

@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
const info = @typeInfo(@TypeOf(key));
switch (info.pointer.size) {
.One => switch (strat) {
.one => switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
.Deep => hash(hasher, key.*, .Shallow),
.DeepRecursive => hash(hasher, key.*, .DeepRecursive),
},
.Slice => {
.slice => {
switch (strat) {
.Shallow => {
hashPointer(hasher, key.ptr, .Shallow);
@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
hash(hasher, key.len, .Shallow);
},
.Many,
.C,
.many,
.c,
=> switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
else => @compileError(
@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
inline fn typeContainsSlice(comptime K: type) bool {
return switch (@typeInfo(K)) {
.pointer => |info| info.size == .Slice,
.pointer => |info| info.size == .slice,
inline .@"struct", .@"union" => |info| {
inline for (info.fields) |field| {

View file

@ -118,14 +118,14 @@ fn Slice(comptime T: type) type {
.pointer => |ptr_info| {
var new_ptr_info = ptr_info;
switch (ptr_info.size) {
.Slice => {},
.One => switch (@typeInfo(ptr_info.child)) {
.slice => {},
.one => switch (@typeInfo(ptr_info.child)) {
.array => |info| new_ptr_info.child = info.child,
else => @compileError("invalid type given to fixedBufferStream"),
},
else => @compileError("invalid type given to fixedBufferStream"),
}
new_ptr_info.size = .Slice;
new_ptr_info.size = .slice;
return @Type(.{ .pointer = new_ptr_info });
},
else => @compileError("invalid type given to fixedBufferStream"),

View file

@ -451,12 +451,12 @@ pub fn innerParse(
.pointer => |ptrInfo| {
switch (ptrInfo.size) {
.One => {
.one => {
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
r.* = try innerParse(ptrInfo.child, allocator, source, options);
return r;
},
.Slice => {
.slice => {
switch (try source.peekNextTokenType()) {
.array_begin => {
_ = try source.next();
@ -706,12 +706,12 @@ pub fn innerParseFromValue(
.pointer => |ptrInfo| {
switch (ptrInfo.size) {
.One => {
.one => {
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options);
return r;
},
.Slice => {
.slice => {
switch (source) {
.array => |array| {
const r = if (ptrInfo.sentinel) |sentinel_ptr|

View file

@ -631,7 +631,7 @@ pub fn WriteStream(
},
.error_set => return self.stringValue(@errorName(value)),
.pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.one => switch (@typeInfo(ptr_info.child)) {
.array => {
// Coerce `*[N]T` to `[]const T`.
const Slice = []const std.meta.Elem(ptr_info.child);
@ -641,10 +641,10 @@ pub fn WriteStream(
return self.write(value.*);
},
},
.Many, .Slice => {
if (ptr_info.size == .Many and ptr_info.sentinel == null)
.many, .slice => {
if (ptr_info.size == .many and ptr_info.sentinel == null)
@compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel");
const slice = if (ptr_info.size == .Many) std.mem.span(value) else value;
const slice = if (ptr_info.size == .many) std.mem.span(value) else value;
if (ptr_info.child == u8) {
// This is a []const u8, or some similar Zig string.

View file

@ -262,7 +262,7 @@ pub fn zeroes(comptime T: type) T {
},
.pointer => |ptr_info| {
switch (ptr_info.size) {
.Slice => {
.slice => {
if (ptr_info.sentinel) |sentinel| {
if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) {
return ""; // A special case for the most common use-case: null-terminated strings.
@ -272,10 +272,10 @@ pub fn zeroes(comptime T: type) T {
return &[_]ptr_info.child{};
}
},
.C => {
.c => {
return null;
},
.One, .Many => {
.one, .many => {
if (ptr_info.is_allowzero) return @ptrFromInt(0);
@compileError("Only nullable and allowzero pointers can be set to zero.");
},
@ -781,14 +781,14 @@ fn Span(comptime T: type) type {
.pointer => |ptr_info| {
var new_ptr_info = ptr_info;
switch (ptr_info.size) {
.C => {
.c => {
new_ptr_info.sentinel = &@as(ptr_info.child, 0);
new_ptr_info.is_allowzero = false;
},
.Many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
.One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
.many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
.one, .slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
}
new_ptr_info.size = .Slice;
new_ptr_info.size = .slice;
return @Type(.{ .pointer = new_ptr_info });
},
else => {},
@ -845,9 +845,9 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
},
.pointer => |ptr_info| {
var new_ptr_info = ptr_info;
new_ptr_info.size = .Slice;
new_ptr_info.size = .slice;
switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| {
new_ptr_info.child = array_info.child;
// The return type must only be sentinel terminated if we are guaranteed
@ -864,7 +864,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
},
else => {},
},
.Many, .Slice => {
.many, .slice => {
// The return type must only be sentinel terminated if we are guaranteed
// to find the value searched for, which is only the case if it matches
// the sentinel of the type passed.
@ -877,7 +877,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
}
}
},
.C => {
.c => {
new_ptr_info.sentinel = &end;
// C pointers are always allowzero, but we don't want the return type to be.
assert(new_ptr_info.is_allowzero);
@ -957,7 +957,7 @@ test sliceTo {
fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
switch (@typeInfo(@TypeOf(ptr))) {
.pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| {
if (array_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
@ -969,7 +969,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
},
else => {},
},
.Many => if (ptr_info.sentinel) |sentinel_ptr| {
.many => if (ptr_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) {
return indexOfSentinel(ptr_info.child, end, ptr);
@ -981,11 +981,11 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
while (ptr[i] != end and ptr[i] != sentinel) i += 1;
return i;
},
.C => {
.c => {
assert(ptr != null);
return indexOfSentinel(ptr_info.child, end, ptr);
},
.Slice => {
.slice => {
if (ptr_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) {
@ -1039,13 +1039,13 @@ test lenSliceTo {
pub fn len(value: anytype) usize {
switch (@typeInfo(@TypeOf(value))) {
.pointer => |info| switch (info.size) {
.Many => {
.many => {
const sentinel_ptr = info.sentinel orelse
@compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
return indexOfSentinel(info.child, sentinel, value);
},
.C => {
.c => {
assert(value != null);
return indexOfSentinel(info.child, 0, value);
},
@ -3582,19 +3582,19 @@ fn ReverseIterator(comptime T: type) type {
const Pointer = blk: {
switch (@typeInfo(T)) {
.pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| {
var new_ptr_info = ptr_info;
new_ptr_info.size = .Many;
new_ptr_info.size = .many;
new_ptr_info.child = array_info.child;
new_ptr_info.sentinel = array_info.sentinel;
break :blk @Type(.{ .pointer = new_ptr_info });
},
else => {},
},
.Slice => {
.slice => {
var new_ptr_info = ptr_info;
new_ptr_info.size = .Many;
new_ptr_info.size = .many;
break :blk @Type(.{ .pointer = new_ptr_info });
},
else => {},
@ -3606,7 +3606,7 @@ fn ReverseIterator(comptime T: type) type {
const Element = std.meta.Elem(Pointer);
const ElementPointer = @Type(.{ .pointer = ptr: {
var ptr = @typeInfo(Pointer).pointer;
ptr.size = .One;
ptr.size = .one;
ptr.child = Element;
ptr.sentinel = null;
break :ptr ptr;
@ -3912,7 +3912,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
const T = @TypeOf(ptr);
const info = @typeInfo(T);
if (info != .pointer or info.pointer.size != .Many)
if (info != .pointer or info.pointer.size != .many)
@compileError("expected many item pointer, got " ++ @typeName(T));
// Do nothing if the pointer is already well-aligned.
@ -3986,9 +3986,9 @@ fn CopyPtrAttrs(
fn AsBytesReturnType(comptime P: type) type {
const pointer = @typeInfo(P).pointer;
assert(pointer.size == .One);
assert(pointer.size == .one);
const size = @sizeOf(pointer.child);
return CopyPtrAttrs(P, .One, [size]u8);
return CopyPtrAttrs(P, .one, [size]u8);
}
/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes.
@ -4071,7 +4071,7 @@ test toBytes {
}
fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
return CopyPtrAttrs(B, .One, T);
return CopyPtrAttrs(B, .one, T);
}
/// Given a pointer to an array of bytes, returns a pointer to a value of the specified type
@ -4150,7 +4150,7 @@ test bytesToValue {
}
fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {
return CopyPtrAttrs(bytesType, .Slice, T);
return CopyPtrAttrs(bytesType, .slice, T);
}
/// Given a slice of bytes, returns a slice of the specified type
@ -4162,7 +4162,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T,
return &[0]T{};
}
const cast_target = CopyPtrAttrs(@TypeOf(bytes), .Many, T);
const cast_target = CopyPtrAttrs(@TypeOf(bytes), .many, T);
return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))];
}
@ -4237,7 +4237,7 @@ test "bytesAsSlice preserves pointer attributes" {
}
fn SliceAsBytesReturnType(comptime Slice: type) type {
return CopyPtrAttrs(Slice, .Slice, u8);
return CopyPtrAttrs(Slice, .slice, u8);
}
/// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes.
@ -4251,7 +4251,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {
// it may be equal to zero and fail a null check
if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{};
const cast_target = CopyPtrAttrs(Slice, .Many, u8);
const cast_target = CopyPtrAttrs(Slice, .many, u8);
return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))];
}
@ -4540,7 +4540,7 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t
const info = @typeInfo(AttributeSource).pointer;
return @Type(.{
.pointer = .{
.size = .Slice,
.size = .slice,
.is_const = info.is_const,
.is_volatile = info.is_volatile,
.is_allowzero = info.is_allowzero,

View file

@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {
/// have the same address and alignment property.
pub fn destroy(self: Allocator, ptr: anytype) void {
const info = @typeInfo(@TypeOf(ptr)).pointer;
if (info.size != .One) @compileError("ptr must be a single item pointer");
if (info.size != .one) @compileError("ptr must be a single item pointer");
const T = info.child;
if (@sizeOf(T) == 0) return;
const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr)));

View file

@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type {
.array => |info| return info.child,
.vector => |info| return info.child,
.pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) {
.one => switch (@typeInfo(info.child)) {
.array => |array_info| return array_info.child,
.vector => |vector_info| return vector_info.child,
else => {},
},
.Many, .C, .Slice => return info.child,
.many, .c, .slice => return info.child,
},
.optional => |info| return Elem(info.child),
else => {},
@ -138,11 +138,11 @@ pub inline fn sentinel(comptime T: type) ?Elem(T) {
},
.pointer => |info| {
switch (info.size) {
.Many, .Slice => {
.many, .slice => {
const sentinel_ptr = info.sentinel orelse return null;
return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
},
.One => switch (@typeInfo(info.child)) {
.one => switch (@typeInfo(info.child)) {
.array => |array_info| {
const sentinel_ptr = array_info.sentinel orelse return null;
return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
@ -178,7 +178,7 @@ fn testSentinel() !void {
pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
switch (@typeInfo(T)) {
.pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) {
.one => switch (@typeInfo(info.child)) {
.array => |array_info| return @Type(.{
.pointer = .{
.size = info.size,
@ -199,7 +199,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
}),
else => {},
},
.Many, .Slice => return @Type(.{
.many, .slice => return @Type(.{
.pointer = .{
.size = info.size,
.is_const = info.is_const,
@ -215,7 +215,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
},
.optional => |info| switch (@typeInfo(info.child)) {
.pointer => |ptr_info| switch (ptr_info.size) {
.Many => return @Type(.{
.many => return @Type(.{
.optional = .{
.child = @Type(.{
.pointer = .{
@ -786,8 +786,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
},
.pointer => |info| {
return switch (info.size) {
.One, .Many, .C => a == b,
.Slice => a.ptr == b.ptr and a.len == b.len,
.one, .many, .c => a == b,
.slice => a.ptr == b.ptr and a.len == b.len,
};
},
.optional => {
@ -1090,7 +1090,7 @@ test "Tuple deduplication" {
test "ArgsTuple forwarding" {
const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);
const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.C) noreturn);
const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn);
if (T1 != T2) {
@compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple");
@ -1144,8 +1144,8 @@ test hasFn {
pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
return switch (@typeInfo(T)) {
.pointer => |P| switch (P.size) {
.One => hasFn(P.child, name),
.Many, .Slice, .C => false,
.one => hasFn(P.child, name),
.many, .slice, .c => false,
},
else => hasFn(T, name),
};
@ -1200,12 +1200,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
.int => |info| @sizeOf(T) * 8 == info.bits,
.pointer => |info| info.size != .Slice,
.pointer => |info| info.size != .slice,
.optional => |info| switch (@typeInfo(info.child)) {
.pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
.Slice, .C => false,
.One, .Many => true,
.slice, .c => false,
.one, .many => true,
},
else => false,
},

View file

@ -12,7 +12,7 @@ const c = std.c;
pub const FILE = c.FILE;
var __stack_chk_guard: usize = 0;
fn __stack_chk_fail() callconv(.C) void {
fn __stack_chk_fail() callconv(.c) void {
std.debug.print("stack smashing detected: terminated\n", .{});
emscripten_force_exit(127);
}
@ -547,8 +547,8 @@ pub const SIG = struct {
};
pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@ -556,7 +556,7 @@ pub const Sigaction = extern struct {
},
mask: sigset_t,
flags: c_uint,
restorer: ?*const fn () callconv(.C) void = null,
restorer: ?*const fn () callconv(.c) void = null,
};
pub const sigset_t = [1024 / 32]u32;
@ -909,23 +909,23 @@ pub const LOG = struct {
pub const INFO = 512;
};
pub const em_callback_func = ?*const fn () callconv(.C) void;
pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.C) void;
pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.C) void;
pub const em_callback_func = ?*const fn () callconv(.c) void;
pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.c) void;
pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.c) void;
pub extern "c" fn emscripten_async_wget(url: [*:0]const u8, file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) void;
pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void;
pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_async_wget_data(url: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget_onload_func, onerror: em_arg_callback_func) void;
pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.C) void;
pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.C) void;
pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.c) void;
pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_async_wget2(url: [*:0]const u8, file: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget2_onload_func, onerror: em_async_wget2_onstatus_func, onprogress: em_async_wget2_onstatus_func) c_int;
pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.C) void;
pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.C) void;
pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.C) void;
pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.c) void;
pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.c) void;
pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.c) void;
pub extern "c" fn emscripten_async_wget2_data(url: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, free: c_int, onload: em_async_wget2_data_onload_func, onerror: em_async_wget2_data_onerror_func, onprogress: em_async_wget2_data_onprogress_func) c_int;
pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void;
@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void;
pub extern "c" fn emscripten_resume_main_loop() void;
pub extern "c" fn emscripten_cancel_main_loop() void;
pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.C) void;
pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.C) void;
pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.c) void;
pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void;
pub extern "c" fn emscripten_set_socket_open_callback(userData: ?*anyopaque, callback: em_socket_callback) void;
@ -968,11 +968,11 @@ pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void;
pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void;
pub extern "c" fn emscripten_get_now() f64;
pub extern "c" fn emscripten_random() f32;
pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void;
pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_idb_async_store(db_name: [*:0]const u8, file_id: [*:0]const u8, ptr: ?*anyopaque, num: c_int, arg: ?*anyopaque, onstore: em_arg_callback_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_idb_async_delete(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, ondelete: em_arg_callback_func, onerror: em_arg_callback_func) void;
pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.C) void;
pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_idb_async_exists(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, oncheck: em_idb_exists_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_idb_load(db_name: [*:0]const u8, file_id: [*:0]const u8, pbuffer: *?*anyopaque, pnum: *c_int, perror: *c_int) void;
pub extern "c" fn emscripten_idb_store(db_name: [*:0]const u8, file_id: [*:0]const u8, buffer: *anyopaque, num: c_int, perror: *c_int) void;
@ -983,13 +983,13 @@ pub extern "c" fn emscripten_idb_store_blob(db_name: [*:0]const u8, file_id: [*:
pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void;
pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void;
pub extern "c" fn emscripten_run_preload_plugins(file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) c_int;
pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.C) void;
pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.c) void;
pub extern "c" fn emscripten_run_preload_plugins_data(data: [*]u8, size: c_int, suffix: [*:0]const u8, arg: ?*anyopaque, onload: em_run_preload_plugins_data_onload_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_lazy_load_code() void;
pub const worker_handle = c_int;
pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle;
pub extern "c" fn emscripten_destroy_worker(worker: worker_handle) void;
pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.C) void;
pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_call_worker(worker: worker_handle, funcname: [*:0]const u8, data: [*]u8, size: c_int, callback: em_worker_callback_func, arg: ?*anyopaque) void;
pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void;
pub extern "c" fn emscripten_worker_respond_provisionally(data: [*]u8, size: c_int) void;
@ -1003,10 +1003,10 @@ pub extern "c" fn emscripten_get_preloaded_image_data_from_FILE(file: *FILE, w:
pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void;
pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int;
pub extern "c" fn emscripten_print_double(x: f64, to: ?[*]u8, max: c_int) c_int;
pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void;
pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void;
pub extern "c" fn emscripten_scan_stack(func: em_scan_func) void;
pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void;
pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_dlopen(filename: [*:0]const u8, flags: c_int, user_data: ?*anyopaque, onsuccess: em_dlopen_callback, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t;
pub extern "c" fn emscripten_throw_number(number: f64) void;
@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {};
pub const em_promise_t = ?*struct__em_promise;
pub const enum_em_promise_result_t = c_uint;
pub const em_promise_result_t = enum_em_promise_result_t;
pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) em_promise_result_t;
pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.c) em_promise_result_t;
pub extern "c" fn emscripten_promise_create() em_promise_t;
pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void;

View file

@ -67,7 +67,7 @@ pub const syscall_pipe = syscall_bits.syscall_pipe;
pub const syscall_fork = syscall_bits.syscall_fork;
pub fn clone(
func: *const fn (arg: usize) callconv(.C) u8,
func: *const fn (arg: usize) callconv(.c) u8,
stack: usize,
flags: u32,
arg: usize,
@ -77,14 +77,14 @@ pub fn clone(
) usize {
// Can't directly call a naked function; cast to C calling convention first.
return @as(*const fn (
*const fn (arg: usize) callconv(.C) u8,
*const fn (arg: usize) callconv(.c) u8,
usize,
u32,
usize,
?*i32,
usize,
?*i32,
) callconv(.C) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);
) callconv(.c) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);
}
pub const ARCH = arch_bits.ARCH;
@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct {
extern fn getauxval(index: usize) usize;
}.getauxval else getauxvalImpl;
fn getauxvalImpl(index: usize) callconv(.C) usize {
fn getauxvalImpl(index: usize) callconv(.c) usize {
const auxv = elf_aux_maybe orelse return 0;
var i: usize = 0;
while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {
@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {
}
// We must follow the C calling convention when we call into the VDSO
const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C) usize;
const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize;
var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
@ -1502,7 +1502,7 @@ pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp));
}
fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.C) usize {
fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize {
const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
// Note that we may not have a VDSO at all, update the stub address anyway
// so that clock_gettime will fall back on the good old (and slow) syscall
@ -5070,8 +5070,8 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.l
pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
const k_sigaction_funcs = struct {
const handler = ?*align(1) const fn (i32) callconv(.C) void;
const restorer = *const fn () callconv(.C) void;
const handler = ?*align(1) const fn (i32) callconv(.c) void;
const restorer = *const fn () callconv(.c) void;
};
pub const k_sigaction = switch (native_arch) {
@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) {
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct {
},
mask: sigset_t,
flags: c_uint,
restorer: ?*const fn () callconv(.C) void = null,
restorer: ?*const fn () callconv(.c) void = null,
};
const sigset_len = @typeInfo(sigset_t).array.len;

View file

@ -233,7 +233,7 @@ pub const restore = restore_rt;
// Need to use C ABI here instead of naked
// to prevent an infinite loop when calling rt_sigreturn.
pub fn restore_rt() callconv(.C) void {
pub fn restore_rt() callconv(.c) void {
return asm volatile ("t 0x6d"
:
: [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),

View file

@ -186,8 +186,8 @@ pub const empty_sigset = 0;
pub const siginfo_t = c_long;
// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible.
pub const Sigaction = extern struct {
pub const handler_fn = *const fn (i32) callconv(.C) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
pub const handler_fn = *const fn (i32) callconv(.c) void;
pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,

View file

@ -149,11 +149,11 @@ pub const BootServices = extern struct {
/// Installs one or more protocol interfaces into the boot services environment
// TODO: use callconv(cc) instead once that works
installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status,
installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status,
/// Removes one or more protocol interfaces into the boot services environment
// TODO: use callconv(cc) instead once that works
uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status,
uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status,
/// Computes and returns a 32-bit CRC for a data buffer.
calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status,

View file

@ -5552,7 +5552,7 @@ pub fn dl_iterate_phdr(
if (builtin.link_libc) {
switch (system.dl_iterate_phdr(struct {
fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int {
fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int {
const context_ptr: *const Context = @ptrCast(@alignCast(data));
callback(info, size, context_ptr.*) catch |err| return @intFromError(err);
return 0;

View file

@ -849,7 +849,7 @@ test "sigaction" {
const S = struct {
var handler_called_count: u32 = 0;
fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {
fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
_ = ctx_ptr;
// Check that we received the correct signal.
switch (native_os) {

View file

@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
.pointer => |pointer| {
switch (pointer.size) {
.One, .Many, .C => {
.one, .many, .c => {
if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual;
}
},
.Slice => {
.slice => {
if (actual.ptr != expected.ptr) {
print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr });
return error.TestExpectedEqual;
@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
.pointer => |pointer| {
switch (pointer.size) {
// We have no idea what is behind those pointers, so the best we can do is `==` check.
.C, .Many => {
.c, .many => {
if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual;
}
},
.One => {
.one => {
// Length of those pointers are runtime value, so the best we can do is `==` check.
switch (@typeInfo(pointer.child)) {
.@"fn", .@"opaque" => {
@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
else => try expectEqualDeep(expected.*, actual.*),
}
},
.Slice => {
.slice => {
if (expected.len != actual.len) {
print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
return error.TestExpectedEqual;

View file

@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto
fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
const token_tags = tree.tokens.items(.tag);
const Size = std.builtin.Type.Pointer.Size;
const size: Size = switch (token_tags[info.main_token]) {
const size: std.builtin.Type.Pointer.Size = switch (token_tags[info.main_token]) {
.asterisk,
.asterisk_asterisk,
=> .One,
=> .one,
.l_bracket => switch (token_tags[info.main_token + 1]) {
.asterisk => if (token_tags[info.main_token + 2] == .identifier) Size.C else Size.Many,
else => Size.Slice,
.asterisk => if (token_tags[info.main_token + 2] == .identifier) .c else .many,
else => .slice,
},
else => unreachable,
};
@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType
// positives. Therefore, start after a sentinel if there is one and
// skip over any align node and bit range nodes.
var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) {
.Many, .C => info.main_token + 1,
.many, .c => info.main_token + 1,
else => info.main_token,
};
const end = tree.firstToken(info.child_type);

View file

@ -3917,7 +3917,7 @@ fn ptrType(
node: Ast.Node.Index,
ptr_info: Ast.full.PtrType,
) InnerError!Zir.Inst.Ref {
if (ptr_info.size == .C and ptr_info.allowzero_token != null) {
if (ptr_info.size == .c and ptr_info.allowzero_token != null) {
return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{});
}
@ -3946,7 +3946,7 @@ fn ptrType(
.{ .rl = .{ .ty = elem_type } },
ptr_info.ast.sentinel,
switch (ptr_info.size) {
.Slice => .slice_sentinel,
.slice => .slice_sentinel,
else => .pointer_sentinel,
},
);

View file

@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize {
}
},
.pointer => |ptr| {
if (ptr.size == .Slice) {
if (ptr.size == .slice) {
@compileError("Cannot use C sizeof on slice type " ++ @typeName(T));
}
// for strings, sizeof("a") returns 2.
@ -178,7 +178,7 @@ pub fn sizeof(target: anytype) usize {
// in the .array case above, but strings remain literals
// and are therefore always pointers, so they need to be
// specially handled here.
if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) {
if (ptr.size == .one and ptr.is_const and @typeInfo(ptr.child) == .array) {
const array_info = @typeInfo(ptr.child).array;
if ((array_info.child == u8 or array_info.child == u16) and
array_info.sentinel != null and
@ -341,7 +341,7 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty
switch (@typeInfo(SelfType)) {
.pointer => |ptr| {
return @Type(.{ .pointer = .{
.size = .C,
.size = .c,
.is_const = ptr.is_const,
.is_volatile = ptr.is_volatile,
.alignment = @alignOf(ElementType),

View file

@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" {
\\pub fn f(
\\ a: i32,
\\ b: i32,
\\) callconv(.C) i32 {}
\\) callconv(.c) i32 {}
\\pub fn f(
\\ a: i32,
\\ b: i32,
@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" {
\\pub fn f(
\\ a: i32,
\\ b: i32,
\\) align(8) callconv(.C) i32 {}
\\) align(8) callconv(.c) i32 {}
\\pub fn f(
\\ a: i32,
\\ b: i32,
\\) align(8) linksection(".text") callconv(.C) i32 {}
\\) align(8) linksection(".text") callconv(.c) i32 {}
\\pub fn f(
\\ a: i32,
\\ b: i32,
\\) linksection(".text") callconv(.C) i32 {}
\\) linksection(".text") callconv(.c) i32 {}
\\
);
}

View file

@ -938,7 +938,7 @@ fn renderArrayType(
fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void {
const tree = r.tree;
switch (ptr_type.size) {
.One => {
.one => {
// Since ** tokens exist and the same token is shared by two
// nested pointer types, we check to see if we are the parent
// in such a relationship. If so, skip rendering anything for
@ -951,7 +951,7 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
}
try renderToken(r, ptr_type.ast.main_token, .none); // asterisk
},
.Many => {
.many => {
if (ptr_type.ast.sentinel == 0) {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
@ -964,13 +964,13 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket
}
},
.C => {
.c => {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
try renderToken(r, ptr_type.ast.main_token + 2, .none); // c
try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket
},
.Slice => {
.slice => {
if (ptr_type.ast.sentinel == 0) {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket

View file

@ -475,7 +475,7 @@ const CpuidLeaf = packed struct {
/// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly.
extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.C) void;
extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.c) void;
fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
// valid for both x86 and x86_64
@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
/// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly.
extern fn zig_x86_get_xcr0() callconv(.C) u32;
extern fn zig_x86_get_xcr0() callconv(.c) u32;
// Read control register 0 (XCR0). Used to detect features such as AVX.
fn getXCR0() u32 {

View file

@ -1176,17 +1176,17 @@ const Local = struct {
} });
}
pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .One }) {
pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .one }) {
try mutable.ensureUnusedCapacity(1);
return mutable.addOneAssumeCapacity();
}
pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .One }) {
pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .one }) {
const index = mutable.mutate.len;
assert(index < mutable.list.header().capacity);
mutable.mutate.len = index + 1;
const mutable_view = mutable.view().slice();
var ptr: PtrElem(.{ .size = .One }) = undefined;
var ptr: PtrElem(.{ .size = .one }) = undefined;
inline for (fields) |field| {
@field(ptr, @tagName(field)) = &mutable_view.items(field)[index];
}
@ -1206,7 +1206,7 @@ const Local = struct {
pub fn appendSliceAssumeCapacity(
mutable: Mutable,
slice: PtrElem(.{ .size = .Slice, .is_const = true }),
slice: PtrElem(.{ .size = .slice, .is_const = true }),
) void {
if (fields.len == 0) return;
const start = mutable.mutate.len;
@ -1253,17 +1253,17 @@ const Local = struct {
return ptr_array;
}
pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .Slice }) {
pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .slice }) {
try mutable.ensureUnusedCapacity(len);
return mutable.addManyAsSliceAssumeCapacity(len);
}
pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .Slice }) {
pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .slice }) {
const start = mutable.mutate.len;
assert(len <= mutable.list.header().capacity - start);
mutable.mutate.len = @intCast(start + len);
const mutable_view = mutable.view().slice();
var slice: PtrElem(.{ .size = .Slice }) = undefined;
var slice: PtrElem(.{ .size = .slice }) = undefined;
inline for (fields) |field| {
@field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len];
}
@ -2060,7 +2060,7 @@ pub const Key = union(enum) {
};
pub const Flags = packed struct(u32) {
size: Size = .One,
size: Size = .one,
/// `none` indicates the ABI alignment of the pointee_type. In this
/// case, this field *must* be set to `none`, otherwise the
/// `InternPool` equality and hashing functions will return incorrect
@ -4891,7 +4891,7 @@ pub const Index = enum(u32) {
checkField(name ++ ".?", info.child);
},
.pointer => |info| {
assert(info.size == .Slice);
assert(info.size == .slice);
checkConfig(name ++ ".len");
checkField(name ++ "[0]", info.child);
},
@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .u8_type,
.flags = .{
.size = .Many,
.size = .many,
},
} },
@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .u8_type,
.flags = .{
.size = .Many,
.size = .many,
.is_const = true,
},
} },
@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{
.child = .u8_type,
.sentinel = .zero_u8,
.flags = .{
.size = .Many,
.size = .many,
.is_const = true,
},
} },
@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .comptime_int_type,
.flags = .{
.size = .One,
.size = .one,
.is_const = true,
},
} },
@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .u8_type,
.flags = .{
.size = .Slice,
.size = .slice,
.is_const = true,
},
} },
@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{
.child = .u8_type,
.sentinel = .zero_u8,
.flags = .{
.size = .Slice,
.size = .slice,
.is_const = true,
},
} },
@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
const many_ptr_item = many_ptr_unwrapped.getItem(ip);
assert(many_ptr_item.tag == .type_pointer);
var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data);
ptr_info.flags.size = .Slice;
ptr_info.flags.size = .slice;
return .{ .ptr_type = ptr_info };
},
@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
assert(ptr_type.child != .none);
assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child);
if (ptr_type.flags.size == .Slice) {
if (ptr_type.flags.size == .slice) {
gop.cancel();
var new_key = key;
new_key.ptr_type.flags.size = .Many;
new_key.ptr_type.flags.size = .many;
const ptr_type_index = try ip.get(gpa, tid, new_key);
gop = try ip.getOrPutKey(gpa, tid, key);
@ -7588,7 +7588,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
}
var ptr_type_adjusted = ptr_type;
if (ptr_type.flags.size == .C) ptr_type_adjusted.flags.is_allowzero = true;
if (ptr_type.flags.size == .c) ptr_type_adjusted.flags.is_allowzero = true;
items.appendAssumeCapacity(.{
.tag = .type_pointer,
@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
},
.slice => |slice| {
assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .Slice);
assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .Many);
assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .slice);
assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .many);
items.appendAssumeCapacity(.{
.tag = .ptr_slice,
.data = try addExtra(extra, PtrSlice{
@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
.ptr => |ptr| {
const ptr_type = ip.indexToKey(ptr.ty).ptr_type;
assert(ptr_type.flags.size != .Slice);
assert(ptr_type.flags.size != .slice);
items.appendAssumeCapacity(switch (ptr.base_addr) {
.nav => |nav| .{
.tag = .ptr_nav,
@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
.arr_elem, .field => |base_index| {
const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type;
switch (ptr.base_addr) {
.arr_elem => assert(base_ptr_type.flags.size == .Many),
.arr_elem => assert(base_ptr_type.flags.size == .many),
.field => {
assert(base_ptr_type.flags.size == .One);
assert(base_ptr_type.flags.size == .one);
switch (ip.indexToKey(base_ptr_type.child)) {
.tuple_type => |tuple_type| {
assert(ptr.base_addr == .field);
@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
},
.ptr_type => |slice_type| {
assert(ptr.base_addr == .field);
assert(slice_type.flags.size == .Slice);
assert(slice_type.flags.size == .slice);
assert(base_index.index < 2);
},
else => unreachable,
@ -10314,12 +10314,12 @@ pub fn getCoerced(
} });
if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) {
.One, .Many, .C => return ip.get(gpa, tid, .{ .ptr = .{
.one, .many, .c => return ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty,
.base_addr = .int,
.byte_offset = 0,
} }),
.Slice => return ip.get(gpa, tid, .{ .slice = .{
.slice => return ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty,
.ptr = try ip.get(gpa, tid, .{ .ptr = .{
.ty = ip.slicePtrType(new_ty),
@ -10408,7 +10408,7 @@ pub fn getCoerced(
},
else => {},
},
.slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .Slice)
.slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .slice)
return ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty,
.ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)),
@ -10416,7 +10416,7 @@ pub fn getCoerced(
} })
else if (ip.isIntegerType(new_ty))
return ip.getCoerced(gpa, tid, slice.ptr, new_ty),
.ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .Slice)
.ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .slice)
return ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty,
.base_addr = ptr.base_addr,
@ -10433,12 +10433,12 @@ pub fn getCoerced(
.opt => |opt| switch (ip.indexToKey(new_ty)) {
.ptr_type => |ptr_type| return switch (opt.val) {
.none => switch (ptr_type.flags.size) {
.One, .Many, .C => try ip.get(gpa, tid, .{ .ptr = .{
.one, .many, .c => try ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty,
.base_addr = .int,
.byte_offset = 0,
} }),
.Slice => try ip.get(gpa, tid, .{ .slice = .{
.slice => try ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty,
.ptr = try ip.get(gpa, tid, .{ .ptr = .{
.ty = ip.slicePtrType(new_ty),

File diff suppressed because it is too large Load diff

View file

@ -192,16 +192,16 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
const info = ty.ptrInfo(zcu);
if (info.sentinel != .none) switch (info.flags.size) {
.One, .C => unreachable,
.Many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
.Slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
.one, .c => unreachable,
.many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
.slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
} else switch (info.flags.size) {
.One => try writer.writeAll("*"),
.Many => try writer.writeAll("[*]"),
.C => try writer.writeAll("[*c]"),
.Slice => try writer.writeAll("[]"),
.one => try writer.writeAll("*"),
.many => try writer.writeAll("[*]"),
.c => try writer.writeAll("[*c]"),
.slice => try writer.writeAll("[]"),
}
if (info.flags.is_allowzero and info.flags.size != .C) try writer.writeAll("allowzero ");
if (info.flags.is_allowzero and info.flags.size != .c) try writer.writeAll("allowzero ");
if (info.flags.alignment != .none or
info.packed_offset.host_size != 0 or
info.flags.vector_index != .none)
@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool {
.array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu),
.opt_type => ty.isPtrLikeOptional(zcu),
.ptr_type => |ptr_type| ptr_type.flags.size != .Slice,
.ptr_type => |ptr_type| ptr_type.flags.size != .slice,
.simple_type => |t| switch (t) {
.f16,
@ -1303,7 +1303,7 @@ pub fn abiSizeInner(
return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) };
},
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 },
.slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 },
else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
},
.anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
@ -1741,7 +1741,7 @@ pub fn bitSizeInner(
switch (ip.indexToKey(ty.toIntern())) {
.int_type => |int_type| return int_type.bits,
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice => return target.ptrBitWidth() * 2,
.slice => return target.ptrBitWidth() * 2,
else => return target.ptrBitWidth(),
},
.anyframe_type => return target.ptrBitWidth(),
@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool {
pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_info| ptr_info.flags.size == .One,
.ptr_type => |ptr_info| ptr_info.flags.size == .one,
else => false,
};
}
@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size {
pub fn isSlice(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| ptr_type.flags.size == .Slice,
.ptr_type => |ptr_type| ptr_type.flags.size == .slice,
else => false,
};
}
@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool {
pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| ptr_type.flags.size == .C,
.ptr_type => |ptr_type| ptr_type.flags.size == .c,
else => false,
};
}
@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice => false,
.One, .Many, .C => true,
.slice => false,
.one, .many, .c => true,
},
.opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
.ptr_type => |p| switch (p.flags.size) {
.Slice, .C => false,
.Many, .One => !p.flags.is_allowzero,
.slice, .c => false,
.many, .one => !p.flags.is_allowzero,
},
else => false,
},
@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool {
pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) {
.ptr_type => |ptr_type| ptr_type.flags.size != .C and !ptr_type.flags.is_allowzero,
.ptr_type => |ptr_type| ptr_type.flags.size != .c and !ptr_type.flags.is_allowzero,
.error_set_type, .inferred_error_set_type => true,
else => false,
},
.ptr_type => |ptr_type| ptr_type.flags.size == .C,
.ptr_type => |ptr_type| ptr_type.flags.size == .c,
else => false,
};
}
@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
/// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`.
pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| ptr_type.flags.size == .C,
.ptr_type => |ptr_type| ptr_type.flags.size == .c,
.opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice, .C => false,
.Many, .One => !ptr_type.flags.is_allowzero,
.slice, .c => false,
.many, .one => !ptr_type.flags.is_allowzero,
},
else => false,
},
@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {
pub fn elemType2(ty: Type, zcu: *const Zcu) Type {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.One => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
.Many, .C, .Slice => Type.fromInterned(ptr_type.child),
.one => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
.many, .c, .slice => Type.fromInterned(ptr_type.child),
},
.anyframe_type => |child| {
assert(child != .none);
@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.opt_type => |child| Type.fromInterned(child),
.ptr_type => |ptr_type| b: {
assert(ptr_type.flags.size == .C);
assert(ptr_type.flags.size == .c);
break :b ty;
},
else => unreachable,
@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {
return switch (ty.zigTypeTag(zcu)) {
.array, .vector => true,
.pointer => switch (ty.ptrSize(zcu)) {
.Slice, .Many, .C => true,
.One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.slice, .many, .c => true,
.one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.array, .vector => true,
.@"struct" => ty.childType(zcu).isTuple(zcu),
else => false,
@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {
return switch (ty.zigTypeTag(zcu)) {
.array, .vector => true,
.pointer => switch (ty.ptrSize(zcu)) {
.Many, .C => false,
.Slice => true,
.One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.many, .c => false,
.slice => true,
.one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.array, .vector => true,
.@"struct" => ty.childType(zcu).isTuple(zcu),
else => false,
@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type {
host_size: u16 = 0,
alignment: Alignment = .none,
vector_index: VI = .none,
} = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .One) blk: {
} = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .one) blk: {
const elem_bits = elem_ty.bitSize(zcu);
if (elem_bits == 0) break :blk .{};
const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits);

View file

@ -3724,7 +3724,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
const parent_ptr_ty = parent_ptr.typeOf(zcu);
const opt_ty = parent_ptr_ty.childType(zcu);
assert(parent_ptr_ty.ptrSize(zcu) == .One);
assert(parent_ptr_ty.ptrSize(zcu) == .one);
assert(opt_ty.zigTypeTag(zcu) == .optional);
const result_ty = try pt.ptrTypeSema(info: {
@ -3742,7 +3742,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
return pt.getCoerced(parent_ptr, result_ty);
}
const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, opt_ty, pt);
const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, opt_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .opt_payload = base_ptr.toIntern() },
@ -3758,7 +3758,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
const parent_ptr_ty = parent_ptr.typeOf(zcu);
const eu_ty = parent_ptr_ty.childType(zcu);
assert(parent_ptr_ty.ptrSize(zcu) == .One);
assert(parent_ptr_ty.ptrSize(zcu) == .one);
assert(eu_ty.zigTypeTag(zcu) == .error_union);
const result_ty = try pt.ptrTypeSema(info: {
@ -3771,7 +3771,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, eu_ty, pt);
const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, eu_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .eu_payload = base_ptr.toIntern() },
@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
const aggregate_ty = parent_ptr_ty.childType(zcu);
const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
assert(parent_ptr_info.flags.size == .One);
assert(parent_ptr_info.flags.size == .one);
// Exiting this `switch` indicates that the `field` pointer representation should be used.
// `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.
@ -3920,7 +3920,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, aggregate_ty, pt);
const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, aggregate_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .field = .{
@ -3937,8 +3937,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value {
const zcu = pt.zcu;
const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) {
.One, .Many, .C => orig_parent_ptr,
.Slice => orig_parent_ptr.slicePtr(zcu),
.one, .many, .c => orig_parent_ptr,
.slice => orig_parent_ptr.slicePtr(zcu),
};
const parent_ptr_ty = parent_ptr.typeOf(zcu);
@ -3959,7 +3959,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
};
const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {
.One => switch (elem_ty.zigTypeTag(zcu)) {
.one => switch (elem_ty.zigTypeTag(zcu)) {
.vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },
.array => strat: {
const arr_elem_ty = elem_ty.childType(zcu);
@ -3971,12 +3971,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
else => unreachable,
},
.Many, .C => if (try elem_ty.comptimeOnlySema(pt))
.many, .c => if (try elem_ty.comptimeOnlySema(pt))
.{ .elem_ptr = elem_ty }
else
.{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar },
.Slice => unreachable,
.slice => unreachable,
};
switch (strat) {
@ -4004,7 +4004,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
},
else => {},
}
const base_ptr = try parent_ptr.canonicalizeBasePtr(.Many, arr_base_ty, pt);
const base_ptr = try parent_ptr.canonicalizeBasePtr(.many, arr_base_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .arr_elem = .{
@ -4234,7 +4234,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
.child = parent_ptr_info.child,
.flags = flags: {
var flags = parent_ptr_info.flags;
flags.size = .One;
flags.size = .one;
break :flags flags;
},
});
@ -4304,8 +4304,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt;
if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt;
switch (need_child.ptrSize(zcu)) {
.One, .Many => {},
.Slice, .C => break :ptr_opt,
.one, .many => {},
.slice, .c => break :ptr_opt,
}
const parent = try arena.create(PointerDeriveStep);
parent.* = cur_derive;
@ -4323,7 +4323,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
const elem_size = elem_ty.abiSize(zcu);
const start_idx = cur_offset / elem_size;
const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size;
if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .One) {
if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) {
const parent = try arena.create(PointerDeriveStep);
parent.* = cur_derive;
cur_derive = .{ .elem_ptr = .{

View file

@ -3068,7 +3068,7 @@ pub fn populateTestFunctions(
.child = test_fn_ty.toIntern(),
.flags = .{
.is_const = true,
.size = .Slice,
.size = .slice,
},
});
const new_init = try pt.intern(.{ .slice = .{
@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E
pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type {
var canon_info = info;
if (info.flags.size == .C) canon_info.flags.is_allowzero = true;
if (info.flags.size == .c) canon_info.flags.is_allowzero = true;
// Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee
// type, we change it to 0 here. If this causes an assertion trip because the
@ -3360,7 +3360,7 @@ pub fn manyConstPtrType(pt: Zcu.PerThread, child_type: Type) Allocator.Error!Typ
return pt.ptrType(.{
.child = child_type.toIntern(),
.flags = .{
.size = .Many,
.size = .many,
.is_const = true,
},
});

View file

@ -2398,7 +2398,7 @@ fn ptrArithmetic(
const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
.One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
.one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
const elem_size = elem_ty.abiSize(zcu);

View file

@ -3919,7 +3919,7 @@ fn ptrArithmetic(
const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
.One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
.one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
const elem_size: u32 = @intCast(elem_ty.abiSize(zcu));

View file

@ -7843,15 +7843,15 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
if (elem_abi_size == 1) {
const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
.Slice => dst_ptr,
.One => dst_ptr,
.C, .Many => unreachable,
.slice => dst_ptr,
.one => dst_ptr,
.c, .many => unreachable,
};
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
.Slice => dst_ptr.address().offset(8).deref(),
.One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
.C, .Many => unreachable,
.slice => dst_ptr.address().offset(8).deref(),
.one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
.c, .many => unreachable,
};
const len_lock: ?RegisterLock = switch (len) {
.register => |reg| func.register_manager.lockRegAssumeUnused(reg),
@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
// Length zero requires a runtime check - so we handle arrays specially
// here to elide it.
switch (dst_ptr_ty.ptrSize(zcu)) {
.Slice => return func.fail("TODO: airMemset Slices", .{}),
.One => {
.slice => return func.fail("TODO: airMemset Slices", .{}),
.one => {
const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
},
.C, .Many => unreachable,
.c, .many => unreachable,
}
}
return func.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });
@ -7906,7 +7906,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
const dst_ty = func.typeOf(bin_op.lhs);
const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) {
.Slice => len: {
.slice => len: {
const len_reg, const len_lock = try func.allocReg(.int);
defer func.register_manager.unlockReg(len_lock);
@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
);
break :len .{ .register = len_reg };
},
.One => len: {
.one => len: {
const array_ty = dst_ty.childType(zcu);
break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
},

View file

@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
return result;
},
.pointer => switch (ty.ptrSize(zcu)) {
.Slice => {
.slice => {
result[0] = .integer;
result[1] = .integer;
return result;

View file

@ -2953,7 +2953,7 @@ fn binOp(
.pointer => {
const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
.One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
.one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
const elem_size = elem_ty.abiSize(zcu);

View file

@ -4726,7 +4726,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
const offset = try cg.resolveInst(bin_op.rhs);
const ptr_ty = cg.typeOf(bin_op.lhs);
const pointee_ty = switch (ptr_ty.ptrSize(zcu)) {
.One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
.one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
const ptr_ty = cg.typeOf(bin_op.lhs);
const value = try cg.resolveInst(bin_op.rhs);
const len = switch (ptr_ty.ptrSize(zcu)) {
.Slice => try cg.sliceLen(ptr),
.One => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
.C, .Many => unreachable,
.slice => try cg.sliceLen(ptr),
.one => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
.c, .many => unreachable,
};
const elem_ty = if (ptr_ty.ptrSize(zcu) == .One)
const elem_ty = if (ptr_ty.ptrSize(zcu) == .one)
ptr_ty.childType(zcu).childType(zcu)
else
ptr_ty.childType(zcu);
@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const src = try cg.resolveInst(bin_op.rhs);
const src_ty = cg.typeOf(bin_op.rhs);
const len = switch (dst_ty.ptrSize(zcu)) {
.Slice => blk: {
.slice => blk: {
const slice_len = try cg.sliceLen(dst);
if (ptr_elem_ty.abiSize(zcu) != 1) {
try cg.emitWValue(slice_len);
@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
break :blk slice_len;
},
.One => @as(WValue, .{
.one => @as(WValue, .{
.imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))),
}),
.C, .Many => unreachable,
.c, .many => unreachable,
};
const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty);
const src_ptr = try cg.sliceOrArrayPtr(src, src_ty);

View file

@ -9607,13 +9607,13 @@ fn genMulDivBinOp(
const manyptr_u32_ty = try pt.ptrType(.{
.child = .u32_type,
.flags = .{
.size = .Many,
.size = .many,
},
});
const manyptr_const_u32_ty = try pt.ptrType(.{
.child = .u32_type,
.flags = .{
.size = .Many,
.size = .many,
.is_const = true,
},
});
@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
if (elem_abi_size == 1) {
const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
.Slice => dst_ptr,
.One => dst_ptr,
.C, .Many => unreachable,
.slice => dst_ptr,
.one => dst_ptr,
.c, .many => unreachable,
};
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
.Slice => dst_ptr.address().offset(8).deref(),
.One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
.C, .Many => unreachable,
.slice => dst_ptr.address().offset(8).deref(),
.one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
.c, .many => unreachable,
};
const len_lock: ?RegisterLock = switch (len) {
.register => |reg| self.register_manager.lockRegAssumeUnused(reg),
@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
// Length zero requires a runtime check - so we handle arrays specially
// here to elide it.
switch (dst_ptr_ty.ptrSize(zcu)) {
.Slice => {
.slice => {
const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu);
// TODO: this only handles slices stored in the stack
@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
self.performReloc(skip_reloc);
},
.One => {
.one => {
const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
},
.C, .Many => unreachable,
.c, .many => unreachable,
}
}
return self.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });
@ -16735,7 +16735,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock);
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
.Slice => len: {
.slice => len: {
const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
const len_lock = self.register_manager.lockRegAssumeUnused(len_reg);
defer self.register_manager.unlockReg(len_lock);
@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
);
break :len .{ .register = len_reg };
},
.One => len: {
.one => len: {
const array_ty = dst_ptr_ty.childType(zcu);
break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
},
.C, .Many => unreachable,
.c, .many => unreachable,
};
const len_lock: ?RegisterLock = switch (len) {
.register => |reg| self.register_manager.lockRegAssumeUnused(reg),

View file

@ -108,7 +108,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
var result = [1]Class{.none} ** 8;
switch (ty.zigTypeTag(zcu)) {
.pointer => switch (ty.ptrSize(zcu)) {
.Slice => {
.slice => {
result[0] = .integer;
result[1] = .integer;
return result;

View file

@ -177,7 +177,7 @@ pub const ASTUnit = opaque {
extern fn ZigClangASTUnit_visitLocalTopLevelDecls(
*ASTUnit,
context: ?*anyopaque,
Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.C) bool,
Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.c) bool,
) bool;
pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin;

View file

@ -945,7 +945,7 @@ pub fn genTypedValue(
switch (ty.zigTypeTag(zcu)) {
.void => return .{ .mcv = .none },
.pointer => switch (ty.ptrSize(zcu)) {
.Slice => {},
.slice => {},
else => switch (val.toIntern()) {
.null_value => {
return .{ .mcv = .{ .immediate = 0 } };

View file

@ -1589,14 +1589,14 @@ pub const DeclGen = struct {
try dg.fmtIntLiteral(try pt.undefValue(ty), location),
}),
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.One, .Many, .C => {
.one, .many, .c => {
try writer.writeAll("((");
try dg.renderCType(writer, ctype);
return writer.print("){x})", .{
try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other),
});
},
.Slice => {
.slice => {
if (!location.isInitializer()) {
try writer.writeByte('(');
try dg.renderCType(writer, ctype);
@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
try f.renderType(writer, inst_ty);
try writer.writeByte(')');
if (elem_has_bits) try writer.writeByte('&');
if (elem_has_bits and ptr_ty.ptrSize(zcu) == .One) {
if (elem_has_bits and ptr_ty.ptrSize(zcu) == .one) {
// It's a pointer to an array, so we need to de-reference.
try f.writeCValueDeref(writer, ptr);
} else try f.writeCValue(writer, ptr, .Other);
@ -5798,8 +5798,8 @@ fn fieldLocation(
}
},
.ptr_type => |ptr_info| switch (ptr_info.flags.size) {
.One, .Many, .C => unreachable,
.Slice => switch (field_index) {
.one, .many, .c => unreachable,
.slice => switch (field_index) {
0 => return .{ .field = .{ .identifier = "ptr" } },
1 => return .{ .field = .{ .identifier = "len" } },
else => unreachable,
@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll("memset(");
switch (dest_ty.ptrSize(zcu)) {
.Slice => {
.slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
try writer.writeAll(", 0xaa, ");
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll(");\n");
}
},
.One => {
.one => {
const array_ty = dest_ty.childType(zcu);
const len = array_ty.arrayLen(zcu) * elem_abi_size;
try f.writeCValue(writer, dest_slice, .FunctionArgument);
try writer.print(", 0xaa, {d});\n", .{len});
},
.Many, .C => unreachable,
.many, .c => unreachable,
}
try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
return .none;
@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
const elem_ptr_ty = try pt.ptrType(.{
.child = elem_ty.toIntern(),
.flags = .{
.size = .C,
.size = .c,
},
});
@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try f.writeCValue(writer, index, .Other);
try writer.writeAll(" != ");
switch (dest_ty.ptrSize(zcu)) {
.Slice => {
.slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
},
.One => {
.one => {
const array_ty = dest_ty.childType(zcu);
try writer.print("{d}", .{array_ty.arrayLen(zcu)});
},
.Many, .C => unreachable,
.many, .c => unreachable,
}
try writer.writeAll("; ++");
try f.writeCValue(writer, index, .Other);
@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll("memset(");
switch (dest_ty.ptrSize(zcu)) {
.Slice => {
.slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
try writer.writeAll(", ");
try f.writeCValue(writer, bitcasted, .FunctionArgument);
@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
try writer.writeAll(");\n");
},
.One => {
.one => {
const array_ty = dest_ty.childType(zcu);
const len = array_ty.arrayLen(zcu) * elem_abi_size;
@ -6998,7 +6998,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try f.writeCValue(writer, bitcasted, .FunctionArgument);
try writer.print(", {d});\n", .{len});
},
.Many, .C => unreachable,
.many, .c => unreachable,
}
try f.freeCValue(inst, bitcasted);
try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
const src_ty = f.typeOf(bin_op.rhs);
const writer = f.object.writer();
if (dest_ty.ptrSize(zcu) != .One) {
if (dest_ty.ptrSize(zcu) != .one) {
try writer.writeAll("if (");
try writeArrayLen(f, writer, dest_ptr, dest_ty);
try writer.writeAll(" != 0) ");
@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t
const pt = f.object.dg.pt;
const zcu = pt.zcu;
switch (dest_ty.ptrSize(zcu)) {
.One => try writer.print("{}", .{
.one => try writer.print("{}", .{
try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))),
}),
.Many, .C => unreachable,
.Slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
.many, .c => unreachable,
.slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
}
}

View file

@ -1458,7 +1458,7 @@ pub const Pool = struct {
_ => |ip_index| switch (ip.indexToKey(ip_index)) {
.int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),
.ptr_type => |ptr_info| switch (ptr_info.flags.size) {
.One, .Many, .C => {
.one, .many, .c => {
const elem_ctype = elem_ctype: {
if (ptr_info.packed_offset.host_size > 0 and
ptr_info.flags.vector_index == .none)
@ -1505,7 +1505,7 @@ pub const Pool = struct {
.@"volatile" = ptr_info.flags.is_volatile,
});
},
.Slice => {
.slice => {
const target = &mod.resolved_target.result;
var fields = [_]Info.Field{
.{
@ -1598,7 +1598,7 @@ pub const Pool = struct {
switch (payload_type) {
.anyerror_type => return payload_ctype,
else => switch (ip.indexToKey(payload_type)) {
.ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .C and
.ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .c and
!payload_ptr_info.flags.is_allowzero) return payload_ctype,
.error_set_type, .inferred_error_set_type => return payload_ctype,
else => {},

View file

@ -2109,7 +2109,7 @@ pub const Object = struct {
ptr_info.flags.is_allowzero or
ptr_info.flags.is_const or
ptr_info.flags.is_volatile or
ptr_info.flags.size == .Many or ptr_info.flags.size == .C or
ptr_info.flags.size == .many or ptr_info.flags.size == .c or
!Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu))
{
const bland_ptr_ty = try pt.ptrType(.{
@ -2120,8 +2120,8 @@ pub const Object = struct {
.flags = .{
.alignment = ptr_info.flags.alignment,
.size = switch (ptr_info.flags.size) {
.Many, .C, .One => .One,
.Slice => .Slice,
.many, .c, .one => .one,
.slice => .slice,
},
},
});
@ -3382,8 +3382,8 @@ pub const Object = struct {
toLlvmAddressSpace(ptr_type.flags.address_space, target),
);
break :type switch (ptr_type.flags.size) {
.One, .Many, .C => ptr_ty,
.Slice => try o.builder.structType(.normal, &.{
.one, .many, .c => ptr_ty,
.slice => try o.builder.structType(.normal, &.{
ptr_ty,
try o.lowerType(Type.usize),
}),
@ -6988,7 +6988,7 @@ pub const FuncGen = struct {
const zcu = pt.zcu;
const llvm_usize = try o.lowerType(Type.usize);
switch (ty.ptrSize(zcu)) {
.Slice => {
.slice => {
const len = try fg.wip.extractValue(ptr, &.{1}, "");
const elem_ty = ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu);
@ -6996,13 +6996,13 @@ pub const FuncGen = struct {
const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size);
return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, "");
},
.One => {
.one => {
const array_ty = ty.childType(zcu);
const elem_ty = array_ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu);
return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size);
},
.Many, .C => unreachable,
.many, .c => unreachable,
}
}
@ -8670,11 +8670,11 @@ pub const FuncGen = struct {
const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
switch (ptr_ty.ptrSize(zcu)) {
// It's a pointer to an array, so according to LLVM we need an extra GEP index.
.One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
.one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
try o.builder.intValue(try o.lowerType(Type.usize), 0), offset,
}, ""),
.C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
.Slice => {
.c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
.slice => {
const base = try self.wip.extractValue(ptr, &.{0}, "");
return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, "");
},
@ -8693,11 +8693,11 @@ pub const FuncGen = struct {
const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
switch (ptr_ty.ptrSize(zcu)) {
// It's a pointer to an array, so according to LLVM we need an extra GEP index.
.One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
.one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset,
}, ""),
.C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
.Slice => {
.c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
.slice => {
const base = try self.wip.extractValue(ptr, &.{0}, "");
return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, "");
},
@ -10034,9 +10034,9 @@ pub const FuncGen = struct {
const llvm_usize_ty = try o.lowerType(Type.usize);
const len = switch (ptr_ty.ptrSize(zcu)) {
.Slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
.One => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
.Many, .C => unreachable,
.slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
.one => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
.many, .c => unreachable,
};
const elem_llvm_ty = try o.lowerType(elem_ty);
const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, "");

View file

@ -1705,13 +1705,13 @@ const NavGen = struct {
const storage_class = self.spvStorageClass(ptr_info.flags.address_space);
const ptr_ty_id = try self.ptrType(child_ty, storage_class);
if (target.os.tag == .vulkan and ptr_info.flags.size == .Many) {
if (target.os.tag == .vulkan and ptr_info.flags.size == .many) {
try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{
.array_stride = @intCast(child_ty.abiSize(zcu)),
} });
}
if (ptr_info.flags.size != .Slice) {
if (ptr_info.flags.size != .slice) {
return ptr_ty_id;
}
@ -4399,15 +4399,15 @@ const NavGen = struct {
const result_ty_id = try self.resolveType(result_ty, .direct);
switch (ptr_ty.ptrSize(zcu)) {
.One => {
.one => {
// Pointer to array
// TODO: Is this correct?
return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id});
},
.C, .Many => {
.c, .many => {
return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{});
},
.Slice => {
.slice => {
// TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does.
const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0);
return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{});
@ -4989,15 +4989,15 @@ const NavGen = struct {
const pt = self.pt;
const zcu = pt.zcu;
switch (ty.ptrSize(zcu)) {
.Slice => return self.extractField(Type.usize, operand_id, 1),
.One => {
.slice => return self.extractField(Type.usize, operand_id, 1),
.one => {
const array_ty = ty.childType(zcu);
const elem_ty = array_ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu);
const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size;
return try self.constInt(Type.usize, size, .direct);
},
.Many, .C => unreachable,
.many, .c => unreachable,
}
}

View file

@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
section.writeOperand(info.child, child);
},
.pointer => |info| {
std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.
std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec.
for (operand) |item| {
section.writeOperand(info.child, item);
}
@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
.@"enum" => 1,
.optional => |info| if (operand) |child| operandSize(info.child, child) else 0,
.pointer => |info| blk: {
std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.
std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec.
var total: usize = 0;
for (operand) |item| {
total += operandSize(info.child, item);

View file

@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void {
debug.updateSegfaultHandler(&act);
}
fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn {
fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
// TODO: use alarm() here to prevent infinite loops
PanicSwitch.preDispatch();

View file

@ -3182,7 +3182,7 @@ fn updateLazyType(
try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
},
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.One, .Many, .C => {
.one, .many, .c => {
const ptr_child_type: Type = .fromInterned(ptr_type.child);
try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);
try wip_nav.strp(name);
@ -3210,7 +3210,7 @@ fn updateLazyType(
try wip_nav.refType(ptr_child_type);
}
},
.Slice => {
.slice => {
try wip_nav.abbrevCode(.generated_struct_type);
try wip_nav.strp(name);
try uleb128(diw, ty.abiSize(zcu));

View file

@ -248,7 +248,7 @@ pub const Value = union(enum) {
.array => return encode(arena, &input),
.pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) {
.one => switch (@typeInfo(info.child)) {
.array => |child_info| {
const Slice = []const child_info.child;
return encode(arena, @as(Slice, input));
@ -257,7 +257,7 @@ pub const Value = union(enum) {
@compileError("Unhandled type: {s}" ++ @typeName(info.child));
},
},
.Slice => {
.slice => {
if (info.child == u8) {
return Value{ .string = try arena.dupe(u8, input) };
}
@ -357,7 +357,7 @@ pub const Yaml = struct {
},
.pointer => |info| {
switch (info.size) {
.Slice => {
.slice => {
var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);
for (self.docs.items, 0..) |doc, i| {
parsed[i] = try self.parseValue(info.child, doc);
@ -446,7 +446,7 @@ pub const Yaml = struct {
const arena = self.arena.allocator();
switch (ptr_info.size) {
.Slice => {
.slice => {
if (ptr_info.child == u8) {
return value.asString();
}

View file

@ -256,7 +256,7 @@ pub const MutableValue = union(enum) {
},
.pointer => {
const ptr_ty = ip.indexToKey(ty_ip).ptr_type;
if (ptr_ty.flags.size != .Slice) return;
if (ptr_ty.flags.size != .slice) return;
const ptr = try arena.create(MutableValue);
const len = try arena.create(MutableValue);
ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) };

View file

@ -231,13 +231,13 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {
}
}
fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {
fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
const c: *Context = @ptrCast(@alignCast(context));
declVisitorNamesOnly(c, decl) catch return false;
return true;
}
fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {
fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
const c: *Context = @ptrCast(@alignCast(context));
declVisitor(c, decl) catch return false;
return true;

View file

@ -410,11 +410,11 @@ test "alignment of function with c calling convention" {
var runtime_nothing = &nothing;
_ = &runtime_nothing;
const casted1: *align(a) const u8 = @ptrCast(runtime_nothing);
const casted2: *const fn () callconv(.C) void = @ptrCast(casted1);
const casted2: *const fn () callconv(.c) void = @ptrCast(casted1);
casted2();
}
fn nothing() callconv(.C) void {}
fn nothing() callconv(.c) void {}
const DefaultAligned = struct {
nevermind: u32,

View file

@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" {
// On some architectures function pointers must be aligned.
const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);
pub const FUNCTION_CONSTANT = @as(PFN_void, @ptrFromInt(hardcoded_fn_addr));
pub const PFN_void = *const fn (*anyopaque) callconv(.C) void;
pub const PFN_void = *const fn (*anyopaque) callconv(.c) void;
fn foobar(func: PFN_void) !void {
try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);
@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" {
var global_array: [4]u8 = undefined;
test "cast from array reference to fn: comptime fn ptr" {
const f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array));
const f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array));
try expect(@intFromPtr(f) == @intFromPtr(&global_array));
}
test "cast from array reference to fn: runtime fn ptr" {
var f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array));
var f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array));
_ = &f;
try expect(@intFromPtr(f) == @intFromPtr(&global_array));
}
@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" {
test "cast between [*c]T and ?[*:0]T on fn parameter" {
const S = struct {
const Handler = ?fn ([*c]const u8) callconv(.C) void;
const Handler = ?fn ([*c]const u8) callconv(.c) void;
fn addCallback(comptime handler: Handler) void {
_ = handler;
}
fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {
fn myCallback(cstr: ?[*:0]const u8) callconv(.c) void {
_ = cstr;
}

View file

@ -26,7 +26,7 @@ test "exporting with internal linkage" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
const S = struct {
fn foo() callconv(.C) void {}
fn foo() callconv(.c) void {}
comptime {
@export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
}

View file

@ -44,7 +44,7 @@ test "export function alias" {
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
_ = struct {
fn foo_internal() callconv(.C) u32 {
fn foo_internal() callconv(.c) u32 {
return 123;
}
export const foo_exported = foo_internal;

View file

@ -20,7 +20,7 @@ test "function extern symbol" {
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const a = @extern(*const fn () callconv(.C) i32, .{ .name = "a_mystery_function" });
const a = @extern(*const fn () callconv(.c) i32, .{ .name = "a_mystery_function" });
try expect(a() == 4567);
}
@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" {
const S = struct {
extern fn another_mystery_function() u32;
const same_thing = @extern(*const fn () callconv(.C) u32, .{ .name = "another_mystery_function" });
const same_thing = @extern(*const fn () callconv(.c) u32, .{ .name = "another_mystery_function" });
};
try expect(S.another_mystery_function() == 12345);
try expect(S.same_thing() == 12345);
@ -55,5 +55,5 @@ test "coerce extern function types" {
};
_ = S;
_ = @as(fn () callconv(.C) ?*u32, c_extern_function);
_ = @as(fn () callconv(.c) ?*u32, c_extern_function);
}

View file

@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = extern struct {
ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32,
ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32,
fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32 {
fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32 {
return 1234;
}
};
@ -169,7 +169,7 @@ const nComplexCallconv = 100;
fn fComplexCallconvRet(x: u32) callconv(blk: {
const s: struct { n: u32 } = .{ .n = nComplexCallconv };
break :blk switch (s.n) {
0 => .C,
0 => .c,
1 => .Inline,
else => .Unspecified,
};
@ -435,13 +435,13 @@ test "implicit cast function to function ptr" {
return 123;
}
};
var fnPtr1: *const fn () callconv(.C) c_int = S1.someFunctionThatReturnsAValue;
var fnPtr1: *const fn () callconv(.c) c_int = S1.someFunctionThatReturnsAValue;
_ = &fnPtr1;
try expect(fnPtr1() == 123);
const S2 = struct {
extern fn someFunctionThatReturnsAValue() c_int;
};
var fnPtr2: *const fn () callconv(.C) c_int = S2.someFunctionThatReturnsAValue;
var fnPtr2: *const fn () callconv(.c) c_int = S2.someFunctionThatReturnsAValue;
_ = &fnPtr2;
try expect(fnPtr2() == 123);
}

View file

@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" {
for (source, 0..) |s, i| dest[i] = s;
}
fn foo() callconv(.C) void {}
fn foo() callconv(.c) void {}
};
var buffer: [100]u8 = undefined;
S.copy(u8, &buffer, "hello");
@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" {
try expect(S.A.do() == 1234);
}
test "generic function returns value from callconv(.C) function" {
test "generic function returns value from callconv(.c) function" {
const S = struct {
fn getU8() callconv(.C) u8 {
fn getU8() callconv(.c) u8 {
return 123;
}
fn getGeneric(comptime T: type, supplier: fn () callconv(.C) T) T {
fn getGeneric(comptime T: type, supplier: fn () callconv(.c) T) T {
return supplier();
}
};
@ -521,11 +521,11 @@ test "function argument tuple used as struct field" {
try expect(c.t[0] == null);
}
test "comptime callconv(.C) function ptr uses comptime type argument" {
test "comptime callconv(.c) function ptr uses comptime type argument" {
const S = struct {
fn A(
comptime T: type,
comptime destroycb: ?*const fn (?*T) callconv(.C) void,
comptime destroycb: ?*const fn (?*T) callconv(.c) void,
) !void {
try expect(destroycb == null);
}

View file

@ -80,7 +80,7 @@ test "import c keywords" {
try std.testing.expect(ptr_id == &some_non_c_keyword_constant);
if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) {
var ptr_fn: *const fn () callconv(.C) Id = &double;
var ptr_fn: *const fn () callconv(.c) Id = &double;
try std.testing.expect(ptr_fn == &float);
ptr_fn = &an_alias_of_float;
try std.testing.expect(ptr_fn == &float);

View file

@ -891,7 +891,7 @@ test "runtime init of unnamed packed struct type" {
}{ .x = z }).m();
}
test "packed struct passed to callconv(.C) function" {
test "packed struct passed to callconv(.c) function" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" {
d: u46 = 0,
};
fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.C) bool {
fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.c) bool {
return p.a == 12345 and p.b == true and p.c == true and p.d == 0 and a1 == 5 and a2 == 4 and a3 == 3 and a4 == 2 and a5 == 1;
}
};
@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" {
x: u15 = 0,
y: u1 = 0,
fn foo(s: @This()) callconv(.C) i32 {
fn foo(s: @This()) callconv(.c) i32 {
return s.x;
}
fn bar(s: @This()) !void {

View file

@ -803,7 +803,7 @@ test "fn with C calling convention returns struct by value" {
handle: i32,
};
fn makeBar(t: i32) callconv(.C) ExternBar {
fn makeBar(t: i32) callconv(.c) ExternBar {
return ExternBar{
.handle = t,
};

View file

@ -141,7 +141,7 @@ test "Type.Array" {
test "@Type create slice with null sentinel" {
const Slice = @Type(.{
.pointer = .{
.size = .Slice,
.size = .slice,
.is_const = true,
.is_volatile = false,
.is_allowzero = false,
@ -548,11 +548,11 @@ test "Type.Fn" {
const some_opaque = opaque {};
const some_ptr = *some_opaque;
const T = fn (c_int, some_ptr) callconv(.C) void;
const T = fn (c_int, some_ptr) callconv(.c) void;
{
const fn_info = std.builtin.Type{ .@"fn" = .{
.calling_convention = .C,
.calling_convention = .c,
.is_generic = false,
.is_var_args = false,
.return_type = void,

View file

@ -44,7 +44,7 @@ test "type info: C pointer type info" {
fn testCPtr() !void {
const ptr_info = @typeInfo([*c]align(4) const i8);
try expect(ptr_info == .pointer);
try expect(ptr_info.pointer.size == .C);
try expect(ptr_info.pointer.size == .c);
try expect(ptr_info.pointer.is_const);
try expect(!ptr_info.pointer.is_volatile);
try expect(ptr_info.pointer.alignment == 4);
@ -54,8 +54,8 @@ fn testCPtr() !void {
test "type info: value is correctly copied" {
comptime {
var ptrInfo = @typeInfo([]u32);
ptrInfo.pointer.size = .One;
try expect(@typeInfo([]u32).pointer.size == .Slice);
ptrInfo.pointer.size = .one;
try expect(@typeInfo([]u32).pointer.size == .slice);
}
}
@ -79,7 +79,7 @@ test "type info: pointer type info" {
fn testPointer() !void {
const u32_ptr_info = @typeInfo(*u32);
try expect(u32_ptr_info == .pointer);
try expect(u32_ptr_info.pointer.size == .One);
try expect(u32_ptr_info.pointer.size == .one);
try expect(u32_ptr_info.pointer.is_const == false);
try expect(u32_ptr_info.pointer.is_volatile == false);
try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));
@ -95,7 +95,7 @@ test "type info: unknown length pointer type info" {
fn testUnknownLenPtr() !void {
const u32_ptr_info = @typeInfo([*]const volatile f64);
try expect(u32_ptr_info == .pointer);
try expect(u32_ptr_info.pointer.size == .Many);
try expect(u32_ptr_info.pointer.size == .many);
try expect(u32_ptr_info.pointer.is_const == true);
try expect(u32_ptr_info.pointer.is_volatile == true);
try expect(u32_ptr_info.pointer.sentinel == null);
@ -111,7 +111,7 @@ test "type info: null terminated pointer type info" {
fn testNullTerminatedPtr() !void {
const ptr_info = @typeInfo([*:0]u8);
try expect(ptr_info == .pointer);
try expect(ptr_info.pointer.size == .Many);
try expect(ptr_info.pointer.size == .many);
try expect(ptr_info.pointer.is_const == false);
try expect(ptr_info.pointer.is_volatile == false);
try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);
@ -127,7 +127,7 @@ test "type info: slice type info" {
fn testSlice() !void {
const u32_slice_info = @typeInfo([]u32);
try expect(u32_slice_info == .pointer);
try expect(u32_slice_info.pointer.size == .Slice);
try expect(u32_slice_info.pointer.size == .slice);
try expect(u32_slice_info.pointer.is_const == false);
try expect(u32_slice_info.pointer.is_volatile == false);
try expect(u32_slice_info.pointer.alignment == 4);
@ -374,7 +374,7 @@ fn testFunction() !void {
try expect(foo_fn_info.@"fn".is_var_args);
try expect(foo_fn_info.@"fn".return_type.? == usize);
const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo));
try expect(foo_ptr_fn_info.pointer.size == .One);
try expect(foo_ptr_fn_info.pointer.size == .one);
try expect(foo_ptr_fn_info.pointer.is_const);
try expect(!foo_ptr_fn_info.pointer.is_volatile);
try expect(foo_ptr_fn_info.pointer.address_space == .generic);
@ -401,7 +401,7 @@ fn testFunction() !void {
try expect(aligned_foo_fn_info.@"fn".is_var_args);
try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);
const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned));
try expect(aligned_foo_ptr_fn_info.pointer.size == .One);
try expect(aligned_foo_ptr_fn_info.pointer.size == .one);
try expect(aligned_foo_ptr_fn_info.pointer.is_const);
try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);
try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4);

View file

@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" {
s: S,
};
fn bar(arg_u: U) callconv(.C) U {
fn bar(arg_u: U) callconv(.c) U {
var u = arg_u;
_ = &u;
return u;

View file

@ -108,19 +108,19 @@ test "simple variadic function" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
fn simple(...) callconv(.C) c_int {
fn simple(...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
return @cVaArg(&ap, c_int);
}
fn compatible(_: c_int, ...) callconv(.C) c_int {
fn compatible(_: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
return @cVaArg(&ap, c_int);
}
fn add(count: c_int, ...) callconv(.C) c_int {
fn add(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
var i: usize = 0;
@ -169,7 +169,7 @@ test "coerce reference to var arg" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
fn addPtr(count: c_int, ...) callconv(.C) c_int {
fn addPtr(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
var i: usize = 0;
@ -202,7 +202,7 @@ test "variadic functions" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.C) void {
fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.c) void {
var ap = @cVaStart();
defer @cVaEnd(&ap);
vprintf(list_ptr, format, &ap);
@ -212,7 +212,7 @@ test "variadic functions" {
list: *std.ArrayList(u8),
format: [*:0]const u8,
ap: *std.builtin.VaList,
) callconv(.C) void {
) callconv(.c) void {
for (std.mem.span(format)) |c| switch (c) {
's' => {
const arg = @cVaArg(ap, [*:0]const u8);
@ -247,7 +247,7 @@ test "copy VaList" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
fn add(count: c_int, ...) callconv(.C) c_int {
fn add(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
var copy = @cVaCopy(&ap);
@ -284,7 +284,7 @@ test "unused VaList arg" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
fn thirdArg(dummy: c_int, ...) callconv(.C) c_int {
fn thirdArg(dummy: c_int, ...) callconv(.c) c_int {
_ = dummy;
var ap = @cVaStart();

View file

@ -21,7 +21,7 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {
pub fn isSingleItemPtr(comptime T: type) bool {
if (comptime is(.pointer)(T)) {
return @typeInfo(T).pointer.size == .One;
return @typeInfo(T).pointer.size == .one;
}
return false;
}

View file

@ -1,6 +1,6 @@
export fn entry() void {
_ = @Type(.{ .pointer = .{
.size = .One,
.size = .one,
.is_const = false,
.is_volatile = false,
.alignment = 1,
@ -12,7 +12,5 @@ export fn entry() void {
}
// error
// backend=stage2
// target=native
//
// :2:9: error: sentinels are only allowed on slices and unknown-length pointers

View file

@ -16,7 +16,7 @@ comptime {
}
comptime {
_ = @Type(.{ .pointer = .{
.size = .Many,
.size = .slice,
.is_const = false,
.is_volatile = false,
.alignment = @alignOf(S),
@ -28,7 +28,7 @@ comptime {
}
comptime {
_ = @Type(.{ .pointer = .{
.size = .Many,
.size = .many,
.is_const = false,
.is_volatile = false,
.alignment = @alignOf(S),

View file

@ -29,7 +29,7 @@ comptime {
comptime {
_ = @Type(.{
.pointer = .{
.size = .Many,
.size = .many,
.is_const = true,
.is_volatile = false,
.alignment = 7,
@ -42,8 +42,6 @@ comptime {
}
// error
// backend=stage2
// target=native
//
// :2:9: error: alignment value '3' is not a power of two or zero
// :14:9: error: alignment value '5' is not a power of two or zero