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| { .pointer => |ptr| {
switch (@typeInfo(ptr.child)) { switch (@typeInfo(ptr.child)) {
.array => |array| { .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 }); try config_header.values.put(field_name, .{ .string = v });
return; return;
} }
}, },
.int => { .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 }); try config_header.values.put(field_name, .{ .string = v });
return; return;
} }

View File

@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
return; return;
}, },
.pointer => |p| { .pointer => |p| {
if (p.size != .Slice) { if (p.size != .slice) {
@compileError("Non-slice pointers are not yet supported in build options"); @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; _ = info;
_ = ctx_ptr; _ = ctx_ptr;
assert(sig == posix.SIG.WINCH); 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 { pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
const Ptr = @TypeOf(pointer); const Ptr = @TypeOf(pointer);
assert(@typeInfo(Ptr) == .pointer); // Must be a 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 assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
const gen = struct { const gen = struct {
fn fill(ptr: *anyopaque, buf: []u8) void { fn fill(ptr: *anyopaque, buf: []u8) void {

View File

@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) {
=> if (builtin.target.isMusl()) => if (builtin.target.isMusl())
linux.Sigaction linux.Sigaction
else if (builtin.target.ptrBitWidth() == 64) extern struct { else if (builtin.target.ptrBitWidth() == 64) extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
flags: c_uint, flags: c_uint,
handler: extern union { handler: extern union {
@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) {
sigaction: ?sigaction_fn, sigaction: ?sigaction_fn,
}, },
mask: sigset_t, mask: sigset_t,
restorer: ?*const fn () callconv(.C) void = null, restorer: ?*const fn () callconv(.c) void = null,
} else extern struct { } else extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
flags: c_uint, flags: c_uint,
handler: extern union { handler: extern union {
@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) {
sigaction: ?sigaction_fn, sigaction: ?sigaction_fn,
}, },
mask: sigset_t, mask: sigset_t,
restorer: ?*const fn () callconv(.C) void = null, restorer: ?*const fn () callconv(.c) void = null,
__resv: [1]c_int = .{0}, __resv: [1]c_int = .{0},
}, },
.s390x => if (builtin.abi == .gnu) extern struct { .s390x => if (builtin.abi == .gnu) extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union { handler: extern union {
handler: ?handler_fn, handler: ?handler_fn,
@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) {
}, },
__glibc_reserved0: c_int = 0, __glibc_reserved0: c_int = 0,
flags: c_uint, flags: c_uint,
restorer: ?*const fn () callconv(.C) void = null, restorer: ?*const fn () callconv(.c) void = null,
mask: sigset_t, mask: sigset_t,
} else linux.Sigaction, } else linux.Sigaction,
else => linux.Sigaction, else => linux.Sigaction,
}, },
.emscripten => emscripten.Sigaction, .emscripten => emscripten.Sigaction,
.netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union { handler: extern union {
handler: ?handler_fn, handler: ?handler_fn,
@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {
flags: c_uint, flags: c_uint,
}, },
.dragonfly, .freebsd => extern struct { .dragonfly, .freebsd => extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler /// signal handler
handler: extern union { handler: extern union {
@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {
mask: sigset_t, mask: sigset_t,
}, },
.solaris, .illumos => extern struct { .solaris, .illumos => extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal options /// signal options
flags: c_uint, flags: c_uint,
@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {
mask: sigset_t, mask: sigset_t,
}, },
.haiku => extern struct { .haiku => extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler /// signal handler
handler: extern union { handler: extern union {
@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {
userdata: *allowzero anyopaque = undefined, userdata: *allowzero anyopaque = undefined,
}, },
.openbsd => extern struct { .openbsd => extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler /// signal handler
handler: extern union { handler: extern union {
@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {
else => void, 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) { pub const Stat = switch (native_os) {
.linux => switch (native_arch) { .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( pub extern "c" fn pthread_create(
noalias newthread: *pthread_t, noalias newthread: *pthread_t,
noalias attr: ?*const pthread_attr_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, noalias arg: ?*anyopaque,
) E; ) E;
pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) 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_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
pub extern "c" fn pthread_detach(thread: pthread_t) E; pub extern "c" fn pthread_detach(thread: pthread_t) E;
pub extern "c" fn pthread_atfork( pub extern "c" fn pthread_atfork(
prepare: ?*const fn () callconv(.C) void, prepare: ?*const fn () callconv(.c) void,
parent: ?*const fn () callconv(.C) void, parent: ?*const fn () callconv(.c) void,
child: ?*const fn () callconv(.C) void, child: ?*const fn () callconv(.c) void,
) c_int; ) c_int;
pub extern "c" fn pthread_key_create( pub extern "c" fn pthread_key_create(
key: *pthread_key_t, key: *pthread_key_t,
destructor: ?*const fn (value: *anyopaque) callconv(.C) void, destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
) E; ) E;
pub extern "c" fn pthread_key_delete(key: pthread_key_t) E; pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque; 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_broadcast(cond: *pthread_cond_t) E;
pub extern "c" fn pthread_cond_destroy(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_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_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_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_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_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_unlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub const pthread_t = *opaque {}; pub const pthread_t = *opaque {};
pub const FILE = 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; 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_; 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; pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;
const dispatch_once_t = usize; 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( pub extern fn dispatch_once_f(
predicate: *dispatch_once_t, predicate: *dispatch_once_t,
context: ?*anyopaque, context: ?*anyopaque,

View File

@ -156,7 +156,7 @@ pub const E = enum(u16) {
pub const BADSIG = SIG.ERR; 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 { pub const cmsghdr = extern struct {
len: socklen_t, len: socklen_t,

View File

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

View File

@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void {
updateSegfaultHandler(&act); 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 // 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 // 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. // 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)) { switch (@typeInfo(T)) {
.pointer => |info| { .pointer => |info| {
try writer.writeAll(@typeName(info.child) ++ "@"); try writer.writeAll(@typeName(info.child) ++ "@");
if (info.size == .Slice) if (info.size == .slice)
try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer) try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
else else
try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {
switch (@typeInfo(T)) { switch (@typeInfo(T)) {
.array, .vector => return ANY, .array, .vector => return ANY,
.pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .one => switch (@typeInfo(ptr_info.child)) {
.array => return ANY, .array => return ANY,
else => {}, else => {},
}, },
.Many, .C => return "*", .many, .c => return "*",
.Slice => return ANY, .slice => return ANY,
}, },
.optional => |info| return "?" ++ defaultSpec(info.child), .optional => |info| return "?" ++ defaultSpec(info.child),
.error_union => |info| return "!" ++ defaultSpec(info.payload), .error_union => |info| return "!" ++ defaultSpec(info.payload),
@ -624,13 +624,13 @@ pub fn formatType(
try writer.writeAll(" }"); try writer.writeAll(" }");
}, },
.pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .one => switch (@typeInfo(ptr_info.child)) {
.array, .@"enum", .@"union", .@"struct" => { .array, .@"enum", .@"union", .@"struct" => {
return formatType(value.*, actual_fmt, options, writer, max_depth); return formatType(value.*, actual_fmt, options, writer, max_depth);
}, },
else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }), else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
}, },
.Many, .C => { .many, .c => {
if (actual_fmt.len == 0) if (actual_fmt.len == 0)
@compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
if (ptr_info.sentinel) |_| { if (ptr_info.sentinel) |_| {
@ -641,7 +641,7 @@ pub fn formatType(
} }
invalidFmtError(fmt, value); invalidFmtError(fmt, value);
}, },
.Slice => { .slice => {
if (actual_fmt.len == 0) if (actual_fmt.len == 0)
@compileError("cannot format slice without a specifier (i.e. {s} or {any})"); @compileError("cannot format slice without a specifier (i.e. {s} or {any})");
if (max_depth == 0) { 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)); const info = @typeInfo(@TypeOf(key));
switch (info.pointer.size) { switch (info.pointer.size) {
.One => switch (strat) { .one => switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow), .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
.Deep => hash(hasher, key.*, .Shallow), .Deep => hash(hasher, key.*, .Shallow),
.DeepRecursive => hash(hasher, key.*, .DeepRecursive), .DeepRecursive => hash(hasher, key.*, .DeepRecursive),
}, },
.Slice => { .slice => {
switch (strat) { switch (strat) {
.Shallow => { .Shallow => {
hashPointer(hasher, key.ptr, .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); hash(hasher, key.len, .Shallow);
}, },
.Many, .many,
.C, .c,
=> switch (strat) { => switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow), .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
else => @compileError( else => @compileError(
@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
inline fn typeContainsSlice(comptime K: type) bool { inline fn typeContainsSlice(comptime K: type) bool {
return switch (@typeInfo(K)) { return switch (@typeInfo(K)) {
.pointer => |info| info.size == .Slice, .pointer => |info| info.size == .slice,
inline .@"struct", .@"union" => |info| { inline .@"struct", .@"union" => |info| {
inline for (info.fields) |field| { inline for (info.fields) |field| {

View File

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

View File

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

View File

@ -631,7 +631,7 @@ pub fn WriteStream(
}, },
.error_set => return self.stringValue(@errorName(value)), .error_set => return self.stringValue(@errorName(value)),
.pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .one => switch (@typeInfo(ptr_info.child)) {
.array => { .array => {
// Coerce `*[N]T` to `[]const T`. // Coerce `*[N]T` to `[]const T`.
const Slice = []const std.meta.Elem(ptr_info.child); const Slice = []const std.meta.Elem(ptr_info.child);
@ -641,10 +641,10 @@ pub fn WriteStream(
return self.write(value.*); return self.write(value.*);
}, },
}, },
.Many, .Slice => { .many, .slice => {
if (ptr_info.size == .Many and ptr_info.sentinel == null) if (ptr_info.size == .many and ptr_info.sentinel == null)
@compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel"); @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) { if (ptr_info.child == u8) {
// This is a []const u8, or some similar Zig string. // 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| { .pointer => |ptr_info| {
switch (ptr_info.size) { switch (ptr_info.size) {
.Slice => { .slice => {
if (ptr_info.sentinel) |sentinel| { if (ptr_info.sentinel) |sentinel| {
if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) { 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. 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{}; return &[_]ptr_info.child{};
} }
}, },
.C => { .c => {
return null; return null;
}, },
.One, .Many => { .one, .many => {
if (ptr_info.is_allowzero) return @ptrFromInt(0); if (ptr_info.is_allowzero) return @ptrFromInt(0);
@compileError("Only nullable and allowzero pointers can be set to zero."); @compileError("Only nullable and allowzero pointers can be set to zero.");
}, },
@ -781,14 +781,14 @@ fn Span(comptime T: type) type {
.pointer => |ptr_info| { .pointer => |ptr_info| {
var new_ptr_info = ptr_info; var new_ptr_info = ptr_info;
switch (ptr_info.size) { switch (ptr_info.size) {
.C => { .c => {
new_ptr_info.sentinel = &@as(ptr_info.child, 0); new_ptr_info.sentinel = &@as(ptr_info.child, 0);
new_ptr_info.is_allowzero = false; new_ptr_info.is_allowzero = false;
}, },
.Many => if (ptr_info.sentinel == null) @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)), .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 }); return @Type(.{ .pointer = new_ptr_info });
}, },
else => {}, else => {},
@ -845,9 +845,9 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
}, },
.pointer => |ptr_info| { .pointer => |ptr_info| {
var new_ptr_info = ptr_info; var new_ptr_info = ptr_info;
new_ptr_info.size = .Slice; new_ptr_info.size = .slice;
switch (ptr_info.size) { switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| { .array => |array_info| {
new_ptr_info.child = array_info.child; new_ptr_info.child = array_info.child;
// The return type must only be sentinel terminated if we are guaranteed // 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 => {}, else => {},
}, },
.Many, .Slice => { .many, .slice => {
// The return type must only be sentinel terminated if we are guaranteed // 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 // to find the value searched for, which is only the case if it matches
// the sentinel of the type passed. // 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; new_ptr_info.sentinel = &end;
// C pointers are always allowzero, but we don't want the return type to be. // C pointers are always allowzero, but we don't want the return type to be.
assert(new_ptr_info.is_allowzero); assert(new_ptr_info.is_allowzero);
@ -957,7 +957,7 @@ test sliceTo {
fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
switch (@typeInfo(@TypeOf(ptr))) { switch (@typeInfo(@TypeOf(ptr))) {
.pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| { .array => |array_info| {
if (array_info.sentinel) |sentinel_ptr| { if (array_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const array_info.child, @ptrCast(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 => {}, 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)).*; const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) { if (sentinel == end) {
return indexOfSentinel(ptr_info.child, end, ptr); 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; while (ptr[i] != end and ptr[i] != sentinel) i += 1;
return i; return i;
}, },
.C => { .c => {
assert(ptr != null); assert(ptr != null);
return indexOfSentinel(ptr_info.child, end, ptr); return indexOfSentinel(ptr_info.child, end, ptr);
}, },
.Slice => { .slice => {
if (ptr_info.sentinel) |sentinel_ptr| { if (ptr_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) { if (sentinel == end) {
@ -1039,13 +1039,13 @@ test lenSliceTo {
pub fn len(value: anytype) usize { pub fn len(value: anytype) usize {
switch (@typeInfo(@TypeOf(value))) { switch (@typeInfo(@TypeOf(value))) {
.pointer => |info| switch (info.size) { .pointer => |info| switch (info.size) {
.Many => { .many => {
const sentinel_ptr = info.sentinel orelse const sentinel_ptr = info.sentinel orelse
@compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))); @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
return indexOfSentinel(info.child, sentinel, value); return indexOfSentinel(info.child, sentinel, value);
}, },
.C => { .c => {
assert(value != null); assert(value != null);
return indexOfSentinel(info.child, 0, value); return indexOfSentinel(info.child, 0, value);
}, },
@ -3582,19 +3582,19 @@ fn ReverseIterator(comptime T: type) type {
const Pointer = blk: { const Pointer = blk: {
switch (@typeInfo(T)) { switch (@typeInfo(T)) {
.pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) { .one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| { .array => |array_info| {
var new_ptr_info = ptr_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.child = array_info.child;
new_ptr_info.sentinel = array_info.sentinel; new_ptr_info.sentinel = array_info.sentinel;
break :blk @Type(.{ .pointer = new_ptr_info }); break :blk @Type(.{ .pointer = new_ptr_info });
}, },
else => {}, else => {},
}, },
.Slice => { .slice => {
var new_ptr_info = ptr_info; var new_ptr_info = ptr_info;
new_ptr_info.size = .Many; new_ptr_info.size = .many;
break :blk @Type(.{ .pointer = new_ptr_info }); break :blk @Type(.{ .pointer = new_ptr_info });
}, },
else => {}, else => {},
@ -3606,7 +3606,7 @@ fn ReverseIterator(comptime T: type) type {
const Element = std.meta.Elem(Pointer); const Element = std.meta.Elem(Pointer);
const ElementPointer = @Type(.{ .pointer = ptr: { const ElementPointer = @Type(.{ .pointer = ptr: {
var ptr = @typeInfo(Pointer).pointer; var ptr = @typeInfo(Pointer).pointer;
ptr.size = .One; ptr.size = .one;
ptr.child = Element; ptr.child = Element;
ptr.sentinel = null; ptr.sentinel = null;
break :ptr ptr; break :ptr ptr;
@ -3912,7 +3912,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
const T = @TypeOf(ptr); const T = @TypeOf(ptr);
const info = @typeInfo(T); 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)); @compileError("expected many item pointer, got " ++ @typeName(T));
// Do nothing if the pointer is already well-aligned. // Do nothing if the pointer is already well-aligned.
@ -3986,9 +3986,9 @@ fn CopyPtrAttrs(
fn AsBytesReturnType(comptime P: type) type { fn AsBytesReturnType(comptime P: type) type {
const pointer = @typeInfo(P).pointer; const pointer = @typeInfo(P).pointer;
assert(pointer.size == .One); assert(pointer.size == .one);
const size = @sizeOf(pointer.child); 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. /// 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 { 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 /// 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 { 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 /// 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{}; 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))]; 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 { 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. /// 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 // it may be equal to zero and fail a null check
if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{}; 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))]; 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; const info = @typeInfo(AttributeSource).pointer;
return @Type(.{ return @Type(.{
.pointer = .{ .pointer = .{
.size = .Slice, .size = .slice,
.is_const = info.is_const, .is_const = info.is_const,
.is_volatile = info.is_volatile, .is_volatile = info.is_volatile,
.is_allowzero = info.is_allowzero, .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. /// have the same address and alignment property.
pub fn destroy(self: Allocator, ptr: anytype) void { pub fn destroy(self: Allocator, ptr: anytype) void {
const info = @typeInfo(@TypeOf(ptr)).pointer; 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; const T = info.child;
if (@sizeOf(T) == 0) return; if (@sizeOf(T) == 0) return;
const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr))); 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, .array => |info| return info.child,
.vector => |info| return info.child, .vector => |info| return info.child,
.pointer => |info| switch (info.size) { .pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) { .one => switch (@typeInfo(info.child)) {
.array => |array_info| return array_info.child, .array => |array_info| return array_info.child,
.vector => |vector_info| return vector_info.child, .vector => |vector_info| return vector_info.child,
else => {}, else => {},
}, },
.Many, .C, .Slice => return info.child, .many, .c, .slice => return info.child,
}, },
.optional => |info| return Elem(info.child), .optional => |info| return Elem(info.child),
else => {}, else => {},
@ -138,11 +138,11 @@ pub inline fn sentinel(comptime T: type) ?Elem(T) {
}, },
.pointer => |info| { .pointer => |info| {
switch (info.size) { switch (info.size) {
.Many, .Slice => { .many, .slice => {
const sentinel_ptr = info.sentinel orelse return null; const sentinel_ptr = info.sentinel orelse return null;
return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
}, },
.One => switch (@typeInfo(info.child)) { .one => switch (@typeInfo(info.child)) {
.array => |array_info| { .array => |array_info| {
const sentinel_ptr = array_info.sentinel orelse return null; const sentinel_ptr = array_info.sentinel orelse return null;
return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; 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 { pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
switch (@typeInfo(T)) { switch (@typeInfo(T)) {
.pointer => |info| switch (info.size) { .pointer => |info| switch (info.size) {
.One => switch (@typeInfo(info.child)) { .one => switch (@typeInfo(info.child)) {
.array => |array_info| return @Type(.{ .array => |array_info| return @Type(.{
.pointer = .{ .pointer = .{
.size = info.size, .size = info.size,
@ -199,7 +199,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
}), }),
else => {}, else => {},
}, },
.Many, .Slice => return @Type(.{ .many, .slice => return @Type(.{
.pointer = .{ .pointer = .{
.size = info.size, .size = info.size,
.is_const = info.is_const, .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)) { .optional => |info| switch (@typeInfo(info.child)) {
.pointer => |ptr_info| switch (ptr_info.size) { .pointer => |ptr_info| switch (ptr_info.size) {
.Many => return @Type(.{ .many => return @Type(.{
.optional = .{ .optional = .{
.child = @Type(.{ .child = @Type(.{
.pointer = .{ .pointer = .{
@ -786,8 +786,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
}, },
.pointer => |info| { .pointer => |info| {
return switch (info.size) { return switch (info.size) {
.One, .Many, .C => a == b, .one, .many, .c => a == b,
.Slice => a.ptr == b.ptr and a.len == b.len, .slice => a.ptr == b.ptr and a.len == b.len,
}; };
}, },
.optional => { .optional => {
@ -1090,7 +1090,7 @@ test "Tuple deduplication" {
test "ArgsTuple forwarding" { test "ArgsTuple forwarding" {
const T1 = std.meta.Tuple(&.{ u32, f32, i8 }); const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void); 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) { if (T1 != T2) {
@compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple"); @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 { pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
return switch (@typeInfo(T)) { return switch (@typeInfo(T)) {
.pointer => |P| switch (P.size) { .pointer => |P| switch (P.size) {
.One => hasFn(P.child, name), .one => hasFn(P.child, name),
.Many, .Slice, .C => false, .many, .slice, .c => false,
}, },
else => hasFn(T, name), else => hasFn(T, name),
}; };
@ -1200,12 +1200,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
.int => |info| @sizeOf(T) * 8 == info.bits, .int => |info| @sizeOf(T) * 8 == info.bits,
.pointer => |info| info.size != .Slice, .pointer => |info| info.size != .slice,
.optional => |info| switch (@typeInfo(info.child)) { .optional => |info| switch (@typeInfo(info.child)) {
.pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
.Slice, .C => false, .slice, .c => false,
.One, .Many => true, .one, .many => true,
}, },
else => false, else => false,
}, },

View File

@ -12,7 +12,7 @@ const c = std.c;
pub const FILE = c.FILE; pub const FILE = c.FILE;
var __stack_chk_guard: usize = 0; 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", .{}); std.debug.print("stack smashing detected: terminated\n", .{});
emscripten_force_exit(127); emscripten_force_exit(127);
} }
@ -547,8 +547,8 @@ pub const SIG = struct {
}; };
pub const Sigaction = extern struct { pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union { handler: extern union {
handler: ?handler_fn, handler: ?handler_fn,
@ -556,7 +556,7 @@ pub const Sigaction = extern struct {
}, },
mask: sigset_t, mask: sigset_t,
flags: c_uint, flags: c_uint,
restorer: ?*const fn () callconv(.C) void = null, restorer: ?*const fn () callconv(.c) void = null,
}; };
pub const sigset_t = [1024 / 32]u32; pub const sigset_t = [1024 / 32]u32;
@ -909,23 +909,23 @@ pub const LOG = struct {
pub const INFO = 512; pub const INFO = 512;
}; };
pub const em_callback_func = ?*const fn () 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_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_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 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 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_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_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 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_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_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_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_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; 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_resume_main_loop() void;
pub extern "c" fn emscripten_cancel_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_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_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_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; 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_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_get_now() f64;
pub extern "c" fn emscripten_random() f32; 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_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_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 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_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_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; 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_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_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 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_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 extern "c" fn emscripten_lazy_load_code() void;
pub const worker_handle = c_int; pub const worker_handle = c_int;
pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle; 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 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_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(data: [*]u8, size: c_int) void;
pub extern "c" fn emscripten_worker_respond_provisionally(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_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_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 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_registers(func: em_scan_func) void;
pub extern "c" fn emscripten_scan_stack(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(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_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t;
pub extern "c" fn emscripten_throw_number(number: f64) void; 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 em_promise_t = ?*struct__em_promise;
pub const enum_em_promise_result_t = c_uint; pub const enum_em_promise_result_t = c_uint;
pub const em_promise_result_t = enum_em_promise_result_t; 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_create() em_promise_t;
pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void; 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 const syscall_fork = syscall_bits.syscall_fork;
pub fn clone( pub fn clone(
func: *const fn (arg: usize) callconv(.C) u8, func: *const fn (arg: usize) callconv(.c) u8,
stack: usize, stack: usize,
flags: u32, flags: u32,
arg: usize, arg: usize,
@ -77,14 +77,14 @@ pub fn clone(
) usize { ) usize {
// Can't directly call a naked function; cast to C calling convention first. // Can't directly call a naked function; cast to C calling convention first.
return @as(*const fn ( return @as(*const fn (
*const fn (arg: usize) callconv(.C) u8, *const fn (arg: usize) callconv(.c) u8,
usize, usize,
u32, u32,
usize, usize,
?*i32, ?*i32,
usize, usize,
?*i32, ?*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; pub const ARCH = arch_bits.ARCH;
@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct {
extern fn getauxval(index: usize) usize; extern fn getauxval(index: usize) usize;
}.getauxval else getauxvalImpl; }.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; const auxv = elf_aux_maybe orelse return 0;
var i: usize = 0; var i: usize = 0;
while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { 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 // 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; var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { 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)); 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)); 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 // 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 // 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; pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
const k_sigaction_funcs = struct { const k_sigaction_funcs = struct {
const handler = ?*align(1) const fn (i32) callconv(.C) void; const handler = ?*align(1) const fn (i32) callconv(.c) void;
const restorer = *const fn () callconv(.C) void; const restorer = *const fn () callconv(.c) void;
}; };
pub const k_sigaction = switch (native_arch) { 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. /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
pub const Sigaction = extern struct { pub const Sigaction = extern struct {
pub const handler_fn = *align(1) const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union { handler: extern union {
handler: ?handler_fn, handler: ?handler_fn,
@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct {
}, },
mask: sigset_t, mask: sigset_t,
flags: c_uint, 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; 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 // Need to use C ABI here instead of naked
// to prevent an infinite loop when calling rt_sigreturn. // 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" return asm volatile ("t 0x6d"
: :
: [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)), : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),

View File

@ -186,8 +186,8 @@ pub const empty_sigset = 0;
pub const siginfo_t = c_long; 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. // 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 Sigaction = extern struct {
pub const handler_fn = *const fn (i32) 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; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union { handler: extern union {
handler: ?handler_fn, 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 /// Installs one or more protocol interfaces into the boot services environment
// TODO: use callconv(cc) instead once that works // 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 /// Removes one or more protocol interfaces into the boot services environment
// TODO: use callconv(cc) instead once that works // 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. /// Computes and returns a 32-bit CRC for a data buffer.
calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status, 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) { if (builtin.link_libc) {
switch (system.dl_iterate_phdr(struct { 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)); const context_ptr: *const Context = @ptrCast(@alignCast(data));
callback(info, size, context_ptr.*) catch |err| return @intFromError(err); callback(info, size, context_ptr.*) catch |err| return @intFromError(err);
return 0; return 0;

View File

@ -849,7 +849,7 @@ test "sigaction" {
const S = struct { const S = struct {
var handler_called_count: u32 = 0; 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; _ = ctx_ptr;
// Check that we received the correct signal. // Check that we received the correct signal.
switch (native_os) { switch (native_os) {

View File

@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
.pointer => |pointer| { .pointer => |pointer| {
switch (pointer.size) { switch (pointer.size) {
.One, .Many, .C => { .one, .many, .c => {
if (actual != expected) { if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual }); print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual; return error.TestExpectedEqual;
} }
}, },
.Slice => { .slice => {
if (actual.ptr != expected.ptr) { if (actual.ptr != expected.ptr) {
print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr }); print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr });
return error.TestExpectedEqual; return error.TestExpectedEqual;
@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
.pointer => |pointer| { .pointer => |pointer| {
switch (pointer.size) { switch (pointer.size) {
// We have no idea what is behind those pointers, so the best we can do is `==` check. // We have no idea what is behind those pointers, so the best we can do is `==` check.
.C, .Many => { .c, .many => {
if (actual != expected) { if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual }); print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual; return error.TestExpectedEqual;
} }
}, },
.One => { .one => {
// Length of those pointers are runtime value, so the best we can do is `==` check. // Length of those pointers are runtime value, so the best we can do is `==` check.
switch (@typeInfo(pointer.child)) { switch (@typeInfo(pointer.child)) {
.@"fn", .@"opaque" => { .@"fn", .@"opaque" => {
@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
else => try expectEqualDeep(expected.*, actual.*), else => try expectEqualDeep(expected.*, actual.*),
} }
}, },
.Slice => { .slice => {
if (expected.len != actual.len) { if (expected.len != actual.len) {
print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len }); print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
return error.TestExpectedEqual; 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 { fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
const token_tags = tree.tokens.items(.tag); const token_tags = tree.tokens.items(.tag);
const Size = std.builtin.Type.Pointer.Size; const size: std.builtin.Type.Pointer.Size = switch (token_tags[info.main_token]) {
const size: Size = switch (token_tags[info.main_token]) {
.asterisk, .asterisk,
.asterisk_asterisk, .asterisk_asterisk,
=> .One, => .one,
.l_bracket => switch (token_tags[info.main_token + 1]) { .l_bracket => switch (token_tags[info.main_token + 1]) {
.asterisk => if (token_tags[info.main_token + 2] == .identifier) Size.C else Size.Many, .asterisk => if (token_tags[info.main_token + 2] == .identifier) .c else .many,
else => Size.Slice, else => .slice,
}, },
else => unreachable, 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 // positives. Therefore, start after a sentinel if there is one and
// skip over any align node and bit range nodes. // skip over any align node and bit range nodes.
var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) { 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, else => info.main_token,
}; };
const end = tree.firstToken(info.child_type); const end = tree.firstToken(info.child_type);

View File

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

View File

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

View File

@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" {
\\pub fn f( \\pub fn f(
\\ a: i32, \\ a: i32,
\\ b: i32, \\ b: i32,
\\) callconv(.C) i32 {} \\) callconv(.c) i32 {}
\\pub fn f( \\pub fn f(
\\ a: i32, \\ a: i32,
\\ b: i32, \\ b: i32,
@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" {
\\pub fn f( \\pub fn f(
\\ a: i32, \\ a: i32,
\\ b: i32, \\ b: i32,
\\) align(8) callconv(.C) i32 {} \\) align(8) callconv(.c) i32 {}
\\pub fn f( \\pub fn f(
\\ a: i32, \\ a: i32,
\\ b: i32, \\ b: i32,
\\) align(8) linksection(".text") callconv(.C) i32 {} \\) align(8) linksection(".text") callconv(.c) i32 {}
\\pub fn f( \\pub fn f(
\\ a: i32, \\ a: i32,
\\ b: 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 { fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void {
const tree = r.tree; const tree = r.tree;
switch (ptr_type.size) { switch (ptr_type.size) {
.One => { .one => {
// Since ** tokens exist and the same token is shared by two // Since ** tokens exist and the same token is shared by two
// nested pointer types, we check to see if we are the parent // nested pointer types, we check to see if we are the parent
// in such a relationship. If so, skip rendering anything for // 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 try renderToken(r, ptr_type.ast.main_token, .none); // asterisk
}, },
.Many => { .many => {
if (ptr_type.ast.sentinel == 0) { if (ptr_type.ast.sentinel == 0) {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket 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 + 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 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, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk 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 + 2, .none); // c
try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket
}, },
.Slice => { .slice => {
if (ptr_type.ast.sentinel == 0) { if (ptr_type.ast.sentinel == 0) {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket 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 /// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly. /// 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 { fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
// valid for both x86 and x86_64 // 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 /// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly. /// 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. // Read control register 0 (XCR0). Used to detect features such as AVX.
fn getXCR0() u32 { 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); try mutable.ensureUnusedCapacity(1);
return mutable.addOneAssumeCapacity(); return mutable.addOneAssumeCapacity();
} }
pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .One }) { pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .one }) {
const index = mutable.mutate.len; const index = mutable.mutate.len;
assert(index < mutable.list.header().capacity); assert(index < mutable.list.header().capacity);
mutable.mutate.len = index + 1; mutable.mutate.len = index + 1;
const mutable_view = mutable.view().slice(); const mutable_view = mutable.view().slice();
var ptr: PtrElem(.{ .size = .One }) = undefined; var ptr: PtrElem(.{ .size = .one }) = undefined;
inline for (fields) |field| { inline for (fields) |field| {
@field(ptr, @tagName(field)) = &mutable_view.items(field)[index]; @field(ptr, @tagName(field)) = &mutable_view.items(field)[index];
} }
@ -1206,7 +1206,7 @@ const Local = struct {
pub fn appendSliceAssumeCapacity( pub fn appendSliceAssumeCapacity(
mutable: Mutable, mutable: Mutable,
slice: PtrElem(.{ .size = .Slice, .is_const = true }), slice: PtrElem(.{ .size = .slice, .is_const = true }),
) void { ) void {
if (fields.len == 0) return; if (fields.len == 0) return;
const start = mutable.mutate.len; const start = mutable.mutate.len;
@ -1253,17 +1253,17 @@ const Local = struct {
return ptr_array; 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); try mutable.ensureUnusedCapacity(len);
return mutable.addManyAsSliceAssumeCapacity(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; const start = mutable.mutate.len;
assert(len <= mutable.list.header().capacity - start); assert(len <= mutable.list.header().capacity - start);
mutable.mutate.len = @intCast(start + len); mutable.mutate.len = @intCast(start + len);
const mutable_view = mutable.view().slice(); const mutable_view = mutable.view().slice();
var slice: PtrElem(.{ .size = .Slice }) = undefined; var slice: PtrElem(.{ .size = .slice }) = undefined;
inline for (fields) |field| { inline for (fields) |field| {
@field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len]; @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) { pub const Flags = packed struct(u32) {
size: Size = .One, size: Size = .one,
/// `none` indicates the ABI alignment of the pointee_type. In this /// `none` indicates the ABI alignment of the pointee_type. In this
/// case, this field *must* be set to `none`, otherwise the /// case, this field *must* be set to `none`, otherwise the
/// `InternPool` equality and hashing functions will return incorrect /// `InternPool` equality and hashing functions will return incorrect
@ -4891,7 +4891,7 @@ pub const Index = enum(u32) {
checkField(name ++ ".?", info.child); checkField(name ++ ".?", info.child);
}, },
.pointer => |info| { .pointer => |info| {
assert(info.size == .Slice); assert(info.size == .slice);
checkConfig(name ++ ".len"); checkConfig(name ++ ".len");
checkField(name ++ "[0]", info.child); checkField(name ++ "[0]", info.child);
}, },
@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{ .{ .ptr_type = .{
.child = .u8_type, .child = .u8_type,
.flags = .{ .flags = .{
.size = .Many, .size = .many,
}, },
} }, } },
@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{ .{ .ptr_type = .{
.child = .u8_type, .child = .u8_type,
.flags = .{ .flags = .{
.size = .Many, .size = .many,
.is_const = true, .is_const = true,
}, },
} }, } },
@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{
.child = .u8_type, .child = .u8_type,
.sentinel = .zero_u8, .sentinel = .zero_u8,
.flags = .{ .flags = .{
.size = .Many, .size = .many,
.is_const = true, .is_const = true,
}, },
} }, } },
@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{ .{ .ptr_type = .{
.child = .comptime_int_type, .child = .comptime_int_type,
.flags = .{ .flags = .{
.size = .One, .size = .one,
.is_const = true, .is_const = true,
}, },
} }, } },
@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{ .{ .ptr_type = .{
.child = .u8_type, .child = .u8_type,
.flags = .{ .flags = .{
.size = .Slice, .size = .slice,
.is_const = true, .is_const = true,
}, },
} }, } },
@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{
.child = .u8_type, .child = .u8_type,
.sentinel = .zero_u8, .sentinel = .zero_u8,
.flags = .{ .flags = .{
.size = .Slice, .size = .slice,
.is_const = true, .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); const many_ptr_item = many_ptr_unwrapped.getItem(ip);
assert(many_ptr_item.tag == .type_pointer); assert(many_ptr_item.tag == .type_pointer);
var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data); 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 }; 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.child != .none);
assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child); 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(); gop.cancel();
var new_key = key; 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); const ptr_type_index = try ip.get(gpa, tid, new_key);
gop = try ip.getOrPutKey(gpa, tid, 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; 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(.{ items.appendAssumeCapacity(.{
.tag = .type_pointer, .tag = .type_pointer,
@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
}, },
.slice => |slice| { .slice => |slice| {
assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .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(ip.typeOf(slice.ptr)).ptr_type.flags.size == .many);
items.appendAssumeCapacity(.{ items.appendAssumeCapacity(.{
.tag = .ptr_slice, .tag = .ptr_slice,
.data = try addExtra(extra, PtrSlice{ .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| { .ptr => |ptr| {
const ptr_type = ip.indexToKey(ptr.ty).ptr_type; 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) { items.appendAssumeCapacity(switch (ptr.base_addr) {
.nav => |nav| .{ .nav => |nav| .{
.tag = .ptr_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| { .arr_elem, .field => |base_index| {
const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type; const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type;
switch (ptr.base_addr) { switch (ptr.base_addr) {
.arr_elem => assert(base_ptr_type.flags.size == .Many), .arr_elem => assert(base_ptr_type.flags.size == .many),
.field => { .field => {
assert(base_ptr_type.flags.size == .One); assert(base_ptr_type.flags.size == .one);
switch (ip.indexToKey(base_ptr_type.child)) { switch (ip.indexToKey(base_ptr_type.child)) {
.tuple_type => |tuple_type| { .tuple_type => |tuple_type| {
assert(ptr.base_addr == .field); 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| { .ptr_type => |slice_type| {
assert(ptr.base_addr == .field); assert(ptr.base_addr == .field);
assert(slice_type.flags.size == .Slice); assert(slice_type.flags.size == .slice);
assert(base_index.index < 2); assert(base_index.index < 2);
}, },
else => unreachable, else => unreachable,
@ -10314,12 +10314,12 @@ pub fn getCoerced(
} }); } });
if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) { 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, .ty = new_ty,
.base_addr = .int, .base_addr = .int,
.byte_offset = 0, .byte_offset = 0,
} }), } }),
.Slice => return ip.get(gpa, tid, .{ .slice = .{ .slice => return ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty, .ty = new_ty,
.ptr = try ip.get(gpa, tid, .{ .ptr = .{ .ptr = try ip.get(gpa, tid, .{ .ptr = .{
.ty = ip.slicePtrType(new_ty), .ty = ip.slicePtrType(new_ty),
@ -10408,7 +10408,7 @@ pub fn getCoerced(
}, },
else => {}, 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 = .{ return ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty, .ty = new_ty,
.ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(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)) else if (ip.isIntegerType(new_ty))
return ip.getCoerced(gpa, tid, slice.ptr, 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 = .{ return ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty, .ty = new_ty,
.base_addr = ptr.base_addr, .base_addr = ptr.base_addr,
@ -10433,12 +10433,12 @@ pub fn getCoerced(
.opt => |opt| switch (ip.indexToKey(new_ty)) { .opt => |opt| switch (ip.indexToKey(new_ty)) {
.ptr_type => |ptr_type| return switch (opt.val) { .ptr_type => |ptr_type| return switch (opt.val) {
.none => switch (ptr_type.flags.size) { .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, .ty = new_ty,
.base_addr = .int, .base_addr = .int,
.byte_offset = 0, .byte_offset = 0,
} }), } }),
.Slice => try ip.get(gpa, tid, .{ .slice = .{ .slice => try ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty, .ty = new_ty,
.ptr = try ip.get(gpa, tid, .{ .ptr = .{ .ptr = try ip.get(gpa, tid, .{ .ptr = .{
.ty = ip.slicePtrType(new_ty), .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); const info = ty.ptrInfo(zcu);
if (info.sentinel != .none) switch (info.flags.size) { if (info.sentinel != .none) switch (info.flags.size) {
.One, .C => unreachable, .one, .c => unreachable,
.Many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), .many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
.Slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), .slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
} else switch (info.flags.size) { } else switch (info.flags.size) {
.One => try writer.writeAll("*"), .one => try writer.writeAll("*"),
.Many => try writer.writeAll("[*]"), .many => try writer.writeAll("[*]"),
.C => try writer.writeAll("[*c]"), .c => try writer.writeAll("[*c]"),
.Slice => try writer.writeAll("[]"), .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 if (info.flags.alignment != .none or
info.packed_offset.host_size != 0 or info.packed_offset.host_size != 0 or
info.flags.vector_index != .none) 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), .array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu),
.opt_type => ty.isPtrLikeOptional(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) { .simple_type => |t| switch (t) {
.f16, .f16,
@ -1303,7 +1303,7 @@ pub fn abiSizeInner(
return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) }; return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) };
}, },
.ptr_type => |ptr_type| switch (ptr_type.flags.size) { .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) }, else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
}, },
.anyframe_type => 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())) { switch (ip.indexToKey(ty.toIntern())) {
.int_type => |int_type| return int_type.bits, .int_type => |int_type| return int_type.bits,
.ptr_type => |ptr_type| switch (ptr_type.flags.size) { .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice => return target.ptrBitWidth() * 2, .slice => return target.ptrBitWidth() * 2,
else => return target.ptrBitWidth(), else => return target.ptrBitWidth(),
}, },
.anyframe_type => 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 { pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { 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, 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 { pub fn isSlice(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { 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, else => false,
}; };
} }
@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool {
pub fn isCPtr(ty: Type, zcu: *const Zcu) bool { pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { 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, else => false,
}; };
} }
@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool { pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) { .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice => false, .slice => false,
.One, .Many, .C => true, .one, .many, .c => true,
}, },
.opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) { .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
.ptr_type => |p| switch (p.flags.size) { .ptr_type => |p| switch (p.flags.size) {
.Slice, .C => false, .slice, .c => false,
.Many, .One => !p.flags.is_allowzero, .many, .one => !p.flags.is_allowzero,
}, },
else => false, else => false,
}, },
@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool {
pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool { pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) { .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, .error_set_type, .inferred_error_set_type => true,
else => false, else => false,
}, },
.ptr_type => |ptr_type| ptr_type.flags.size == .C, .ptr_type => |ptr_type| ptr_type.flags.size == .c,
else => false, 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`. /// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`.
pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool { pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { 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)) { .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) { .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.Slice, .C => false, .slice, .c => false,
.Many, .One => !ptr_type.flags.is_allowzero, .many, .one => !ptr_type.flags.is_allowzero,
}, },
else => false, else => false,
}, },
@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {
pub fn elemType2(ty: Type, zcu: *const Zcu) Type { pub fn elemType2(ty: Type, zcu: *const Zcu) Type {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) { .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.One => Type.fromInterned(ptr_type.child).shallowElemType(zcu), .one => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
.Many, .C, .Slice => Type.fromInterned(ptr_type.child), .many, .c, .slice => Type.fromInterned(ptr_type.child),
}, },
.anyframe_type => |child| { .anyframe_type => |child| {
assert(child != .none); assert(child != .none);
@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.opt_type => |child| Type.fromInterned(child), .opt_type => |child| Type.fromInterned(child),
.ptr_type => |ptr_type| b: { .ptr_type => |ptr_type| b: {
assert(ptr_type.flags.size == .C); assert(ptr_type.flags.size == .c);
break :b ty; break :b ty;
}, },
else => unreachable, else => unreachable,
@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {
return switch (ty.zigTypeTag(zcu)) { return switch (ty.zigTypeTag(zcu)) {
.array, .vector => true, .array, .vector => true,
.pointer => switch (ty.ptrSize(zcu)) { .pointer => switch (ty.ptrSize(zcu)) {
.Slice, .Many, .C => true, .slice, .many, .c => true,
.One => switch (ty.childType(zcu).zigTypeTag(zcu)) { .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.array, .vector => true, .array, .vector => true,
.@"struct" => ty.childType(zcu).isTuple(zcu), .@"struct" => ty.childType(zcu).isTuple(zcu),
else => false, else => false,
@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {
return switch (ty.zigTypeTag(zcu)) { return switch (ty.zigTypeTag(zcu)) {
.array, .vector => true, .array, .vector => true,
.pointer => switch (ty.ptrSize(zcu)) { .pointer => switch (ty.ptrSize(zcu)) {
.Many, .C => false, .many, .c => false,
.Slice => true, .slice => true,
.One => switch (ty.childType(zcu).zigTypeTag(zcu)) { .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.array, .vector => true, .array, .vector => true,
.@"struct" => ty.childType(zcu).isTuple(zcu), .@"struct" => ty.childType(zcu).isTuple(zcu),
else => false, else => false,
@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type {
host_size: u16 = 0, host_size: u16 = 0,
alignment: Alignment = .none, alignment: Alignment = .none,
vector_index: VI = .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); const elem_bits = elem_ty.bitSize(zcu);
if (elem_bits == 0) break :blk .{}; if (elem_bits == 0) break :blk .{};
const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits); 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 parent_ptr_ty = parent_ptr.typeOf(zcu);
const opt_ty = parent_ptr_ty.childType(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); assert(opt_ty.zigTypeTag(zcu) == .optional);
const result_ty = try pt.ptrTypeSema(info: { 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); 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 = .{ return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(), .ty = result_ty.toIntern(),
.base_addr = .{ .opt_payload = base_ptr.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 parent_ptr_ty = parent_ptr.typeOf(zcu);
const eu_ty = parent_ptr_ty.childType(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); assert(eu_ty.zigTypeTag(zcu) == .error_union);
const result_ty = try pt.ptrTypeSema(info: { 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); 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 = .{ return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(), .ty = result_ty.toIntern(),
.base_addr = .{ .eu_payload = base_ptr.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 aggregate_ty = parent_ptr_ty.childType(zcu);
const parent_ptr_info = parent_ptr_ty.ptrInfo(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. // 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. // `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); 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 = .{ return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(), .ty = result_ty.toIntern(),
.base_addr = .{ .field = .{ .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 { pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value {
const zcu = pt.zcu; const zcu = pt.zcu;
const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) { const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) {
.One, .Many, .C => orig_parent_ptr, .one, .many, .c => orig_parent_ptr,
.Slice => orig_parent_ptr.slicePtr(zcu), .slice => orig_parent_ptr.slicePtr(zcu),
}; };
const parent_ptr_ty = parent_ptr.typeOf(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)) { 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) }, .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },
.array => strat: { .array => strat: {
const arr_elem_ty = elem_ty.childType(zcu); 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, else => unreachable,
}, },
.Many, .C => if (try elem_ty.comptimeOnlySema(pt)) .many, .c => if (try elem_ty.comptimeOnlySema(pt))
.{ .elem_ptr = elem_ty } .{ .elem_ptr = elem_ty }
else else
.{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar }, .{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar },
.Slice => unreachable, .slice => unreachable,
}; };
switch (strat) { switch (strat) {
@ -4004,7 +4004,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
}, },
else => {}, 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 = .{ return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(), .ty = result_ty.toIntern(),
.base_addr = .{ .arr_elem = .{ .base_addr = .{ .arr_elem = .{
@ -4234,7 +4234,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
.child = parent_ptr_info.child, .child = parent_ptr_info.child,
.flags = flags: { .flags = flags: {
var flags = parent_ptr_info.flags; var flags = parent_ptr_info.flags;
flags.size = .One; flags.size = .one;
break :flags flags; 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 (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt;
if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt; if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt;
switch (need_child.ptrSize(zcu)) { switch (need_child.ptrSize(zcu)) {
.One, .Many => {}, .one, .many => {},
.Slice, .C => break :ptr_opt, .slice, .c => break :ptr_opt,
} }
const parent = try arena.create(PointerDeriveStep); const parent = try arena.create(PointerDeriveStep);
parent.* = cur_derive; 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 elem_size = elem_ty.abiSize(zcu);
const start_idx = cur_offset / elem_size; const start_idx = cur_offset / elem_size;
const end_idx = (cur_offset + need_bytes + elem_size - 1) / 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); const parent = try arena.create(PointerDeriveStep);
parent.* = cur_derive; parent.* = cur_derive;
cur_derive = .{ .elem_ptr = .{ cur_derive = .{ .elem_ptr = .{

View File

@ -3068,7 +3068,7 @@ pub fn populateTestFunctions(
.child = test_fn_ty.toIntern(), .child = test_fn_ty.toIntern(),
.flags = .{ .flags = .{
.is_const = true, .is_const = true,
.size = .Slice, .size = .slice,
}, },
}); });
const new_init = try pt.intern(.{ .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 { pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type {
var canon_info = info; 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 // 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 // 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(.{ return pt.ptrType(.{
.child = child_type.toIntern(), .child = child_type.toIntern(),
.flags = .{ .flags = .{
.size = .Many, .size = .many,
.is_const = true, .is_const = true,
}, },
}); });

View File

@ -2398,7 +2398,7 @@ fn ptrArithmetic(
const ptr_ty = lhs_ty; const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) { 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), else => ptr_ty.childType(zcu),
}; };
const elem_size = elem_ty.abiSize(zcu); const elem_size = elem_ty.abiSize(zcu);

View File

@ -3919,7 +3919,7 @@ fn ptrArithmetic(
const ptr_ty = lhs_ty; const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) { 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), else => ptr_ty.childType(zcu),
}; };
const elem_size: u32 = @intCast(elem_ty.abiSize(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) { if (elem_abi_size == 1) {
const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack // TODO: this only handles slices stored in the stack
.Slice => dst_ptr, .slice => dst_ptr,
.One => dst_ptr, .one => dst_ptr,
.C, .Many => unreachable, .c, .many => unreachable,
}; };
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack // TODO: this only handles slices stored in the stack
.Slice => dst_ptr.address().offset(8).deref(), .slice => dst_ptr.address().offset(8).deref(),
.One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) }, .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
.C, .Many => unreachable, .c, .many => unreachable,
}; };
const len_lock: ?RegisterLock = switch (len) { const len_lock: ?RegisterLock = switch (len) {
.register => |reg| func.register_manager.lockRegAssumeUnused(reg), .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 // Length zero requires a runtime check - so we handle arrays specially
// here to elide it. // here to elide it.
switch (dst_ptr_ty.ptrSize(zcu)) { switch (dst_ptr_ty.ptrSize(zcu)) {
.Slice => return func.fail("TODO: airMemset Slices", .{}), .slice => return func.fail("TODO: airMemset Slices", .{}),
.One => { .one => {
const elem_ptr_ty = try pt.singleMutPtrType(elem_ty); const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
const len = dst_ptr_ty.childType(zcu).arrayLen(zcu); 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) }; const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy); 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 }); 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 dst_ty = func.typeOf(bin_op.lhs);
const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) { const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) {
.Slice => len: { .slice => len: {
const len_reg, const len_lock = try func.allocReg(.int); const len_reg, const len_lock = try func.allocReg(.int);
defer func.register_manager.unlockReg(len_lock); 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 }; break :len .{ .register = len_reg };
}, },
.One => len: { .one => len: {
const array_ty = dst_ty.childType(zcu); const array_ty = dst_ty.childType(zcu);
break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(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; return result;
}, },
.pointer => switch (ty.ptrSize(zcu)) { .pointer => switch (ty.ptrSize(zcu)) {
.Slice => { .slice => {
result[0] = .integer; result[0] = .integer;
result[1] = .integer; result[1] = .integer;
return result; return result;

View File

@ -2953,7 +2953,7 @@ fn binOp(
.pointer => { .pointer => {
const ptr_ty = lhs_ty; const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) { 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), else => ptr_ty.childType(zcu),
}; };
const elem_size = elem_ty.abiSize(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 offset = try cg.resolveInst(bin_op.rhs);
const ptr_ty = cg.typeOf(bin_op.lhs); const ptr_ty = cg.typeOf(bin_op.lhs);
const pointee_ty = switch (ptr_ty.ptrSize(zcu)) { 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), 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 ptr_ty = cg.typeOf(bin_op.lhs);
const value = try cg.resolveInst(bin_op.rhs); const value = try cg.resolveInst(bin_op.rhs);
const len = switch (ptr_ty.ptrSize(zcu)) { const len = switch (ptr_ty.ptrSize(zcu)) {
.Slice => try cg.sliceLen(ptr), .slice => try cg.sliceLen(ptr),
.One => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }), .one => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
.C, .Many => unreachable, .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) ptr_ty.childType(zcu).childType(zcu)
else else
ptr_ty.childType(zcu); 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 = try cg.resolveInst(bin_op.rhs);
const src_ty = cg.typeOf(bin_op.rhs); const src_ty = cg.typeOf(bin_op.rhs);
const len = switch (dst_ty.ptrSize(zcu)) { const len = switch (dst_ty.ptrSize(zcu)) {
.Slice => blk: { .slice => blk: {
const slice_len = try cg.sliceLen(dst); const slice_len = try cg.sliceLen(dst);
if (ptr_elem_ty.abiSize(zcu) != 1) { if (ptr_elem_ty.abiSize(zcu) != 1) {
try cg.emitWValue(slice_len); try cg.emitWValue(slice_len);
@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
} }
break :blk slice_len; 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))), .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 dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty);
const src_ptr = try cg.sliceOrArrayPtr(src, src_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(.{ const manyptr_u32_ty = try pt.ptrType(.{
.child = .u32_type, .child = .u32_type,
.flags = .{ .flags = .{
.size = .Many, .size = .many,
}, },
}); });
const manyptr_const_u32_ty = try pt.ptrType(.{ const manyptr_const_u32_ty = try pt.ptrType(.{
.child = .u32_type, .child = .u32_type,
.flags = .{ .flags = .{
.size = .Many, .size = .many,
.is_const = true, .is_const = true,
}, },
}); });
@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
if (elem_abi_size == 1) { if (elem_abi_size == 1) {
const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack // TODO: this only handles slices stored in the stack
.Slice => dst_ptr, .slice => dst_ptr,
.One => dst_ptr, .one => dst_ptr,
.C, .Many => unreachable, .c, .many => unreachable,
}; };
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack // TODO: this only handles slices stored in the stack
.Slice => dst_ptr.address().offset(8).deref(), .slice => dst_ptr.address().offset(8).deref(),
.One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) }, .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
.C, .Many => unreachable, .c, .many => unreachable,
}; };
const len_lock: ?RegisterLock = switch (len) { const len_lock: ?RegisterLock = switch (len) {
.register => |reg| self.register_manager.lockRegAssumeUnused(reg), .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 // Length zero requires a runtime check - so we handle arrays specially
// here to elide it. // here to elide it.
switch (dst_ptr_ty.ptrSize(zcu)) { switch (dst_ptr_ty.ptrSize(zcu)) {
.Slice => { .slice => {
const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu); const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu);
// TODO: this only handles slices stored in the stack // 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); self.performReloc(skip_reloc);
}, },
.One => { .one => {
const elem_ptr_ty = try pt.singleMutPtrType(elem_ty); const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
const len = dst_ptr_ty.childType(zcu).arrayLen(zcu); 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) }; const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy); 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 }); 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); defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock);
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) { 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_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
const len_lock = self.register_manager.lockRegAssumeUnused(len_reg); const len_lock = self.register_manager.lockRegAssumeUnused(len_reg);
defer self.register_manager.unlockReg(len_lock); 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 }; break :len .{ .register = len_reg };
}, },
.One => len: { .one => len: {
const array_ty = dst_ptr_ty.childType(zcu); const array_ty = dst_ptr_ty.childType(zcu);
break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(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) { const len_lock: ?RegisterLock = switch (len) {
.register => |reg| self.register_manager.lockRegAssumeUnused(reg), .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; var result = [1]Class{.none} ** 8;
switch (ty.zigTypeTag(zcu)) { switch (ty.zigTypeTag(zcu)) {
.pointer => switch (ty.ptrSize(zcu)) { .pointer => switch (ty.ptrSize(zcu)) {
.Slice => { .slice => {
result[0] = .integer; result[0] = .integer;
result[1] = .integer; result[1] = .integer;
return result; return result;

View File

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

View File

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

View File

@ -1589,14 +1589,14 @@ pub const DeclGen = struct {
try dg.fmtIntLiteral(try pt.undefValue(ty), location), try dg.fmtIntLiteral(try pt.undefValue(ty), location),
}), }),
.ptr_type => |ptr_type| switch (ptr_type.flags.size) { .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
.One, .Many, .C => { .one, .many, .c => {
try writer.writeAll("(("); try writer.writeAll("((");
try dg.renderCType(writer, ctype); try dg.renderCType(writer, ctype);
return writer.print("){x})", .{ return writer.print("){x})", .{
try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other), try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other),
}); });
}, },
.Slice => { .slice => {
if (!location.isInitializer()) { if (!location.isInitializer()) {
try writer.writeByte('('); try writer.writeByte('(');
try dg.renderCType(writer, ctype); 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 f.renderType(writer, inst_ty);
try writer.writeByte(')'); try writer.writeByte(')');
if (elem_has_bits) 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. // It's a pointer to an array, so we need to de-reference.
try f.writeCValueDeref(writer, ptr); try f.writeCValueDeref(writer, ptr);
} else try f.writeCValue(writer, ptr, .Other); } else try f.writeCValue(writer, ptr, .Other);
@ -5798,8 +5798,8 @@ fn fieldLocation(
} }
}, },
.ptr_type => |ptr_info| switch (ptr_info.flags.size) { .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
.One, .Many, .C => unreachable, .one, .many, .c => unreachable,
.Slice => switch (field_index) { .slice => switch (field_index) {
0 => return .{ .field = .{ .identifier = "ptr" } }, 0 => return .{ .field = .{ .identifier = "ptr" } },
1 => return .{ .field = .{ .identifier = "len" } }, 1 => return .{ .field = .{ .identifier = "len" } },
else => unreachable, else => unreachable,
@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll("memset("); try writer.writeAll("memset(");
switch (dest_ty.ptrSize(zcu)) { switch (dest_ty.ptrSize(zcu)) {
.Slice => { .slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" }); try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
try writer.writeAll(", 0xaa, "); try writer.writeAll(", 0xaa, ");
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); 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"); try writer.writeAll(");\n");
} }
}, },
.One => { .one => {
const array_ty = dest_ty.childType(zcu); const array_ty = dest_ty.childType(zcu);
const len = array_ty.arrayLen(zcu) * elem_abi_size; const len = array_ty.arrayLen(zcu) * elem_abi_size;
try f.writeCValue(writer, dest_slice, .FunctionArgument); try f.writeCValue(writer, dest_slice, .FunctionArgument);
try writer.print(", 0xaa, {d});\n", .{len}); try writer.print(", 0xaa, {d});\n", .{len});
}, },
.Many, .C => unreachable, .many, .c => unreachable,
} }
try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
return .none; return .none;
@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
const elem_ptr_ty = try pt.ptrType(.{ const elem_ptr_ty = try pt.ptrType(.{
.child = elem_ty.toIntern(), .child = elem_ty.toIntern(),
.flags = .{ .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 f.writeCValue(writer, index, .Other);
try writer.writeAll(" != "); try writer.writeAll(" != ");
switch (dest_ty.ptrSize(zcu)) { switch (dest_ty.ptrSize(zcu)) {
.Slice => { .slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" }); try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
}, },
.One => { .one => {
const array_ty = dest_ty.childType(zcu); const array_ty = dest_ty.childType(zcu);
try writer.print("{d}", .{array_ty.arrayLen(zcu)}); try writer.print("{d}", .{array_ty.arrayLen(zcu)});
}, },
.Many, .C => unreachable, .many, .c => unreachable,
} }
try writer.writeAll("; ++"); try writer.writeAll("; ++");
try f.writeCValue(writer, index, .Other); 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("); try writer.writeAll("memset(");
switch (dest_ty.ptrSize(zcu)) { switch (dest_ty.ptrSize(zcu)) {
.Slice => { .slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" }); try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
try writer.writeAll(", "); try writer.writeAll(", ");
try f.writeCValue(writer, bitcasted, .FunctionArgument); 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 f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
try writer.writeAll(");\n"); try writer.writeAll(");\n");
}, },
.One => { .one => {
const array_ty = dest_ty.childType(zcu); const array_ty = dest_ty.childType(zcu);
const len = array_ty.arrayLen(zcu) * elem_abi_size; 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 f.writeCValue(writer, bitcasted, .FunctionArgument);
try writer.print(", {d});\n", .{len}); try writer.print(", {d});\n", .{len});
}, },
.Many, .C => unreachable, .many, .c => unreachable,
} }
try f.freeCValue(inst, bitcasted); try f.freeCValue(inst, bitcasted);
try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); 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 src_ty = f.typeOf(bin_op.rhs);
const writer = f.object.writer(); const writer = f.object.writer();
if (dest_ty.ptrSize(zcu) != .One) { if (dest_ty.ptrSize(zcu) != .one) {
try writer.writeAll("if ("); try writer.writeAll("if (");
try writeArrayLen(f, writer, dest_ptr, dest_ty); try writeArrayLen(f, writer, dest_ptr, dest_ty);
try writer.writeAll(" != 0) "); 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 pt = f.object.dg.pt;
const zcu = pt.zcu; const zcu = pt.zcu;
switch (dest_ty.ptrSize(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))), try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))),
}), }),
.Many, .C => unreachable, .many, .c => unreachable,
.Slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }), .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)) { _ => |ip_index| switch (ip.indexToKey(ip_index)) {
.int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind), .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),
.ptr_type => |ptr_info| switch (ptr_info.flags.size) { .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
.One, .Many, .C => { .one, .many, .c => {
const elem_ctype = elem_ctype: { const elem_ctype = elem_ctype: {
if (ptr_info.packed_offset.host_size > 0 and if (ptr_info.packed_offset.host_size > 0 and
ptr_info.flags.vector_index == .none) ptr_info.flags.vector_index == .none)
@ -1505,7 +1505,7 @@ pub const Pool = struct {
.@"volatile" = ptr_info.flags.is_volatile, .@"volatile" = ptr_info.flags.is_volatile,
}); });
}, },
.Slice => { .slice => {
const target = &mod.resolved_target.result; const target = &mod.resolved_target.result;
var fields = [_]Info.Field{ var fields = [_]Info.Field{
.{ .{
@ -1598,7 +1598,7 @@ pub const Pool = struct {
switch (payload_type) { switch (payload_type) {
.anyerror_type => return payload_ctype, .anyerror_type => return payload_ctype,
else => switch (ip.indexToKey(payload_type)) { 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, !payload_ptr_info.flags.is_allowzero) return payload_ctype,
.error_set_type, .inferred_error_set_type => return payload_ctype, .error_set_type, .inferred_error_set_type => return payload_ctype,
else => {}, else => {},

View File

@ -2109,7 +2109,7 @@ pub const Object = struct {
ptr_info.flags.is_allowzero or ptr_info.flags.is_allowzero or
ptr_info.flags.is_const or ptr_info.flags.is_const or
ptr_info.flags.is_volatile 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)) !Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu))
{ {
const bland_ptr_ty = try pt.ptrType(.{ const bland_ptr_ty = try pt.ptrType(.{
@ -2120,8 +2120,8 @@ pub const Object = struct {
.flags = .{ .flags = .{
.alignment = ptr_info.flags.alignment, .alignment = ptr_info.flags.alignment,
.size = switch (ptr_info.flags.size) { .size = switch (ptr_info.flags.size) {
.Many, .C, .One => .One, .many, .c, .one => .one,
.Slice => .Slice, .slice => .slice,
}, },
}, },
}); });
@ -3382,8 +3382,8 @@ pub const Object = struct {
toLlvmAddressSpace(ptr_type.flags.address_space, target), toLlvmAddressSpace(ptr_type.flags.address_space, target),
); );
break :type switch (ptr_type.flags.size) { break :type switch (ptr_type.flags.size) {
.One, .Many, .C => ptr_ty, .one, .many, .c => ptr_ty,
.Slice => try o.builder.structType(.normal, &.{ .slice => try o.builder.structType(.normal, &.{
ptr_ty, ptr_ty,
try o.lowerType(Type.usize), try o.lowerType(Type.usize),
}), }),
@ -6988,7 +6988,7 @@ pub const FuncGen = struct {
const zcu = pt.zcu; const zcu = pt.zcu;
const llvm_usize = try o.lowerType(Type.usize); const llvm_usize = try o.lowerType(Type.usize);
switch (ty.ptrSize(zcu)) { switch (ty.ptrSize(zcu)) {
.Slice => { .slice => {
const len = try fg.wip.extractValue(ptr, &.{1}, ""); const len = try fg.wip.extractValue(ptr, &.{1}, "");
const elem_ty = ty.childType(zcu); const elem_ty = ty.childType(zcu);
const abi_size = elem_ty.abiSize(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); const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size);
return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, ""); return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, "");
}, },
.One => { .one => {
const array_ty = ty.childType(zcu); const array_ty = ty.childType(zcu);
const elem_ty = array_ty.childType(zcu); const elem_ty = array_ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu); const abi_size = elem_ty.abiSize(zcu);
return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size); 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)); const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
switch (ptr_ty.ptrSize(zcu)) { switch (ptr_ty.ptrSize(zcu)) {
// It's a pointer to an array, so according to LLVM we need an extra GEP index. // 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, try o.builder.intValue(try o.lowerType(Type.usize), 0), offset,
}, ""), }, ""),
.C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""), .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
.Slice => { .slice => {
const base = try self.wip.extractValue(ptr, &.{0}, ""); const base = try self.wip.extractValue(ptr, &.{0}, "");
return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, ""); 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)); const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
switch (ptr_ty.ptrSize(zcu)) { switch (ptr_ty.ptrSize(zcu)) {
// It's a pointer to an array, so according to LLVM we need an extra GEP index. // 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, 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}, ""), .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
.Slice => { .slice => {
const base = try self.wip.extractValue(ptr, &.{0}, ""); const base = try self.wip.extractValue(ptr, &.{0}, "");
return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, ""); 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 llvm_usize_ty = try o.lowerType(Type.usize);
const len = switch (ptr_ty.ptrSize(zcu)) { const len = switch (ptr_ty.ptrSize(zcu)) {
.Slice => try self.wip.extractValue(dest_slice, &.{1}, ""), .slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
.One => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)), .one => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
.Many, .C => unreachable, .many, .c => unreachable,
}; };
const elem_llvm_ty = try o.lowerType(elem_ty); const elem_llvm_ty = try o.lowerType(elem_ty);
const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, ""); 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 storage_class = self.spvStorageClass(ptr_info.flags.address_space);
const ptr_ty_id = try self.ptrType(child_ty, storage_class); 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 = .{ try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{
.array_stride = @intCast(child_ty.abiSize(zcu)), .array_stride = @intCast(child_ty.abiSize(zcu)),
} }); } });
} }
if (ptr_info.flags.size != .Slice) { if (ptr_info.flags.size != .slice) {
return ptr_ty_id; return ptr_ty_id;
} }
@ -4399,15 +4399,15 @@ const NavGen = struct {
const result_ty_id = try self.resolveType(result_ty, .direct); const result_ty_id = try self.resolveType(result_ty, .direct);
switch (ptr_ty.ptrSize(zcu)) { switch (ptr_ty.ptrSize(zcu)) {
.One => { .one => {
// Pointer to array // Pointer to array
// TODO: Is this correct? // TODO: Is this correct?
return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id}); 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, &.{}); 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. // 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); const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0);
return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{}); return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{});
@ -4989,15 +4989,15 @@ const NavGen = struct {
const pt = self.pt; const pt = self.pt;
const zcu = pt.zcu; const zcu = pt.zcu;
switch (ty.ptrSize(zcu)) { switch (ty.ptrSize(zcu)) {
.Slice => return self.extractField(Type.usize, operand_id, 1), .slice => return self.extractField(Type.usize, operand_id, 1),
.One => { .one => {
const array_ty = ty.childType(zcu); const array_ty = ty.childType(zcu);
const elem_ty = array_ty.childType(zcu); const elem_ty = array_ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu); const abi_size = elem_ty.abiSize(zcu);
const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size; const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size;
return try self.constInt(Type.usize, size, .direct); 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); section.writeOperand(info.child, child);
}, },
.pointer => |info| { .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| { for (operand) |item| {
section.writeOperand(info.child, item); section.writeOperand(info.child, item);
} }
@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
.@"enum" => 1, .@"enum" => 1,
.optional => |info| if (operand) |child| operandSize(info.child, child) else 0, .optional => |info| if (operand) |child| operandSize(info.child, child) else 0,
.pointer => |info| blk: { .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; var total: usize = 0;
for (operand) |item| { for (operand) |item| {
total += operandSize(info.child, item); total += operandSize(info.child, item);

View File

@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void {
debug.updateSegfaultHandler(&act); 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 // TODO: use alarm() here to prevent infinite loops
PanicSwitch.preDispatch(); PanicSwitch.preDispatch();

View File

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

View File

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

View File

@ -256,7 +256,7 @@ pub const MutableValue = union(enum) {
}, },
.pointer => { .pointer => {
const ptr_ty = ip.indexToKey(ty_ip).ptr_type; 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 ptr = try arena.create(MutableValue);
const len = try arena.create(MutableValue); const len = try arena.create(MutableValue);
ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) }; 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)); const c: *Context = @ptrCast(@alignCast(context));
declVisitorNamesOnly(c, decl) catch return false; declVisitorNamesOnly(c, decl) catch return false;
return true; 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)); const c: *Context = @ptrCast(@alignCast(context));
declVisitor(c, decl) catch return false; declVisitor(c, decl) catch return false;
return true; return true;

View File

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

View File

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

View File

@ -26,7 +26,7 @@ test "exporting with internal linkage" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
const S = struct { const S = struct {
fn foo() callconv(.C) void {} fn foo() callconv(.c) void {}
comptime { comptime {
@export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal }); @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; if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
_ = struct { _ = struct {
fn foo_internal() callconv(.C) u32 { fn foo_internal() callconv(.c) u32 {
return 123; return 123;
} }
export const foo_exported = foo_internal; 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_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) 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); try expect(a() == 4567);
} }
@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" {
const S = struct { const S = struct {
extern fn another_mystery_function() u32; 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.another_mystery_function() == 12345);
try expect(S.same_thing() == 12345); try expect(S.same_thing() == 12345);
@ -55,5 +55,5 @@ test "coerce extern function types" {
}; };
_ = S; _ = 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; if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = extern struct { 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; return 1234;
} }
}; };
@ -169,7 +169,7 @@ const nComplexCallconv = 100;
fn fComplexCallconvRet(x: u32) callconv(blk: { fn fComplexCallconvRet(x: u32) callconv(blk: {
const s: struct { n: u32 } = .{ .n = nComplexCallconv }; const s: struct { n: u32 } = .{ .n = nComplexCallconv };
break :blk switch (s.n) { break :blk switch (s.n) {
0 => .C, 0 => .c,
1 => .Inline, 1 => .Inline,
else => .Unspecified, else => .Unspecified,
}; };
@ -435,13 +435,13 @@ test "implicit cast function to function ptr" {
return 123; return 123;
} }
}; };
var fnPtr1: *const fn () callconv(.C) c_int = S1.someFunctionThatReturnsAValue; var fnPtr1: *const fn () callconv(.c) c_int = S1.someFunctionThatReturnsAValue;
_ = &fnPtr1; _ = &fnPtr1;
try expect(fnPtr1() == 123); try expect(fnPtr1() == 123);
const S2 = struct { const S2 = struct {
extern fn someFunctionThatReturnsAValue() c_int; 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; _ = &fnPtr2;
try expect(fnPtr2() == 123); try expect(fnPtr2() == 123);
} }

View File

@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" {
for (source, 0..) |s, i| dest[i] = s; for (source, 0..) |s, i| dest[i] = s;
} }
fn foo() callconv(.C) void {} fn foo() callconv(.c) void {}
}; };
var buffer: [100]u8 = undefined; var buffer: [100]u8 = undefined;
S.copy(u8, &buffer, "hello"); 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); 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 { const S = struct {
fn getU8() callconv(.C) u8 { fn getU8() callconv(.c) u8 {
return 123; 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(); return supplier();
} }
}; };
@ -521,11 +521,11 @@ test "function argument tuple used as struct field" {
try expect(c.t[0] == null); 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 { const S = struct {
fn A( fn A(
comptime T: type, comptime T: type,
comptime destroycb: ?*const fn (?*T) callconv(.C) void, comptime destroycb: ?*const fn (?*T) callconv(.c) void,
) !void { ) !void {
try expect(destroycb == null); 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); try std.testing.expect(ptr_id == &some_non_c_keyword_constant);
if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) { 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); try std.testing.expect(ptr_fn == &float);
ptr_fn = &an_alias_of_float; ptr_fn = &an_alias_of_float;
try std.testing.expect(ptr_fn == &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(); }{ .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_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO 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, 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; 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, x: u15 = 0,
y: u1 = 0, y: u1 = 0,
fn foo(s: @This()) callconv(.C) i32 { fn foo(s: @This()) callconv(.c) i32 {
return s.x; return s.x;
} }
fn bar(s: @This()) !void { fn bar(s: @This()) !void {

View File

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

View File

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

View File

@ -44,7 +44,7 @@ test "type info: C pointer type info" {
fn testCPtr() !void { fn testCPtr() !void {
const ptr_info = @typeInfo([*c]align(4) const i8); const ptr_info = @typeInfo([*c]align(4) const i8);
try expect(ptr_info == .pointer); 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_const);
try expect(!ptr_info.pointer.is_volatile); try expect(!ptr_info.pointer.is_volatile);
try expect(ptr_info.pointer.alignment == 4); try expect(ptr_info.pointer.alignment == 4);
@ -54,8 +54,8 @@ fn testCPtr() !void {
test "type info: value is correctly copied" { test "type info: value is correctly copied" {
comptime { comptime {
var ptrInfo = @typeInfo([]u32); var ptrInfo = @typeInfo([]u32);
ptrInfo.pointer.size = .One; ptrInfo.pointer.size = .one;
try expect(@typeInfo([]u32).pointer.size == .Slice); try expect(@typeInfo([]u32).pointer.size == .slice);
} }
} }
@ -79,7 +79,7 @@ test "type info: pointer type info" {
fn testPointer() !void { fn testPointer() !void {
const u32_ptr_info = @typeInfo(*u32); const u32_ptr_info = @typeInfo(*u32);
try expect(u32_ptr_info == .pointer); 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_const == false);
try expect(u32_ptr_info.pointer.is_volatile == false); try expect(u32_ptr_info.pointer.is_volatile == false);
try expect(u32_ptr_info.pointer.alignment == @alignOf(u32)); try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));
@ -95,7 +95,7 @@ test "type info: unknown length pointer type info" {
fn testUnknownLenPtr() !void { fn testUnknownLenPtr() !void {
const u32_ptr_info = @typeInfo([*]const volatile f64); const u32_ptr_info = @typeInfo([*]const volatile f64);
try expect(u32_ptr_info == .pointer); 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_const == true);
try expect(u32_ptr_info.pointer.is_volatile == true); try expect(u32_ptr_info.pointer.is_volatile == true);
try expect(u32_ptr_info.pointer.sentinel == null); try expect(u32_ptr_info.pointer.sentinel == null);
@ -111,7 +111,7 @@ test "type info: null terminated pointer type info" {
fn testNullTerminatedPtr() !void { fn testNullTerminatedPtr() !void {
const ptr_info = @typeInfo([*:0]u8); const ptr_info = @typeInfo([*:0]u8);
try expect(ptr_info == .pointer); 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_const == false);
try expect(ptr_info.pointer.is_volatile == false); try expect(ptr_info.pointer.is_volatile == false);
try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0); try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);
@ -127,7 +127,7 @@ test "type info: slice type info" {
fn testSlice() !void { fn testSlice() !void {
const u32_slice_info = @typeInfo([]u32); const u32_slice_info = @typeInfo([]u32);
try expect(u32_slice_info == .pointer); 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_const == false);
try expect(u32_slice_info.pointer.is_volatile == false); try expect(u32_slice_info.pointer.is_volatile == false);
try expect(u32_slice_info.pointer.alignment == 4); 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".is_var_args);
try expect(foo_fn_info.@"fn".return_type.? == usize); try expect(foo_fn_info.@"fn".return_type.? == usize);
const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo)); 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_const);
try expect(!foo_ptr_fn_info.pointer.is_volatile); try expect(!foo_ptr_fn_info.pointer.is_volatile);
try expect(foo_ptr_fn_info.pointer.address_space == .generic); 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".is_var_args);
try expect(aligned_foo_fn_info.@"fn".return_type.? == usize); try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);
const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned)); 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_const);
try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile); try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);
try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4); 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, s: S,
}; };
fn bar(arg_u: U) callconv(.C) U { fn bar(arg_u: U) callconv(.c) U {
var u = arg_u; var u = arg_u;
_ = &u; _ = &u;
return 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 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct { const S = struct {
fn simple(...) callconv(.C) c_int { fn simple(...) callconv(.c) c_int {
var ap = @cVaStart(); var ap = @cVaStart();
defer @cVaEnd(&ap); defer @cVaEnd(&ap);
return @cVaArg(&ap, c_int); return @cVaArg(&ap, c_int);
} }
fn compatible(_: c_int, ...) callconv(.C) c_int { fn compatible(_: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart(); var ap = @cVaStart();
defer @cVaEnd(&ap); defer @cVaEnd(&ap);
return @cVaArg(&ap, c_int); 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(); var ap = @cVaStart();
defer @cVaEnd(&ap); defer @cVaEnd(&ap);
var i: usize = 0; 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 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct { const S = struct {
fn addPtr(count: c_int, ...) callconv(.C) c_int { fn addPtr(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart(); var ap = @cVaStart();
defer @cVaEnd(&ap); defer @cVaEnd(&ap);
var i: usize = 0; 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 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct { 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(); var ap = @cVaStart();
defer @cVaEnd(&ap); defer @cVaEnd(&ap);
vprintf(list_ptr, format, &ap); vprintf(list_ptr, format, &ap);
@ -212,7 +212,7 @@ test "variadic functions" {
list: *std.ArrayList(u8), list: *std.ArrayList(u8),
format: [*:0]const u8, format: [*:0]const u8,
ap: *std.builtin.VaList, ap: *std.builtin.VaList,
) callconv(.C) void { ) callconv(.c) void {
for (std.mem.span(format)) |c| switch (c) { for (std.mem.span(format)) |c| switch (c) {
's' => { 's' => {
const arg = @cVaArg(ap, [*:0]const u8); 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 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct { const S = struct {
fn add(count: c_int, ...) callconv(.C) c_int { fn add(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart(); var ap = @cVaStart();
defer @cVaEnd(&ap); defer @cVaEnd(&ap);
var copy = @cVaCopy(&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 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct { const S = struct {
fn thirdArg(dummy: c_int, ...) callconv(.C) c_int { fn thirdArg(dummy: c_int, ...) callconv(.c) c_int {
_ = dummy; _ = dummy;
var ap = @cVaStart(); 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 { pub fn isSingleItemPtr(comptime T: type) bool {
if (comptime is(.pointer)(T)) { if (comptime is(.pointer)(T)) {
return @typeInfo(T).pointer.size == .One; return @typeInfo(T).pointer.size == .one;
} }
return false; return false;
} }

View File

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

View File

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

View File

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