Skip to content

Commit 3054486

Browse files
authored
Merge pull request ziglang#21843 from alexrp/callconv-followup
Some follow-up work for ziglang#21697
2 parents 2f003f3 + e4e3d7a commit 3054486

24 files changed

+420
-334
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
376376
lib/std/Target.zig
377377
lib/std/Target/Query.zig
378378
lib/std/Target/aarch64.zig
379-
lib/std/Target/amdgpu.zig
379+
lib/std/Target/amdgcn.zig
380380
lib/std/Target/arm.zig
381381
lib/std/Target/avr.zig
382382
lib/std/Target/bpf.zig

lib/compiler_rt/atomics.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const largest_atomic_size = switch (arch) {
4242
// Objects smaller than this threshold are implemented in terms of compare-exchange
4343
// of a larger value.
4444
const smallest_atomic_fetch_exch_size = switch (arch) {
45-
// On AMDGPU, there are no instructions for atomic operations other than load and store
45+
// On AMDGCN, there are no instructions for atomic operations other than load and store
4646
// (as of LLVM 15), and so these need to be implemented in terms of atomic CAS.
4747
.amdgcn => @sizeOf(u32),
4848
else => @sizeOf(u8),

lib/std/Target.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ pub const Os = struct {
719719

720720
pub const aarch64 = @import("Target/aarch64.zig");
721721
pub const arc = @import("Target/arc.zig");
722-
pub const amdgpu = @import("Target/amdgpu.zig");
722+
pub const amdgcn = @import("Target/amdgcn.zig");
723723
pub const arm = @import("Target/arm.zig");
724724
pub const avr = @import("Target/avr.zig");
725725
pub const bpf = @import("Target/bpf.zig");
@@ -1592,7 +1592,6 @@ pub const Cpu = struct {
15921592
.loongarch32, .loongarch64 => "loongarch",
15931593
.mips, .mipsel, .mips64, .mips64el => "mips",
15941594
.powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc",
1595-
.amdgcn => "amdgpu",
15961595
.riscv32, .riscv64 => "riscv",
15971596
.sparc, .sparc64 => "sparc",
15981597
.s390x => "s390x",
@@ -1621,7 +1620,7 @@ pub const Cpu = struct {
16211620
.mips, .mipsel, .mips64, .mips64el => &mips.all_features,
16221621
.msp430 => &msp430.all_features,
16231622
.powerpc, .powerpcle, .powerpc64, .powerpc64le => &powerpc.all_features,
1624-
.amdgcn => &amdgpu.all_features,
1623+
.amdgcn => &amdgcn.all_features,
16251624
.riscv32, .riscv64 => &riscv.all_features,
16261625
.sparc, .sparc64 => &sparc.all_features,
16271626
.spirv, .spirv32, .spirv64 => &spirv.all_features,
@@ -1653,7 +1652,7 @@ pub const Cpu = struct {
16531652
.mips, .mipsel, .mips64, .mips64el => comptime allCpusFromDecls(mips.cpu),
16541653
.msp430 => comptime allCpusFromDecls(msp430.cpu),
16551654
.powerpc, .powerpcle, .powerpc64, .powerpc64le => comptime allCpusFromDecls(powerpc.cpu),
1656-
.amdgcn => comptime allCpusFromDecls(amdgpu.cpu),
1655+
.amdgcn => comptime allCpusFromDecls(amdgcn.cpu),
16571656
.riscv32, .riscv64 => comptime allCpusFromDecls(riscv.cpu),
16581657
.sparc, .sparc64 => comptime allCpusFromDecls(sparc.cpu),
16591658
.spirv, .spirv32, .spirv64 => comptime allCpusFromDecls(spirv.cpu),
@@ -1891,7 +1890,7 @@ pub const Cpu = struct {
18911890
};
18921891
};
18931892
return switch (arch) {
1894-
.amdgcn => &amdgpu.cpu.gfx600,
1893+
.amdgcn => &amdgcn.cpu.gfx600,
18951894
.arc => &arc.cpu.generic,
18961895
.arm, .armeb, .thumb, .thumbeb => &arm.cpu.generic,
18971896
.aarch64, .aarch64_be => &aarch64.cpu.generic,
@@ -1940,7 +1939,7 @@ pub const Cpu = struct {
19401939
/// `Os.Tag.freestanding`.
19411940
pub fn baseline(arch: Arch, os: Os) *const Model {
19421941
return switch (arch) {
1943-
.amdgcn => &amdgpu.cpu.gfx906,
1942+
.amdgcn => &amdgcn.cpu.gfx906,
19441943
.arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline,
19451944
.aarch64 => switch (os.tag) {
19461945
.bridgeos, .driverkit, .macos => &aarch64.cpu.apple_m1,
@@ -3308,6 +3307,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
33083307
},
33093308
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
33103309
.netbsd => .{ .arm_apcs = .{} },
3310+
.watchos => .{ .arm_aapcs16_vfp = .{} },
33113311
else => switch (target.abi.floatAbi()) {
33123312
.soft => .{ .arm_aapcs = .{} },
33133313
.hard => .{ .arm_aapcs_vfp = .{} },
File renamed without changes.

lib/std/Thread.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ const WindowsThreadImpl = struct {
589589
fn_args: Args,
590590
thread: ThreadCompletion,
591591

592-
fn entryFn(raw_ptr: windows.PVOID) callconv(.C) windows.DWORD {
592+
fn entryFn(raw_ptr: windows.PVOID) callconv(.winapi) windows.DWORD {
593593
const self: *@This() = @ptrCast(@alignCast(raw_ptr));
594594
defer switch (self.thread.completion.swap(.completed, .seq_cst)) {
595595
.running => {},
@@ -749,7 +749,7 @@ const PosixThreadImpl = struct {
749749
const allocator = std.heap.c_allocator;
750750

751751
const Instance = struct {
752-
fn entryFn(raw_arg: ?*anyopaque) callconv(.C) ?*anyopaque {
752+
fn entryFn(raw_arg: ?*anyopaque) callconv(.c) ?*anyopaque {
753753
const args_ptr: *Args = @ptrCast(@alignCast(raw_arg));
754754
defer allocator.destroy(args_ptr);
755755
return callFn(f, args_ptr.*);
@@ -1363,7 +1363,7 @@ const LinuxThreadImpl = struct {
13631363
fn_args: Args,
13641364
thread: ThreadCompletion,
13651365

1366-
fn entryFn(raw_arg: usize) callconv(.C) u8 {
1366+
fn entryFn(raw_arg: usize) callconv(.c) u8 {
13671367
const self = @as(*@This(), @ptrFromInt(raw_arg));
13681368
defer switch (self.thread.completion.swap(.completed, .seq_cst)) {
13691369
.running => {},

lib/std/builtin.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,12 @@ pub const CallingConvention = union(enum(u8)) {
293293
arm_aapcs16_vfp: CommonOptions,
294294
arm_interrupt: ArmInterruptOptions,
295295

296-
// Calling conventions for the `mips64` architecture.
296+
// Calling conventions for the `mips64` and `mips64el` architectures.
297297
mips64_n64: CommonOptions,
298298
mips64_n32: CommonOptions,
299299
mips64_interrupt: MipsInterruptOptions,
300300

301-
// Calling conventions for the `mips` architecture.
301+
// Calling conventions for the `mips` and `mipsel` architectures.
302302
mips_o32: CommonOptions,
303303
mips_interrupt: MipsInterruptOptions,
304304

@@ -329,7 +329,7 @@ pub const CallingConvention = union(enum(u8)) {
329329
powerpc_aix: CommonOptions,
330330
powerpc_aix_altivec: CommonOptions,
331331

332-
/// The standard `wasm32`/`wasm64` calling convention, as specified in the WebAssembly Tool Conventions.
332+
/// The standard `wasm32` and `wasm64` calling convention, as specified in the WebAssembly Tool Conventions.
333333
wasm_watc: CommonOptions,
334334

335335
/// The standard `arc` calling convention.
@@ -396,7 +396,7 @@ pub const CallingConvention = union(enum(u8)) {
396396
amdgcn_kernel,
397397
amdgcn_cs: CommonOptions,
398398

399-
// Calling conventions for the `nvptx` architecture.
399+
// Calling conventions for the `nvptx` and `nvptx64` architectures.
400400
nvptx_device,
401401
nvptx_kernel,
402402

lib/std/debug.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ fn dumpSegfaultInfoPosix(sig: i32, code: i32, addr: usize, ctx_ptr: ?*anyopaque)
13441344
}
13451345
}
13461346

1347-
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long {
1347+
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.winapi) c_long {
13481348
switch (info.ExceptionRecord.ExceptionCode) {
13491349
windows.EXCEPTION_DATATYPE_MISALIGNMENT => handleSegfaultWindowsExtra(info, 0, "Unaligned Memory Access"),
13501350
windows.EXCEPTION_ACCESS_VIOLATION => handleSegfaultWindowsExtra(info, 1, null),

lib/std/os/windows.zig

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,8 +2101,8 @@ pub fn UnlockFile(
21012101

21022102
/// This is a workaround for the C backend until zig has the ability to put
21032103
/// C code in inline assembly.
2104-
extern fn zig_x86_windows_teb() callconv(.C) *anyopaque;
2105-
extern fn zig_x86_64_windows_teb() callconv(.C) *anyopaque;
2104+
extern fn zig_x86_windows_teb() callconv(.c) *anyopaque;
2105+
extern fn zig_x86_64_windows_teb() callconv(.c) *anyopaque;
21062106

21072107
pub fn teb() *TEB {
21082108
return switch (native_arch) {
@@ -2824,6 +2824,7 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1;
28242824
/// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
28252825
pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1;
28262826

2827+
/// Deprecated; use `std.builtin.CallingConvention.winapi` instead.
28272828
pub const WINAPI: std.builtin.CallingConvention = .winapi;
28282829

28292830
pub const BOOL = c_int;
@@ -3567,7 +3568,7 @@ pub const MEM_RESERVE_PLACEHOLDERS = 0x2;
35673568
pub const MEM_DECOMMIT = 0x4000;
35683569
pub const MEM_RELEASE = 0x8000;
35693570

3570-
pub const PTHREAD_START_ROUTINE = *const fn (LPVOID) callconv(.C) DWORD;
3571+
pub const PTHREAD_START_ROUTINE = *const fn (LPVOID) callconv(.winapi) DWORD;
35713572
pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
35723573

35733574
pub const WIN32_FIND_DATAW = extern struct {
@@ -3745,7 +3746,7 @@ pub const IMAGE_TLS_DIRECTORY = extern struct {
37453746
pub const IMAGE_TLS_DIRECTORY64 = IMAGE_TLS_DIRECTORY;
37463747
pub const IMAGE_TLS_DIRECTORY32 = IMAGE_TLS_DIRECTORY;
37473748

3748-
pub const PIMAGE_TLS_CALLBACK = ?*const fn (PVOID, DWORD, PVOID) callconv(.C) void;
3749+
pub const PIMAGE_TLS_CALLBACK = ?*const fn (PVOID, DWORD, PVOID) callconv(.winapi) void;
37493750

37503751
pub const PROV_RSA_FULL = 1;
37513752

@@ -3843,7 +3844,7 @@ pub const RTL_QUERY_REGISTRY_ROUTINE = ?*const fn (
38433844
ULONG,
38443845
?*anyopaque,
38453846
?*anyopaque,
3846-
) callconv(WINAPI) NTSTATUS;
3847+
) callconv(.winapi) NTSTATUS;
38473848

38483849
/// Path is a full path
38493850
pub const RTL_REGISTRY_ABSOLUTE = 0;
@@ -3940,7 +3941,7 @@ pub const FILE_ACTION_MODIFIED = 0x00000003;
39403941
pub const FILE_ACTION_RENAMED_OLD_NAME = 0x00000004;
39413942
pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
39423943

3943-
pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
3944+
pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.winapi) void;
39443945

39453946
pub const FileNotifyChangeFilter = packed struct(DWORD) {
39463947
file_name: bool = false,
@@ -4003,7 +4004,7 @@ pub const RTL_CRITICAL_SECTION = extern struct {
40034004
pub const CRITICAL_SECTION = RTL_CRITICAL_SECTION;
40044005
pub const INIT_ONCE = RTL_RUN_ONCE;
40054006
pub const INIT_ONCE_STATIC_INIT = RTL_RUN_ONCE_INIT;
4006-
pub const INIT_ONCE_FN = *const fn (InitOnce: *INIT_ONCE, Parameter: ?*anyopaque, Context: ?*anyopaque) callconv(.C) BOOL;
4007+
pub const INIT_ONCE_FN = *const fn (InitOnce: *INIT_ONCE, Parameter: ?*anyopaque, Context: ?*anyopaque) callconv(.winapi) BOOL;
40074008

40084009
pub const RTL_RUN_ONCE = extern struct {
40094010
Ptr: ?*anyopaque,
@@ -4467,15 +4468,15 @@ pub const EXCEPTION_POINTERS = extern struct {
44674468
ContextRecord: *CONTEXT,
44684469
};
44694470

4470-
pub const VECTORED_EXCEPTION_HANDLER = *const fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;
4471+
pub const VECTORED_EXCEPTION_HANDLER = *const fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(.winapi) c_long;
44714472

44724473
pub const EXCEPTION_DISPOSITION = i32;
44734474
pub const EXCEPTION_ROUTINE = *const fn (
44744475
ExceptionRecord: ?*EXCEPTION_RECORD,
44754476
EstablisherFrame: PVOID,
44764477
ContextRecord: *(Self.CONTEXT),
44774478
DispatcherContext: PVOID,
4478-
) callconv(WINAPI) EXCEPTION_DISPOSITION;
4479+
) callconv(.winapi) EXCEPTION_DISPOSITION;
44794480

44804481
pub const UNWIND_HISTORY_TABLE_SIZE = 12;
44814482
pub const UNWIND_HISTORY_TABLE_ENTRY = extern struct {
@@ -4851,7 +4852,7 @@ pub const RTL_DRIVE_LETTER_CURDIR = extern struct {
48514852
DosPath: UNICODE_STRING,
48524853
};
48534854

4854-
pub const PPS_POST_PROCESS_INIT_ROUTINE = ?*const fn () callconv(.C) void;
4855+
pub const PPS_POST_PROCESS_INIT_ROUTINE = ?*const fn () callconv(.winapi) void;
48554856

48564857
pub const FILE_DIRECTORY_INFORMATION = extern struct {
48574858
NextEntryOffset: ULONG,
@@ -4905,7 +4906,7 @@ pub fn FileInformationIterator(comptime FileInformationType: type) type {
49054906
};
49064907
}
49074908

4908-
pub const IO_APC_ROUTINE = *const fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.C) void;
4909+
pub const IO_APC_ROUTINE = *const fn (PVOID, *IO_STATUS_BLOCK, ULONG) callconv(.winapi) void;
49094910

49104911
pub const CURDIR = extern struct {
49114912
DosPath: UNICODE_STRING,
@@ -5009,8 +5010,8 @@ pub const ENUM_PAGE_FILE_INFORMATION = extern struct {
50095010
PeakUsage: SIZE_T,
50105011
};
50115012

5012-
pub const PENUM_PAGE_FILE_CALLBACKW = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCWSTR) callconv(.C) BOOL;
5013-
pub const PENUM_PAGE_FILE_CALLBACKA = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCSTR) callconv(.C) BOOL;
5013+
pub const PENUM_PAGE_FILE_CALLBACKW = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCWSTR) callconv(.winapi) BOOL;
5014+
pub const PENUM_PAGE_FILE_CALLBACKA = ?*const fn (?LPVOID, *ENUM_PAGE_FILE_INFORMATION, LPCSTR) callconv(.winapi) BOOL;
50145015

50155016
pub const PSAPI_WS_WATCH_INFORMATION_EX = extern struct {
50165017
BasicInfo: PSAPI_WS_WATCH_INFORMATION,
@@ -5122,7 +5123,7 @@ pub const CTRL_CLOSE_EVENT: DWORD = 2;
51225123
pub const CTRL_LOGOFF_EVENT: DWORD = 5;
51235124
pub const CTRL_SHUTDOWN_EVENT: DWORD = 6;
51245125

5125-
pub const HANDLER_ROUTINE = *const fn (dwCtrlType: DWORD) callconv(WINAPI) BOOL;
5126+
pub const HANDLER_ROUTINE = *const fn (dwCtrlType: DWORD) callconv(.winapi) BOOL;
51265127

51275128
/// Processor feature enumeration.
51285129
pub const PF = enum(DWORD) {

lib/std/os/windows/advapi32.zig

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ const LPCWSTR = windows.LPCWSTR;
88
const LSTATUS = windows.LSTATUS;
99
const REGSAM = windows.REGSAM;
1010
const ULONG = windows.ULONG;
11-
const WINAPI = windows.WINAPI;
1211

1312
pub extern "advapi32" fn RegOpenKeyExW(
1413
hKey: HKEY,
1514
lpSubKey: LPCWSTR,
1615
ulOptions: DWORD,
1716
samDesired: REGSAM,
1817
phkResult: *HKEY,
19-
) callconv(WINAPI) LSTATUS;
18+
) callconv(.winapi) LSTATUS;
2019

2120
pub extern "advapi32" fn RegQueryValueExW(
2221
hKey: HKEY,
@@ -25,13 +24,13 @@ pub extern "advapi32" fn RegQueryValueExW(
2524
lpType: ?*DWORD,
2625
lpData: ?*BYTE,
2726
lpcbData: ?*DWORD,
28-
) callconv(WINAPI) LSTATUS;
27+
) callconv(.winapi) LSTATUS;
2928

30-
pub extern "advapi32" fn RegCloseKey(hKey: HKEY) callconv(WINAPI) LSTATUS;
29+
pub extern "advapi32" fn RegCloseKey(hKey: HKEY) callconv(.winapi) LSTATUS;
3130

3231
// RtlGenRandom is known as SystemFunction036 under advapi32
3332
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
34-
pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(WINAPI) BOOL;
33+
pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(.winapi) BOOL;
3534
pub const RtlGenRandom = SystemFunction036;
3635

3736
pub const RRF = struct {
@@ -62,12 +61,12 @@ pub extern "advapi32" fn RegGetValueW(
6261
pdwType: ?*DWORD,
6362
pvData: ?*anyopaque,
6463
pcbData: ?*DWORD,
65-
) callconv(WINAPI) LSTATUS;
64+
) callconv(.winapi) LSTATUS;
6665

6766
pub extern "advapi32" fn RegLoadAppKeyW(
6867
lpFile: LPCWSTR,
6968
phkResult: *HKEY,
7069
samDesired: REGSAM,
7170
dwOptions: DWORD,
7271
reserved: DWORD,
73-
) callconv(WINAPI) LSTATUS;
72+
) callconv(.winapi) LSTATUS;

lib/std/os/windows/crypt32.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const BOOL = windows.BOOL;
44
const DWORD = windows.DWORD;
55
const BYTE = windows.BYTE;
66
const LPCWSTR = windows.LPCWSTR;
7-
const WINAPI = windows.WINAPI;
87

98
pub const CERT_INFO = *opaque {};
109
pub const HCERTSTORE = *opaque {};
@@ -19,14 +18,14 @@ pub const CERT_CONTEXT = extern struct {
1918
pub extern "crypt32" fn CertOpenSystemStoreW(
2019
_: ?*const anyopaque,
2120
szSubsystemProtocol: LPCWSTR,
22-
) callconv(WINAPI) ?HCERTSTORE;
21+
) callconv(.winapi) ?HCERTSTORE;
2322

2423
pub extern "crypt32" fn CertCloseStore(
2524
hCertStore: HCERTSTORE,
2625
dwFlags: DWORD,
27-
) callconv(WINAPI) BOOL;
26+
) callconv(.winapi) BOOL;
2827

2928
pub extern "crypt32" fn CertEnumCertificatesInStore(
3029
hCertStore: HCERTSTORE,
3130
pPrevCertContext: ?*CERT_CONTEXT,
32-
) callconv(WINAPI) ?*CERT_CONTEXT;
31+
) callconv(.winapi) ?*CERT_CONTEXT;

0 commit comments

Comments
 (0)