Commit d00e05f186
Changed files (74)
lib
std
Build
crypto
hash
os
posix
src
arch
aarch64
arm
riscv64
sparc64
wasm
x86_64
codegen
test
behavior
lib/std/Build/Step/ConfigHeader.zig
@@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty
.pointer => |ptr| {
switch (@typeInfo(ptr.child)) {
.array => |array| {
- if (ptr.size == .One and array.child == u8) {
+ if (ptr.size == .one and array.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
}
},
.int => {
- if (ptr.size == .Slice and ptr.child == u8) {
+ if (ptr.size == .slice and ptr.child == u8) {
try config_header.values.put(field_name, .{ .string = v });
return;
}
lib/std/Build/Step/Options.zig
@@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
return;
},
.pointer => |p| {
- if (p.size != .Slice) {
+ if (p.size != .slice) {
@compileError("Non-slice pointers are not yet supported in build options");
}
lib/std/c/darwin.zig
@@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) {
};
extern "c" var mach_task_self_: mach_port_t;
-pub fn mach_task_self() callconv(.C) mach_port_t {
+pub fn mach_task_self() callconv(.c) mach_port_t {
return mach_task_self_;
}
@@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0);
pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;
const dispatch_once_t = usize;
-const dispatch_function_t = fn (?*anyopaque) callconv(.C) void;
+const dispatch_function_t = fn (?*anyopaque) callconv(.c) void;
pub extern fn dispatch_once_f(
predicate: *dispatch_once_t,
context: ?*anyopaque,
lib/std/c/dragonfly.zig
@@ -156,7 +156,7 @@ pub const E = enum(u16) {
pub const BADSIG = SIG.ERR;
-pub const sig_t = *const fn (i32) callconv(.C) void;
+pub const sig_t = *const fn (i32) callconv(.c) void;
pub const cmsghdr = extern struct {
len: socklen_t,
lib/std/crypto/tlcsprng.zig
@@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
return initAndFill(buffer);
}
-fn childAtForkHandler() callconv(.C) void {
+fn childAtForkHandler() callconv(.c) void {
// The atfork handler is global, this function may be called after
// fork()-ing threads that never initialized the CSPRNG context.
if (wipe_mem.len == 0) return;
lib/std/hash/auto_hash.zig
@@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
const info = @typeInfo(@TypeOf(key));
switch (info.pointer.size) {
- .One => switch (strat) {
+ .one => switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
.Deep => hash(hasher, key.*, .Shallow),
.DeepRecursive => hash(hasher, key.*, .DeepRecursive),
},
- .Slice => {
+ .slice => {
switch (strat) {
.Shallow => {
hashPointer(hasher, key.ptr, .Shallow);
@@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
hash(hasher, key.len, .Shallow);
},
- .Many,
- .C,
+ .many,
+ .c,
=> switch (strat) {
.Shallow => hash(hasher, @intFromPtr(key), .Shallow),
else => @compileError(
@@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
inline fn typeContainsSlice(comptime K: type) bool {
return switch (@typeInfo(K)) {
- .pointer => |info| info.size == .Slice,
+ .pointer => |info| info.size == .slice,
inline .@"struct", .@"union" => |info| {
inline for (info.fields) |field| {
lib/std/io/fixed_buffer_stream.zig
@@ -118,14 +118,14 @@ fn Slice(comptime T: type) type {
.pointer => |ptr_info| {
var new_ptr_info = ptr_info;
switch (ptr_info.size) {
- .Slice => {},
- .One => switch (@typeInfo(ptr_info.child)) {
+ .slice => {},
+ .one => switch (@typeInfo(ptr_info.child)) {
.array => |info| new_ptr_info.child = info.child,
else => @compileError("invalid type given to fixedBufferStream"),
},
else => @compileError("invalid type given to fixedBufferStream"),
}
- new_ptr_info.size = .Slice;
+ new_ptr_info.size = .slice;
return @Type(.{ .pointer = new_ptr_info });
},
else => @compileError("invalid type given to fixedBufferStream"),
lib/std/json/static.zig
@@ -451,12 +451,12 @@ pub fn innerParse(
.pointer => |ptrInfo| {
switch (ptrInfo.size) {
- .One => {
+ .one => {
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
r.* = try innerParse(ptrInfo.child, allocator, source, options);
return r;
},
- .Slice => {
+ .slice => {
switch (try source.peekNextTokenType()) {
.array_begin => {
_ = try source.next();
@@ -706,12 +706,12 @@ pub fn innerParseFromValue(
.pointer => |ptrInfo| {
switch (ptrInfo.size) {
- .One => {
+ .one => {
const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options);
return r;
},
- .Slice => {
+ .slice => {
switch (source) {
.array => |array| {
const r = if (ptrInfo.sentinel) |sentinel_ptr|
lib/std/json/stringify.zig
@@ -631,7 +631,7 @@ pub fn WriteStream(
},
.error_set => return self.stringValue(@errorName(value)),
.pointer => |ptr_info| switch (ptr_info.size) {
- .One => switch (@typeInfo(ptr_info.child)) {
+ .one => switch (@typeInfo(ptr_info.child)) {
.array => {
// Coerce `*[N]T` to `[]const T`.
const Slice = []const std.meta.Elem(ptr_info.child);
@@ -641,10 +641,10 @@ pub fn WriteStream(
return self.write(value.*);
},
},
- .Many, .Slice => {
- if (ptr_info.size == .Many and ptr_info.sentinel == null)
+ .many, .slice => {
+ if (ptr_info.size == .many and ptr_info.sentinel == null)
@compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel");
- const slice = if (ptr_info.size == .Many) std.mem.span(value) else value;
+ const slice = if (ptr_info.size == .many) std.mem.span(value) else value;
if (ptr_info.child == u8) {
// This is a []const u8, or some similar Zig string.
lib/std/mem/Allocator.zig
@@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {
/// have the same address and alignment property.
pub fn destroy(self: Allocator, ptr: anytype) void {
const info = @typeInfo(@TypeOf(ptr)).pointer;
- if (info.size != .One) @compileError("ptr must be a single item pointer");
+ if (info.size != .one) @compileError("ptr must be a single item pointer");
const T = info.child;
if (@sizeOf(T) == 0) return;
const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr)));
lib/std/os/linux/sparc64.zig
@@ -233,7 +233,7 @@ pub const restore = restore_rt;
// Need to use C ABI here instead of naked
// to prevent an infinite loop when calling rt_sigreturn.
-pub fn restore_rt() callconv(.C) void {
+pub fn restore_rt() callconv(.c) void {
return asm volatile ("t 0x6d"
:
: [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),
lib/std/os/uefi/tables/boot_services.zig
@@ -149,11 +149,11 @@ pub const BootServices = extern struct {
/// Installs one or more protocol interfaces into the boot services environment
// TODO: use callconv(cc) instead once that works
- installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status,
+ installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status,
/// Removes one or more protocol interfaces into the boot services environment
// TODO: use callconv(cc) instead once that works
- uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status,
+ uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status,
/// Computes and returns a 32-bit CRC for a data buffer.
calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status,
lib/std/os/emscripten.zig
@@ -12,7 +12,7 @@ const c = std.c;
pub const FILE = c.FILE;
var __stack_chk_guard: usize = 0;
-fn __stack_chk_fail() callconv(.C) void {
+fn __stack_chk_fail() callconv(.c) void {
std.debug.print("stack smashing detected: terminated\n", .{});
emscripten_force_exit(127);
}
@@ -547,8 +547,8 @@ pub const SIG = struct {
};
pub const Sigaction = extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@@ -556,7 +556,7 @@ pub const Sigaction = extern struct {
},
mask: sigset_t,
flags: c_uint,
- restorer: ?*const fn () callconv(.C) void = null,
+ restorer: ?*const fn () callconv(.c) void = null,
};
pub const sigset_t = [1024 / 32]u32;
@@ -909,23 +909,23 @@ pub const LOG = struct {
pub const INFO = 512;
};
-pub const em_callback_func = ?*const fn () callconv(.C) void;
-pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.C) void;
-pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.C) void;
+pub const em_callback_func = ?*const fn () callconv(.c) void;
+pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.c) void;
+pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.c) void;
pub extern "c" fn emscripten_async_wget(url: [*:0]const u8, file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) void;
-pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void;
+pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_async_wget_data(url: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget_onload_func, onerror: em_arg_callback_func) void;
-pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.C) void;
-pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.C) void;
+pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.c) void;
+pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_async_wget2(url: [*:0]const u8, file: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget2_onload_func, onerror: em_async_wget2_onstatus_func, onprogress: em_async_wget2_onstatus_func) c_int;
-pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.C) void;
-pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.C) void;
-pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.C) void;
+pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.c) void;
+pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.c) void;
+pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.c) void;
pub extern "c" fn emscripten_async_wget2_data(url: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, free: c_int, onload: em_async_wget2_data_onload_func, onerror: em_async_wget2_data_onerror_func, onprogress: em_async_wget2_data_onprogress_func) c_int;
pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void;
@@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void;
pub extern "c" fn emscripten_resume_main_loop() void;
pub extern "c" fn emscripten_cancel_main_loop() void;
-pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.C) void;
-pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.C) void;
+pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.c) void;
+pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void;
pub extern "c" fn emscripten_set_socket_open_callback(userData: ?*anyopaque, callback: em_socket_callback) void;
@@ -968,11 +968,11 @@ pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void;
pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void;
pub extern "c" fn emscripten_get_now() f64;
pub extern "c" fn emscripten_random() f32;
-pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void;
+pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_idb_async_store(db_name: [*:0]const u8, file_id: [*:0]const u8, ptr: ?*anyopaque, num: c_int, arg: ?*anyopaque, onstore: em_arg_callback_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_idb_async_delete(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, ondelete: em_arg_callback_func, onerror: em_arg_callback_func) void;
-pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.C) void;
+pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.c) void;
pub extern "c" fn emscripten_idb_async_exists(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, oncheck: em_idb_exists_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_idb_load(db_name: [*:0]const u8, file_id: [*:0]const u8, pbuffer: *?*anyopaque, pnum: *c_int, perror: *c_int) void;
pub extern "c" fn emscripten_idb_store(db_name: [*:0]const u8, file_id: [*:0]const u8, buffer: *anyopaque, num: c_int, perror: *c_int) void;
@@ -983,13 +983,13 @@ pub extern "c" fn emscripten_idb_store_blob(db_name: [*:0]const u8, file_id: [*:
pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void;
pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void;
pub extern "c" fn emscripten_run_preload_plugins(file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) c_int;
-pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.C) void;
+pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.c) void;
pub extern "c" fn emscripten_run_preload_plugins_data(data: [*]u8, size: c_int, suffix: [*:0]const u8, arg: ?*anyopaque, onload: em_run_preload_plugins_data_onload_func, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_lazy_load_code() void;
pub const worker_handle = c_int;
pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle;
pub extern "c" fn emscripten_destroy_worker(worker: worker_handle) void;
-pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.C) void;
+pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_call_worker(worker: worker_handle, funcname: [*:0]const u8, data: [*]u8, size: c_int, callback: em_worker_callback_func, arg: ?*anyopaque) void;
pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void;
pub extern "c" fn emscripten_worker_respond_provisionally(data: [*]u8, size: c_int) void;
@@ -1003,10 +1003,10 @@ pub extern "c" fn emscripten_get_preloaded_image_data_from_FILE(file: *FILE, w:
pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void;
pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int;
pub extern "c" fn emscripten_print_double(x: f64, to: ?[*]u8, max: c_int) c_int;
-pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void;
+pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void;
pub extern "c" fn emscripten_scan_stack(func: em_scan_func) void;
-pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void;
+pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void;
pub extern "c" fn emscripten_dlopen(filename: [*:0]const u8, flags: c_int, user_data: ?*anyopaque, onsuccess: em_dlopen_callback, onerror: em_arg_callback_func) void;
pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t;
pub extern "c" fn emscripten_throw_number(number: f64) void;
@@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {};
pub const em_promise_t = ?*struct__em_promise;
pub const enum_em_promise_result_t = c_uint;
pub const em_promise_result_t = enum_em_promise_result_t;
-pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) em_promise_result_t;
+pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.c) em_promise_result_t;
pub extern "c" fn emscripten_promise_create() em_promise_t;
pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void;
lib/std/os/linux.zig
@@ -67,7 +67,7 @@ pub const syscall_pipe = syscall_bits.syscall_pipe;
pub const syscall_fork = syscall_bits.syscall_fork;
pub fn clone(
- func: *const fn (arg: usize) callconv(.C) u8,
+ func: *const fn (arg: usize) callconv(.c) u8,
stack: usize,
flags: u32,
arg: usize,
@@ -77,14 +77,14 @@ pub fn clone(
) usize {
// Can't directly call a naked function; cast to C calling convention first.
return @as(*const fn (
- *const fn (arg: usize) callconv(.C) u8,
+ *const fn (arg: usize) callconv(.c) u8,
usize,
u32,
usize,
?*i32,
usize,
?*i32,
- ) callconv(.C) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);
+ ) callconv(.c) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);
}
pub const ARCH = arch_bits.ARCH;
@@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct {
extern fn getauxval(index: usize) usize;
}.getauxval else getauxvalImpl;
-fn getauxvalImpl(index: usize) callconv(.C) usize {
+fn getauxvalImpl(index: usize) callconv(.c) usize {
const auxv = elf_aux_maybe orelse return 0;
var i: usize = 0;
while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {
@@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {
}
// We must follow the C calling convention when we call into the VDSO
-const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C) usize;
+const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize;
var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
@@ -1502,7 +1502,7 @@ pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp));
}
-fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.C) usize {
+fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize {
const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
// Note that we may not have a VDSO at all, update the stub address anyway
// so that clock_gettime will fall back on the good old (and slow) syscall
@@ -5070,8 +5070,8 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.l
pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
const k_sigaction_funcs = struct {
- const handler = ?*align(1) const fn (i32) callconv(.C) void;
- const restorer = *const fn () callconv(.C) void;
+ const handler = ?*align(1) const fn (i32) callconv(.c) void;
+ const restorer = *const fn () callconv(.c) void;
};
pub const k_sigaction = switch (native_arch) {
@@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) {
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
pub const Sigaction = extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct {
},
mask: sigset_t,
flags: c_uint,
- restorer: ?*const fn () callconv(.C) void = null,
+ restorer: ?*const fn () callconv(.c) void = null,
};
const sigset_len = @typeInfo(sigset_t).array.len;
lib/std/os/plan9.zig
@@ -186,8 +186,8 @@ pub const empty_sigset = 0;
pub const siginfo_t = c_long;
// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible.
pub const Sigaction = extern struct {
- pub const handler_fn = *const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
lib/std/posix/test.zig
@@ -849,7 +849,7 @@ test "sigaction" {
const S = struct {
var handler_called_count: u32 = 0;
- fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {
+ fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
_ = ctx_ptr;
// Check that we received the correct signal.
switch (native_os) {
lib/std/zig/system/x86.zig
@@ -475,7 +475,7 @@ const CpuidLeaf = packed struct {
/// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly.
-extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.C) void;
+extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.c) void;
fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
// valid for both x86 and x86_64
@@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
/// This is a workaround for the C backend until zig has the ability to put
/// C code in inline assembly.
-extern fn zig_x86_get_xcr0() callconv(.C) u32;
+extern fn zig_x86_get_xcr0() callconv(.c) u32;
// Read control register 0 (XCR0). Used to detect features such as AVX.
fn getXCR0() u32 {
lib/std/zig/Ast.zig
@@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto
fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
const token_tags = tree.tokens.items(.tag);
- const Size = std.builtin.Type.Pointer.Size;
- const size: Size = switch (token_tags[info.main_token]) {
+ const size: std.builtin.Type.Pointer.Size = switch (token_tags[info.main_token]) {
.asterisk,
.asterisk_asterisk,
- => .One,
+ => .one,
.l_bracket => switch (token_tags[info.main_token + 1]) {
- .asterisk => if (token_tags[info.main_token + 2] == .identifier) Size.C else Size.Many,
- else => Size.Slice,
+ .asterisk => if (token_tags[info.main_token + 2] == .identifier) .c else .many,
+ else => .slice,
},
else => unreachable,
};
@@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType
// positives. Therefore, start after a sentinel if there is one and
// skip over any align node and bit range nodes.
var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) {
- .Many, .C => info.main_token + 1,
+ .many, .c => info.main_token + 1,
else => info.main_token,
};
const end = tree.firstToken(info.child_type);
lib/std/zig/AstGen.zig
@@ -3917,7 +3917,7 @@ fn ptrType(
node: Ast.Node.Index,
ptr_info: Ast.full.PtrType,
) InnerError!Zir.Inst.Ref {
- if (ptr_info.size == .C and ptr_info.allowzero_token != null) {
+ if (ptr_info.size == .c and ptr_info.allowzero_token != null) {
return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{});
}
@@ -3946,7 +3946,7 @@ fn ptrType(
.{ .rl = .{ .ty = elem_type } },
ptr_info.ast.sentinel,
switch (ptr_info.size) {
- .Slice => .slice_sentinel,
+ .slice => .slice_sentinel,
else => .pointer_sentinel,
},
);
lib/std/zig/c_translation.zig
@@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize {
}
},
.pointer => |ptr| {
- if (ptr.size == .Slice) {
+ if (ptr.size == .slice) {
@compileError("Cannot use C sizeof on slice type " ++ @typeName(T));
}
// for strings, sizeof("a") returns 2.
@@ -178,7 +178,7 @@ pub fn sizeof(target: anytype) usize {
// in the .array case above, but strings remain literals
// and are therefore always pointers, so they need to be
// specially handled here.
- if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) {
+ if (ptr.size == .one and ptr.is_const and @typeInfo(ptr.child) == .array) {
const array_info = @typeInfo(ptr.child).array;
if ((array_info.child == u8 or array_info.child == u16) and
array_info.sentinel != null and
@@ -341,7 +341,7 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty
switch (@typeInfo(SelfType)) {
.pointer => |ptr| {
return @Type(.{ .pointer = .{
- .size = .C,
+ .size = .c,
.is_const = ptr.is_const,
.is_volatile = ptr.is_volatile,
.alignment = @alignOf(ElementType),
lib/std/zig/parser_test.zig
@@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" {
\\pub fn f(
\\ a: i32,
\\ b: i32,
- \\) callconv(.C) i32 {}
+ \\) callconv(.c) i32 {}
\\pub fn f(
\\ a: i32,
\\ b: i32,
@@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" {
\\pub fn f(
\\ a: i32,
\\ b: i32,
- \\) align(8) callconv(.C) i32 {}
+ \\) align(8) callconv(.c) i32 {}
\\pub fn f(
\\ a: i32,
\\ b: i32,
- \\) align(8) linksection(".text") callconv(.C) i32 {}
+ \\) align(8) linksection(".text") callconv(.c) i32 {}
\\pub fn f(
\\ a: i32,
\\ b: i32,
- \\) linksection(".text") callconv(.C) i32 {}
+ \\) linksection(".text") callconv(.c) i32 {}
\\
);
}
lib/std/zig/render.zig
@@ -938,7 +938,7 @@ fn renderArrayType(
fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void {
const tree = r.tree;
switch (ptr_type.size) {
- .One => {
+ .one => {
// Since ** tokens exist and the same token is shared by two
// nested pointer types, we check to see if we are the parent
// in such a relationship. If so, skip rendering anything for
@@ -951,7 +951,7 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
}
try renderToken(r, ptr_type.ast.main_token, .none); // asterisk
},
- .Many => {
+ .many => {
if (ptr_type.ast.sentinel == 0) {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
@@ -964,13 +964,13 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket
}
},
- .C => {
+ .c => {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
try renderToken(r, ptr_type.ast.main_token + 2, .none); // c
try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket
},
- .Slice => {
+ .slice => {
if (ptr_type.ast.sentinel == 0) {
try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket
lib/std/c.zig
@@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) {
=> if (builtin.target.isMusl())
linux.Sigaction
else if (builtin.target.ptrBitWidth() == 64) extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
flags: c_uint,
handler: extern union {
@@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) {
sigaction: ?sigaction_fn,
},
mask: sigset_t,
- restorer: ?*const fn () callconv(.C) void = null,
+ restorer: ?*const fn () callconv(.c) void = null,
} else extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
flags: c_uint,
handler: extern union {
@@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) {
sigaction: ?sigaction_fn,
},
mask: sigset_t,
- restorer: ?*const fn () callconv(.C) void = null,
+ restorer: ?*const fn () callconv(.c) void = null,
__resv: [1]c_int = .{0},
},
.s390x => if (builtin.abi == .gnu) extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) {
},
__glibc_reserved0: c_int = 0,
flags: c_uint,
- restorer: ?*const fn () callconv(.C) void = null,
+ restorer: ?*const fn () callconv(.c) void = null,
mask: sigset_t,
} else linux.Sigaction,
else => linux.Sigaction,
},
.emscripten => emscripten.Sigaction,
.netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
handler: extern union {
handler: ?handler_fn,
@@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {
flags: c_uint,
},
.dragonfly, .freebsd => extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler
handler: extern union {
@@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {
mask: sigset_t,
},
.solaris, .illumos => extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal options
flags: c_uint,
@@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {
mask: sigset_t,
},
.haiku => extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler
handler: extern union {
@@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {
userdata: *allowzero anyopaque = undefined,
},
.openbsd => extern struct {
- pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
- pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
+ pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
+ pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
/// signal handler
handler: extern union {
@@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {
else => void,
};
-pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;
+pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int;
pub const Stat = switch (native_os) {
.linux => switch (native_arch) {
@@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
pub extern "c" fn pthread_create(
noalias newthread: *pthread_t,
noalias attr: ?*const pthread_attr_t,
- start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque,
+ start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque,
noalias arg: ?*anyopaque,
) E;
pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
@@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t;
pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
pub extern "c" fn pthread_detach(thread: pthread_t) E;
pub extern "c" fn pthread_atfork(
- prepare: ?*const fn () callconv(.C) void,
- parent: ?*const fn () callconv(.C) void,
- child: ?*const fn () callconv(.C) void,
+ prepare: ?*const fn () callconv(.c) void,
+ parent: ?*const fn () callconv(.c) void,
+ child: ?*const fn () callconv(.c) void,
) c_int;
pub extern "c" fn pthread_key_create(
key: *pthread_key_t,
- destructor: ?*const fn (value: *anyopaque) callconv(.C) void,
+ destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
) E;
pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque;
@@ -9530,12 +9530,12 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
-pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;
+pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E;
+pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
+pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
+pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
+pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
+pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E;
pub const pthread_t = *opaque {};
pub const FILE = opaque {};
lib/std/debug.zig
@@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void {
updateSegfaultHandler(&act);
}
-fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn {
+fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
// Reset to the default handler so that if a segfault happens in this handler it will crash
// the process. Also when this handler returns, the original instruction will be repeated
// and the resulting segfault will crash the process rather than continually dump stack traces.
lib/std/fmt.zig
@@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
switch (@typeInfo(T)) {
.pointer => |info| {
try writer.writeAll(@typeName(info.child) ++ "@");
- if (info.size == .Slice)
+ if (info.size == .slice)
try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
else
try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
@@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {
switch (@typeInfo(T)) {
.array, .vector => return ANY,
.pointer => |ptr_info| switch (ptr_info.size) {
- .One => switch (@typeInfo(ptr_info.child)) {
+ .one => switch (@typeInfo(ptr_info.child)) {
.array => return ANY,
else => {},
},
- .Many, .C => return "*",
- .Slice => return ANY,
+ .many, .c => return "*",
+ .slice => return ANY,
},
.optional => |info| return "?" ++ defaultSpec(info.child),
.error_union => |info| return "!" ++ defaultSpec(info.payload),
@@ -624,13 +624,13 @@ pub fn formatType(
try writer.writeAll(" }");
},
.pointer => |ptr_info| switch (ptr_info.size) {
- .One => switch (@typeInfo(ptr_info.child)) {
+ .one => switch (@typeInfo(ptr_info.child)) {
.array, .@"enum", .@"union", .@"struct" => {
return formatType(value.*, actual_fmt, options, writer, max_depth);
},
else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
},
- .Many, .C => {
+ .many, .c => {
if (actual_fmt.len == 0)
@compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
if (ptr_info.sentinel) |_| {
@@ -641,7 +641,7 @@ pub fn formatType(
}
invalidFmtError(fmt, value);
},
- .Slice => {
+ .slice => {
if (actual_fmt.len == 0)
@compileError("cannot format slice without a specifier (i.e. {s} or {any})");
if (max_depth == 0) {
lib/std/mem.zig
@@ -262,7 +262,7 @@ pub fn zeroes(comptime T: type) T {
},
.pointer => |ptr_info| {
switch (ptr_info.size) {
- .Slice => {
+ .slice => {
if (ptr_info.sentinel) |sentinel| {
if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) {
return ""; // A special case for the most common use-case: null-terminated strings.
@@ -272,10 +272,10 @@ pub fn zeroes(comptime T: type) T {
return &[_]ptr_info.child{};
}
},
- .C => {
+ .c => {
return null;
},
- .One, .Many => {
+ .one, .many => {
if (ptr_info.is_allowzero) return @ptrFromInt(0);
@compileError("Only nullable and allowzero pointers can be set to zero.");
},
@@ -781,14 +781,14 @@ fn Span(comptime T: type) type {
.pointer => |ptr_info| {
var new_ptr_info = ptr_info;
switch (ptr_info.size) {
- .C => {
+ .c => {
new_ptr_info.sentinel = &@as(ptr_info.child, 0);
new_ptr_info.is_allowzero = false;
},
- .Many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
- .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
+ .many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
+ .one, .slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
}
- new_ptr_info.size = .Slice;
+ new_ptr_info.size = .slice;
return @Type(.{ .pointer = new_ptr_info });
},
else => {},
@@ -845,9 +845,9 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
},
.pointer => |ptr_info| {
var new_ptr_info = ptr_info;
- new_ptr_info.size = .Slice;
+ new_ptr_info.size = .slice;
switch (ptr_info.size) {
- .One => switch (@typeInfo(ptr_info.child)) {
+ .one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| {
new_ptr_info.child = array_info.child;
// The return type must only be sentinel terminated if we are guaranteed
@@ -864,7 +864,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
},
else => {},
},
- .Many, .Slice => {
+ .many, .slice => {
// The return type must only be sentinel terminated if we are guaranteed
// to find the value searched for, which is only the case if it matches
// the sentinel of the type passed.
@@ -877,7 +877,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
}
}
},
- .C => {
+ .c => {
new_ptr_info.sentinel = &end;
// C pointers are always allowzero, but we don't want the return type to be.
assert(new_ptr_info.is_allowzero);
@@ -957,7 +957,7 @@ test sliceTo {
fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
switch (@typeInfo(@TypeOf(ptr))) {
.pointer => |ptr_info| switch (ptr_info.size) {
- .One => switch (@typeInfo(ptr_info.child)) {
+ .one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| {
if (array_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
@@ -969,7 +969,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
},
else => {},
},
- .Many => if (ptr_info.sentinel) |sentinel_ptr| {
+ .many => if (ptr_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) {
return indexOfSentinel(ptr_info.child, end, ptr);
@@ -981,11 +981,11 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
while (ptr[i] != end and ptr[i] != sentinel) i += 1;
return i;
},
- .C => {
+ .c => {
assert(ptr != null);
return indexOfSentinel(ptr_info.child, end, ptr);
},
- .Slice => {
+ .slice => {
if (ptr_info.sentinel) |sentinel_ptr| {
const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
if (sentinel == end) {
@@ -1039,13 +1039,13 @@ test lenSliceTo {
pub fn len(value: anytype) usize {
switch (@typeInfo(@TypeOf(value))) {
.pointer => |info| switch (info.size) {
- .Many => {
+ .many => {
const sentinel_ptr = info.sentinel orelse
@compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
return indexOfSentinel(info.child, sentinel, value);
},
- .C => {
+ .c => {
assert(value != null);
return indexOfSentinel(info.child, 0, value);
},
@@ -3582,19 +3582,19 @@ fn ReverseIterator(comptime T: type) type {
const Pointer = blk: {
switch (@typeInfo(T)) {
.pointer => |ptr_info| switch (ptr_info.size) {
- .One => switch (@typeInfo(ptr_info.child)) {
+ .one => switch (@typeInfo(ptr_info.child)) {
.array => |array_info| {
var new_ptr_info = ptr_info;
- new_ptr_info.size = .Many;
+ new_ptr_info.size = .many;
new_ptr_info.child = array_info.child;
new_ptr_info.sentinel = array_info.sentinel;
break :blk @Type(.{ .pointer = new_ptr_info });
},
else => {},
},
- .Slice => {
+ .slice => {
var new_ptr_info = ptr_info;
- new_ptr_info.size = .Many;
+ new_ptr_info.size = .many;
break :blk @Type(.{ .pointer = new_ptr_info });
},
else => {},
@@ -3606,7 +3606,7 @@ fn ReverseIterator(comptime T: type) type {
const Element = std.meta.Elem(Pointer);
const ElementPointer = @Type(.{ .pointer = ptr: {
var ptr = @typeInfo(Pointer).pointer;
- ptr.size = .One;
+ ptr.size = .one;
ptr.child = Element;
ptr.sentinel = null;
break :ptr ptr;
@@ -3912,7 +3912,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
const T = @TypeOf(ptr);
const info = @typeInfo(T);
- if (info != .pointer or info.pointer.size != .Many)
+ if (info != .pointer or info.pointer.size != .many)
@compileError("expected many item pointer, got " ++ @typeName(T));
// Do nothing if the pointer is already well-aligned.
@@ -3986,9 +3986,9 @@ fn CopyPtrAttrs(
fn AsBytesReturnType(comptime P: type) type {
const pointer = @typeInfo(P).pointer;
- assert(pointer.size == .One);
+ assert(pointer.size == .one);
const size = @sizeOf(pointer.child);
- return CopyPtrAttrs(P, .One, [size]u8);
+ return CopyPtrAttrs(P, .one, [size]u8);
}
/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes.
@@ -4071,7 +4071,7 @@ test toBytes {
}
fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
- return CopyPtrAttrs(B, .One, T);
+ return CopyPtrAttrs(B, .one, T);
}
/// Given a pointer to an array of bytes, returns a pointer to a value of the specified type
@@ -4150,7 +4150,7 @@ test bytesToValue {
}
fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {
- return CopyPtrAttrs(bytesType, .Slice, T);
+ return CopyPtrAttrs(bytesType, .slice, T);
}
/// Given a slice of bytes, returns a slice of the specified type
@@ -4162,7 +4162,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T,
return &[0]T{};
}
- const cast_target = CopyPtrAttrs(@TypeOf(bytes), .Many, T);
+ const cast_target = CopyPtrAttrs(@TypeOf(bytes), .many, T);
return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))];
}
@@ -4237,7 +4237,7 @@ test "bytesAsSlice preserves pointer attributes" {
}
fn SliceAsBytesReturnType(comptime Slice: type) type {
- return CopyPtrAttrs(Slice, .Slice, u8);
+ return CopyPtrAttrs(Slice, .slice, u8);
}
/// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes.
@@ -4251,7 +4251,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {
// it may be equal to zero and fail a null check
if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{};
- const cast_target = CopyPtrAttrs(Slice, .Many, u8);
+ const cast_target = CopyPtrAttrs(Slice, .many, u8);
return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))];
}
@@ -4540,7 +4540,7 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t
const info = @typeInfo(AttributeSource).pointer;
return @Type(.{
.pointer = .{
- .size = .Slice,
+ .size = .slice,
.is_const = info.is_const,
.is_volatile = info.is_volatile,
.is_allowzero = info.is_allowzero,
lib/std/meta.zig
@@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type {
.array => |info| return info.child,
.vector => |info| return info.child,
.pointer => |info| switch (info.size) {
- .One => switch (@typeInfo(info.child)) {
+ .one => switch (@typeInfo(info.child)) {
.array => |array_info| return array_info.child,
.vector => |vector_info| return vector_info.child,
else => {},
},
- .Many, .C, .Slice => return info.child,
+ .many, .c, .slice => return info.child,
},
.optional => |info| return Elem(info.child),
else => {},
@@ -138,11 +138,11 @@ pub inline fn sentinel(comptime T: type) ?Elem(T) {
},
.pointer => |info| {
switch (info.size) {
- .Many, .Slice => {
+ .many, .slice => {
const sentinel_ptr = info.sentinel orelse return null;
return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
},
- .One => switch (@typeInfo(info.child)) {
+ .one => switch (@typeInfo(info.child)) {
.array => |array_info| {
const sentinel_ptr = array_info.sentinel orelse return null;
return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
@@ -178,7 +178,7 @@ fn testSentinel() !void {
pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
switch (@typeInfo(T)) {
.pointer => |info| switch (info.size) {
- .One => switch (@typeInfo(info.child)) {
+ .one => switch (@typeInfo(info.child)) {
.array => |array_info| return @Type(.{
.pointer = .{
.size = info.size,
@@ -199,7 +199,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
}),
else => {},
},
- .Many, .Slice => return @Type(.{
+ .many, .slice => return @Type(.{
.pointer = .{
.size = info.size,
.is_const = info.is_const,
@@ -215,7 +215,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
},
.optional => |info| switch (@typeInfo(info.child)) {
.pointer => |ptr_info| switch (ptr_info.size) {
- .Many => return @Type(.{
+ .many => return @Type(.{
.optional = .{
.child = @Type(.{
.pointer = .{
@@ -786,8 +786,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
},
.pointer => |info| {
return switch (info.size) {
- .One, .Many, .C => a == b,
- .Slice => a.ptr == b.ptr and a.len == b.len,
+ .one, .many, .c => a == b,
+ .slice => a.ptr == b.ptr and a.len == b.len,
};
},
.optional => {
@@ -1090,7 +1090,7 @@ test "Tuple deduplication" {
test "ArgsTuple forwarding" {
const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);
- const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.C) noreturn);
+ const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn);
if (T1 != T2) {
@compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple");
@@ -1144,8 +1144,8 @@ test hasFn {
pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
return switch (@typeInfo(T)) {
.pointer => |P| switch (P.size) {
- .One => hasFn(P.child, name),
- .Many, .Slice, .C => false,
+ .one => hasFn(P.child, name),
+ .many, .slice, .c => false,
},
else => hasFn(T, name),
};
@@ -1200,12 +1200,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
.int => |info| @sizeOf(T) * 8 == info.bits,
- .pointer => |info| info.size != .Slice,
+ .pointer => |info| info.size != .slice,
.optional => |info| switch (@typeInfo(info.child)) {
.pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
- .Slice, .C => false,
- .One, .Many => true,
+ .slice, .c => false,
+ .one, .many => true,
},
else => false,
},
lib/std/posix.zig
@@ -5552,7 +5552,7 @@ pub fn dl_iterate_phdr(
if (builtin.link_libc) {
switch (system.dl_iterate_phdr(struct {
- fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int {
+ fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int {
const context_ptr: *const Context = @ptrCast(@alignCast(data));
callback(info, size, context_ptr.*) catch |err| return @intFromError(err);
return 0;
lib/std/Progress.zig
@@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void {
}
}
-fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {
+fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
_ = info;
_ = ctx_ptr;
assert(sig == posix.SIG.WINCH);
lib/std/Random.zig
@@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
const Ptr = @TypeOf(pointer);
assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
- assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer
+ assert(@typeInfo(Ptr).pointer.size == .one); // Must be a single-item pointer
assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
const gen = struct {
fn fill(ptr: *anyopaque, buf: []u8) void {
lib/std/testing.zig
@@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
.pointer => |pointer| {
switch (pointer.size) {
- .One, .Many, .C => {
+ .one, .many, .c => {
if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual;
}
},
- .Slice => {
+ .slice => {
if (actual.ptr != expected.ptr) {
print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr });
return error.TestExpectedEqual;
@@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
.pointer => |pointer| {
switch (pointer.size) {
// We have no idea what is behind those pointers, so the best we can do is `==` check.
- .C, .Many => {
+ .c, .many => {
if (actual != expected) {
print("expected {*}, found {*}\n", .{ expected, actual });
return error.TestExpectedEqual;
}
},
- .One => {
+ .one => {
// Length of those pointers are runtime value, so the best we can do is `==` check.
switch (@typeInfo(pointer.child)) {
.@"fn", .@"opaque" => {
@@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
else => try expectEqualDeep(expected.*, actual.*),
}
},
- .Slice => {
+ .slice => {
if (expected.len != actual.len) {
print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
return error.TestExpectedEqual;
src/arch/aarch64/CodeGen.zig
@@ -2398,7 +2398,7 @@ fn ptrArithmetic(
const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
- .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
+ .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
const elem_size = elem_ty.abiSize(zcu);
src/arch/arm/CodeGen.zig
@@ -3919,7 +3919,7 @@ fn ptrArithmetic(
const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
- .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
+ .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
const elem_size: u32 = @intCast(elem_ty.abiSize(zcu));
src/arch/riscv64/abi.zig
@@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
return result;
},
.pointer => switch (ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
result[0] = .integer;
result[1] = .integer;
return result;
src/arch/riscv64/CodeGen.zig
@@ -7843,15 +7843,15 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
if (elem_abi_size == 1) {
const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
- .Slice => dst_ptr,
- .One => dst_ptr,
- .C, .Many => unreachable,
+ .slice => dst_ptr,
+ .one => dst_ptr,
+ .c, .many => unreachable,
};
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
- .Slice => dst_ptr.address().offset(8).deref(),
- .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
- .C, .Many => unreachable,
+ .slice => dst_ptr.address().offset(8).deref(),
+ .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
+ .c, .many => unreachable,
};
const len_lock: ?RegisterLock = switch (len) {
.register => |reg| func.register_manager.lockRegAssumeUnused(reg),
@@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
// Length zero requires a runtime check - so we handle arrays specially
// here to elide it.
switch (dst_ptr_ty.ptrSize(zcu)) {
- .Slice => return func.fail("TODO: airMemset Slices", .{}),
- .One => {
+ .slice => return func.fail("TODO: airMemset Slices", .{}),
+ .one => {
const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
@@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
},
- .C, .Many => unreachable,
+ .c, .many => unreachable,
}
}
return func.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });
@@ -7906,7 +7906,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
const dst_ty = func.typeOf(bin_op.lhs);
const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) {
- .Slice => len: {
+ .slice => len: {
const len_reg, const len_lock = try func.allocReg(.int);
defer func.register_manager.unlockReg(len_lock);
@@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
);
break :len .{ .register = len_reg };
},
- .One => len: {
+ .one => len: {
const array_ty = dst_ty.childType(zcu);
break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
},
src/arch/sparc64/CodeGen.zig
@@ -2953,7 +2953,7 @@ fn binOp(
.pointer => {
const ptr_ty = lhs_ty;
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
- .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
+ .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
const elem_size = elem_ty.abiSize(zcu);
src/arch/wasm/CodeGen.zig
@@ -4726,7 +4726,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
const offset = try cg.resolveInst(bin_op.rhs);
const ptr_ty = cg.typeOf(bin_op.lhs);
const pointee_ty = switch (ptr_ty.ptrSize(zcu)) {
- .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
+ .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
else => ptr_ty.childType(zcu),
};
@@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
const ptr_ty = cg.typeOf(bin_op.lhs);
const value = try cg.resolveInst(bin_op.rhs);
const len = switch (ptr_ty.ptrSize(zcu)) {
- .Slice => try cg.sliceLen(ptr),
- .One => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
- .C, .Many => unreachable,
+ .slice => try cg.sliceLen(ptr),
+ .one => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
+ .c, .many => unreachable,
};
- const elem_ty = if (ptr_ty.ptrSize(zcu) == .One)
+ const elem_ty = if (ptr_ty.ptrSize(zcu) == .one)
ptr_ty.childType(zcu).childType(zcu)
else
ptr_ty.childType(zcu);
@@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const src = try cg.resolveInst(bin_op.rhs);
const src_ty = cg.typeOf(bin_op.rhs);
const len = switch (dst_ty.ptrSize(zcu)) {
- .Slice => blk: {
+ .slice => blk: {
const slice_len = try cg.sliceLen(dst);
if (ptr_elem_ty.abiSize(zcu) != 1) {
try cg.emitWValue(slice_len);
@@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
break :blk slice_len;
},
- .One => @as(WValue, .{
+ .one => @as(WValue, .{
.imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))),
}),
- .C, .Many => unreachable,
+ .c, .many => unreachable,
};
const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty);
const src_ptr = try cg.sliceOrArrayPtr(src, src_ty);
src/arch/x86_64/abi.zig
@@ -108,7 +108,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
var result = [1]Class{.none} ** 8;
switch (ty.zigTypeTag(zcu)) {
.pointer => switch (ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
result[0] = .integer;
result[1] = .integer;
return result;
src/arch/x86_64/CodeGen.zig
@@ -9607,13 +9607,13 @@ fn genMulDivBinOp(
const manyptr_u32_ty = try pt.ptrType(.{
.child = .u32_type,
.flags = .{
- .size = .Many,
+ .size = .many,
},
});
const manyptr_const_u32_ty = try pt.ptrType(.{
.child = .u32_type,
.flags = .{
- .size = .Many,
+ .size = .many,
.is_const = true,
},
});
@@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
if (elem_abi_size == 1) {
const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
- .Slice => dst_ptr,
- .One => dst_ptr,
- .C, .Many => unreachable,
+ .slice => dst_ptr,
+ .one => dst_ptr,
+ .c, .many => unreachable,
};
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
// TODO: this only handles slices stored in the stack
- .Slice => dst_ptr.address().offset(8).deref(),
- .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
- .C, .Many => unreachable,
+ .slice => dst_ptr.address().offset(8).deref(),
+ .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
+ .c, .many => unreachable,
};
const len_lock: ?RegisterLock = switch (len) {
.register => |reg| self.register_manager.lockRegAssumeUnused(reg),
@@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
// Length zero requires a runtime check - so we handle arrays specially
// here to elide it.
switch (dst_ptr_ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu);
// TODO: this only handles slices stored in the stack
@@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
self.performReloc(skip_reloc);
},
- .One => {
+ .one => {
const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
@@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
},
- .C, .Many => unreachable,
+ .c, .many => unreachable,
}
}
return self.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });
@@ -16735,7 +16735,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock);
const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
- .Slice => len: {
+ .slice => len: {
const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
const len_lock = self.register_manager.lockRegAssumeUnused(len_reg);
defer self.register_manager.unlockReg(len_lock);
@@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
);
break :len .{ .register = len_reg };
},
- .One => len: {
+ .one => len: {
const array_ty = dst_ptr_ty.childType(zcu);
break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
},
- .C, .Many => unreachable,
+ .c, .many => unreachable,
};
const len_lock: ?RegisterLock = switch (len) {
.register => |reg| self.register_manager.lockRegAssumeUnused(reg),
src/codegen/c/Type.zig
@@ -1458,7 +1458,7 @@ pub const Pool = struct {
_ => |ip_index| switch (ip.indexToKey(ip_index)) {
.int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),
.ptr_type => |ptr_info| switch (ptr_info.flags.size) {
- .One, .Many, .C => {
+ .one, .many, .c => {
const elem_ctype = elem_ctype: {
if (ptr_info.packed_offset.host_size > 0 and
ptr_info.flags.vector_index == .none)
@@ -1505,7 +1505,7 @@ pub const Pool = struct {
.@"volatile" = ptr_info.flags.is_volatile,
});
},
- .Slice => {
+ .slice => {
const target = &mod.resolved_target.result;
var fields = [_]Info.Field{
.{
@@ -1598,7 +1598,7 @@ pub const Pool = struct {
switch (payload_type) {
.anyerror_type => return payload_ctype,
else => switch (ip.indexToKey(payload_type)) {
- .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .C and
+ .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .c and
!payload_ptr_info.flags.is_allowzero) return payload_ctype,
.error_set_type, .inferred_error_set_type => return payload_ctype,
else => {},
src/codegen/spirv/Section.zig
@@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
section.writeOperand(info.child, child);
},
.pointer => |info| {
- std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.
+ std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec.
for (operand) |item| {
section.writeOperand(info.child, item);
}
@@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
.@"enum" => 1,
.optional => |info| if (operand) |child| operandSize(info.child, child) else 0,
.pointer => |info| blk: {
- std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.
+ std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec.
var total: usize = 0;
for (operand) |item| {
total += operandSize(info.child, item);
src/codegen/c.zig
@@ -1589,14 +1589,14 @@ pub const DeclGen = struct {
try dg.fmtIntLiteral(try pt.undefValue(ty), location),
}),
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .One, .Many, .C => {
+ .one, .many, .c => {
try writer.writeAll("((");
try dg.renderCType(writer, ctype);
return writer.print("){x})", .{
try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other),
});
},
- .Slice => {
+ .slice => {
if (!location.isInitializer()) {
try writer.writeByte('(');
try dg.renderCType(writer, ctype);
@@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
try f.renderType(writer, inst_ty);
try writer.writeByte(')');
if (elem_has_bits) try writer.writeByte('&');
- if (elem_has_bits and ptr_ty.ptrSize(zcu) == .One) {
+ if (elem_has_bits and ptr_ty.ptrSize(zcu) == .one) {
// It's a pointer to an array, so we need to de-reference.
try f.writeCValueDeref(writer, ptr);
} else try f.writeCValue(writer, ptr, .Other);
@@ -5798,8 +5798,8 @@ fn fieldLocation(
}
},
.ptr_type => |ptr_info| switch (ptr_info.flags.size) {
- .One, .Many, .C => unreachable,
- .Slice => switch (field_index) {
+ .one, .many, .c => unreachable,
+ .slice => switch (field_index) {
0 => return .{ .field = .{ .identifier = "ptr" } },
1 => return .{ .field = .{ .identifier = "len" } },
else => unreachable,
@@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll("memset(");
switch (dest_ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
try writer.writeAll(", 0xaa, ");
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
@@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll(");\n");
}
},
- .One => {
+ .one => {
const array_ty = dest_ty.childType(zcu);
const len = array_ty.arrayLen(zcu) * elem_abi_size;
try f.writeCValue(writer, dest_slice, .FunctionArgument);
try writer.print(", 0xaa, {d});\n", .{len});
},
- .Many, .C => unreachable,
+ .many, .c => unreachable,
}
try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
return .none;
@@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
const elem_ptr_ty = try pt.ptrType(.{
.child = elem_ty.toIntern(),
.flags = .{
- .size = .C,
+ .size = .c,
},
});
@@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try f.writeCValue(writer, index, .Other);
try writer.writeAll(" != ");
switch (dest_ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
},
- .One => {
+ .one => {
const array_ty = dest_ty.childType(zcu);
try writer.print("{d}", .{array_ty.arrayLen(zcu)});
},
- .Many, .C => unreachable,
+ .many, .c => unreachable,
}
try writer.writeAll("; ++");
try f.writeCValue(writer, index, .Other);
@@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try writer.writeAll("memset(");
switch (dest_ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
try writer.writeAll(", ");
try f.writeCValue(writer, bitcasted, .FunctionArgument);
@@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
try writer.writeAll(");\n");
},
- .One => {
+ .one => {
const array_ty = dest_ty.childType(zcu);
const len = array_ty.arrayLen(zcu) * elem_abi_size;
@@ -6998,7 +6998,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
try f.writeCValue(writer, bitcasted, .FunctionArgument);
try writer.print(", {d});\n", .{len});
},
- .Many, .C => unreachable,
+ .many, .c => unreachable,
}
try f.freeCValue(inst, bitcasted);
try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
@@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
const src_ty = f.typeOf(bin_op.rhs);
const writer = f.object.writer();
- if (dest_ty.ptrSize(zcu) != .One) {
+ if (dest_ty.ptrSize(zcu) != .one) {
try writer.writeAll("if (");
try writeArrayLen(f, writer, dest_ptr, dest_ty);
try writer.writeAll(" != 0) ");
@@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t
const pt = f.object.dg.pt;
const zcu = pt.zcu;
switch (dest_ty.ptrSize(zcu)) {
- .One => try writer.print("{}", .{
+ .one => try writer.print("{}", .{
try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))),
}),
- .Many, .C => unreachable,
- .Slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
+ .many, .c => unreachable,
+ .slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
}
}
src/codegen/llvm.zig
@@ -2109,7 +2109,7 @@ pub const Object = struct {
ptr_info.flags.is_allowzero or
ptr_info.flags.is_const or
ptr_info.flags.is_volatile or
- ptr_info.flags.size == .Many or ptr_info.flags.size == .C or
+ ptr_info.flags.size == .many or ptr_info.flags.size == .c or
!Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu))
{
const bland_ptr_ty = try pt.ptrType(.{
@@ -2120,8 +2120,8 @@ pub const Object = struct {
.flags = .{
.alignment = ptr_info.flags.alignment,
.size = switch (ptr_info.flags.size) {
- .Many, .C, .One => .One,
- .Slice => .Slice,
+ .many, .c, .one => .one,
+ .slice => .slice,
},
},
});
@@ -3382,8 +3382,8 @@ pub const Object = struct {
toLlvmAddressSpace(ptr_type.flags.address_space, target),
);
break :type switch (ptr_type.flags.size) {
- .One, .Many, .C => ptr_ty,
- .Slice => try o.builder.structType(.normal, &.{
+ .one, .many, .c => ptr_ty,
+ .slice => try o.builder.structType(.normal, &.{
ptr_ty,
try o.lowerType(Type.usize),
}),
@@ -6988,7 +6988,7 @@ pub const FuncGen = struct {
const zcu = pt.zcu;
const llvm_usize = try o.lowerType(Type.usize);
switch (ty.ptrSize(zcu)) {
- .Slice => {
+ .slice => {
const len = try fg.wip.extractValue(ptr, &.{1}, "");
const elem_ty = ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu);
@@ -6996,13 +6996,13 @@ pub const FuncGen = struct {
const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size);
return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, "");
},
- .One => {
+ .one => {
const array_ty = ty.childType(zcu);
const elem_ty = array_ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu);
return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size);
},
- .Many, .C => unreachable,
+ .many, .c => unreachable,
}
}
@@ -8670,11 +8670,11 @@ pub const FuncGen = struct {
const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
switch (ptr_ty.ptrSize(zcu)) {
// It's a pointer to an array, so according to LLVM we need an extra GEP index.
- .One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
+ .one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
try o.builder.intValue(try o.lowerType(Type.usize), 0), offset,
}, ""),
- .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
- .Slice => {
+ .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
+ .slice => {
const base = try self.wip.extractValue(ptr, &.{0}, "");
return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, "");
},
@@ -8693,11 +8693,11 @@ pub const FuncGen = struct {
const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
switch (ptr_ty.ptrSize(zcu)) {
// It's a pointer to an array, so according to LLVM we need an extra GEP index.
- .One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
+ .one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset,
}, ""),
- .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
- .Slice => {
+ .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
+ .slice => {
const base = try self.wip.extractValue(ptr, &.{0}, "");
return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, "");
},
@@ -10034,9 +10034,9 @@ pub const FuncGen = struct {
const llvm_usize_ty = try o.lowerType(Type.usize);
const len = switch (ptr_ty.ptrSize(zcu)) {
- .Slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
- .One => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
- .Many, .C => unreachable,
+ .slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
+ .one => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
+ .many, .c => unreachable,
};
const elem_llvm_ty = try o.lowerType(elem_ty);
const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, "");
src/codegen/spirv.zig
@@ -1705,13 +1705,13 @@ const NavGen = struct {
const storage_class = self.spvStorageClass(ptr_info.flags.address_space);
const ptr_ty_id = try self.ptrType(child_ty, storage_class);
- if (target.os.tag == .vulkan and ptr_info.flags.size == .Many) {
+ if (target.os.tag == .vulkan and ptr_info.flags.size == .many) {
try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{
.array_stride = @intCast(child_ty.abiSize(zcu)),
} });
}
- if (ptr_info.flags.size != .Slice) {
+ if (ptr_info.flags.size != .slice) {
return ptr_ty_id;
}
@@ -4399,15 +4399,15 @@ const NavGen = struct {
const result_ty_id = try self.resolveType(result_ty, .direct);
switch (ptr_ty.ptrSize(zcu)) {
- .One => {
+ .one => {
// Pointer to array
// TODO: Is this correct?
return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id});
},
- .C, .Many => {
+ .c, .many => {
return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{});
},
- .Slice => {
+ .slice => {
// TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does.
const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0);
return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{});
@@ -4989,15 +4989,15 @@ const NavGen = struct {
const pt = self.pt;
const zcu = pt.zcu;
switch (ty.ptrSize(zcu)) {
- .Slice => return self.extractField(Type.usize, operand_id, 1),
- .One => {
+ .slice => return self.extractField(Type.usize, operand_id, 1),
+ .one => {
const array_ty = ty.childType(zcu);
const elem_ty = array_ty.childType(zcu);
const abi_size = elem_ty.abiSize(zcu);
const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size;
return try self.constInt(Type.usize, size, .direct);
},
- .Many, .C => unreachable,
+ .many, .c => unreachable,
}
}
src/link/tapi/yaml.zig
@@ -248,7 +248,7 @@ pub const Value = union(enum) {
.array => return encode(arena, &input),
.pointer => |info| switch (info.size) {
- .One => switch (@typeInfo(info.child)) {
+ .one => switch (@typeInfo(info.child)) {
.array => |child_info| {
const Slice = []const child_info.child;
return encode(arena, @as(Slice, input));
@@ -257,7 +257,7 @@ pub const Value = union(enum) {
@compileError("Unhandled type: {s}" ++ @typeName(info.child));
},
},
- .Slice => {
+ .slice => {
if (info.child == u8) {
return Value{ .string = try arena.dupe(u8, input) };
}
@@ -357,7 +357,7 @@ pub const Yaml = struct {
},
.pointer => |info| {
switch (info.size) {
- .Slice => {
+ .slice => {
var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);
for (self.docs.items, 0..) |doc, i| {
parsed[i] = try self.parseValue(info.child, doc);
@@ -446,7 +446,7 @@ pub const Yaml = struct {
const arena = self.arena.allocator();
switch (ptr_info.size) {
- .Slice => {
+ .slice => {
if (ptr_info.child == u8) {
return value.asString();
}
src/link/Dwarf.zig
@@ -3182,7 +3182,7 @@ fn updateLazyType(
try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
},
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .One, .Many, .C => {
+ .one, .many, .c => {
const ptr_child_type: Type = .fromInterned(ptr_type.child);
try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);
try wip_nav.strp(name);
@@ -3210,7 +3210,7 @@ fn updateLazyType(
try wip_nav.refType(ptr_child_type);
}
},
- .Slice => {
+ .slice => {
try wip_nav.abbrevCode(.generated_struct_type);
try wip_nav.strp(name);
try uleb128(diw, ty.abiSize(zcu));
src/Zcu/PerThread.zig
@@ -3068,7 +3068,7 @@ pub fn populateTestFunctions(
.child = test_fn_ty.toIntern(),
.flags = .{
.is_const = true,
- .size = .Slice,
+ .size = .slice,
},
});
const new_init = try pt.intern(.{ .slice = .{
@@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E
pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type {
var canon_info = info;
- if (info.flags.size == .C) canon_info.flags.is_allowzero = true;
+ if (info.flags.size == .c) canon_info.flags.is_allowzero = true;
// Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee
// type, we change it to 0 here. If this causes an assertion trip because the
@@ -3360,7 +3360,7 @@ pub fn manyConstPtrType(pt: Zcu.PerThread, child_type: Type) Allocator.Error!Typ
return pt.ptrType(.{
.child = child_type.toIntern(),
.flags = .{
- .size = .Many,
+ .size = .many,
.is_const = true,
},
});
src/clang.zig
@@ -177,7 +177,7 @@ pub const ASTUnit = opaque {
extern fn ZigClangASTUnit_visitLocalTopLevelDecls(
*ASTUnit,
context: ?*anyopaque,
- Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.C) bool,
+ Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.c) bool,
) bool;
pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin;
src/codegen.zig
@@ -945,7 +945,7 @@ pub fn genTypedValue(
switch (ty.zigTypeTag(zcu)) {
.void => return .{ .mcv = .none },
.pointer => switch (ty.ptrSize(zcu)) {
- .Slice => {},
+ .slice => {},
else => switch (val.toIntern()) {
.null_value => {
return .{ .mcv = .{ .immediate = 0 } };
src/crash_report.zig
@@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void {
debug.updateSegfaultHandler(&act);
}
-fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn {
+fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
// TODO: use alarm() here to prevent infinite loops
PanicSwitch.preDispatch();
src/InternPool.zig
@@ -1176,17 +1176,17 @@ const Local = struct {
} });
}
- pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .One }) {
+ pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .one }) {
try mutable.ensureUnusedCapacity(1);
return mutable.addOneAssumeCapacity();
}
- pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .One }) {
+ pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .one }) {
const index = mutable.mutate.len;
assert(index < mutable.list.header().capacity);
mutable.mutate.len = index + 1;
const mutable_view = mutable.view().slice();
- var ptr: PtrElem(.{ .size = .One }) = undefined;
+ var ptr: PtrElem(.{ .size = .one }) = undefined;
inline for (fields) |field| {
@field(ptr, @tagName(field)) = &mutable_view.items(field)[index];
}
@@ -1206,7 +1206,7 @@ const Local = struct {
pub fn appendSliceAssumeCapacity(
mutable: Mutable,
- slice: PtrElem(.{ .size = .Slice, .is_const = true }),
+ slice: PtrElem(.{ .size = .slice, .is_const = true }),
) void {
if (fields.len == 0) return;
const start = mutable.mutate.len;
@@ -1253,17 +1253,17 @@ const Local = struct {
return ptr_array;
}
- pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .Slice }) {
+ pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .slice }) {
try mutable.ensureUnusedCapacity(len);
return mutable.addManyAsSliceAssumeCapacity(len);
}
- pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .Slice }) {
+ pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .slice }) {
const start = mutable.mutate.len;
assert(len <= mutable.list.header().capacity - start);
mutable.mutate.len = @intCast(start + len);
const mutable_view = mutable.view().slice();
- var slice: PtrElem(.{ .size = .Slice }) = undefined;
+ var slice: PtrElem(.{ .size = .slice }) = undefined;
inline for (fields) |field| {
@field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len];
}
@@ -2060,7 +2060,7 @@ pub const Key = union(enum) {
};
pub const Flags = packed struct(u32) {
- size: Size = .One,
+ size: Size = .one,
/// `none` indicates the ABI alignment of the pointee_type. In this
/// case, this field *must* be set to `none`, otherwise the
/// `InternPool` equality and hashing functions will return incorrect
@@ -4891,7 +4891,7 @@ pub const Index = enum(u32) {
checkField(name ++ ".?", info.child);
},
.pointer => |info| {
- assert(info.size == .Slice);
+ assert(info.size == .slice);
checkConfig(name ++ ".len");
checkField(name ++ "[0]", info.child);
},
@@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .u8_type,
.flags = .{
- .size = .Many,
+ .size = .many,
},
} },
@@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .u8_type,
.flags = .{
- .size = .Many,
+ .size = .many,
.is_const = true,
},
} },
@@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{
.child = .u8_type,
.sentinel = .zero_u8,
.flags = .{
- .size = .Many,
+ .size = .many,
.is_const = true,
},
} },
@@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .comptime_int_type,
.flags = .{
- .size = .One,
+ .size = .one,
.is_const = true,
},
} },
@@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{
.{ .ptr_type = .{
.child = .u8_type,
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
} },
@@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{
.child = .u8_type,
.sentinel = .zero_u8,
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
} },
@@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
const many_ptr_item = many_ptr_unwrapped.getItem(ip);
assert(many_ptr_item.tag == .type_pointer);
var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data);
- ptr_info.flags.size = .Slice;
+ ptr_info.flags.size = .slice;
return .{ .ptr_type = ptr_info };
},
@@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
assert(ptr_type.child != .none);
assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child);
- if (ptr_type.flags.size == .Slice) {
+ if (ptr_type.flags.size == .slice) {
gop.cancel();
var new_key = key;
- new_key.ptr_type.flags.size = .Many;
+ new_key.ptr_type.flags.size = .many;
const ptr_type_index = try ip.get(gpa, tid, new_key);
gop = try ip.getOrPutKey(gpa, tid, key);
@@ -7588,7 +7588,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
}
var ptr_type_adjusted = ptr_type;
- if (ptr_type.flags.size == .C) ptr_type_adjusted.flags.is_allowzero = true;
+ if (ptr_type.flags.size == .c) ptr_type_adjusted.flags.is_allowzero = true;
items.appendAssumeCapacity(.{
.tag = .type_pointer,
@@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
},
.slice => |slice| {
- assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .Slice);
- assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .Many);
+ assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .slice);
+ assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .many);
items.appendAssumeCapacity(.{
.tag = .ptr_slice,
.data = try addExtra(extra, PtrSlice{
@@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
.ptr => |ptr| {
const ptr_type = ip.indexToKey(ptr.ty).ptr_type;
- assert(ptr_type.flags.size != .Slice);
+ assert(ptr_type.flags.size != .slice);
items.appendAssumeCapacity(switch (ptr.base_addr) {
.nav => |nav| .{
.tag = .ptr_nav,
@@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
.arr_elem, .field => |base_index| {
const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type;
switch (ptr.base_addr) {
- .arr_elem => assert(base_ptr_type.flags.size == .Many),
+ .arr_elem => assert(base_ptr_type.flags.size == .many),
.field => {
- assert(base_ptr_type.flags.size == .One);
+ assert(base_ptr_type.flags.size == .one);
switch (ip.indexToKey(base_ptr_type.child)) {
.tuple_type => |tuple_type| {
assert(ptr.base_addr == .field);
@@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
},
.ptr_type => |slice_type| {
assert(ptr.base_addr == .field);
- assert(slice_type.flags.size == .Slice);
+ assert(slice_type.flags.size == .slice);
assert(base_index.index < 2);
},
else => unreachable,
@@ -10314,12 +10314,12 @@ pub fn getCoerced(
} });
if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) {
- .One, .Many, .C => return ip.get(gpa, tid, .{ .ptr = .{
+ .one, .many, .c => return ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty,
.base_addr = .int,
.byte_offset = 0,
} }),
- .Slice => return ip.get(gpa, tid, .{ .slice = .{
+ .slice => return ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty,
.ptr = try ip.get(gpa, tid, .{ .ptr = .{
.ty = ip.slicePtrType(new_ty),
@@ -10408,7 +10408,7 @@ pub fn getCoerced(
},
else => {},
},
- .slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .Slice)
+ .slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .slice)
return ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty,
.ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)),
@@ -10416,7 +10416,7 @@ pub fn getCoerced(
} })
else if (ip.isIntegerType(new_ty))
return ip.getCoerced(gpa, tid, slice.ptr, new_ty),
- .ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .Slice)
+ .ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .slice)
return ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty,
.base_addr = ptr.base_addr,
@@ -10433,12 +10433,12 @@ pub fn getCoerced(
.opt => |opt| switch (ip.indexToKey(new_ty)) {
.ptr_type => |ptr_type| return switch (opt.val) {
.none => switch (ptr_type.flags.size) {
- .One, .Many, .C => try ip.get(gpa, tid, .{ .ptr = .{
+ .one, .many, .c => try ip.get(gpa, tid, .{ .ptr = .{
.ty = new_ty,
.base_addr = .int,
.byte_offset = 0,
} }),
- .Slice => try ip.get(gpa, tid, .{ .slice = .{
+ .slice => try ip.get(gpa, tid, .{ .slice = .{
.ty = new_ty,
.ptr = try ip.get(gpa, tid, .{ .ptr = .{
.ty = ip.slicePtrType(new_ty),
src/mutable_value.zig
@@ -256,7 +256,7 @@ pub const MutableValue = union(enum) {
},
.pointer => {
const ptr_ty = ip.indexToKey(ty_ip).ptr_type;
- if (ptr_ty.flags.size != .Slice) return;
+ if (ptr_ty.flags.size != .slice) return;
const ptr = try arena.create(MutableValue);
const len = try arena.create(MutableValue);
ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) };
src/Sema.zig
@@ -2479,7 +2479,7 @@ fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.Nul
.array => return field_name.eqlSlice("len", ip),
.pointer => {
const ptr_info = ty.ptrInfo(zcu);
- if (ptr_info.flags.size == .Slice) {
+ if (ptr_info.flags.size == .slice) {
return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip);
} else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
return field_name.eqlSlice("len", ip);
@@ -3653,7 +3653,7 @@ fn indexablePtrLenOrNone(
const zcu = pt.zcu;
const operand_ty = sema.typeOf(operand);
try checkMemOperand(sema, block, src, operand_ty);
- if (operand_ty.ptrSize(zcu) == .Many) return .none;
+ if (operand_ty.ptrSize(zcu) == .many) return .none;
const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "len", .no_embedded_nulls);
return sema.fieldVal(block, src, operand, field_name, src);
}
@@ -4544,7 +4544,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
const elem_ty = ptr_ty.childType(zcu);
switch (ptr_ty.ptrSize(zcu)) {
- .One => {
+ .one => {
const uncoerced_ty = sema.typeOf(uncoerced_val);
if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) {
// We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion.
@@ -4557,7 +4557,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
return sema.coerce(block, elem_ty, uncoerced_val, src);
}
},
- .Slice, .Many => {
+ .slice, .many => {
// Our goal is to coerce `uncoerced_val` to an array of `elem_ty`.
const val_ty = sema.typeOf(uncoerced_val);
switch (val_ty.zigTypeTag(zcu)) {
@@ -4573,7 +4573,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
});
return sema.coerce(block, want_ty, uncoerced_val, src);
},
- .C => {
+ .c => {
// There's nothing meaningful to do here, because we don't know if this is meant to be a
// single-pointer or a many-pointer.
return uncoerced_val;
@@ -4685,7 +4685,7 @@ fn zirValidateArrayInitRefTy(
assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice, .Many => {
+ .slice, .many => {
// Use array of correct length
const arr_ty = try pt.arrayType(.{
.len = extra.elem_count,
@@ -5502,9 +5502,9 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
if (operand_ty.zigTypeTag(zcu) != .pointer) {
return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)});
} else switch (operand_ty.ptrSize(zcu)) {
- .One, .C => {},
- .Many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}),
- .Slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}),
+ .one, .c => {},
+ .many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}),
+ .slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}),
}
if ((try sema.typeHasOnePossibleValue(operand_ty.childType(zcu))) != null) {
@@ -6521,7 +6521,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});
}
const ptr_ty_info = ptr_ty.ptrInfo(zcu);
- if (ptr_ty_info.flags.size == .Slice) {
+ if (ptr_ty_info.flags.size == .slice) {
return sema.fail(block, ptr_src, "export target cannot be slice", .{});
}
if (ptr_ty_info.packed_offset.host_size != 0) {
@@ -7271,7 +7271,7 @@ fn checkCallArgumentCount(
.@"fn" => break :func_ty callee_ty,
.pointer => {
const ptr_info = callee_ty.ptrInfo(zcu);
- if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
+ if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
break :func_ty Type.fromInterned(ptr_info.child);
}
},
@@ -7350,7 +7350,7 @@ fn callBuiltin(
.@"fn" => break :func_ty callee_ty,
.pointer => {
const ptr_info = callee_ty.ptrInfo(zcu);
- if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
+ if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
break :func_ty Type.fromInterned(ptr_info.child);
}
},
@@ -8344,8 +8344,8 @@ fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
};
try sema.checkMemOperand(block, src, ptr_ty);
const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
- .Slice, .Many, .C => ptr_ty.childType(zcu),
- .One => ptr_ty.childType(zcu).childType(zcu),
+ .slice, .many, .c => ptr_ty.childType(zcu),
+ .one => ptr_ty.childType(zcu).childType(zcu),
};
return Air.internedToRef(elem_ty.toIntern());
}
@@ -8943,7 +8943,7 @@ fn zirOptionalPayload(
const result_ty = switch (operand_ty.zigTypeTag(zcu)) {
.optional => operand_ty.optionalChild(zcu),
.pointer => t: {
- if (operand_ty.ptrSize(zcu) != .C) {
+ if (operand_ty.ptrSize(zcu) != .c) {
return sema.failWithExpectedOptionalType(block, src, operand_ty);
}
// TODO https://github.com/ziglang/zig/issues/6597
@@ -13972,7 +13972,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const has_field = hf: {
switch (ip.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice => {
+ .slice => {
if (field_name.eqlSlice("ptr", ip)) break :hf true;
if (field_name.eqlSlice("len", ip)) break :hf true;
break :hf false;
@@ -14797,7 +14797,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const slice_ty = try pt.ptrTypeSema(.{
.child = resolved_elem_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.address_space = ptr_as,
},
});
@@ -14925,7 +14925,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
.pointer => {
const ptr_info = operand_ty.ptrInfo(zcu);
switch (ptr_info.flags.size) {
- .Slice => {
+ .slice => {
const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand });
return Type.ArrayInfo{
.elem_type = Type.fromInterned(ptr_info.child),
@@ -14936,12 +14936,12 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
.len = try val.sliceLen(pt),
};
},
- .One => {
+ .one => {
if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
return Type.fromInterned(ptr_info.child).arrayInfo(zcu);
}
},
- .C, .Many => {},
+ .c, .many => {},
}
},
.@"struct" => {
@@ -16610,7 +16610,7 @@ fn analyzeArithmetic(
if (lhs_zig_ty_tag == .pointer) {
if (rhs_zig_ty_tag == .pointer) {
- if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) {
+ if (lhs_ty.ptrSize(zcu) != .slice and rhs_ty.ptrSize(zcu) != .slice) {
if (zir_tag != .sub) {
return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction");
}
@@ -16662,8 +16662,8 @@ fn analyzeArithmetic(
}
} else {
switch (lhs_ty.ptrSize(zcu)) {
- .One, .Slice => {},
- .Many, .C => {
+ .one, .slice => {},
+ .many, .c => {
const air_tag: Air.Inst.Tag = switch (zir_tag) {
.add => .ptr_add,
.sub => .ptr_sub,
@@ -17160,7 +17160,7 @@ fn analyzePtrArithmetic(
const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);
const ptr_ty = sema.typeOf(ptr);
const ptr_info = ptr_ty.ptrInfo(zcu);
- assert(ptr_info.flags.size == .Many or ptr_info.flags.size == .C);
+ assert(ptr_info.flags.size == .many or ptr_info.flags.size == .c);
const new_ptr_ty = t: {
// Calculate the new pointer alignment.
@@ -18092,7 +18092,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const slice_ty = (try pt.ptrTypeSema(.{
.child = param_info_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
})).toIntern();
@@ -18335,7 +18335,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const slice_errors_ty = try pt.ptrTypeSema(.{
.child = error_field_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
});
@@ -18462,7 +18462,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const slice_ty = (try pt.ptrTypeSema(.{
.child = enum_field_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
})).toIntern();
@@ -18575,7 +18575,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const slice_ty = (try pt.ptrTypeSema(.{
.child = union_field_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
})).toIntern();
@@ -18770,7 +18770,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
const slice_ty = (try pt.ptrTypeSema(.{
.child = struct_field_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
})).toIntern();
@@ -18879,7 +18879,7 @@ fn typeInfoDecls(
const slice_ty = (try pt.ptrTypeSema(.{
.child = declaration_ty.toIntern(),
.flags = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
},
})).toIntern();
@@ -20138,12 +20138,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
}
if (elem_ty.zigTypeTag(zcu) == .@"fn") {
- if (inst_data.size != .One) {
+ if (inst_data.size != .one) {
return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{});
}
- } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
+ } else if (inst_data.size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{});
- } else if (inst_data.size == .C) {
+ } else if (inst_data.size == .c) {
if (!try sema.validateExternType(elem_ty, .other)) {
const msg = msg: {
const msg = try sema.errMsg(elem_ty_src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});
@@ -21645,7 +21645,7 @@ fn zirReify(
const actual_sentinel: InternPool.Index = s: {
if (!sentinel_val.isNull(zcu)) {
- if (ptr_size == .One or ptr_size == .C) {
+ if (ptr_size == .one or ptr_size == .c) {
return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{});
}
const sentinel_ptr_val = sentinel_val.optionalValue(zcu).?;
@@ -21660,12 +21660,12 @@ fn zirReify(
if (elem_ty.zigTypeTag(zcu) == .noreturn) {
return sema.fail(block, src, "pointer to noreturn not allowed", .{});
} else if (elem_ty.zigTypeTag(zcu) == .@"fn") {
- if (ptr_size != .One) {
+ if (ptr_size != .one) {
return sema.fail(block, src, "function pointers must be single pointers", .{});
}
- } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
+ } else if (ptr_size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{});
- } else if (ptr_size == .C) {
+ } else if (ptr_size == .c) {
if (!try sema.validateExternType(elem_ty, .other)) {
const msg = msg: {
const msg = try sema.errMsg(src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});
@@ -23321,21 +23321,21 @@ fn ptrCastFull(
try Type.fromInterned(src_info.child).resolveLayout(pt);
try Type.fromInterned(dest_info.child).resolveLayout(pt);
- const src_slice_like = src_info.flags.size == .Slice or
- (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array);
+ const src_slice_like = src_info.flags.size == .slice or
+ (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array);
- const dest_slice_like = dest_info.flags.size == .Slice or
- (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array);
+ const dest_slice_like = dest_info.flags.size == .slice or
+ (dest_info.flags.size == .one and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array);
- if (dest_info.flags.size == .Slice and !src_slice_like) {
+ if (dest_info.flags.size == .slice and !src_slice_like) {
return sema.fail(block, src, "illegal pointer cast to slice", .{});
}
- if (dest_info.flags.size == .Slice) {
+ if (dest_info.flags.size == .slice) {
const src_elem_size = switch (src_info.flags.size) {
- .Slice => Type.fromInterned(src_info.child).abiSize(zcu),
+ .slice => Type.fromInterned(src_info.child).abiSize(zcu),
// pointer to array
- .One => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu),
+ .one => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu),
else => unreachable,
};
const dest_elem_size = Type.fromInterned(dest_info.child).abiSize(zcu);
@@ -23350,17 +23350,17 @@ fn ptrCastFull(
check_size: {
if (src_info.flags.size == dest_info.flags.size) break :check_size;
if (src_slice_like and dest_slice_like) break :check_size;
- if (src_info.flags.size == .C) break :check_size;
- if (dest_info.flags.size == .C) break :check_size;
+ if (src_info.flags.size == .c) break :check_size;
+ if (dest_info.flags.size == .c) break :check_size;
return sema.failWithOwnedErrorMsg(block, msg: {
const msg = try sema.errMsg(src, "cannot implicitly convert {s} to {s}", .{
pointerSizeString(src_info.flags.size),
pointerSizeString(dest_info.flags.size),
});
errdefer msg.destroy(sema.gpa);
- if (dest_info.flags.size == .Many and
- (src_info.flags.size == .Slice or
- (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
+ if (dest_info.flags.size == .many and
+ (src_info.flags.size == .slice or
+ (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
{
try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
} else {
@@ -23371,7 +23371,7 @@ fn ptrCastFull(
}
check_child: {
- const src_child = if (dest_info.flags.size == .Slice and src_info.flags.size == .One) blk: {
+ const src_child = if (dest_info.flags.size == .slice and src_info.flags.size == .one) blk: {
// *[n]T -> []T
break :blk Type.fromInterned(src_info.child).childType(zcu);
} else Type.fromInterned(src_info.child);
@@ -23402,12 +23402,12 @@ fn ptrCastFull(
check_sent: {
if (dest_info.sentinel == .none) break :check_sent;
- if (src_info.flags.size == .C) break :check_sent;
+ if (src_info.flags.size == .c) break :check_sent;
if (src_info.sentinel != .none) {
const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child);
if (dest_info.sentinel == coerced_sent) break :check_sent;
}
- if (src_slice_like and src_info.flags.size == .One and dest_info.flags.size == .Slice) {
+ if (src_slice_like and src_info.flags.size == .one and dest_info.flags.size == .slice) {
// [*]nT -> []T
const arr_ty = Type.fromInterned(src_info.child);
if (arr_ty.sentinel(zcu)) |src_sentinel| {
@@ -23555,7 +23555,7 @@ fn ptrCastFull(
}
}
- const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: {
+ const ptr = if (src_info.flags.size == .slice and dest_info.flags.size != .slice) ptr: {
if (operand_ty.zigTypeTag(zcu) == .optional) {
break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty);
} else {
@@ -23563,10 +23563,10 @@ fn ptrCastFull(
}
} else operand;
- const dest_ptr_ty = if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) blk: {
+ const dest_ptr_ty = if (dest_info.flags.size == .slice and src_info.flags.size != .slice) blk: {
// Only convert to a many-pointer at first
var info = dest_info;
- info.flags.size = .Many;
+ info.flags.size = .many;
const ty = try pt.ptrTypeSema(info);
if (dest_ty.zigTypeTag(zcu) == .optional) {
break :blk try pt.optionalType(ty.toIntern());
@@ -23594,7 +23594,7 @@ fn ptrCastFull(
}
}
}
- if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) {
+ if (dest_info.flags.size == .slice and src_info.flags.size != .slice) {
if (ptr_val.isUndef(zcu)) return pt.undefRef(dest_ty);
const arr_len = try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu));
const ptr_val_key = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr;
@@ -23622,7 +23622,7 @@ fn ptrCastFull(
{
const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
- const ok = if (src_info.flags.size == .Slice and dest_info.flags.size == .Slice) ok: {
+ const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: {
const len = try sema.analyzeSliceLen(block, operand_src, ptr);
const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);
break :ok try block.addBinOp(.bool_or, len_zero, is_non_zero);
@@ -23639,7 +23639,7 @@ fn ptrCastFull(
const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);
const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize);
- const ok = if (src_info.flags.size == .Slice and dest_info.flags.size == .Slice) ok: {
+ const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: {
const len = try sema.analyzeSliceLen(block, operand_src, ptr);
const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);
break :ok try block.addBinOp(.bool_or, len_zero, is_aligned);
@@ -23672,7 +23672,7 @@ fn ptrCastFull(
break :ptr try block.addBitCast(dest_ptr_ty, ptr);
};
- if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) {
+ if (dest_info.flags.size == .slice and src_info.flags.size != .slice) {
// We have to construct a slice using the operand's child's array length
// Note that we know from the check at the start of the function that operand_ty is slice-like
const arr_len = Air.internedToRef((try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu))).toIntern());
@@ -24066,8 +24066,8 @@ fn checkInvalidPtrIntArithmetic(
const zcu = pt.zcu;
switch (try ty.zigTypeTagOrPoison(zcu)) {
.pointer => switch (ty.ptrSize(zcu)) {
- .One, .Slice => return,
- .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),
+ .one, .slice => return,
+ .many, .c => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),
},
else => return,
}
@@ -25384,7 +25384,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr");
try sema.checkPtrType(block, inst_src, parent_ptr_ty, true);
const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
- if (parent_ptr_info.flags.size != .One) {
+ if (parent_ptr_info.flags.size != .one) {
return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)});
}
const parent_ty = Type.fromInterned(parent_ptr_info.child);
@@ -25862,7 +25862,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
const zcu = pt.zcu;
const ptr_ty = sema.typeOf(ptr);
const info = ptr_ty.ptrInfo(zcu);
- if (info.flags.size == .One) {
+ if (info.flags.size == .one) {
// Already an array pointer.
return ptr;
}
@@ -25880,7 +25880,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
.address_space = info.flags.address_space,
},
});
- const non_slice_ptr = if (info.flags.size == .Slice)
+ const non_slice_ptr = if (info.flags.size == .slice)
try block.addTyOp(.slice_ptr, ptr_ty.slicePtrFieldType(zcu), ptr)
else
ptr;
@@ -26069,22 +26069,22 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
const new_dest_ptr_ty = sema.typeOf(new_dest_ptr);
const raw_dest_ptr = if (new_dest_ptr_ty.isSlice(zcu))
try sema.analyzeSlicePtr(block, dest_src, new_dest_ptr, new_dest_ptr_ty)
- else if (new_dest_ptr_ty.ptrSize(zcu) == .One) ptr: {
+ else if (new_dest_ptr_ty.ptrSize(zcu) == .one) ptr: {
var dest_manyptr_ty_key = zcu.intern_pool.indexToKey(new_dest_ptr_ty.toIntern()).ptr_type;
- assert(dest_manyptr_ty_key.flags.size == .One);
+ assert(dest_manyptr_ty_key.flags.size == .one);
dest_manyptr_ty_key.child = dest_elem_ty.toIntern();
- dest_manyptr_ty_key.flags.size = .Many;
+ dest_manyptr_ty_key.flags.size = .many;
break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src);
} else new_dest_ptr;
const new_src_ptr_ty = sema.typeOf(new_src_ptr);
const raw_src_ptr = if (new_src_ptr_ty.isSlice(zcu))
try sema.analyzeSlicePtr(block, src_src, new_src_ptr, new_src_ptr_ty)
- else if (new_src_ptr_ty.ptrSize(zcu) == .One) ptr: {
+ else if (new_src_ptr_ty.ptrSize(zcu) == .one) ptr: {
var src_manyptr_ty_key = zcu.intern_pool.indexToKey(new_src_ptr_ty.toIntern()).ptr_type;
- assert(src_manyptr_ty_key.flags.size == .One);
+ assert(src_manyptr_ty_key.flags.size == .one);
src_manyptr_ty_key.child = src_elem_ty.toIntern();
- src_manyptr_ty_key.flags.size = .Many;
+ src_manyptr_ty_key.flags.size = .many;
break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src);
} else new_src_ptr;
@@ -26129,13 +26129,13 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
const dest_elem_ty: Type = dest_elem_ty: {
const ptr_info = dest_ptr_ty.ptrInfo(zcu);
switch (ptr_info.flags.size) {
- .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),
- .One => {
+ .slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),
+ .one => {
if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu);
}
},
- .Many, .C => {},
+ .many, .c => {},
}
return sema.failWithOwnedErrorMsg(block, msg: {
const msg = try sema.errMsg(src, "unknown @memset length", .{});
@@ -26172,7 +26172,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
} }));
const array_ptr_ty = ty: {
var info = dest_ptr_ty.ptrInfo(zcu);
- info.flags.size = .One;
+ info.flags.size = .one;
info.child = array_ty.toIntern();
break :ty try pt.ptrType(info);
};
@@ -26754,15 +26754,15 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
.add_eq => ty: {
const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;
switch (ptr_size) {
- .One, .Slice => break :ty lhs_ty, // invalid, let it error
- .Many, .C => break :ty .usize, // `[*]T + usize`
+ .one, .slice => break :ty lhs_ty, // invalid, let it error
+ .many, .c => break :ty .usize, // `[*]T + usize`
}
},
.sub_eq => ty: {
const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;
switch (ptr_size) {
- .One, .Slice => break :ty lhs_ty, // invalid, let it error
- .Many, .C => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize`
+ .one, .slice => break :ty lhs_ty, // invalid, let it error
+ .many, .c => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize`
}
},
};
@@ -27556,7 +27556,7 @@ fn fieldVal(
.child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),
.sentinel = if (inner_ty.sentinel(zcu)) |s| s.toIntern() else .none,
.flags = .{
- .size = .Many,
+ .size = .many,
.alignment = ptr_info.flags.alignment,
.is_const = ptr_info.flags.is_const,
.is_volatile = ptr_info.flags.is_volatile,
@@ -27578,7 +27578,7 @@ fn fieldVal(
},
.pointer => {
const ptr_info = inner_ty.ptrInfo(zcu);
- if (ptr_info.flags.size == .Slice) {
+ if (ptr_info.flags.size == .slice) {
if (field_name.eqlSlice("ptr", ip)) {
const slice = if (is_pointer_to)
try sema.analyzeLoad(block, src, object, object_src)
@@ -27740,7 +27740,7 @@ fn fieldPtr(
.child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),
.sentinel = if (object_ty.sentinel(zcu)) |s| s.toIntern() else .none,
.flags = .{
- .size = .Many,
+ .size = .many,
.alignment = ptr_info.flags.alignment,
.is_const = ptr_info.flags.is_const,
.is_volatile = ptr_info.flags.is_volatile,
@@ -27953,13 +27953,13 @@ fn fieldCallBind(
const ip = &zcu.intern_pool;
const raw_ptr_src = src; // TODO better source location
const raw_ptr_ty = sema.typeOf(raw_ptr);
- const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C))
+ const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .one or raw_ptr_ty.ptrSize(zcu) == .c))
raw_ptr_ty.childType(zcu)
else
return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)});
// Optionally dereference a second pointer to get the concrete type.
- const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .One;
+ const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .one;
const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty;
const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty;
const object_ptr = if (is_double_ptr)
@@ -28025,8 +28025,8 @@ fn fieldCallBind(
const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
if (first_param_type.isGenericPoison() or
(first_param_type.zigTypeTag(zcu) == .pointer and
- (first_param_type.ptrSize(zcu) == .One or
- first_param_type.ptrSize(zcu) == .C) and
+ (first_param_type.ptrSize(zcu) == .one or
+ first_param_type.ptrSize(zcu) == .c) and
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
{
// Note that if the param type is generic poison, we know that it must
@@ -28053,7 +28053,7 @@ fn fieldCallBind(
.arg0_inst = deref,
} };
} else if (child.zigTypeTag(zcu) == .pointer and
- child.ptrSize(zcu) == .One and
+ child.ptrSize(zcu) == .one and
child.childType(zcu).eql(concrete_ty, zcu))
{
return .{ .method = .{
@@ -28673,8 +28673,8 @@ fn elemPtrOneLayerOnly(
try checkIndexable(sema, block, src, indexable_ty);
switch (indexable_ty.ptrSize(zcu)) {
- .Slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
- .Many, .C => {
+ .slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
+ .many, .c => {
const maybe_ptr_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
ct: {
@@ -28688,7 +28688,7 @@ fn elemPtrOneLayerOnly(
return block.addPtrElemPtr(indexable, elem_index, result_ty);
},
- .One => {
+ .one => {
const child_ty = indexable_ty.childType(zcu);
const elem_ptr = switch (child_ty.zigTypeTag(zcu)) {
.array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety),
@@ -28728,8 +28728,8 @@ fn elemVal(
switch (indexable_ty.zigTypeTag(zcu)) {
.pointer => switch (indexable_ty.ptrSize(zcu)) {
- .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
- .Many, .C => {
+ .slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
+ .many, .c => {
const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
@@ -28748,7 +28748,7 @@ fn elemVal(
return block.addBinOp(.ptr_elem_val, indexable, elem_index);
},
- .One => {
+ .one => {
arr_sent: {
const inner_ty = indexable_ty.childType(zcu);
if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent;
@@ -29293,7 +29293,7 @@ fn coerceExtra(
// *T to *[1]T
single_item: {
- if (dest_info.flags.size != .One) break :single_item;
+ if (dest_info.flags.size != .one) break :single_item;
if (!inst_ty.isSinglePointer(zcu)) break :single_item;
if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
const ptr_elem_ty = inst_ty.childType(zcu);
@@ -29312,7 +29312,7 @@ fn coerceExtra(
// Coercions where the source is a single pointer to an array.
src_array_ptr: {
if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr;
- if (dest_info.flags.size == .One) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid
+ if (dest_info.flags.size == .one) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid
if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
const array_ty = inst_ty.childType(zcu);
if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr;
@@ -29356,25 +29356,25 @@ fn coerceExtra(
}
switch (dest_info.flags.size) {
- .Slice => {
+ .slice => {
// *[N]T to []T
return sema.coerceArrayPtrToSlice(block, dest_ty, inst, inst_src);
},
- .C => {
+ .c => {
// *[N]T to [*c]T
return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);
},
- .Many => {
+ .many => {
// *[N]T to [*]T
return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);
},
- .One => unreachable, // early exit at top of block
+ .one => unreachable, // early exit at top of block
}
}
// coercion from C pointer
if (inst_ty.isCPtr(zcu)) src_c_ptr: {
- if (dest_info.flags.size == .Slice) break :src_c_ptr;
+ if (dest_info.flags.size == .slice) break :src_c_ptr;
if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :src_c_ptr;
// In this case we must add a safety check because the C pointer
// could be null.
@@ -29413,7 +29413,7 @@ fn coerceExtra(
switch (dest_info.flags.size) {
// coercion to C pointer
- .C => switch (inst_ty.zigTypeTag(zcu)) {
+ .c => switch (inst_ty.zigTypeTag(zcu)) {
.null => return Air.internedToRef(try pt.intern(.{ .ptr = .{
.ty = dest_ty.toIntern(),
.base_addr = .int,
@@ -29457,7 +29457,7 @@ fn coerceExtra(
.ok => {},
else => break :p,
}
- if (inst_info.flags.size == .Slice) {
+ if (inst_info.flags.size == .slice) {
assert(dest_info.sentinel == .none);
if (inst_info.sentinel == .none or
inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern())
@@ -29470,8 +29470,8 @@ fn coerceExtra(
},
else => {},
},
- .One => {},
- .Slice => to_slice: {
+ .one => {},
+ .slice => to_slice: {
if (inst_ty.zigTypeTag(zcu) == .array) {
return sema.fail(
block,
@@ -29512,7 +29512,7 @@ fn coerceExtra(
}
return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src);
},
- .Many => p: {
+ .many => p: {
if (!inst_ty.isSlice(zcu)) break :p;
if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p;
const inst_info = inst_ty.ptrInfo(zcu);
@@ -30224,10 +30224,10 @@ const InMemoryCoercionResult = union(enum) {
fn pointerSizeString(size: std.builtin.Type.Pointer.Size) []const u8 {
return switch (size) {
- .One => "single pointer",
- .Many => "many pointer",
- .C => "C pointer",
- .Slice => "slice",
+ .one => "single pointer",
+ .many => "many pointer",
+ .c => "C pointer",
+ .slice => "slice",
};
}
@@ -30775,7 +30775,7 @@ fn coerceInMemoryAllowedPtrs(
const src_info = src_ptr_ty.ptrInfo(zcu);
const ok_ptr_size = src_info.flags.size == dest_info.flags.size or
- src_info.flags.size == .C or dest_info.flags.size == .C;
+ src_info.flags.size == .c or dest_info.flags.size == .c;
if (!ok_ptr_size) {
return InMemoryCoercionResult{ .ptr_size = .{
.actual = src_info.flags.size,
@@ -30874,7 +30874,7 @@ fn coerceInMemoryAllowedPtrs(
if (ss != .none and ds != .none) {
if (ds == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, ss, dest_info.child)) break :ok true;
}
- if (src_info.flags.size == .C) break :ok true;
+ if (src_info.flags.size == .c) break :ok true;
if (!dest_is_mut and dest_info.sentinel == .none) break :ok true;
break :ok false;
};
@@ -31392,7 +31392,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul
const dest_info = dest_ty.ptrInfo(zcu);
const inst_info = inst_ty.ptrInfo(zcu);
const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or
- (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .C and dest_info.flags.size != .Many))) or
+ (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .c and dest_info.flags.size != .many))) or
(Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0);
const ok_const = (!inst_info.flags.is_const or dest_info.flags.is_const) or len0;
@@ -32631,7 +32631,7 @@ fn analyzeSlice(
elem_ty = ptr_ptr_child_ty.childType(zcu);
},
.pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) {
- .One => {
+ .one => {
const double_child_ty = ptr_ptr_child_ty.childType(zcu);
ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
if (double_child_ty.zigTypeTag(zcu) == .array) {
@@ -32721,14 +32721,14 @@ fn analyzeSlice(
elem_ty = double_child_ty;
}
},
- .Many, .C => {
+ .many, .c => {
ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
slice_ty = ptr_ptr_child_ty;
array_ty = ptr_ptr_child_ty;
elem_ty = ptr_ptr_child_ty.childType(zcu);
- if (ptr_ptr_child_ty.ptrSize(zcu) == .C) {
+ if (ptr_ptr_child_ty.ptrSize(zcu) == .c) {
if (try sema.resolveDefinedValue(block, ptr_src, ptr_or_slice)) |ptr_val| {
if (ptr_val.isNull(zcu)) {
return sema.fail(block, src, "slice of null pointer", .{});
@@ -32736,7 +32736,7 @@ fn analyzeSlice(
}
}
},
- .Slice => {
+ .slice => {
ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
slice_ty = ptr_ptr_child_ty;
@@ -32752,9 +32752,9 @@ fn analyzeSlice(
else if (array_ty.zigTypeTag(zcu) == .array) ptr: {
var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type;
assert(manyptr_ty_key.child == array_ty.toIntern());
- assert(manyptr_ty_key.flags.size == .One);
+ assert(manyptr_ty_key.flags.size == .one);
manyptr_ty_key.child = elem_ty.toIntern();
- manyptr_ty_key.flags.size = .Many;
+ manyptr_ty_key.flags.size = .many;
break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src);
} else ptr_or_slice;
@@ -32967,7 +32967,7 @@ fn analyzeSlice(
const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len);
const new_ptr_ty_info = new_ptr_ty.ptrInfo(zcu);
- const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .C;
+ const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .c;
if (opt_new_len_val) |new_len_val| {
const new_len_int = try new_len_val.toUnsignedIntSema(pt);
@@ -33038,7 +33038,7 @@ fn analyzeSlice(
.child = elem_ty.toIntern(),
.sentinel = if (sentinel) |s| s.toIntern() else .none,
.flags = .{
- .size = .Slice,
+ .size = .slice,
.alignment = new_ptr_ty_info.flags.alignment,
.is_const = new_ptr_ty_info.flags.is_const,
.is_volatile = new_ptr_ty_info.flags.is_volatile,
@@ -33739,7 +33739,7 @@ const PeerResolveStrategy = enum {
.int => .fixed_int,
.comptime_float => .comptime_float,
.float => .fixed_float,
- .pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr,
+ .pointer => if (ty.ptrInfo(zcu).flags.size == .c) .c_ptr else .ptr,
.array => .array,
.vector => .vector,
.optional => .optional,
@@ -34235,7 +34235,7 @@ fn resolvePeerTypesInner(
var ptr_info = opt_ptr_info orelse {
opt_ptr_info = peer_info;
- opt_ptr_info.?.flags.size = .C;
+ opt_ptr_info.?.flags.size = .c;
first_idx = i;
continue;
};
@@ -34323,9 +34323,9 @@ fn resolvePeerTypesInner(
};
switch (peer_info.flags.size) {
- .One, .Many => {},
- .Slice => opt_slice_idx = i,
- .C => return .{ .conflict = .{
+ .one, .many => {},
+ .slice => opt_slice_idx = i,
+ .c => return .{ .conflict = .{
.peer_idx_a = strat_reason,
.peer_idx_b = i,
} },
@@ -34370,21 +34370,21 @@ fn resolvePeerTypesInner(
ptr_info.flags.is_allowzero = ptr_info.flags.is_allowzero or peer_info.flags.is_allowzero;
const peer_sentinel: InternPool.Index = switch (peer_info.flags.size) {
- .One => switch (ip.indexToKey(peer_info.child)) {
+ .one => switch (ip.indexToKey(peer_info.child)) {
.array_type => |array_type| array_type.sentinel,
else => .none,
},
- .Many, .Slice => peer_info.sentinel,
- .C => unreachable,
+ .many, .slice => peer_info.sentinel,
+ .c => unreachable,
};
const cur_sentinel: InternPool.Index = switch (ptr_info.flags.size) {
- .One => switch (ip.indexToKey(ptr_info.child)) {
+ .one => switch (ip.indexToKey(ptr_info.child)) {
.array_type => |array_type| array_type.sentinel,
else => .none,
},
- .Many, .Slice => ptr_info.sentinel,
- .C => unreachable,
+ .many, .slice => ptr_info.sentinel,
+ .c => unreachable,
};
// We abstract array handling slightly so that tuple pointers can work like array pointers
@@ -34395,8 +34395,8 @@ fn resolvePeerTypesInner(
// single-pointer array sentinel).
good: {
switch (peer_info.flags.size) {
- .One => switch (ptr_info.flags.size) {
- .One => {
+ .one => switch (ptr_info.flags.size) {
+ .one => {
if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
ptr_info.child = pointee.toIntern();
break :good;
@@ -34415,28 +34415,28 @@ fn resolvePeerTypesInner(
break :good;
}
// *[a]T + *[b]T = []T
- ptr_info.flags.size = .Slice;
+ ptr_info.flags.size = .slice;
ptr_info.child = elem_ty.toIntern();
break :good;
}
if (peer_arr.elem_ty.toIntern() == .noreturn_type) {
// *struct{} + *[a]T = []T
- ptr_info.flags.size = .Slice;
+ ptr_info.flags.size = .slice;
ptr_info.child = cur_arr.elem_ty.toIntern();
break :good;
}
if (cur_arr.elem_ty.toIntern() == .noreturn_type) {
// *[a]T + *struct{} = []T
- ptr_info.flags.size = .Slice;
+ ptr_info.flags.size = .slice;
ptr_info.child = peer_arr.elem_ty.toIntern();
break :good;
}
return generic_err;
},
- .Many => {
+ .many => {
// Only works for *[n]T + [*]T -> [*]T
const arr = peer_pointee_array orelse return generic_err;
if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {
@@ -34449,7 +34449,7 @@ fn resolvePeerTypesInner(
}
return generic_err;
},
- .Slice => {
+ .slice => {
// Only works for *[n]T + []T -> []T
const arr = peer_pointee_array orelse return generic_err;
if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {
@@ -34462,33 +34462,33 @@ fn resolvePeerTypesInner(
}
return generic_err;
},
- .C => unreachable,
+ .c => unreachable,
},
- .Many => switch (ptr_info.flags.size) {
- .One => {
+ .many => switch (ptr_info.flags.size) {
+ .one => {
// Only works for [*]T + *[n]T -> [*]T
const arr = cur_pointee_array orelse return generic_err;
if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {
- ptr_info.flags.size = .Many;
+ ptr_info.flags.size = .many;
ptr_info.child = pointee.toIntern();
break :good;
}
if (arr.elem_ty.toIntern() == .noreturn_type) {
// [*]T + *struct{} -> [*]T
- ptr_info.flags.size = .Many;
+ ptr_info.flags.size = .many;
ptr_info.child = peer_info.child;
break :good;
}
return generic_err;
},
- .Many => {
+ .many => {
if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
ptr_info.child = pointee.toIntern();
break :good;
}
return generic_err;
},
- .Slice => {
+ .slice => {
// Only works if no peers are actually slices
if (opt_slice_idx) |slice_idx| {
return .{ .conflict = .{
@@ -34498,54 +34498,54 @@ fn resolvePeerTypesInner(
}
// Okay, then works for [*]T + "[]T" -> [*]T
if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
- ptr_info.flags.size = .Many;
+ ptr_info.flags.size = .many;
ptr_info.child = pointee.toIntern();
break :good;
}
return generic_err;
},
- .C => unreachable,
+ .c => unreachable,
},
- .Slice => switch (ptr_info.flags.size) {
- .One => {
+ .slice => switch (ptr_info.flags.size) {
+ .one => {
// Only works for []T + *[n]T -> []T
const arr = cur_pointee_array orelse return generic_err;
if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {
- ptr_info.flags.size = .Slice;
+ ptr_info.flags.size = .slice;
ptr_info.child = pointee.toIntern();
break :good;
}
if (arr.elem_ty.toIntern() == .noreturn_type) {
// []T + *struct{} -> []T
- ptr_info.flags.size = .Slice;
+ ptr_info.flags.size = .slice;
ptr_info.child = peer_info.child;
break :good;
}
return generic_err;
},
- .Many => {
+ .many => {
// Impossible! (current peer is an actual slice)
return generic_err;
},
- .Slice => {
+ .slice => {
if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
ptr_info.child = pointee.toIntern();
break :good;
}
return generic_err;
},
- .C => unreachable,
+ .c => unreachable,
},
- .C => unreachable,
+ .c => unreachable,
}
}
const sentinel_ty = switch (ptr_info.flags.size) {
- .One => switch (ip.indexToKey(ptr_info.child)) {
+ .one => switch (ip.indexToKey(ptr_info.child)) {
.array_type => |array_type| array_type.child,
else => ptr_info.child,
},
- .Many, .Slice, .C => ptr_info.child,
+ .many, .slice, .c => ptr_info.child,
};
sentinel: {
@@ -34556,7 +34556,7 @@ fn resolvePeerTypesInner(
const cur_sent_coerced = try ip.getCoerced(sema.gpa, pt.tid, cur_sentinel, sentinel_ty);
if (peer_sent_coerced != cur_sent_coerced) break :no_sentinel;
// Sentinels match
- if (ptr_info.flags.size == .One) switch (ip.indexToKey(ptr_info.child)) {
+ if (ptr_info.flags.size == .one) switch (ip.indexToKey(ptr_info.child)) {
.array_type => |array_type| ptr_info.child = (try pt.arrayType(.{
.len = array_type.len,
.child = array_type.child,
@@ -35416,8 +35416,8 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void
const zcu = pt.zcu;
if (ty.zigTypeTag(zcu) == .pointer) {
switch (ty.ptrSize(zcu)) {
- .Slice, .Many, .C => return,
- .One => {
+ .slice, .many, .c => return,
+ .one => {
const elem_ty = ty.childType(zcu);
if (elem_ty.zigTypeTag(zcu) == .array) return;
// TODO https://github.com/ziglang/zig/issues/15479
@@ -37248,13 +37248,13 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type {
const zcu = pt.zcu;
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .One, .Many, .C => ty,
- .Slice => null,
+ .one, .many, .c => ty,
+ .slice => null,
},
.opt_type => |opt_child| switch (zcu.intern_pool.indexToKey(opt_child)) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice, .C => null,
- .Many, .One => {
+ .slice, .c => null,
+ .many, .one => {
if (ptr_type.flags.is_allowzero) return null;
// optionals of zero sized types behave like bools, not pointers
@@ -38260,7 +38260,7 @@ fn maybeDerefSliceAsArray(
});
const ptr_ty = try pt.ptrTypeSema(p: {
var p = Type.fromInterned(slice.ty).ptrInfo(zcu);
- p.flags.size = .One;
+ p.flags.size = .one;
p.child = array_ty.toIntern();
p.sentinel = .none;
break :p p;
src/translate_c.zig
@@ -231,13 +231,13 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {
}
}
-fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {
+fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
const c: *Context = @ptrCast(@alignCast(context));
declVisitorNamesOnly(c, decl) catch return false;
return true;
}
-fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {
+fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
const c: *Context = @ptrCast(@alignCast(context));
declVisitor(c, decl) catch return false;
return true;
src/Type.zig
@@ -192,16 +192,16 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
const info = ty.ptrInfo(zcu);
if (info.sentinel != .none) switch (info.flags.size) {
- .One, .C => unreachable,
- .Many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
- .Slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
+ .one, .c => unreachable,
+ .many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
+ .slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
} else switch (info.flags.size) {
- .One => try writer.writeAll("*"),
- .Many => try writer.writeAll("[*]"),
- .C => try writer.writeAll("[*c]"),
- .Slice => try writer.writeAll("[]"),
+ .one => try writer.writeAll("*"),
+ .many => try writer.writeAll("[*]"),
+ .c => try writer.writeAll("[*c]"),
+ .slice => try writer.writeAll("[]"),
}
- if (info.flags.is_allowzero and info.flags.size != .C) try writer.writeAll("allowzero ");
+ if (info.flags.is_allowzero and info.flags.size != .c) try writer.writeAll("allowzero ");
if (info.flags.alignment != .none or
info.packed_offset.host_size != 0 or
info.flags.vector_index != .none)
@@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool {
.array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu),
.opt_type => ty.isPtrLikeOptional(zcu),
- .ptr_type => |ptr_type| ptr_type.flags.size != .Slice,
+ .ptr_type => |ptr_type| ptr_type.flags.size != .slice,
.simple_type => |t| switch (t) {
.f16,
@@ -1303,7 +1303,7 @@ pub fn abiSizeInner(
return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) };
},
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 },
+ .slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 },
else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
},
.anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
@@ -1741,7 +1741,7 @@ pub fn bitSizeInner(
switch (ip.indexToKey(ty.toIntern())) {
.int_type => |int_type| return int_type.bits,
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice => return target.ptrBitWidth() * 2,
+ .slice => return target.ptrBitWidth() * 2,
else => return target.ptrBitWidth(),
},
.anyframe_type => return target.ptrBitWidth(),
@@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool {
pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
- .ptr_type => |ptr_info| ptr_info.flags.size == .One,
+ .ptr_type => |ptr_info| ptr_info.flags.size == .one,
else => false,
};
}
@@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size {
pub fn isSlice(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
- .ptr_type => |ptr_type| ptr_type.flags.size == .Slice,
+ .ptr_type => |ptr_type| ptr_type.flags.size == .slice,
else => false,
};
}
@@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool {
pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
- .ptr_type => |ptr_type| ptr_type.flags.size == .C,
+ .ptr_type => |ptr_type| ptr_type.flags.size == .c,
else => false,
};
}
@@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice => false,
- .One, .Many, .C => true,
+ .slice => false,
+ .one, .many, .c => true,
},
.opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
.ptr_type => |p| switch (p.flags.size) {
- .Slice, .C => false,
- .Many, .One => !p.flags.is_allowzero,
+ .slice, .c => false,
+ .many, .one => !p.flags.is_allowzero,
},
else => false,
},
@@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool {
pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) {
- .ptr_type => |ptr_type| ptr_type.flags.size != .C and !ptr_type.flags.is_allowzero,
+ .ptr_type => |ptr_type| ptr_type.flags.size != .c and !ptr_type.flags.is_allowzero,
.error_set_type, .inferred_error_set_type => true,
else => false,
},
- .ptr_type => |ptr_type| ptr_type.flags.size == .C,
+ .ptr_type => |ptr_type| ptr_type.flags.size == .c,
else => false,
};
}
@@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
/// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`.
pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
- .ptr_type => |ptr_type| ptr_type.flags.size == .C,
+ .ptr_type => |ptr_type| ptr_type.flags.size == .c,
.opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .Slice, .C => false,
- .Many, .One => !ptr_type.flags.is_allowzero,
+ .slice, .c => false,
+ .many, .one => !ptr_type.flags.is_allowzero,
},
else => false,
},
@@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {
pub fn elemType2(ty: Type, zcu: *const Zcu) Type {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.ptr_type => |ptr_type| switch (ptr_type.flags.size) {
- .One => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
- .Many, .C, .Slice => Type.fromInterned(ptr_type.child),
+ .one => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
+ .many, .c, .slice => Type.fromInterned(ptr_type.child),
},
.anyframe_type => |child| {
assert(child != .none);
@@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type {
return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
.opt_type => |child| Type.fromInterned(child),
.ptr_type => |ptr_type| b: {
- assert(ptr_type.flags.size == .C);
+ assert(ptr_type.flags.size == .c);
break :b ty;
},
else => unreachable,
@@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {
return switch (ty.zigTypeTag(zcu)) {
.array, .vector => true,
.pointer => switch (ty.ptrSize(zcu)) {
- .Slice, .Many, .C => true,
- .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
+ .slice, .many, .c => true,
+ .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.array, .vector => true,
.@"struct" => ty.childType(zcu).isTuple(zcu),
else => false,
@@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {
return switch (ty.zigTypeTag(zcu)) {
.array, .vector => true,
.pointer => switch (ty.ptrSize(zcu)) {
- .Many, .C => false,
- .Slice => true,
- .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
+ .many, .c => false,
+ .slice => true,
+ .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
.array, .vector => true,
.@"struct" => ty.childType(zcu).isTuple(zcu),
else => false,
@@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type {
host_size: u16 = 0,
alignment: Alignment = .none,
vector_index: VI = .none,
- } = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .One) blk: {
+ } = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .one) blk: {
const elem_bits = elem_ty.bitSize(zcu);
if (elem_bits == 0) break :blk .{};
const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits);
src/Value.zig
@@ -3724,7 +3724,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
const parent_ptr_ty = parent_ptr.typeOf(zcu);
const opt_ty = parent_ptr_ty.childType(zcu);
- assert(parent_ptr_ty.ptrSize(zcu) == .One);
+ assert(parent_ptr_ty.ptrSize(zcu) == .one);
assert(opt_ty.zigTypeTag(zcu) == .optional);
const result_ty = try pt.ptrTypeSema(info: {
@@ -3742,7 +3742,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
return pt.getCoerced(parent_ptr, result_ty);
}
- const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, opt_ty, pt);
+ const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, opt_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .opt_payload = base_ptr.toIntern() },
@@ -3758,7 +3758,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
const parent_ptr_ty = parent_ptr.typeOf(zcu);
const eu_ty = parent_ptr_ty.childType(zcu);
- assert(parent_ptr_ty.ptrSize(zcu) == .One);
+ assert(parent_ptr_ty.ptrSize(zcu) == .one);
assert(eu_ty.zigTypeTag(zcu) == .error_union);
const result_ty = try pt.ptrTypeSema(info: {
@@ -3771,7 +3771,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
- const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, eu_ty, pt);
+ const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, eu_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .eu_payload = base_ptr.toIntern() },
@@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
const aggregate_ty = parent_ptr_ty.childType(zcu);
const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
- assert(parent_ptr_info.flags.size == .One);
+ assert(parent_ptr_info.flags.size == .one);
// Exiting this `switch` indicates that the `field` pointer representation should be used.
// `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.
@@ -3920,7 +3920,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
- const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, aggregate_ty, pt);
+ const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, aggregate_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .field = .{
@@ -3937,8 +3937,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value {
const zcu = pt.zcu;
const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) {
- .One, .Many, .C => orig_parent_ptr,
- .Slice => orig_parent_ptr.slicePtr(zcu),
+ .one, .many, .c => orig_parent_ptr,
+ .slice => orig_parent_ptr.slicePtr(zcu),
};
const parent_ptr_ty = parent_ptr.typeOf(zcu);
@@ -3959,7 +3959,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
};
const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {
- .One => switch (elem_ty.zigTypeTag(zcu)) {
+ .one => switch (elem_ty.zigTypeTag(zcu)) {
.vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },
.array => strat: {
const arr_elem_ty = elem_ty.childType(zcu);
@@ -3971,12 +3971,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
else => unreachable,
},
- .Many, .C => if (try elem_ty.comptimeOnlySema(pt))
+ .many, .c => if (try elem_ty.comptimeOnlySema(pt))
.{ .elem_ptr = elem_ty }
else
.{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar },
- .Slice => unreachable,
+ .slice => unreachable,
};
switch (strat) {
@@ -4004,7 +4004,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
},
else => {},
}
- const base_ptr = try parent_ptr.canonicalizeBasePtr(.Many, arr_base_ty, pt);
+ const base_ptr = try parent_ptr.canonicalizeBasePtr(.many, arr_base_ty, pt);
return Value.fromInterned(try pt.intern(.{ .ptr = .{
.ty = result_ty.toIntern(),
.base_addr = .{ .arr_elem = .{
@@ -4234,7 +4234,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
.child = parent_ptr_info.child,
.flags = flags: {
var flags = parent_ptr_info.flags;
- flags.size = .One;
+ flags.size = .one;
break :flags flags;
},
});
@@ -4304,8 +4304,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt;
if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt;
switch (need_child.ptrSize(zcu)) {
- .One, .Many => {},
- .Slice, .C => break :ptr_opt,
+ .one, .many => {},
+ .slice, .c => break :ptr_opt,
}
const parent = try arena.create(PointerDeriveStep);
parent.* = cur_derive;
@@ -4323,7 +4323,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
const elem_size = elem_ty.abiSize(zcu);
const start_idx = cur_offset / elem_size;
const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size;
- if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .One) {
+ if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) {
const parent = try arena.create(PointerDeriveStep);
parent.* = cur_derive;
cur_derive = .{ .elem_ptr = .{
test/behavior/align.zig
@@ -410,11 +410,11 @@ test "alignment of function with c calling convention" {
var runtime_nothing = ¬hing;
_ = &runtime_nothing;
const casted1: *align(a) const u8 = @ptrCast(runtime_nothing);
- const casted2: *const fn () callconv(.C) void = @ptrCast(casted1);
+ const casted2: *const fn () callconv(.c) void = @ptrCast(casted1);
casted2();
}
-fn nothing() callconv(.C) void {}
+fn nothing() callconv(.c) void {}
const DefaultAligned = struct {
nevermind: u32,
test/behavior/cast.zig
@@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" {
// On some architectures function pointers must be aligned.
const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);
pub const FUNCTION_CONSTANT = @as(PFN_void, @ptrFromInt(hardcoded_fn_addr));
-pub const PFN_void = *const fn (*anyopaque) callconv(.C) void;
+pub const PFN_void = *const fn (*anyopaque) callconv(.c) void;
fn foobar(func: PFN_void) !void {
try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);
@@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" {
var global_array: [4]u8 = undefined;
test "cast from array reference to fn: comptime fn ptr" {
- const f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array));
+ const f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array));
try expect(@intFromPtr(f) == @intFromPtr(&global_array));
}
test "cast from array reference to fn: runtime fn ptr" {
- var f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array));
+ var f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array));
_ = &f;
try expect(@intFromPtr(f) == @intFromPtr(&global_array));
}
@@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" {
test "cast between [*c]T and ?[*:0]T on fn parameter" {
const S = struct {
- const Handler = ?fn ([*c]const u8) callconv(.C) void;
+ const Handler = ?fn ([*c]const u8) callconv(.c) void;
fn addCallback(comptime handler: Handler) void {
_ = handler;
}
- fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {
+ fn myCallback(cstr: ?[*:0]const u8) callconv(.c) void {
_ = cstr;
}
test/behavior/export_builtin.zig
@@ -26,7 +26,7 @@ test "exporting with internal linkage" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
const S = struct {
- fn foo() callconv(.C) void {}
+ fn foo() callconv(.c) void {}
comptime {
@export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
}
test/behavior/export_keyword.zig
@@ -44,7 +44,7 @@ test "export function alias" {
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
_ = struct {
- fn foo_internal() callconv(.C) u32 {
+ fn foo_internal() callconv(.c) u32 {
return 123;
}
export const foo_exported = foo_internal;
test/behavior/extern.zig
@@ -20,7 +20,7 @@ test "function extern symbol" {
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
- const a = @extern(*const fn () callconv(.C) i32, .{ .name = "a_mystery_function" });
+ const a = @extern(*const fn () callconv(.c) i32, .{ .name = "a_mystery_function" });
try expect(a() == 4567);
}
@@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" {
const S = struct {
extern fn another_mystery_function() u32;
- const same_thing = @extern(*const fn () callconv(.C) u32, .{ .name = "another_mystery_function" });
+ const same_thing = @extern(*const fn () callconv(.c) u32, .{ .name = "another_mystery_function" });
};
try expect(S.another_mystery_function() == 12345);
try expect(S.same_thing() == 12345);
@@ -55,5 +55,5 @@ test "coerce extern function types" {
};
_ = S;
- _ = @as(fn () callconv(.C) ?*u32, c_extern_function);
+ _ = @as(fn () callconv(.c) ?*u32, c_extern_function);
}
test/behavior/fn.zig
@@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = extern struct {
- ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32,
+ ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32,
- fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32 {
+ fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32 {
return 1234;
}
};
@@ -169,7 +169,7 @@ const nComplexCallconv = 100;
fn fComplexCallconvRet(x: u32) callconv(blk: {
const s: struct { n: u32 } = .{ .n = nComplexCallconv };
break :blk switch (s.n) {
- 0 => .C,
+ 0 => .c,
1 => .Inline,
else => .Unspecified,
};
@@ -435,13 +435,13 @@ test "implicit cast function to function ptr" {
return 123;
}
};
- var fnPtr1: *const fn () callconv(.C) c_int = S1.someFunctionThatReturnsAValue;
+ var fnPtr1: *const fn () callconv(.c) c_int = S1.someFunctionThatReturnsAValue;
_ = &fnPtr1;
try expect(fnPtr1() == 123);
const S2 = struct {
extern fn someFunctionThatReturnsAValue() c_int;
};
- var fnPtr2: *const fn () callconv(.C) c_int = S2.someFunctionThatReturnsAValue;
+ var fnPtr2: *const fn () callconv(.c) c_int = S2.someFunctionThatReturnsAValue;
_ = &fnPtr2;
try expect(fnPtr2() == 123);
}
test/behavior/generics.zig
@@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" {
for (source, 0..) |s, i| dest[i] = s;
}
- fn foo() callconv(.C) void {}
+ fn foo() callconv(.c) void {}
};
var buffer: [100]u8 = undefined;
S.copy(u8, &buffer, "hello");
@@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" {
try expect(S.A.do() == 1234);
}
-test "generic function returns value from callconv(.C) function" {
+test "generic function returns value from callconv(.c) function" {
const S = struct {
- fn getU8() callconv(.C) u8 {
+ fn getU8() callconv(.c) u8 {
return 123;
}
- fn getGeneric(comptime T: type, supplier: fn () callconv(.C) T) T {
+ fn getGeneric(comptime T: type, supplier: fn () callconv(.c) T) T {
return supplier();
}
};
@@ -521,11 +521,11 @@ test "function argument tuple used as struct field" {
try expect(c.t[0] == null);
}
-test "comptime callconv(.C) function ptr uses comptime type argument" {
+test "comptime callconv(.c) function ptr uses comptime type argument" {
const S = struct {
fn A(
comptime T: type,
- comptime destroycb: ?*const fn (?*T) callconv(.C) void,
+ comptime destroycb: ?*const fn (?*T) callconv(.c) void,
) !void {
try expect(destroycb == null);
}
test/behavior/import_c_keywords.zig
@@ -80,7 +80,7 @@ test "import c keywords" {
try std.testing.expect(ptr_id == &some_non_c_keyword_constant);
if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) {
- var ptr_fn: *const fn () callconv(.C) Id = &double;
+ var ptr_fn: *const fn () callconv(.c) Id = &double;
try std.testing.expect(ptr_fn == &float);
ptr_fn = &an_alias_of_float;
try std.testing.expect(ptr_fn == &float);
test/behavior/packed-struct.zig
@@ -891,7 +891,7 @@ test "runtime init of unnamed packed struct type" {
}{ .x = z }).m();
}
-test "packed struct passed to callconv(.C) function" {
+test "packed struct passed to callconv(.c) function" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
@@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" {
d: u46 = 0,
};
- fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.C) bool {
+ fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.c) bool {
return p.a == 12345 and p.b == true and p.c == true and p.d == 0 and a1 == 5 and a2 == 4 and a3 == 3 and a4 == 2 and a5 == 1;
}
};
@@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" {
x: u15 = 0,
y: u1 = 0,
- fn foo(s: @This()) callconv(.C) i32 {
+ fn foo(s: @This()) callconv(.c) i32 {
return s.x;
}
fn bar(s: @This()) !void {
test/behavior/struct.zig
@@ -803,7 +803,7 @@ test "fn with C calling convention returns struct by value" {
handle: i32,
};
- fn makeBar(t: i32) callconv(.C) ExternBar {
+ fn makeBar(t: i32) callconv(.c) ExternBar {
return ExternBar{
.handle = t,
};
test/behavior/type.zig
@@ -141,7 +141,7 @@ test "Type.Array" {
test "@Type create slice with null sentinel" {
const Slice = @Type(.{
.pointer = .{
- .size = .Slice,
+ .size = .slice,
.is_const = true,
.is_volatile = false,
.is_allowzero = false,
@@ -548,11 +548,11 @@ test "Type.Fn" {
const some_opaque = opaque {};
const some_ptr = *some_opaque;
- const T = fn (c_int, some_ptr) callconv(.C) void;
+ const T = fn (c_int, some_ptr) callconv(.c) void;
{
const fn_info = std.builtin.Type{ .@"fn" = .{
- .calling_convention = .C,
+ .calling_convention = .c,
.is_generic = false,
.is_var_args = false,
.return_type = void,
test/behavior/type_info.zig
@@ -44,7 +44,7 @@ test "type info: C pointer type info" {
fn testCPtr() !void {
const ptr_info = @typeInfo([*c]align(4) const i8);
try expect(ptr_info == .pointer);
- try expect(ptr_info.pointer.size == .C);
+ try expect(ptr_info.pointer.size == .c);
try expect(ptr_info.pointer.is_const);
try expect(!ptr_info.pointer.is_volatile);
try expect(ptr_info.pointer.alignment == 4);
@@ -54,8 +54,8 @@ fn testCPtr() !void {
test "type info: value is correctly copied" {
comptime {
var ptrInfo = @typeInfo([]u32);
- ptrInfo.pointer.size = .One;
- try expect(@typeInfo([]u32).pointer.size == .Slice);
+ ptrInfo.pointer.size = .one;
+ try expect(@typeInfo([]u32).pointer.size == .slice);
}
}
@@ -79,7 +79,7 @@ test "type info: pointer type info" {
fn testPointer() !void {
const u32_ptr_info = @typeInfo(*u32);
try expect(u32_ptr_info == .pointer);
- try expect(u32_ptr_info.pointer.size == .One);
+ try expect(u32_ptr_info.pointer.size == .one);
try expect(u32_ptr_info.pointer.is_const == false);
try expect(u32_ptr_info.pointer.is_volatile == false);
try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));
@@ -95,7 +95,7 @@ test "type info: unknown length pointer type info" {
fn testUnknownLenPtr() !void {
const u32_ptr_info = @typeInfo([*]const volatile f64);
try expect(u32_ptr_info == .pointer);
- try expect(u32_ptr_info.pointer.size == .Many);
+ try expect(u32_ptr_info.pointer.size == .many);
try expect(u32_ptr_info.pointer.is_const == true);
try expect(u32_ptr_info.pointer.is_volatile == true);
try expect(u32_ptr_info.pointer.sentinel == null);
@@ -111,7 +111,7 @@ test "type info: null terminated pointer type info" {
fn testNullTerminatedPtr() !void {
const ptr_info = @typeInfo([*:0]u8);
try expect(ptr_info == .pointer);
- try expect(ptr_info.pointer.size == .Many);
+ try expect(ptr_info.pointer.size == .many);
try expect(ptr_info.pointer.is_const == false);
try expect(ptr_info.pointer.is_volatile == false);
try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);
@@ -127,7 +127,7 @@ test "type info: slice type info" {
fn testSlice() !void {
const u32_slice_info = @typeInfo([]u32);
try expect(u32_slice_info == .pointer);
- try expect(u32_slice_info.pointer.size == .Slice);
+ try expect(u32_slice_info.pointer.size == .slice);
try expect(u32_slice_info.pointer.is_const == false);
try expect(u32_slice_info.pointer.is_volatile == false);
try expect(u32_slice_info.pointer.alignment == 4);
@@ -374,7 +374,7 @@ fn testFunction() !void {
try expect(foo_fn_info.@"fn".is_var_args);
try expect(foo_fn_info.@"fn".return_type.? == usize);
const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo));
- try expect(foo_ptr_fn_info.pointer.size == .One);
+ try expect(foo_ptr_fn_info.pointer.size == .one);
try expect(foo_ptr_fn_info.pointer.is_const);
try expect(!foo_ptr_fn_info.pointer.is_volatile);
try expect(foo_ptr_fn_info.pointer.address_space == .generic);
@@ -401,7 +401,7 @@ fn testFunction() !void {
try expect(aligned_foo_fn_info.@"fn".is_var_args);
try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);
const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned));
- try expect(aligned_foo_ptr_fn_info.pointer.size == .One);
+ try expect(aligned_foo_ptr_fn_info.pointer.size == .one);
try expect(aligned_foo_ptr_fn_info.pointer.is_const);
try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);
try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4);
test/behavior/union.zig
@@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" {
s: S,
};
- fn bar(arg_u: U) callconv(.C) U {
+ fn bar(arg_u: U) callconv(.c) U {
var u = arg_u;
_ = &u;
return u;
test/behavior/var_args.zig
@@ -108,19 +108,19 @@ test "simple variadic function" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
- fn simple(...) callconv(.C) c_int {
+ fn simple(...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
return @cVaArg(&ap, c_int);
}
- fn compatible(_: c_int, ...) callconv(.C) c_int {
+ fn compatible(_: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
return @cVaArg(&ap, c_int);
}
- fn add(count: c_int, ...) callconv(.C) c_int {
+ fn add(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
var i: usize = 0;
@@ -169,7 +169,7 @@ test "coerce reference to var arg" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
- fn addPtr(count: c_int, ...) callconv(.C) c_int {
+ fn addPtr(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
var i: usize = 0;
@@ -202,7 +202,7 @@ test "variadic functions" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
- fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.C) void {
+ fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.c) void {
var ap = @cVaStart();
defer @cVaEnd(&ap);
vprintf(list_ptr, format, &ap);
@@ -212,7 +212,7 @@ test "variadic functions" {
list: *std.ArrayList(u8),
format: [*:0]const u8,
ap: *std.builtin.VaList,
- ) callconv(.C) void {
+ ) callconv(.c) void {
for (std.mem.span(format)) |c| switch (c) {
's' => {
const arg = @cVaArg(ap, [*:0]const u8);
@@ -247,7 +247,7 @@ test "copy VaList" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
- fn add(count: c_int, ...) callconv(.C) c_int {
+ fn add(count: c_int, ...) callconv(.c) c_int {
var ap = @cVaStart();
defer @cVaEnd(&ap);
var copy = @cVaCopy(&ap);
@@ -284,7 +284,7 @@ test "unused VaList arg" {
if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
const S = struct {
- fn thirdArg(dummy: c_int, ...) callconv(.C) c_int {
+ fn thirdArg(dummy: c_int, ...) callconv(.c) c_int {
_ = dummy;
var ap = @cVaStart();
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig
@@ -21,7 +21,7 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {
pub fn isSingleItemPtr(comptime T: type) bool {
if (comptime is(.pointer)(T)) {
- return @typeInfo(T).pointer.size == .One;
+ return @typeInfo(T).pointer.size == .one;
}
return false;
}
test/cases/compile_errors/invalid_pointer_with_reify_type.zig
@@ -1,6 +1,6 @@
export fn entry() void {
_ = @Type(.{ .pointer = .{
- .size = .One,
+ .size = .one,
.is_const = false,
.is_volatile = false,
.alignment = 1,
@@ -12,7 +12,5 @@ export fn entry() void {
}
// error
-// backend=stage2
-// target=native
//
// :2:9: error: sentinels are only allowed on slices and unknown-length pointers
test/cases/compile_errors/non_scalar_sentinel.zig
@@ -16,7 +16,7 @@ comptime {
}
comptime {
_ = @Type(.{ .pointer = .{
- .size = .Many,
+ .size = .slice,
.is_const = false,
.is_volatile = false,
.alignment = @alignOf(S),
@@ -28,7 +28,7 @@ comptime {
}
comptime {
_ = @Type(.{ .pointer = .{
- .size = .Many,
+ .size = .many,
.is_const = false,
.is_volatile = false,
.alignment = @alignOf(S),
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig
@@ -29,7 +29,7 @@ comptime {
comptime {
_ = @Type(.{
.pointer = .{
- .size = .Many,
+ .size = .many,
.is_const = true,
.is_volatile = false,
.alignment = 7,
@@ -42,8 +42,6 @@ comptime {
}
// error
-// backend=stage2
-// target=native
//
// :2:9: error: alignment value '3' is not a power of two or zero
// :14:9: error: alignment value '5' is not a power of two or zero