mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
Merge branch 'LemonBoy-cc-work'
This commit is contained in:
commit
633b6bf920
@ -818,6 +818,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
|
||||
.Keyword_resume,
|
||||
.Keyword_return,
|
||||
.Keyword_linksection,
|
||||
.Keyword_callconv,
|
||||
.Keyword_stdcallcc,
|
||||
.Keyword_struct,
|
||||
.Keyword_suspend,
|
||||
|
||||
@ -2829,7 +2829,7 @@ test "@tagName" {
|
||||
<p>
|
||||
By default, enums are not guaranteed to be compatible with the C ABI:
|
||||
</p>
|
||||
{#code_begin|obj_err|parameter of type 'Foo' not allowed in function with calling convention 'ccc'#}
|
||||
{#code_begin|obj_err|parameter of type 'Foo' not allowed in function with calling convention 'C'#}
|
||||
const Foo = enum { A, B, C };
|
||||
export fn entry(foo: Foo) void { }
|
||||
{#code_end#}
|
||||
@ -3974,7 +3974,7 @@ test "noreturn" {
|
||||
<p>Another use case for {#syntax#}noreturn{#endsyntax#} is the {#syntax#}exit{#endsyntax#} function:</p>
|
||||
{#code_begin|test#}
|
||||
{#target_windows#}
|
||||
pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: c_uint) noreturn;
|
||||
pub extern "kernel32" fn ExitProcess(exit_code: c_uint) callconv(.Stdcall) noreturn;
|
||||
|
||||
test "foo" {
|
||||
const value = bar() catch ExitProcess(1);
|
||||
@ -4008,8 +4008,8 @@ export fn sub(a: i8, b: i8) i8 { return a - b; }
|
||||
// The extern specifier is used to declare a function that will be resolved
|
||||
// at link time, when linking statically, or at runtime, when linking
|
||||
// dynamically.
|
||||
// The stdcallcc specifier changes the calling convention of the function.
|
||||
extern "kernel32" stdcallcc fn ExitProcess(exit_code: u32) noreturn;
|
||||
// The callconv specifier changes the calling convention of the function.
|
||||
extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.Stdcall) noreturn;
|
||||
extern "c" fn atan2(a: f64, b: f64) f64;
|
||||
|
||||
// The @setCold builtin tells the optimizer that a function is rarely called.
|
||||
@ -4018,9 +4018,9 @@ fn abort() noreturn {
|
||||
while (true) {}
|
||||
}
|
||||
|
||||
// The nakedcc specifier makes a function not have any function prologue or epilogue.
|
||||
// The naked calling convention makes a function not have any function prologue or epilogue.
|
||||
// This can be useful when integrating with assembly.
|
||||
nakedcc fn _start() noreturn {
|
||||
fn _start() callconv(.Naked) noreturn {
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -7735,7 +7735,7 @@ const Derp = @OpaqueType();
|
||||
const Wat = @OpaqueType();
|
||||
|
||||
extern fn bar(d: *Derp) void;
|
||||
export fn foo(w: *Wat) void {
|
||||
fn foo(w: *Wat) callconv(.C) void {
|
||||
bar(w);
|
||||
}
|
||||
|
||||
@ -10382,9 +10382,7 @@ LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN
|
||||
|
||||
# Fn specific
|
||||
FnCC
|
||||
<- KEYWORD_nakedcc
|
||||
/ KEYWORD_stdcallcc
|
||||
/ KEYWORD_extern
|
||||
<- KEYWORD_extern
|
||||
/ KEYWORD_async
|
||||
|
||||
ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
|
||||
@ -10648,7 +10646,6 @@ KEYWORD_fn <- 'fn' end_of_word
|
||||
KEYWORD_for <- 'for' end_of_word
|
||||
KEYWORD_if <- 'if' end_of_word
|
||||
KEYWORD_inline <- 'inline' end_of_word
|
||||
KEYWORD_nakedcc <- 'nakedcc' end_of_word
|
||||
KEYWORD_noalias <- 'noalias' end_of_word
|
||||
KEYWORD_null <- 'null' end_of_word
|
||||
KEYWORD_or <- 'or' end_of_word
|
||||
@ -10659,7 +10656,6 @@ KEYWORD_pub <- 'pub' end_of_word
|
||||
KEYWORD_resume <- 'resume' end_of_word
|
||||
KEYWORD_return <- 'return' end_of_word
|
||||
KEYWORD_linksection <- 'linksection' end_of_word
|
||||
KEYWORD_stdcallcc <- 'stdcallcc' end_of_word
|
||||
KEYWORD_struct <- 'struct' end_of_word
|
||||
KEYWORD_suspend <- 'suspend' end_of_word
|
||||
KEYWORD_switch <- 'switch' end_of_word
|
||||
@ -10681,10 +10677,10 @@ keyword <- KEYWORD_align / KEYWORD_and / KEYWORD_allowzero / KEYWORD_asm
|
||||
/ KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer
|
||||
/ KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false
|
||||
/ KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline
|
||||
/ KEYWORD_nakedcc / KEYWORD_noalias / KEYWORD_null / KEYWORD_or
|
||||
/ KEYWORD_noalias / KEYWORD_null / KEYWORD_or
|
||||
/ KEYWORD_orelse / KEYWORD_packed / KEYWORD_promise / KEYWORD_pub
|
||||
/ KEYWORD_resume / KEYWORD_return / KEYWORD_linksection
|
||||
/ KEYWORD_stdcallcc / KEYWORD_struct / KEYWORD_suspend
|
||||
/ KEYWORD_struct / KEYWORD_suspend
|
||||
/ KEYWORD_switch / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try
|
||||
/ KEYWORD_undefined / KEYWORD_union / KEYWORD_unreachable
|
||||
/ KEYWORD_usingnamespace / KEYWORD_var / KEYWORD_volatile / KEYWORD_while</code></pre>
|
||||
|
||||
@ -14,6 +14,7 @@ pub const TranslateCStep = struct {
|
||||
source: build.FileSource,
|
||||
output_dir: ?[]const u8,
|
||||
out_basename: []const u8,
|
||||
target: std.Target = .Native,
|
||||
|
||||
pub fn create(builder: *Builder, source: build.FileSource) *TranslateCStep {
|
||||
const self = builder.allocator.create(TranslateCStep) catch unreachable;
|
||||
@ -38,6 +39,10 @@ pub const TranslateCStep = struct {
|
||||
) catch unreachable;
|
||||
}
|
||||
|
||||
pub fn setTarget(self: *TranslateCStep, target: std.Target) void {
|
||||
self.target = target;
|
||||
}
|
||||
|
||||
/// Creates a step to build an executable from the translated source.
|
||||
pub fn addExecutable(self: *TranslateCStep) *LibExeObjStep {
|
||||
return self.builder.addExecutableSource("translated_c", @as(build.FileSource, .{ .translate_c = self }));
|
||||
@ -50,16 +55,25 @@ pub const TranslateCStep = struct {
|
||||
fn make(step: *Step) !void {
|
||||
const self = @fieldParentPtr(TranslateCStep, "step", step);
|
||||
|
||||
const argv = [_][]const u8{
|
||||
self.builder.zig_exe,
|
||||
"translate-c",
|
||||
"-lc",
|
||||
"--cache",
|
||||
"on",
|
||||
self.source.getPath(self.builder),
|
||||
};
|
||||
var argv_list = std.ArrayList([]const u8).init(self.builder.allocator);
|
||||
try argv_list.append(self.builder.zig_exe);
|
||||
try argv_list.append("translate-c");
|
||||
try argv_list.append("-lc");
|
||||
|
||||
const output_path_nl = try self.builder.exec(&argv);
|
||||
try argv_list.append("--cache");
|
||||
try argv_list.append("on");
|
||||
|
||||
switch (self.target) {
|
||||
.Native => {},
|
||||
.Cross => {
|
||||
try argv_list.append("-target");
|
||||
try argv_list.append(try self.target.zigTriple(self.builder.allocator));
|
||||
},
|
||||
}
|
||||
|
||||
try argv_list.append(self.source.getPath(self.builder));
|
||||
|
||||
const output_path_nl = try self.builder.exec(argv_list.toSliceConst());
|
||||
const output_path = mem.trimRight(u8, output_path_nl, "\r\n");
|
||||
|
||||
self.out_basename = fs.path.basename(output_path);
|
||||
|
||||
@ -91,6 +91,25 @@ pub const Mode = enum {
|
||||
ReleaseSmall,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
/// therefore must be kept in sync with the compiler implementation.
|
||||
pub const CallingConvention = enum {
|
||||
Unspecified,
|
||||
C,
|
||||
Cold,
|
||||
Naked,
|
||||
Async,
|
||||
Interrupt,
|
||||
Signal,
|
||||
Stdcall,
|
||||
Fastcall,
|
||||
Vectorcall,
|
||||
Thiscall,
|
||||
APCS,
|
||||
AAPCS,
|
||||
AAPCSVFP,
|
||||
};
|
||||
|
||||
pub const TypeId = @TagType(TypeInfo);
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
@ -253,17 +272,6 @@ pub const TypeInfo = union(enum) {
|
||||
decls: []Declaration,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
/// therefore must be kept in sync with the compiler implementation.
|
||||
pub const CallingConvention = enum {
|
||||
Unspecified,
|
||||
C,
|
||||
Cold,
|
||||
Naked,
|
||||
Stdcall,
|
||||
Async,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
/// therefore must be kept in sync with the compiler implementation.
|
||||
pub const FnArg = struct {
|
||||
@ -314,7 +322,6 @@ pub const TypeInfo = union(enum) {
|
||||
pub const FnDecl = struct {
|
||||
fn_type: type,
|
||||
inline_type: Inline,
|
||||
calling_convention: CallingConvention,
|
||||
is_var_args: bool,
|
||||
is_extern: bool,
|
||||
is_export: bool,
|
||||
|
||||
@ -2428,7 +2428,7 @@ fn resetSegfaultHandler() void {
|
||||
os.sigaction(os.SIGILL, &act, null);
|
||||
}
|
||||
|
||||
extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) noreturn {
|
||||
fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *const c_void) 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.
|
||||
@ -2475,7 +2475,7 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con
|
||||
os.abort();
|
||||
}
|
||||
|
||||
stdcallcc fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) c_long {
|
||||
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.Stdcall) c_long {
|
||||
const exception_address = @ptrToInt(info.ExceptionRecord.ExceptionAddress);
|
||||
switch (info.ExceptionRecord.ExceptionCode) {
|
||||
windows.EXCEPTION_DATATYPE_MISALIGNMENT => panicExtra(null, exception_address, "Unaligned Memory Access", .{}),
|
||||
|
||||
@ -22,7 +22,7 @@ fn err(comptime s: []const u8) void {
|
||||
const allocator = &std.heap.FixedBufferAllocator.init(&mem_buffer).allocator;
|
||||
var p = std.json.Parser.init(allocator, false);
|
||||
|
||||
if(p.parse(s)) |_| {
|
||||
if (p.parse(s)) |_| {
|
||||
unreachable;
|
||||
} else |_| {}
|
||||
}
|
||||
@ -33,7 +33,7 @@ fn any(comptime s: []const u8) void {
|
||||
var mem_buffer: [1024 * 20]u8 = undefined;
|
||||
const allocator = &std.heap.FixedBufferAllocator.init(&mem_buffer).allocator;
|
||||
var p = std.json.Parser.init(allocator, false);
|
||||
|
||||
|
||||
_ = p.parse(s) catch {};
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ fn anyStreamingErrNonStreaming(comptime s: []const u8) void {
|
||||
const allocator = &std.heap.FixedBufferAllocator.init(&mem_buffer).allocator;
|
||||
var p = std.json.Parser.init(allocator, false);
|
||||
|
||||
if(p.parse(s)) |_| {
|
||||
if (p.parse(s)) |_| {
|
||||
unreachable;
|
||||
} else |_| {}
|
||||
}
|
||||
@ -1742,9 +1742,9 @@ test "i_number_double_huge_neg_exp" {
|
||||
test "i_number_huge_exp" {
|
||||
return error.SkipZigTest;
|
||||
// FIXME Integer overflow in parseFloat
|
||||
// any(
|
||||
// \\[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]
|
||||
// );
|
||||
// any(
|
||||
// \\[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]
|
||||
// );
|
||||
}
|
||||
|
||||
test "i_number_neg_int_huge_exp" {
|
||||
|
||||
@ -70,4 +70,3 @@ pub fn Sqrt(comptime T: type) type {
|
||||
else => T,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ const ResetEvent = std.ResetEvent;
|
||||
/// Example usage:
|
||||
/// var m = Mutex.init();
|
||||
/// defer m.deinit();
|
||||
///
|
||||
///
|
||||
/// const lock = m.acquire();
|
||||
/// defer lock.release();
|
||||
/// ... critical code
|
||||
@ -73,8 +73,8 @@ pub const Mutex = if (builtin.single_threaded)
|
||||
return self.tryAcquire() orelse @panic("deadlock detected");
|
||||
}
|
||||
}
|
||||
else if (builtin.os == .windows)
|
||||
// https://locklessinc.com/articles/keyed_events/
|
||||
else if (builtin.os == .windows)
|
||||
// https://locklessinc.com/articles/keyed_events/
|
||||
extern union {
|
||||
locked: u8,
|
||||
waiters: u32,
|
||||
@ -122,8 +122,8 @@ else if (builtin.os == .windows)
|
||||
return Held{ .mutex = self };
|
||||
}
|
||||
|
||||
// otherwise, try and update the waiting count.
|
||||
// then unset the WAKE bit so that another unlocker can wake up a thread.
|
||||
// otherwise, try and update the waiting count.
|
||||
// then unset the WAKE bit so that another unlocker can wake up a thread.
|
||||
} else if (@cmpxchgWeak(u32, &self.waiters, waiters, (waiters + WAIT) | 1, .Monotonic, .Monotonic) == null) {
|
||||
const rc = windows.ntdll.NtWaitForKeyedEvent(handle, key, windows.FALSE, null);
|
||||
assert(rc == 0);
|
||||
@ -143,7 +143,7 @@ else if (builtin.os == .windows)
|
||||
|
||||
while (true) : (SpinLock.loopHint(1)) {
|
||||
const waiters = @atomicLoad(u32, &self.mutex.waiters, .Monotonic);
|
||||
|
||||
|
||||
// no one is waiting
|
||||
if (waiters < WAIT) return;
|
||||
// someone grabbed the lock and will do the wake instead
|
||||
@ -155,14 +155,14 @@ else if (builtin.os == .windows)
|
||||
if (@cmpxchgWeak(u32, &self.mutex.waiters, waiters, waiters - WAIT + WAKE, .Release, .Monotonic) == null) {
|
||||
const rc = windows.ntdll.NtReleaseKeyedEvent(handle, key, windows.FALSE, null);
|
||||
assert(rc == 0);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
else if (builtin.link_libc or builtin.os == .linux)
|
||||
// stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs
|
||||
// stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs
|
||||
struct {
|
||||
state: usize,
|
||||
|
||||
@ -195,8 +195,8 @@ else if (builtin.link_libc or builtin.os == .linux)
|
||||
|
||||
pub fn acquire(self: *Mutex) Held {
|
||||
return self.tryAcquire() orelse {
|
||||
self.acquireSlow();
|
||||
return Held{ .mutex = self };
|
||||
self.acquireSlow();
|
||||
return Held{ .mutex = self };
|
||||
};
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ else if (builtin.link_libc or builtin.os == .linux)
|
||||
|
||||
fn releaseSlow(self: *Mutex) void {
|
||||
@setCold(true);
|
||||
|
||||
|
||||
// try and lock the LFIO queue to pop a node off,
|
||||
// stopping altogether if its already locked or the queue is empty
|
||||
var state = @atomicLoad(usize, &self.state, .Monotonic);
|
||||
@ -293,9 +293,10 @@ else if (builtin.link_libc or builtin.os == .linux)
|
||||
}
|
||||
}
|
||||
|
||||
// for platforms without a known OS blocking
|
||||
// primitive, default to SpinLock for correctness
|
||||
else SpinLock;
|
||||
// for platforms without a known OS blocking
|
||||
// primitive, default to SpinLock for correctness
|
||||
else
|
||||
SpinLock;
|
||||
|
||||
const TestContext = struct {
|
||||
mutex: *Mutex,
|
||||
|
||||
@ -451,11 +451,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
|
||||
.next = null,
|
||||
};
|
||||
var res: *os.addrinfo = undefined;
|
||||
switch (os.system.getaddrinfo(
|
||||
name_c.ptr,
|
||||
@ptrCast([*:0]const u8, port_c.ptr),
|
||||
&hints,
|
||||
&res)) {
|
||||
switch (os.system.getaddrinfo(name_c.ptr, @ptrCast([*:0]const u8, port_c.ptr), &hints, &res)) {
|
||||
0 => {},
|
||||
c.EAI_ADDRFAMILY => return error.HostLacksNetworkAddresses,
|
||||
c.EAI_AGAIN => return error.TemporaryNameServerFailure,
|
||||
|
||||
@ -512,7 +512,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
|
||||
return syscall2(SYS_clock_gettime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
|
||||
}
|
||||
|
||||
extern fn init_vdso_clock_gettime(clk: i32, ts: *timespec) usize {
|
||||
fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
|
||||
const ptr = @intToPtr(?*const c_void, 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
|
||||
|
||||
@ -91,13 +91,13 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, a
|
||||
// LLVM calls this when the read-tp-hard feature is set to false. Currently, there is no way to pass
|
||||
// that to llvm via zig, see https://github.com/ziglang/zig/issues/2883.
|
||||
// LLVM expects libc to provide this function as __aeabi_read_tp, so it is exported if needed from special/c.zig.
|
||||
pub extern fn getThreadPointer() usize {
|
||||
pub fn getThreadPointer() callconv(.C) usize {
|
||||
return asm volatile ("mrc p15, 0, %[ret], c13, c0, 3"
|
||||
: [ret] "=r" (-> usize)
|
||||
);
|
||||
}
|
||||
|
||||
pub nakedcc fn restore() void {
|
||||
pub fn restore() callconv(.Naked) void {
|
||||
return asm volatile ("svc #0"
|
||||
:
|
||||
: [number] "{r7}" (@as(usize, SYS_sigreturn))
|
||||
@ -105,7 +105,7 @@ pub nakedcc fn restore() void {
|
||||
);
|
||||
}
|
||||
|
||||
pub nakedcc fn restore_rt() void {
|
||||
pub fn restore_rt() callconv(.Naked) void {
|
||||
return asm volatile ("svc #0"
|
||||
:
|
||||
: [number] "{r7}" (@as(usize, SYS_rt_sigreturn))
|
||||
|
||||
@ -90,7 +90,7 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, a
|
||||
|
||||
pub const restore = restore_rt;
|
||||
|
||||
pub nakedcc fn restore_rt() void {
|
||||
pub fn restore_rt() callconv(.Naked) void {
|
||||
return asm volatile ("svc #0"
|
||||
:
|
||||
: [number] "{x8}" (@as(usize, SYS_rt_sigreturn))
|
||||
|
||||
@ -102,7 +102,7 @@ pub fn socketcall(call: usize, args: [*]usize) usize {
|
||||
/// This matches the libc clone function.
|
||||
pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
|
||||
|
||||
pub nakedcc fn restore() void {
|
||||
pub fn restore() callconv(.Naked) void {
|
||||
return asm volatile ("int $0x80"
|
||||
:
|
||||
: [number] "{eax}" (@as(usize, SYS_sigreturn))
|
||||
@ -110,7 +110,7 @@ pub nakedcc fn restore() void {
|
||||
);
|
||||
}
|
||||
|
||||
pub nakedcc fn restore_rt() void {
|
||||
pub fn restore_rt() callconv(.Naked) void {
|
||||
return asm volatile ("int $0x80"
|
||||
:
|
||||
: [number] "{eax}" (@as(usize, SYS_rt_sigreturn))
|
||||
|
||||
@ -144,7 +144,7 @@ pub fn syscall6(
|
||||
/// This matches the libc clone function.
|
||||
pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
|
||||
|
||||
pub nakedcc fn restore() void {
|
||||
pub fn restore() callconv(.Naked) void {
|
||||
return asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{$2}" (@as(usize, SYS_sigreturn))
|
||||
@ -152,7 +152,7 @@ pub nakedcc fn restore() void {
|
||||
);
|
||||
}
|
||||
|
||||
pub nakedcc fn restore_rt() void {
|
||||
pub fn restore_rt() callconv(.Naked) void {
|
||||
return asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{$2}" (@as(usize, SYS_rt_sigreturn))
|
||||
|
||||
@ -89,7 +89,7 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, a
|
||||
|
||||
pub const restore = restore_rt;
|
||||
|
||||
pub nakedcc fn restore_rt() void {
|
||||
pub fn restore_rt() callconv(.Naked) void {
|
||||
return asm volatile ("ecall"
|
||||
:
|
||||
: [number] "{x17}" (@as(usize, SYS_rt_sigreturn))
|
||||
|
||||
@ -90,7 +90,7 @@ pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize,
|
||||
|
||||
pub const restore = restore_rt;
|
||||
|
||||
pub nakedcc fn restore_rt() void {
|
||||
pub fn restore_rt() callconv(.Naked) void {
|
||||
return asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (@as(usize, SYS_rt_sigreturn))
|
||||
|
||||
@ -166,7 +166,7 @@ test "sigaltstack" {
|
||||
// analyzed
|
||||
const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void;
|
||||
|
||||
export fn iter_fn(info: *dl_phdr_info, size: usize, data: ?*usize) i32 {
|
||||
fn iter_fn(info: *dl_phdr_info, size: usize, data: ?*usize) callconv(.C) i32 {
|
||||
if (builtin.os == .windows or builtin.os == .wasi or builtin.os == .macosx)
|
||||
return 0;
|
||||
|
||||
|
||||
@ -27,4 +27,3 @@ pub const SimpleTextInputProtocol = extern struct {
|
||||
.node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
usingnamespace @import("bits.zig");
|
||||
|
||||
pub extern "advapi32" stdcallcc fn RegOpenKeyExW(
|
||||
pub extern "advapi32" fn RegOpenKeyExW(
|
||||
hKey: HKEY,
|
||||
lpSubKey: LPCWSTR,
|
||||
ulOptions: DWORD,
|
||||
samDesired: REGSAM,
|
||||
phkResult: *HKEY,
|
||||
) LSTATUS;
|
||||
) callconv(.Stdcall) LSTATUS;
|
||||
|
||||
pub extern "advapi32" stdcallcc fn RegQueryValueExW(
|
||||
pub extern "advapi32" fn RegQueryValueExW(
|
||||
hKey: HKEY,
|
||||
lpValueName: LPCWSTR,
|
||||
lpReserved: LPDWORD,
|
||||
lpType: LPDWORD,
|
||||
lpData: LPBYTE,
|
||||
lpcbData: LPDWORD,
|
||||
) LSTATUS;
|
||||
) callconv(.Stdcall) LSTATUS;
|
||||
|
||||
// RtlGenRandom is known as SystemFunction036 under advapi32
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
|
||||
pub extern "advapi32" stdcallcc fn SystemFunction036(output: [*]u8, length: ULONG) BOOL;
|
||||
pub extern "advapi32" fn SystemFunction036(output: [*]u8, length: ULONG) callconv(.Stdcall) BOOL;
|
||||
pub const RtlGenRandom = SystemFunction036;
|
||||
|
||||
@ -892,7 +892,7 @@ pub const EXCEPTION_POINTERS = extern struct {
|
||||
ContextRecord: *c_void,
|
||||
};
|
||||
|
||||
pub const VECTORED_EXCEPTION_HANDLER = stdcallcc fn (ExceptionInfo: *EXCEPTION_POINTERS) c_long;
|
||||
pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(.Stdcall) c_long;
|
||||
|
||||
pub const OBJECT_ATTRIBUTES = extern struct {
|
||||
Length: ULONG,
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
usingnamespace @import("bits.zig");
|
||||
|
||||
pub extern "kernel32" stdcallcc fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) ?*c_void;
|
||||
pub extern "kernel32" stdcallcc fn RemoveVectoredExceptionHandler(Handle: HANDLE) c_ulong;
|
||||
pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(.Stdcall) ?*c_void;
|
||||
pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(.Stdcall) c_ulong;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) BOOL;
|
||||
pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CloseHandle(hObject: HANDLE) BOOL;
|
||||
pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateDirectoryW(lpPathName: [*]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) BOOL;
|
||||
pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*]const u16, lpSecurityAttributes: ?*SECURITY_ATTRIBUTES) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateEventExW(
|
||||
pub extern "kernel32" fn CreateEventExW(
|
||||
lpEventAttributes: ?*SECURITY_ATTRIBUTES,
|
||||
lpName: [*:0]const u16,
|
||||
dwFlags: DWORD,
|
||||
dwDesiredAccess: DWORD,
|
||||
) ?HANDLE;
|
||||
) callconv(.Stdcall) ?HANDLE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateFileW(
|
||||
pub extern "kernel32" fn CreateFileW(
|
||||
lpFileName: [*]const u16, // TODO null terminated pointer type
|
||||
dwDesiredAccess: DWORD,
|
||||
dwShareMode: DWORD,
|
||||
@ -24,16 +24,16 @@ pub extern "kernel32" stdcallcc fn CreateFileW(
|
||||
dwCreationDisposition: DWORD,
|
||||
dwFlagsAndAttributes: DWORD,
|
||||
hTemplateFile: ?HANDLE,
|
||||
) HANDLE;
|
||||
) callconv(.Stdcall) HANDLE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreatePipe(
|
||||
pub extern "kernel32" fn CreatePipe(
|
||||
hReadPipe: *HANDLE,
|
||||
hWritePipe: *HANDLE,
|
||||
lpPipeAttributes: *const SECURITY_ATTRIBUTES,
|
||||
nSize: DWORD,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateProcessW(
|
||||
pub extern "kernel32" fn CreateProcessW(
|
||||
lpApplicationName: ?LPWSTR,
|
||||
lpCommandLine: LPWSTR,
|
||||
lpProcessAttributes: ?*SECURITY_ATTRIBUTES,
|
||||
@ -44,15 +44,15 @@ pub extern "kernel32" stdcallcc fn CreateProcessW(
|
||||
lpCurrentDirectory: ?LPWSTR,
|
||||
lpStartupInfo: *STARTUPINFOW,
|
||||
lpProcessInformation: *PROCESS_INFORMATION,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateSymbolicLinkW(lpSymlinkFileName: [*]const u16, lpTargetFileName: [*]const u16, dwFlags: DWORD) BOOLEAN;
|
||||
pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*]const u16, lpTargetFileName: [*]const u16, dwFlags: DWORD) callconv(.Stdcall) BOOLEAN;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) ?HANDLE;
|
||||
pub extern "kernel32" fn CreateIoCompletionPort(FileHandle: HANDLE, ExistingCompletionPort: ?HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) callconv(.Stdcall) ?HANDLE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) ?HANDLE;
|
||||
pub extern "kernel32" fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) callconv(.Stdcall) ?HANDLE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn DeviceIoControl(
|
||||
pub extern "kernel32" fn DeviceIoControl(
|
||||
h: HANDLE,
|
||||
dwIoControlCode: DWORD,
|
||||
lpInBuffer: ?*const c_void,
|
||||
@ -61,107 +61,107 @@ pub extern "kernel32" stdcallcc fn DeviceIoControl(
|
||||
nOutBufferSize: DWORD,
|
||||
lpBytesReturned: ?*DWORD,
|
||||
lpOverlapped: ?*OVERLAPPED,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn DeleteFileW(lpFileName: [*]const u16) BOOL;
|
||||
pub extern "kernel32" fn DeleteFileW(lpFileName: [*]const u16) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) BOOL;
|
||||
pub extern "kernel32" fn DuplicateHandle(hSourceProcessHandle: HANDLE, hSourceHandle: HANDLE, hTargetProcessHandle: HANDLE, lpTargetHandle: *HANDLE, dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwOptions: DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) noreturn;
|
||||
pub extern "kernel32" fn ExitProcess(exit_code: UINT) callconv(.Stdcall) noreturn;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn FindFirstFileW(lpFileName: [*]const u16, lpFindFileData: *WIN32_FIND_DATAW) HANDLE;
|
||||
pub extern "kernel32" stdcallcc fn FindClose(hFindFile: HANDLE) BOOL;
|
||||
pub extern "kernel32" stdcallcc fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) BOOL;
|
||||
pub extern "kernel32" fn FindFirstFileW(lpFileName: [*]const u16, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) HANDLE;
|
||||
pub extern "kernel32" fn FindClose(hFindFile: HANDLE) callconv(.Stdcall) BOOL;
|
||||
pub extern "kernel32" fn FindNextFileW(hFindFile: HANDLE, lpFindFileData: *WIN32_FIND_DATAW) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: ?*va_list) DWORD;
|
||||
pub extern "kernel32" fn FormatMessageW(dwFlags: DWORD, lpSource: ?LPVOID, dwMessageId: DWORD, dwLanguageId: DWORD, lpBuffer: LPWSTR, nSize: DWORD, Arguments: ?*va_list) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn FreeEnvironmentStringsW(penv: [*]u16) BOOL;
|
||||
pub extern "kernel32" fn FreeEnvironmentStringsW(penv: [*]u16) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetCommandLineA() LPSTR;
|
||||
pub extern "kernel32" fn GetCommandLineA() callconv(.Stdcall) LPSTR;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) BOOL;
|
||||
pub extern "kernel32" fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) BOOL;
|
||||
pub extern "kernel32" fn GetConsoleScreenBufferInfo(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: *CONSOLE_SCREEN_BUFFER_INFO) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) DWORD;
|
||||
pub extern "kernel32" fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: ?[*]WCHAR) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetCurrentThread() HANDLE;
|
||||
pub extern "kernel32" stdcallcc fn GetCurrentThreadId() DWORD;
|
||||
pub extern "kernel32" fn GetCurrentThread() callconv(.Stdcall) HANDLE;
|
||||
pub extern "kernel32" fn GetCurrentThreadId() callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetEnvironmentStringsW() ?[*]u16;
|
||||
pub extern "kernel32" fn GetEnvironmentStringsW() callconv(.Stdcall) ?[*]u16;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: LPWSTR, nSize: DWORD) DWORD;
|
||||
pub extern "kernel32" fn GetEnvironmentVariableW(lpName: LPWSTR, lpBuffer: LPWSTR, nSize: DWORD) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) BOOL;
|
||||
pub extern "kernel32" fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) BOOL;
|
||||
pub extern "kernel32" fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetFileAttributesW(lpFileName: [*]const WCHAR) DWORD;
|
||||
pub extern "kernel32" fn GetFileAttributesW(lpFileName: [*]const WCHAR) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) DWORD;
|
||||
pub extern "kernel32" fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u16, nSize: DWORD) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetModuleHandleW(lpModuleName: ?[*]const WCHAR) HMODULE;
|
||||
pub extern "kernel32" fn GetModuleHandleW(lpModuleName: ?[*]const WCHAR) callconv(.Stdcall) HMODULE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetLastError() DWORD;
|
||||
pub extern "kernel32" fn GetLastError() callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetFileInformationByHandle(
|
||||
pub extern "kernel32" fn GetFileInformationByHandle(
|
||||
hFile: HANDLE,
|
||||
lpFileInformation: *BY_HANDLE_FILE_INFORMATION,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(
|
||||
pub extern "kernel32" fn GetFileInformationByHandleEx(
|
||||
in_hFile: HANDLE,
|
||||
in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
|
||||
out_lpFileInformation: *c_void,
|
||||
in_dwBufferSize: DWORD,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleW(
|
||||
pub extern "kernel32" fn GetFinalPathNameByHandleW(
|
||||
hFile: HANDLE,
|
||||
lpszFilePath: [*]u16,
|
||||
cchFilePath: DWORD,
|
||||
dwFlags: DWORD,
|
||||
) DWORD;
|
||||
) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) BOOL;
|
||||
pub extern "kernel32" fn GetOverlappedResult(hFile: HANDLE, lpOverlapped: *OVERLAPPED, lpNumberOfBytesTransferred: *DWORD, bWait: BOOL) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetProcessHeap() ?HANDLE;
|
||||
pub extern "kernel32" stdcallcc fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) BOOL;
|
||||
pub extern "kernel32" fn GetProcessHeap() callconv(.Stdcall) ?HANDLE;
|
||||
pub extern "kernel32" fn GetQueuedCompletionStatus(CompletionPort: HANDLE, lpNumberOfBytesTransferred: LPDWORD, lpCompletionKey: *ULONG_PTR, lpOverlapped: *?*OVERLAPPED, dwMilliseconds: DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) void;
|
||||
pub extern "kernel32" stdcallcc fn GetSystemTimeAsFileTime(*FILETIME) void;
|
||||
pub extern "kernel32" fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) callconv(.Stdcall) void;
|
||||
pub extern "kernel32" fn GetSystemTimeAsFileTime(*FILETIME) callconv(.Stdcall) void;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) ?HANDLE;
|
||||
pub extern "kernel32" stdcallcc fn HeapDestroy(hHeap: HANDLE) BOOL;
|
||||
pub extern "kernel32" stdcallcc fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) ?*c_void;
|
||||
pub extern "kernel32" stdcallcc fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) SIZE_T;
|
||||
pub extern "kernel32" stdcallcc fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) SIZE_T;
|
||||
pub extern "kernel32" stdcallcc fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) BOOL;
|
||||
pub extern "kernel32" fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) callconv(.Stdcall) ?HANDLE;
|
||||
pub extern "kernel32" fn HeapDestroy(hHeap: HANDLE) callconv(.Stdcall) BOOL;
|
||||
pub extern "kernel32" fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) callconv(.Stdcall) ?*c_void;
|
||||
pub extern "kernel32" fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) callconv(.Stdcall) SIZE_T;
|
||||
pub extern "kernel32" fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) callconv(.Stdcall) SIZE_T;
|
||||
pub extern "kernel32" fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetStdHandle(in_nStdHandle: DWORD) ?HANDLE;
|
||||
pub extern "kernel32" fn GetStdHandle(in_nStdHandle: DWORD) callconv(.Stdcall) ?HANDLE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) ?*c_void;
|
||||
pub extern "kernel32" fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) callconv(.Stdcall) ?*c_void;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) BOOL;
|
||||
pub extern "kernel32" fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: ?*const c_void) BOOL;
|
||||
pub extern "kernel32" fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: ?*const c_void) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD) ?LPVOID;
|
||||
pub extern "kernel32" stdcallcc fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) BOOL;
|
||||
pub extern "kernel32" fn VirtualAlloc(lpAddress: ?LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD) callconv(.Stdcall) ?LPVOID;
|
||||
pub extern "kernel32" fn VirtualFree(lpAddress: ?LPVOID, dwSize: SIZE_T, dwFreeType: DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn MoveFileExW(
|
||||
pub extern "kernel32" fn MoveFileExW(
|
||||
lpExistingFileName: [*]const u16,
|
||||
lpNewFileName: [*]const u16,
|
||||
dwFlags: DWORD,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn PostQueuedCompletionStatus(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ?*OVERLAPPED) BOOL;
|
||||
pub extern "kernel32" fn PostQueuedCompletionStatus(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ?*OVERLAPPED) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) BOOL;
|
||||
pub extern "kernel32" fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) BOOL;
|
||||
pub extern "kernel32" fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn ReadDirectoryChangesW(
|
||||
pub extern "kernel32" fn ReadDirectoryChangesW(
|
||||
hDirectory: HANDLE,
|
||||
lpBuffer: [*]align(@alignOf(FILE_NOTIFY_INFORMATION)) u8,
|
||||
nBufferLength: DWORD,
|
||||
@ -170,79 +170,79 @@ pub extern "kernel32" stdcallcc fn ReadDirectoryChangesW(
|
||||
lpBytesReturned: ?*DWORD,
|
||||
lpOverlapped: ?*OVERLAPPED,
|
||||
lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn ReadFile(
|
||||
pub extern "kernel32" fn ReadFile(
|
||||
in_hFile: HANDLE,
|
||||
out_lpBuffer: [*]u8,
|
||||
in_nNumberOfBytesToRead: DWORD,
|
||||
out_lpNumberOfBytesRead: ?*DWORD,
|
||||
in_out_lpOverlapped: ?*OVERLAPPED,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn RemoveDirectoryW(lpPathName: [*]const u16) BOOL;
|
||||
pub extern "kernel32" fn RemoveDirectoryW(lpPathName: [*]const u16) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) BOOL;
|
||||
pub extern "kernel32" fn SetConsoleTextAttribute(hConsoleOutput: HANDLE, wAttributes: WORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn SetFilePointerEx(
|
||||
pub extern "kernel32" fn SetFilePointerEx(
|
||||
in_fFile: HANDLE,
|
||||
in_liDistanceToMove: LARGE_INTEGER,
|
||||
out_opt_ldNewFilePointer: ?*LARGE_INTEGER,
|
||||
in_dwMoveMethod: DWORD,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn SetFileTime(
|
||||
pub extern "kernel32" fn SetFileTime(
|
||||
hFile: HANDLE,
|
||||
lpCreationTime: ?*const FILETIME,
|
||||
lpLastAccessTime: ?*const FILETIME,
|
||||
lpLastWriteTime: ?*const FILETIME,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) BOOL;
|
||||
pub extern "kernel32" fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn Sleep(dwMilliseconds: DWORD) void;
|
||||
pub extern "kernel32" fn Sleep(dwMilliseconds: DWORD) callconv(.Stdcall) void;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn SwitchToThread() BOOL;
|
||||
pub extern "kernel32" fn SwitchToThread() callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) BOOL;
|
||||
pub extern "kernel32" fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn TlsAlloc() DWORD;
|
||||
pub extern "kernel32" fn TlsAlloc() callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn TlsFree(dwTlsIndex: DWORD) BOOL;
|
||||
pub extern "kernel32" fn TlsFree(dwTlsIndex: DWORD) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) DWORD;
|
||||
pub extern "kernel32" fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) DWORD;
|
||||
pub extern "kernel32" fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) DWORD;
|
||||
pub extern "kernel32" fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn WaitForMultipleObjectsEx(
|
||||
pub extern "kernel32" fn WaitForMultipleObjectsEx(
|
||||
nCount: DWORD,
|
||||
lpHandle: [*]const HANDLE,
|
||||
bWaitAll: BOOL,
|
||||
dwMilliseconds: DWORD,
|
||||
bAlertable: BOOL,
|
||||
) DWORD;
|
||||
) callconv(.Stdcall) DWORD;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn WriteFile(
|
||||
pub extern "kernel32" fn WriteFile(
|
||||
in_hFile: HANDLE,
|
||||
in_lpBuffer: [*]const u8,
|
||||
in_nNumberOfBytesToWrite: DWORD,
|
||||
out_lpNumberOfBytesWritten: ?*DWORD,
|
||||
in_out_lpOverlapped: ?*OVERLAPPED,
|
||||
) BOOL;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) BOOL;
|
||||
pub extern "kernel32" fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const u8, nNumberOfBytesToWrite: DWORD, lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn LoadLibraryW(lpLibFileName: [*]const u16) ?HMODULE;
|
||||
pub extern "kernel32" fn LoadLibraryW(lpLibFileName: [*]const u16) callconv(.Stdcall) ?HMODULE;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) ?FARPROC;
|
||||
pub extern "kernel32" fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) callconv(.Stdcall) ?FARPROC;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn FreeLibrary(hModule: HMODULE) BOOL;
|
||||
pub extern "kernel32" fn FreeLibrary(hModule: HMODULE) callconv(.Stdcall) BOOL;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn InitializeCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
|
||||
pub extern "kernel32" stdcallcc fn EnterCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
|
||||
pub extern "kernel32" stdcallcc fn LeaveCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
|
||||
pub extern "kernel32" stdcallcc fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECTION) void;
|
||||
pub extern "kernel32" fn InitializeCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
|
||||
pub extern "kernel32" fn EnterCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
|
||||
pub extern "kernel32" fn LeaveCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
|
||||
pub extern "kernel32" fn DeleteCriticalSection(lpCriticalSection: *CRITICAL_SECTION) callconv(.Stdcall) void;
|
||||
|
||||
pub extern "kernel32" stdcallcc fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) BOOL;
|
||||
pub extern "kernel32" fn InitOnceExecuteOnce(InitOnce: *INIT_ONCE, InitFn: INIT_ONCE_FN, Parameter: ?*c_void, Context: ?*c_void) callconv(.Stdcall) BOOL;
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
usingnamespace @import("bits.zig");
|
||||
|
||||
pub extern "NtDll" stdcallcc fn RtlCaptureStackBackTrace(FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: **c_void, BackTraceHash: ?*DWORD) WORD;
|
||||
pub extern "NtDll" stdcallcc fn NtQueryInformationFile(
|
||||
pub extern "NtDll" fn RtlCaptureStackBackTrace(FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: **c_void, BackTraceHash: ?*DWORD) callconv(.Stdcall) WORD;
|
||||
pub extern "NtDll" fn NtQueryInformationFile(
|
||||
FileHandle: HANDLE,
|
||||
IoStatusBlock: *IO_STATUS_BLOCK,
|
||||
FileInformation: *c_void,
|
||||
Length: ULONG,
|
||||
FileInformationClass: FILE_INFORMATION_CLASS,
|
||||
) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn NtCreateFile(
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn NtCreateFile(
|
||||
FileHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: *OBJECT_ATTRIBUTES,
|
||||
@ -20,8 +20,8 @@ pub extern "NtDll" stdcallcc fn NtCreateFile(
|
||||
CreateOptions: ULONG,
|
||||
EaBuffer: ?*c_void,
|
||||
EaLength: ULONG,
|
||||
) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn NtDeviceIoControlFile(
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn NtDeviceIoControlFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
@ -32,17 +32,17 @@ pub extern "NtDll" stdcallcc fn NtDeviceIoControlFile(
|
||||
InputBufferLength: ULONG,
|
||||
OutputBuffer: ?PVOID,
|
||||
OutputBufferLength: ULONG,
|
||||
) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn NtClose(Handle: HANDLE) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn RtlDosPathNameToNtPathName_U(
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn NtClose(Handle: HANDLE) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn RtlDosPathNameToNtPathName_U(
|
||||
DosPathName: [*]const u16,
|
||||
NtPathName: *UNICODE_STRING,
|
||||
NtFileNamePart: ?*?[*]const u16,
|
||||
DirectoryInfo: ?*CURDIR,
|
||||
) BOOL;
|
||||
pub extern "NtDll" stdcallcc fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) void;
|
||||
) callconv(.Stdcall) BOOL;
|
||||
pub extern "NtDll" fn RtlFreeUnicodeString(UnicodeString: *UNICODE_STRING) callconv(.Stdcall) void;
|
||||
|
||||
pub extern "NtDll" stdcallcc fn NtQueryDirectoryFile(
|
||||
pub extern "NtDll" fn NtQueryDirectoryFile(
|
||||
FileHandle: HANDLE,
|
||||
Event: ?HANDLE,
|
||||
ApcRoutine: ?IO_APC_ROUTINE,
|
||||
@ -54,22 +54,22 @@ pub extern "NtDll" stdcallcc fn NtQueryDirectoryFile(
|
||||
ReturnSingleEntry: BOOLEAN,
|
||||
FileName: ?*UNICODE_STRING,
|
||||
RestartScan: BOOLEAN,
|
||||
) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn NtCreateKeyedEvent(
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn NtCreateKeyedEvent(
|
||||
KeyedEventHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: ?PVOID,
|
||||
Flags: ULONG,
|
||||
) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn NtReleaseKeyedEvent(
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn NtReleaseKeyedEvent(
|
||||
EventHandle: HANDLE,
|
||||
Key: *const c_void,
|
||||
Alertable: BOOLEAN,
|
||||
Timeout: ?*LARGE_INTEGER,
|
||||
) NTSTATUS;
|
||||
pub extern "NtDll" stdcallcc fn NtWaitForKeyedEvent(
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
pub extern "NtDll" fn NtWaitForKeyedEvent(
|
||||
EventHandle: HANDLE,
|
||||
Key: *const c_void,
|
||||
Alertable: BOOLEAN,
|
||||
Timeout: ?*LARGE_INTEGER,
|
||||
) NTSTATUS;
|
||||
) callconv(.Stdcall) NTSTATUS;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
usingnamespace @import("bits.zig");
|
||||
|
||||
pub extern "ole32" stdcallcc fn CoTaskMemFree(pv: LPVOID) void;
|
||||
pub extern "ole32" stdcallcc fn CoUninitialize() void;
|
||||
pub extern "ole32" stdcallcc fn CoGetCurrentProcess() DWORD;
|
||||
pub extern "ole32" stdcallcc fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) HRESULT;
|
||||
pub extern "ole32" fn CoTaskMemFree(pv: LPVOID) callconv(.Stdcall) void;
|
||||
pub extern "ole32" fn CoUninitialize() callconv(.Stdcall) void;
|
||||
pub extern "ole32" fn CoGetCurrentProcess() callconv(.Stdcall) DWORD;
|
||||
pub extern "ole32" fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) callconv(.Stdcall) HRESULT;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
usingnamespace @import("bits.zig");
|
||||
|
||||
pub extern "shell32" stdcallcc fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) HRESULT;
|
||||
pub extern "shell32" fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) callconv(.Stdcall) HRESULT;
|
||||
|
||||
@ -315,30 +315,30 @@ const IOC_WS2 = 0x08000000;
|
||||
|
||||
pub const SIO_BASE_HANDLE = IOC_OUT | IOC_WS2 | 34;
|
||||
|
||||
pub extern "ws2_32" stdcallcc fn WSAStartup(
|
||||
pub extern "ws2_32" fn WSAStartup(
|
||||
wVersionRequired: WORD,
|
||||
lpWSAData: *WSADATA,
|
||||
) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSACleanup() c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSAGetLastError() c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSASocketA(
|
||||
) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSACleanup() callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSAGetLastError() callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSASocketA(
|
||||
af: c_int,
|
||||
type: c_int,
|
||||
protocol: c_int,
|
||||
lpProtocolInfo: ?*WSAPROTOCOL_INFOA,
|
||||
g: GROUP,
|
||||
dwFlags: DWORD,
|
||||
) SOCKET;
|
||||
pub extern "ws2_32" stdcallcc fn WSASocketW(
|
||||
) callconv(.Stdcall) SOCKET;
|
||||
pub extern "ws2_32" fn WSASocketW(
|
||||
af: c_int,
|
||||
type: c_int,
|
||||
protocol: c_int,
|
||||
lpProtocolInfo: ?*WSAPROTOCOL_INFOW,
|
||||
g: GROUP,
|
||||
dwFlags: DWORD,
|
||||
) SOCKET;
|
||||
pub extern "ws2_32" stdcallcc fn closesocket(s: SOCKET) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSAIoctl(
|
||||
) callconv(.Stdcall) SOCKET;
|
||||
pub extern "ws2_32" fn closesocket(s: SOCKET) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSAIoctl(
|
||||
s: SOCKET,
|
||||
dwIoControlCode: DWORD,
|
||||
lpvInBuffer: ?*const c_void,
|
||||
@ -348,18 +348,18 @@ pub extern "ws2_32" stdcallcc fn WSAIoctl(
|
||||
lpcbBytesReturned: LPDWORD,
|
||||
lpOverlapped: ?*WSAOVERLAPPED,
|
||||
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn accept(
|
||||
) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn accept(
|
||||
s: SOCKET,
|
||||
addr: ?*sockaddr,
|
||||
addrlen: socklen_t,
|
||||
) SOCKET;
|
||||
pub extern "ws2_32" stdcallcc fn connect(
|
||||
) callconv(.Stdcall) SOCKET;
|
||||
pub extern "ws2_32" fn connect(
|
||||
s: SOCKET,
|
||||
name: *const sockaddr,
|
||||
namelen: socklen_t,
|
||||
) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSARecv(
|
||||
) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSARecv(
|
||||
s: SOCKET,
|
||||
lpBuffers: [*]const WSABUF,
|
||||
dwBufferCount: DWORD,
|
||||
@ -367,8 +367,8 @@ pub extern "ws2_32" stdcallcc fn WSARecv(
|
||||
lpFlags: *DWORD,
|
||||
lpOverlapped: ?*WSAOVERLAPPED,
|
||||
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSARecvFrom(
|
||||
) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSARecvFrom(
|
||||
s: SOCKET,
|
||||
lpBuffers: [*]const WSABUF,
|
||||
dwBufferCount: DWORD,
|
||||
@ -378,8 +378,8 @@ pub extern "ws2_32" stdcallcc fn WSARecvFrom(
|
||||
lpFromlen: socklen_t,
|
||||
lpOverlapped: ?*WSAOVERLAPPED,
|
||||
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSASend(
|
||||
) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSASend(
|
||||
s: SOCKET,
|
||||
lpBuffers: [*]WSABUF,
|
||||
dwBufferCount: DWORD,
|
||||
@ -387,8 +387,8 @@ pub extern "ws2_32" stdcallcc fn WSASend(
|
||||
dwFlags: DWORD,
|
||||
lpOverlapped: ?*WSAOVERLAPPED,
|
||||
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) c_int;
|
||||
pub extern "ws2_32" stdcallcc fn WSASendTo(
|
||||
) callconv(.Stdcall) c_int;
|
||||
pub extern "ws2_32" fn WSASendTo(
|
||||
s: SOCKET,
|
||||
lpBuffers: [*]WSABUF,
|
||||
dwBufferCount: DWORD,
|
||||
@ -398,4 +398,4 @@ pub extern "ws2_32" stdcallcc fn WSASendTo(
|
||||
iTolen: socklen_t,
|
||||
lpOverlapped: ?*WSAOVERLAPPED,
|
||||
lpCompletionRoutine: ?WSAOVERLAPPED_COMPLETION_ROUTINE,
|
||||
) c_int;
|
||||
) callconv(.Stdcall) c_int;
|
||||
|
||||
@ -14,13 +14,12 @@ const windows = os.windows;
|
||||
pub const ResetEvent = struct {
|
||||
os_event: OsEvent,
|
||||
|
||||
pub const OsEvent =
|
||||
if (builtin.single_threaded)
|
||||
DebugEvent
|
||||
else if (builtin.link_libc and builtin.os != .windows and builtin.os != .linux)
|
||||
PosixEvent
|
||||
else
|
||||
AtomicEvent;
|
||||
pub const OsEvent = if (builtin.single_threaded)
|
||||
DebugEvent
|
||||
else if (builtin.link_libc and builtin.os != .windows and builtin.os != .linux)
|
||||
PosixEvent
|
||||
else
|
||||
AtomicEvent;
|
||||
|
||||
pub fn init() ResetEvent {
|
||||
return ResetEvent{ .os_event = OsEvent.init() };
|
||||
@ -105,7 +104,7 @@ const PosixEvent = struct {
|
||||
}
|
||||
|
||||
fn deinit(self: *PosixEvent) void {
|
||||
// on dragonfly, *destroy() functions can return EINVAL
|
||||
// on dragonfly, *destroy() functions can return EINVAL
|
||||
// for statically initialized pthread structures
|
||||
const err = if (builtin.os == .dragonfly) os.EINVAL else 0;
|
||||
|
||||
@ -212,8 +211,7 @@ const AtomicEvent = struct {
|
||||
fn wait(self: *AtomicEvent, timeout: ?u64) !void {
|
||||
var waiters = @atomicLoad(u32, &self.waiters, .Acquire);
|
||||
while (waiters != WAKE) {
|
||||
waiters = @cmpxchgWeak(u32, &self.waiters, waiters, waiters + WAIT, .Acquire, .Acquire)
|
||||
orelse return Futex.wait(&self.waiters, timeout);
|
||||
waiters = @cmpxchgWeak(u32, &self.waiters, waiters, waiters + WAIT, .Acquire, .Acquire) orelse return Futex.wait(&self.waiters, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +279,7 @@ const AtomicEvent = struct {
|
||||
pub fn wake(waiters: *u32, wake_count: u32) void {
|
||||
const handle = getEventHandle() orelse return SpinFutex.wake(waiters, wake_count);
|
||||
const key = @ptrCast(*const c_void, waiters);
|
||||
|
||||
|
||||
var waiting = wake_count;
|
||||
while (waiting != 0) : (waiting -= 1) {
|
||||
const rc = windows.ntdll.NtReleaseKeyedEvent(handle, key, windows.FALSE, null);
|
||||
@ -408,7 +406,7 @@ test "std.ResetEvent" {
|
||||
// wait for receiver to update value and signal output
|
||||
self.out.wait();
|
||||
testing.expect(self.value == 2);
|
||||
|
||||
|
||||
// update value and signal final input
|
||||
self.value = 3;
|
||||
self.in.set();
|
||||
@ -418,12 +416,12 @@ test "std.ResetEvent" {
|
||||
// wait for sender to update value and signal input
|
||||
self.in.wait();
|
||||
assert(self.value == 1);
|
||||
|
||||
|
||||
// update value and signal output
|
||||
self.in.reset();
|
||||
self.value = 2;
|
||||
self.out.set();
|
||||
|
||||
|
||||
// wait for sender to update value and signal final input
|
||||
self.in.wait();
|
||||
assert(self.value == 3);
|
||||
|
||||
@ -40,19 +40,19 @@ comptime {
|
||||
extern var _fltused: c_int = 1;
|
||||
|
||||
extern fn main(argc: c_int, argv: [*:null]?[*:0]u8) c_int;
|
||||
extern fn wasm_start() void {
|
||||
fn wasm_start() callconv(.C) void {
|
||||
_ = main(0, undefined);
|
||||
}
|
||||
|
||||
extern fn strcmp(s1: [*:0]const u8, s2: [*:0]const u8) c_int {
|
||||
fn strcmp(s1: [*:0]const u8, s2: [*:0]const u8) callconv(.C) c_int {
|
||||
return std.cstr.cmp(s1, s2);
|
||||
}
|
||||
|
||||
extern fn strlen(s: [*:0]const u8) usize {
|
||||
fn strlen(s: [*:0]const u8) callconv(.C) usize {
|
||||
return std.mem.len(u8, s);
|
||||
}
|
||||
|
||||
extern fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) c_int {
|
||||
fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int {
|
||||
if (_n == 0) return 0;
|
||||
var l = _l;
|
||||
var r = _r;
|
||||
@ -65,7 +65,7 @@ extern fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) c_int {
|
||||
return @as(c_int, l[0]) - @as(c_int, r[0]);
|
||||
}
|
||||
|
||||
extern fn strerror(errnum: c_int) [*:0]const u8 {
|
||||
fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {
|
||||
return "TODO strerror implementation";
|
||||
}
|
||||
|
||||
@ -188,14 +188,14 @@ comptime {
|
||||
@export("clone", clone, builtin.GlobalLinkage.Strong);
|
||||
}
|
||||
}
|
||||
extern fn __stack_chk_fail() noreturn {
|
||||
fn __stack_chk_fail() callconv(.C) noreturn {
|
||||
@panic("stack smashing detected");
|
||||
}
|
||||
|
||||
// TODO we should be able to put this directly in std/linux/x86_64.zig but
|
||||
// it causes a segfault in release mode. this is a workaround of calling it
|
||||
// across .o file boundaries. fix comptime @ptrCast of nakedcc functions.
|
||||
nakedcc fn clone() void {
|
||||
fn clone() callconv(.Naked) void {
|
||||
switch (builtin.arch) {
|
||||
.i386 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
@ -750,7 +750,6 @@ test "sqrt special" {
|
||||
std.testing.expect(std.math.isNan(sqrt(std.math.nan(f64))));
|
||||
}
|
||||
|
||||
|
||||
export fn sqrtf(x: f32) f32 {
|
||||
const tiny: f32 = 1.0e-30;
|
||||
const sign: i32 = @bitCast(i32, @as(u32, 0x80000000));
|
||||
@ -848,4 +847,3 @@ test "sqrtf special" {
|
||||
std.testing.expect(std.math.isNan(sqrtf(-1.0)));
|
||||
std.testing.expect(std.math.isNan(sqrtf(std.math.nan(f32))));
|
||||
}
|
||||
|
||||
|
||||
@ -309,7 +309,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
|
||||
}
|
||||
}
|
||||
|
||||
extern fn __stack_chk_fail() noreturn {
|
||||
fn __stack_chk_fail() callconv(.C) noreturn {
|
||||
@panic("stack smashing detected");
|
||||
}
|
||||
|
||||
@ -320,17 +320,17 @@ extern var __stack_chk_guard: usize = blk: {
|
||||
break :blk @bitCast(usize, buf);
|
||||
};
|
||||
|
||||
extern fn __aeabi_unwind_cpp_pr0() void {
|
||||
fn __aeabi_unwind_cpp_pr0() callconv(.C) void {
|
||||
unreachable;
|
||||
}
|
||||
extern fn __aeabi_unwind_cpp_pr1() void {
|
||||
fn __aeabi_unwind_cpp_pr1() callconv(.C) void {
|
||||
unreachable;
|
||||
}
|
||||
extern fn __aeabi_unwind_cpp_pr2() void {
|
||||
fn __aeabi_unwind_cpp_pr2() callconv(.C) void {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
extern fn __divmoddi4(a: i64, b: i64, rem: *i64) i64 {
|
||||
fn __divmoddi4(a: i64, b: i64, rem: *i64) callconv(.C) i64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const d = __divdi3(a, b);
|
||||
@ -338,7 +338,7 @@ extern fn __divmoddi4(a: i64, b: i64, rem: *i64) i64 {
|
||||
return d;
|
||||
}
|
||||
|
||||
extern fn __divdi3(a: i64, b: i64) i64 {
|
||||
fn __divdi3(a: i64, b: i64) callconv(.C) i64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
// Set aside the sign of the quotient.
|
||||
@ -352,7 +352,7 @@ extern fn __divdi3(a: i64, b: i64) i64 {
|
||||
return @bitCast(i64, (res ^ sign) -% sign);
|
||||
}
|
||||
|
||||
extern fn __moddi3(a: i64, b: i64) i64 {
|
||||
fn __moddi3(a: i64, b: i64) callconv(.C) i64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
// Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63).
|
||||
@ -365,12 +365,12 @@ extern fn __moddi3(a: i64, b: i64) i64 {
|
||||
return (@bitCast(i64, r) ^ (a >> 63)) -% (a >> 63);
|
||||
}
|
||||
|
||||
extern fn __udivdi3(a: u64, b: u64) u64 {
|
||||
fn __udivdi3(a: u64, b: u64) callconv(.C) u64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
return __udivmoddi4(a, b, null);
|
||||
}
|
||||
|
||||
extern fn __umoddi3(a: u64, b: u64) u64 {
|
||||
fn __umoddi3(a: u64, b: u64) callconv(.C) u64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
var r: u64 = undefined;
|
||||
@ -378,7 +378,7 @@ extern fn __umoddi3(a: u64, b: u64) u64 {
|
||||
return r;
|
||||
}
|
||||
|
||||
extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct {
|
||||
fn __aeabi_uidivmod(n: u32, d: u32) callconv(.C) extern struct {
|
||||
q: u32,
|
||||
r: u32,
|
||||
} {
|
||||
@ -389,7 +389,7 @@ extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct {
|
||||
fn __aeabi_uldivmod(n: u64, d: u64) callconv(.C) extern struct {
|
||||
q: u64,
|
||||
r: u64,
|
||||
} {
|
||||
@ -400,7 +400,7 @@ extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn __aeabi_idivmod(n: i32, d: i32) extern struct {
|
||||
fn __aeabi_idivmod(n: i32, d: i32) callconv(.C) extern struct {
|
||||
q: i32,
|
||||
r: i32,
|
||||
} {
|
||||
@ -411,7 +411,7 @@ extern fn __aeabi_idivmod(n: i32, d: i32) extern struct {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct {
|
||||
fn __aeabi_ldivmod(n: i64, d: i64) callconv(.C) extern struct {
|
||||
q: i64,
|
||||
r: i64,
|
||||
} {
|
||||
@ -528,7 +528,7 @@ fn usesThumb1PreArmv6(arch: builtin.Arch) bool {
|
||||
};
|
||||
}
|
||||
|
||||
nakedcc fn __aeabi_memcpy() noreturn {
|
||||
fn __aeabi_memcpy() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1) {
|
||||
asm volatile (
|
||||
@ -544,7 +544,7 @@ nakedcc fn __aeabi_memcpy() noreturn {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
nakedcc fn __aeabi_memmove() noreturn {
|
||||
fn __aeabi_memmove() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1) {
|
||||
asm volatile (
|
||||
@ -560,7 +560,7 @@ nakedcc fn __aeabi_memmove() noreturn {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
nakedcc fn __aeabi_memset() noreturn {
|
||||
fn __aeabi_memset() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1_pre_armv6) {
|
||||
asm volatile (
|
||||
@ -591,7 +591,7 @@ nakedcc fn __aeabi_memset() noreturn {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
nakedcc fn __aeabi_memclr() noreturn {
|
||||
fn __aeabi_memclr() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1_pre_armv6) {
|
||||
asm volatile (
|
||||
@ -619,7 +619,7 @@ nakedcc fn __aeabi_memclr() noreturn {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
nakedcc fn __aeabi_memcmp() noreturn {
|
||||
fn __aeabi_memcmp() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1) {
|
||||
asm volatile (
|
||||
@ -635,7 +635,7 @@ nakedcc fn __aeabi_memcmp() noreturn {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
extern fn __divmodsi4(a: i32, b: i32, rem: *i32) i32 {
|
||||
fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const d = __divsi3(a, b);
|
||||
@ -643,7 +643,7 @@ extern fn __divmodsi4(a: i32, b: i32, rem: *i32) i32 {
|
||||
return d;
|
||||
}
|
||||
|
||||
extern fn __udivmodsi4(a: u32, b: u32, rem: *u32) u32 {
|
||||
fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const d = __udivsi3(a, b);
|
||||
@ -651,7 +651,7 @@ extern fn __udivmodsi4(a: u32, b: u32, rem: *u32) u32 {
|
||||
return d;
|
||||
}
|
||||
|
||||
extern fn __divsi3(n: i32, d: i32) i32 {
|
||||
fn __divsi3(n: i32, d: i32) callconv(.C) i32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
// Set aside the sign of the quotient.
|
||||
@ -665,7 +665,7 @@ extern fn __divsi3(n: i32, d: i32) i32 {
|
||||
return @bitCast(i32, (res ^ sign) -% sign);
|
||||
}
|
||||
|
||||
extern fn __udivsi3(n: u32, d: u32) u32 {
|
||||
fn __udivsi3(n: u32, d: u32) callconv(.C) u32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const n_uword_bits: c_uint = u32.bit_count;
|
||||
@ -706,13 +706,13 @@ extern fn __udivsi3(n: u32, d: u32) u32 {
|
||||
return q;
|
||||
}
|
||||
|
||||
extern fn __modsi3(n: i32, d: i32) i32 {
|
||||
fn __modsi3(n: i32, d: i32) callconv(.C) i32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
return n -% __divsi3(n, d) *% d;
|
||||
}
|
||||
|
||||
extern fn __umodsi3(n: u32, d: u32) u32 {
|
||||
fn __umodsi3(n: u32, d: u32) callconv(.C) u32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
return n -% __udivsi3(n, d) *% d;
|
||||
|
||||
@ -6,29 +6,29 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __addsf3(a: f32, b: f32) f32 {
|
||||
pub fn __addsf3(a: f32, b: f32) callconv(.C) f32 {
|
||||
return addXf3(f32, a, b);
|
||||
}
|
||||
|
||||
pub extern fn __adddf3(a: f64, b: f64) f64 {
|
||||
pub fn __adddf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
return addXf3(f64, a, b);
|
||||
}
|
||||
|
||||
pub extern fn __addtf3(a: f128, b: f128) f128 {
|
||||
pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
|
||||
return addXf3(f128, a, b);
|
||||
}
|
||||
|
||||
pub extern fn __subsf3(a: f32, b: f32) f32 {
|
||||
pub fn __subsf3(a: f32, b: f32) callconv(.C) f32 {
|
||||
const neg_b = @bitCast(f32, @bitCast(u32, b) ^ (@as(u32, 1) << 31));
|
||||
return addXf3(f32, a, neg_b);
|
||||
}
|
||||
|
||||
pub extern fn __subdf3(a: f64, b: f64) f64 {
|
||||
pub fn __subdf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
const neg_b = @bitCast(f64, @bitCast(u64, b) ^ (@as(u64, 1) << 63));
|
||||
return addXf3(f64, a, neg_b);
|
||||
}
|
||||
|
||||
pub extern fn __subtf3(a: f128, b: f128) f128 {
|
||||
pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
|
||||
const neg_b = @bitCast(f128, @bitCast(u128, b) ^ (@as(u128, 1) << 127));
|
||||
return addXf3(f128, a, neg_b);
|
||||
}
|
||||
|
||||
@ -12,31 +12,31 @@ const ConditionalOperator = enum {
|
||||
Gt,
|
||||
};
|
||||
|
||||
pub nakedcc fn __aeabi_dcmpeq() noreturn {
|
||||
pub fn __aeabi_dcmpeq() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Eq});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_dcmplt() noreturn {
|
||||
pub fn __aeabi_dcmplt() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Lt});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_dcmple() noreturn {
|
||||
pub fn __aeabi_dcmple() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Le});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_dcmpge() noreturn {
|
||||
pub fn __aeabi_dcmpge() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Ge});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_dcmpgt() noreturn {
|
||||
pub fn __aeabi_dcmpgt() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_dcmp, .{.Gt});
|
||||
unreachable;
|
||||
|
||||
@ -12,31 +12,31 @@ const ConditionalOperator = enum {
|
||||
Gt,
|
||||
};
|
||||
|
||||
pub nakedcc fn __aeabi_fcmpeq() noreturn {
|
||||
pub fn __aeabi_fcmpeq() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Eq});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_fcmplt() noreturn {
|
||||
pub fn __aeabi_fcmplt() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Lt});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_fcmple() noreturn {
|
||||
pub fn __aeabi_fcmple() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Le});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_fcmpge() noreturn {
|
||||
pub fn __aeabi_fcmpge() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Ge});
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub nakedcc fn __aeabi_fcmpgt() noreturn {
|
||||
pub fn __aeabi_fcmpgt() callconv(.Naked) noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, aeabi_fcmp, .{.Gt});
|
||||
unreachable;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __ashlti3(a: i128, b: i32) i128 {
|
||||
pub fn __ashlti3(a: i128, b: i32) callconv(.C) i128 {
|
||||
var input = twords{ .all = a };
|
||||
var result: twords = undefined;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __ashrti3(a: i128, b: i32) i128 {
|
||||
pub fn __ashrti3(a: i128, b: i32) callconv(.C) i128 {
|
||||
var input = twords{ .all = a };
|
||||
var result: twords = undefined;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern stdcallcc fn _alldiv(a: i64, b: i64) i64 {
|
||||
pub fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
const s_a = a >> (i64.bit_count - 1);
|
||||
const s_b = b >> (i64.bit_count - 1);
|
||||
@ -13,7 +13,7 @@ pub extern stdcallcc fn _alldiv(a: i64, b: i64) i64 {
|
||||
return (@bitCast(i64, r) ^ s) -% s;
|
||||
}
|
||||
|
||||
pub nakedcc fn _aulldiv() void {
|
||||
pub fn _aulldiv() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
// The stack layout is:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern stdcallcc fn _allrem(a: i64, b: i64) i64 {
|
||||
pub fn _allrem(a: i64, b: i64) callconv(.Stdcall) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
const s_a = a >> (i64.bit_count - 1);
|
||||
const s_b = b >> (i64.bit_count - 1);
|
||||
@ -13,7 +13,7 @@ pub extern stdcallcc fn _allrem(a: i64, b: i64) i64 {
|
||||
return (@bitCast(i64, r) ^ s) -% s;
|
||||
}
|
||||
|
||||
pub nakedcc fn _aullrem() void {
|
||||
pub fn _aullrem() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
// The stack layout is:
|
||||
|
||||
@ -27,7 +27,7 @@ const LE_EQUAL = @as(c_int, 0);
|
||||
const LE_GREATER = @as(c_int, 1);
|
||||
const LE_UNORDERED = @as(c_int, 1);
|
||||
|
||||
pub extern fn __ledf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __ledf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
const aInt: srep_t = @bitCast(srep_t, a);
|
||||
const bInt: srep_t = @bitCast(srep_t, b);
|
||||
@ -70,7 +70,7 @@ const GE_EQUAL = @as(c_int, 0);
|
||||
const GE_GREATER = @as(c_int, 1);
|
||||
const GE_UNORDERED = @as(c_int, -1); // Note: different from LE_UNORDERED
|
||||
|
||||
pub extern fn __gedf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __gedf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
const aInt: srep_t = @bitCast(srep_t, a);
|
||||
const bInt: srep_t = @bitCast(srep_t, b);
|
||||
@ -94,26 +94,26 @@ pub extern fn __gedf2(a: fp_t, b: fp_t) c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub extern fn __unorddf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __unorddf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
const aAbs: rep_t = @bitCast(rep_t, a) & absMask;
|
||||
const bAbs: rep_t = @bitCast(rep_t, b) & absMask;
|
||||
return @boolToInt(aAbs > infRep or bAbs > infRep);
|
||||
}
|
||||
|
||||
pub extern fn __eqdf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __eqdf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __ledf2(a, b);
|
||||
}
|
||||
|
||||
pub extern fn __ltdf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __ltdf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __ledf2(a, b);
|
||||
}
|
||||
|
||||
pub extern fn __nedf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __nedf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __ledf2(a, b);
|
||||
}
|
||||
|
||||
pub extern fn __gtdf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __gtdf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __gedf2(a, b);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ const LE_EQUAL = @as(c_int, 0);
|
||||
const LE_GREATER = @as(c_int, 1);
|
||||
const LE_UNORDERED = @as(c_int, 1);
|
||||
|
||||
pub extern fn __lesf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __lesf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
const aInt: srep_t = @bitCast(srep_t, a);
|
||||
const bInt: srep_t = @bitCast(srep_t, b);
|
||||
@ -70,7 +70,7 @@ const GE_EQUAL = @as(c_int, 0);
|
||||
const GE_GREATER = @as(c_int, 1);
|
||||
const GE_UNORDERED = @as(c_int, -1); // Note: different from LE_UNORDERED
|
||||
|
||||
pub extern fn __gesf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __gesf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
const aInt: srep_t = @bitCast(srep_t, a);
|
||||
const bInt: srep_t = @bitCast(srep_t, b);
|
||||
@ -94,26 +94,26 @@ pub extern fn __gesf2(a: fp_t, b: fp_t) c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub extern fn __unordsf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __unordsf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
const aAbs: rep_t = @bitCast(rep_t, a) & absMask;
|
||||
const bAbs: rep_t = @bitCast(rep_t, b) & absMask;
|
||||
return @boolToInt(aAbs > infRep or bAbs > infRep);
|
||||
}
|
||||
|
||||
pub extern fn __eqsf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __eqsf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __lesf2(a, b);
|
||||
}
|
||||
|
||||
pub extern fn __ltsf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __ltsf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __lesf2(a, b);
|
||||
}
|
||||
|
||||
pub extern fn __nesf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __nesf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __lesf2(a, b);
|
||||
}
|
||||
|
||||
pub extern fn __gtsf2(a: fp_t, b: fp_t) c_int {
|
||||
pub fn __gtsf2(a: fp_t, b: fp_t) callconv(.C) c_int {
|
||||
return __gesf2(a, b);
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ const infRep = exponentMask;
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
pub extern fn __letf2(a: f128, b: f128) c_int {
|
||||
pub fn __letf2(a: f128, b: f128) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const aInt = @bitCast(rep_t, a);
|
||||
@ -65,7 +65,7 @@ const GE_EQUAL = @as(c_int, 0);
|
||||
const GE_GREATER = @as(c_int, 1);
|
||||
const GE_UNORDERED = @as(c_int, -1); // Note: different from LE_UNORDERED
|
||||
|
||||
pub extern fn __getf2(a: f128, b: f128) c_int {
|
||||
pub fn __getf2(a: f128, b: f128) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const aInt = @bitCast(srep_t, a);
|
||||
@ -90,7 +90,7 @@ pub extern fn __getf2(a: f128, b: f128) c_int {
|
||||
GE_GREATER;
|
||||
}
|
||||
|
||||
pub extern fn __unordtf2(a: f128, b: f128) c_int {
|
||||
pub fn __unordtf2(a: f128, b: f128) callconv(.C) c_int {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
const aAbs = @bitCast(rep_t, a) & absMask;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __divdf3(a: f64, b: f64) f64 {
|
||||
pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
const Z = @IntType(false, f64.bit_count);
|
||||
const SignedZ = @IntType(true, f64.bit_count);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __divsf3(a: f32, b: f32) f32 {
|
||||
pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
const Z = @IntType(false, f32.bit_count);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const udivmod = @import("udivmod.zig").udivmod;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __divti3(a: i128, b: i128) i128 {
|
||||
pub fn __divti3(a: i128, b: i128) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
const s_a = a >> (i128.bit_count - 1);
|
||||
@ -16,7 +16,7 @@ pub extern fn __divti3(a: i128, b: i128) i128 {
|
||||
}
|
||||
|
||||
const v128 = @Vector(2, u64);
|
||||
pub extern fn __divti3_windows_x86_64(a: v128, b: v128) v128 {
|
||||
pub fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
|
||||
return @bitCast(v128, @call(.{ .modifier = .always_inline }, __divti3, .{
|
||||
@bitCast(i128, a),
|
||||
@bitCast(i128, b),
|
||||
|
||||
@ -2,19 +2,19 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
pub extern fn __extendsfdf2(a: f32) f64 {
|
||||
pub fn __extendsfdf2(a: f32) callconv(.C) f64 {
|
||||
return @call(.{ .modifier = .always_inline }, extendXfYf2, .{ f64, f32, @bitCast(u32, a) });
|
||||
}
|
||||
|
||||
pub extern fn __extenddftf2(a: f64) f128 {
|
||||
pub fn __extenddftf2(a: f64) callconv(.C) f128 {
|
||||
return @call(.{ .modifier = .always_inline }, extendXfYf2, .{ f128, f64, @bitCast(u64, a) });
|
||||
}
|
||||
|
||||
pub extern fn __extendsftf2(a: f32) f128 {
|
||||
pub fn __extendsftf2(a: f32) callconv(.C) f128 {
|
||||
return @call(.{ .modifier = .always_inline }, extendXfYf2, .{ f128, f32, @bitCast(u32, a) });
|
||||
}
|
||||
|
||||
pub extern fn __extendhfsf2(a: u16) f32 {
|
||||
pub fn __extendhfsf2(a: u16) callconv(.C) f32 {
|
||||
return @call(.{ .modifier = .always_inline }, extendXfYf2, .{ f32, f16, a });
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixdfdi(a: f64) i64 {
|
||||
pub fn __fixdfdi(a: f64) callconv(.C) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f64, i64, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixdfsi(a: f64) i32 {
|
||||
pub fn __fixdfsi(a: f64) callconv(.C) i32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f64, i32, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixdfti(a: f64) i128 {
|
||||
pub fn __fixdfti(a: f64) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f64, i128, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixsfdi(a: f32) i64 {
|
||||
pub fn __fixsfdi(a: f32) callconv(.C) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f32, i64, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixsfsi(a: f32) i32 {
|
||||
pub fn __fixsfsi(a: f32) callconv(.C) i32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f32, i32, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixsfti(a: f32) i128 {
|
||||
pub fn __fixsfti(a: f32) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f32, i128, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixtfdi(a: f128) i64 {
|
||||
pub fn __fixtfdi(a: f128) callconv(.C) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f128, i64, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixtfsi(a: f128) i32 {
|
||||
pub fn __fixtfsi(a: f128) callconv(.C) i32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f128, i32, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixint = @import("fixint.zig").fixint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixtfti(a: f128) i128 {
|
||||
pub fn __fixtfti(a: f128) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixint(f128, i128, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunsdfdi(a: f64) u64 {
|
||||
pub fn __fixunsdfdi(a: f64) callconv(.C) u64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f64, u64, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunsdfsi(a: f64) u32 {
|
||||
pub fn __fixunsdfsi(a: f64) callconv(.C) u32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f64, u32, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunsdfti(a: f64) u128 {
|
||||
pub fn __fixunsdfti(a: f64) callconv(.C) u128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f64, u128, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunssfdi(a: f32) u64 {
|
||||
pub fn __fixunssfdi(a: f32) callconv(.C) u64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f32, u64, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunssfsi(a: f32) u32 {
|
||||
pub fn __fixunssfsi(a: f32) callconv(.C) u32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f32, u32, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunssfti(a: f32) u128 {
|
||||
pub fn __fixunssfti(a: f32) callconv(.C) u128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f32, u128, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunstfdi(a: f128) u64 {
|
||||
pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f128, u64, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunstfsi(a: f128) u32 {
|
||||
pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f128, u32, a);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const fixuint = @import("fixuint.zig").fixuint;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __fixunstfti(a: f128) u128 {
|
||||
pub fn __fixunstfti(a: f128) callconv(.C) u128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return fixuint(f128, u128, a);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ const std = @import("std");
|
||||
const twop52: f64 = 0x1.0p52;
|
||||
const twop32: f64 = 0x1.0p32;
|
||||
|
||||
pub extern fn __floatdidf(a: i64) f64 {
|
||||
pub fn __floatdidf(a: i64) callconv(.C) f64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
if (a == 0) return 0;
|
||||
|
||||
@ -53,17 +53,17 @@ fn floatsiXf(comptime T: type, a: i32) T {
|
||||
return @bitCast(T, result);
|
||||
}
|
||||
|
||||
pub extern fn __floatsisf(arg: i32) f32 {
|
||||
pub fn __floatsisf(arg: i32) callconv(.C) f32 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f32, arg });
|
||||
}
|
||||
|
||||
pub extern fn __floatsidf(arg: i32) f64 {
|
||||
pub fn __floatsidf(arg: i32) callconv(.C) f64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f64, arg });
|
||||
}
|
||||
|
||||
pub extern fn __floatsitf(arg: i32) f128 {
|
||||
pub fn __floatsitf(arg: i32) callconv(.C) f128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f128, arg });
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const DBL_MANT_DIG = 53;
|
||||
|
||||
pub extern fn __floattidf(arg: i128) f64 {
|
||||
pub fn __floattidf(arg: i128) callconv(.C) f64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (arg == 0)
|
||||
|
||||
@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const FLT_MANT_DIG = 24;
|
||||
|
||||
pub extern fn __floattisf(arg: i128) f32 {
|
||||
pub fn __floattisf(arg: i128) callconv(.C) f32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (arg == 0)
|
||||
|
||||
@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const LDBL_MANT_DIG = 113;
|
||||
|
||||
pub extern fn __floattitf(arg: i128) f128 {
|
||||
pub fn __floattitf(arg: i128) callconv(.C) f128 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (arg == 0)
|
||||
|
||||
@ -5,7 +5,7 @@ const twop52: f64 = 0x1.0p52;
|
||||
const twop84: f64 = 0x1.0p84;
|
||||
const twop84_plus_twop52: f64 = 0x1.00000001p84;
|
||||
|
||||
pub extern fn __floatundidf(a: u64) f64 {
|
||||
pub fn __floatundidf(a: u64) callconv(.C) f64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
if (a == 0) return 0;
|
||||
|
||||
@ -2,7 +2,7 @@ const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const std = @import("std");
|
||||
|
||||
pub extern fn __floatunditf(a: u128) f128 {
|
||||
pub fn __floatunditf(a: u128) callconv(.C) f128 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (a == 0) {
|
||||
|
||||
@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const implicitBit = @as(u64, 1) << 52;
|
||||
|
||||
pub extern fn __floatunsidf(arg: u32) f64 {
|
||||
pub fn __floatunsidf(arg: u32) callconv(.C) f64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
if (arg == 0) return 0.0;
|
||||
|
||||
@ -2,7 +2,7 @@ const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const std = @import("std");
|
||||
|
||||
pub extern fn __floatunsitf(a: u64) f128 {
|
||||
pub fn __floatunsitf(a: u64) callconv(.C) f128 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (a == 0) {
|
||||
|
||||
@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const DBL_MANT_DIG = 53;
|
||||
|
||||
pub extern fn __floatuntidf(arg: u128) f64 {
|
||||
pub fn __floatuntidf(arg: u128) callconv(.C) f64 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (arg == 0)
|
||||
|
||||
@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const FLT_MANT_DIG = 24;
|
||||
|
||||
pub extern fn __floatuntisf(arg: u128) f32 {
|
||||
pub fn __floatuntisf(arg: u128) callconv(.C) f32 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (arg == 0)
|
||||
|
||||
@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
|
||||
|
||||
const LDBL_MANT_DIG = 113;
|
||||
|
||||
pub extern fn __floatuntitf(arg: u128) f128 {
|
||||
pub fn __floatuntitf(arg: u128) callconv(.C) f128 {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
if (arg == 0)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __lshrti3(a: i128, b: i32) i128 {
|
||||
pub fn __lshrti3(a: i128, b: i32) callconv(.C) i128 {
|
||||
var input = twords{ .all = a };
|
||||
var result: twords = undefined;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ const udivmod = @import("udivmod.zig").udivmod;
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __modti3(a: i128, b: i128) i128 {
|
||||
pub fn __modti3(a: i128, b: i128) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
const s_a = a >> (i128.bit_count - 1); // s = a < 0 ? -1 : 0
|
||||
@ -21,7 +21,7 @@ pub extern fn __modti3(a: i128, b: i128) i128 {
|
||||
}
|
||||
|
||||
const v128 = @Vector(2, u64);
|
||||
pub extern fn __modti3_windows_x86_64(a: v128, b: v128) v128 {
|
||||
pub fn __modti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
|
||||
return @bitCast(v128, @call(.{ .modifier = .always_inline }, __modti3, .{
|
||||
@bitCast(i128, a),
|
||||
@bitCast(i128, b),
|
||||
|
||||
@ -6,13 +6,13 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __multf3(a: f128, b: f128) f128 {
|
||||
pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {
|
||||
return mulXf3(f128, a, b);
|
||||
}
|
||||
pub extern fn __muldf3(a: f64, b: f64) f64 {
|
||||
pub fn __muldf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
return mulXf3(f64, a, b);
|
||||
}
|
||||
pub extern fn __mulsf3(a: f32, b: f32) f32 {
|
||||
pub fn __mulsf3(a: f32, b: f32) callconv(.C) f32 {
|
||||
return mulXf3(f32, a, b);
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ fn __muldsi3(a: u32, b: u32) i64 {
|
||||
return r.all;
|
||||
}
|
||||
|
||||
pub extern fn __muldi3(a: i64, b: i64) i64 {
|
||||
pub fn __muldi3(a: i64, b: i64) callconv(.C) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
const x = dwords{ .all = a };
|
||||
|
||||
@ -3,7 +3,7 @@ const compiler_rt = @import("../compiler_rt.zig");
|
||||
const maxInt = std.math.maxInt;
|
||||
const minInt = std.math.minInt;
|
||||
|
||||
pub extern fn __mulodi4(a: i64, b: i64, overflow: *c_int) i64 {
|
||||
pub fn __mulodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
const min = @bitCast(i64, @as(u64, 1 << (i64.bit_count - 1)));
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {
|
||||
pub fn __muloti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
|
||||
const min = @bitCast(i128, @as(u128, 1 << (i128.bit_count - 1)));
|
||||
|
||||
@ -5,7 +5,7 @@ const compiler_rt = @import("../compiler_rt.zig");
|
||||
// ae684fad6d34858c014c94da69c15e7774a633c3
|
||||
// 2018-08-13
|
||||
|
||||
pub extern fn __multi3(a: i128, b: i128) i128 {
|
||||
pub fn __multi3(a: i128, b: i128) callconv(.C) i128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
const x = twords{ .all = a };
|
||||
const y = twords{ .all = b };
|
||||
@ -15,7 +15,7 @@ pub extern fn __multi3(a: i128, b: i128) i128 {
|
||||
}
|
||||
|
||||
const v128 = @Vector(2, u64);
|
||||
pub extern fn __multi3_windows_x86_64(a: v128, b: v128) v128 {
|
||||
pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
|
||||
return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{
|
||||
@bitCast(i128, a),
|
||||
@bitCast(i128, b),
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub extern fn __negsf2(a: f32) f32 {
|
||||
pub fn __negsf2(a: f32) callconv(.C) f32 {
|
||||
return negXf2(f32, a);
|
||||
}
|
||||
|
||||
pub extern fn __negdf2(a: f64) f64 {
|
||||
pub fn __negdf2(a: f64) callconv(.C) f64 {
|
||||
return negXf2(f64, a);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
// ported from llvm compiler-rt 8.0.0rc3 95e1c294cb0415a377a7b1d6c7c7d4f89e1c04e4
|
||||
pub extern fn __popcountdi2(a: i64) i32 {
|
||||
pub fn __popcountdi2(a: i64) callconv(.C) i32 {
|
||||
var x2 = @bitCast(u64, a);
|
||||
x2 = x2 - ((x2 >> 1) & 0x5555555555555555);
|
||||
// Every 2 bits holds the sum of every pair of bits (32)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
// Zig's own stack-probe routine (available only on x86 and x86_64)
|
||||
pub nakedcc fn zig_probe_stack() void {
|
||||
pub fn zig_probe_stack() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
// Versions of the Linux kernel before 5.1 treat any access below SP as
|
||||
@ -180,11 +180,11 @@ fn win_probe_stack_adjust_sp() void {
|
||||
// ___chkstk (__alloca) | yes | yes |
|
||||
// ___chkstk_ms | no | no |
|
||||
|
||||
pub nakedcc fn _chkstk() void {
|
||||
pub fn _chkstk() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{});
|
||||
}
|
||||
pub nakedcc fn __chkstk() void {
|
||||
pub fn __chkstk() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
switch (builtin.arch) {
|
||||
.i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}),
|
||||
@ -192,15 +192,15 @@ pub nakedcc fn __chkstk() void {
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
pub nakedcc fn ___chkstk() void {
|
||||
pub fn ___chkstk() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{});
|
||||
}
|
||||
pub nakedcc fn __chkstk_ms() void {
|
||||
pub fn __chkstk_ms() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
|
||||
}
|
||||
pub nakedcc fn ___chkstk_ms() void {
|
||||
pub fn ___chkstk_ms() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
@call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
|
||||
}
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub extern fn __truncsfhf2(a: f32) u16 {
|
||||
pub fn __truncsfhf2(a: f32) callconv(.C) u16 {
|
||||
return @bitCast(u16, truncXfYf2(f16, f32, a));
|
||||
}
|
||||
|
||||
pub extern fn __truncdfhf2(a: f64) u16 {
|
||||
pub fn __truncdfhf2(a: f64) callconv(.C) u16 {
|
||||
return @bitCast(u16, truncXfYf2(f16, f64, a));
|
||||
}
|
||||
|
||||
pub extern fn __trunctfsf2(a: f128) f32 {
|
||||
pub fn __trunctfsf2(a: f128) callconv(.C) f32 {
|
||||
return truncXfYf2(f32, f128, a);
|
||||
}
|
||||
|
||||
pub extern fn __trunctfdf2(a: f128) f64 {
|
||||
pub fn __trunctfdf2(a: f128) callconv(.C) f64 {
|
||||
return truncXfYf2(f64, f128, a);
|
||||
}
|
||||
|
||||
pub extern fn __truncdfsf2(a: f64) f32 {
|
||||
pub fn __truncdfsf2(a: f64) callconv(.C) f32 {
|
||||
return truncXfYf2(f32, f64, a);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const udivmod = @import("udivmod.zig").udivmod;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) u64 {
|
||||
pub fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) callconv(.C) u64 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return udivmod(u64, a, b, maybe_rem);
|
||||
}
|
||||
|
||||
@ -2,13 +2,13 @@ const udivmod = @import("udivmod.zig").udivmod;
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) u128 {
|
||||
pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return udivmod(u128, a, b, maybe_rem);
|
||||
}
|
||||
|
||||
const v128 = @Vector(2, u64);
|
||||
pub extern fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) v128 {
|
||||
pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem));
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
const udivmodti4 = @import("udivmodti4.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn __udivti3(a: u128, b: u128) u128 {
|
||||
pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return udivmodti4.__udivmodti4(a, b, null);
|
||||
}
|
||||
|
||||
const v128 = @Vector(2, u64);
|
||||
pub extern fn __udivti3_windows_x86_64(a: v128, b: v128) v128 {
|
||||
pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
return udivmodti4.__udivmodti4_windows_x86_64(a, b, null);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ const udivmodti4 = @import("udivmodti4.zig");
|
||||
const builtin = @import("builtin");
|
||||
const compiler_rt = @import("../compiler_rt.zig");
|
||||
|
||||
pub extern fn __umodti3(a: u128, b: u128) u128 {
|
||||
pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
var r: u128 = undefined;
|
||||
_ = udivmodti4.__udivmodti4(a, b, &r);
|
||||
@ -10,7 +10,7 @@ pub extern fn __umodti3(a: u128, b: u128) u128 {
|
||||
}
|
||||
|
||||
const v128 = @Vector(2, u64);
|
||||
pub extern fn __umodti3_windows_x86_64(a: v128, b: v128) v128 {
|
||||
pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
|
||||
return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{
|
||||
@bitCast(u128, a),
|
||||
@bitCast(u128, b),
|
||||
|
||||
@ -60,8 +60,16 @@ pub const SpinLock = struct {
|
||||
switch (builtin.arch) {
|
||||
// these instructions use a memory clobber as they
|
||||
// flush the pipeline of any speculated reads/writes.
|
||||
.i386, .x86_64 => asm volatile ("pause" ::: "memory"),
|
||||
.arm, .aarch64 => asm volatile ("yield" ::: "memory"),
|
||||
.i386, .x86_64 => asm volatile ("pause"
|
||||
:
|
||||
:
|
||||
: "memory"
|
||||
),
|
||||
.arm, .aarch64 => asm volatile ("yield"
|
||||
:
|
||||
:
|
||||
: "memory"
|
||||
),
|
||||
else => std.os.sched_yield() catch {},
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,11 +43,7 @@ comptime {
|
||||
}
|
||||
}
|
||||
|
||||
stdcallcc fn _DllMainCRTStartup(
|
||||
hinstDLL: std.os.windows.HINSTANCE,
|
||||
fdwReason: std.os.windows.DWORD,
|
||||
lpReserved: std.os.windows.LPVOID,
|
||||
) std.os.windows.BOOL {
|
||||
fn _DllMainCRTStartup(hinstDLL: std.os.windows.HINSTANCE, fdwReason: std.os.windows.DWORD, lpReserved: std.os.windows.LPVOID) callconv(.Stdcall) std.os.windows.BOOL {
|
||||
if (@hasDecl(root, "DllMain")) {
|
||||
return root.DllMain(hinstDLL, fdwReason, lpReserved);
|
||||
}
|
||||
@ -55,13 +51,13 @@ stdcallcc fn _DllMainCRTStartup(
|
||||
return std.os.windows.TRUE;
|
||||
}
|
||||
|
||||
extern fn wasm_freestanding_start() void {
|
||||
fn wasm_freestanding_start() callconv(.C) void {
|
||||
// This is marked inline because for some reason LLVM in release mode fails to inline it,
|
||||
// and we want fewer call frames in stack traces.
|
||||
_ = @call(.{ .modifier = .always_inline }, callMain, .{});
|
||||
}
|
||||
|
||||
extern fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) usize {
|
||||
fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.C) usize {
|
||||
const bad_efi_main_ret = "expected return type of main to be 'void', 'noreturn', or 'usize'";
|
||||
uefi.handle = handle;
|
||||
uefi.system_table = system_table;
|
||||
@ -84,7 +80,7 @@ extern fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) u
|
||||
}
|
||||
}
|
||||
|
||||
nakedcc fn _start() noreturn {
|
||||
fn _start() callconv(.Naked) noreturn {
|
||||
if (builtin.os == builtin.Os.wasi) {
|
||||
// This is marked inline because for some reason LLVM in release mode fails to inline it,
|
||||
// and we want fewer call frames in stack traces.
|
||||
@ -127,7 +123,7 @@ nakedcc fn _start() noreturn {
|
||||
@call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
|
||||
}
|
||||
|
||||
stdcallcc fn WinMainCRTStartup() noreturn {
|
||||
fn WinMainCRTStartup() callconv(.Stdcall) noreturn {
|
||||
@setAlignStack(16);
|
||||
if (!builtin.single_threaded) {
|
||||
_ = @import("start_windows_tls.zig");
|
||||
@ -198,7 +194,7 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
|
||||
return initEventLoopAndCallMain();
|
||||
}
|
||||
|
||||
extern fn main(c_argc: i32, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) i32 {
|
||||
fn main(c_argc: i32, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) callconv(.C) i32 {
|
||||
var env_count: usize = 0;
|
||||
while (c_envp[env_count] != null) : (env_count += 1) {}
|
||||
const envp = @ptrCast([*][*:0]u8, c_envp)[0..env_count];
|
||||
|
||||
@ -156,7 +156,7 @@ pub const Thread = struct {
|
||||
thread: Thread,
|
||||
inner: Context,
|
||||
};
|
||||
extern fn threadMain(raw_arg: windows.LPVOID) windows.DWORD {
|
||||
fn threadMain(raw_arg: windows.LPVOID) callconv(.C) windows.DWORD {
|
||||
const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*;
|
||||
switch (@typeId(@TypeOf(startFn).ReturnType)) {
|
||||
.Int => {
|
||||
@ -198,7 +198,7 @@ pub const Thread = struct {
|
||||
}
|
||||
|
||||
const MainFuncs = struct {
|
||||
extern fn linuxThreadMain(ctx_addr: usize) u8 {
|
||||
fn linuxThreadMain(ctx_addr: usize) callconv(.C) u8 {
|
||||
const arg = if (@sizeOf(Context) == 0) {} else @intToPtr(*const Context, ctx_addr).*;
|
||||
|
||||
switch (@typeId(@TypeOf(startFn).ReturnType)) {
|
||||
@ -212,7 +212,7 @@ pub const Thread = struct {
|
||||
else => @compileError("expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'"),
|
||||
}
|
||||
}
|
||||
extern fn posixThreadMain(ctx: ?*c_void) ?*c_void {
|
||||
fn posixThreadMain(ctx: ?*c_void) callconv(.C) ?*c_void {
|
||||
if (@sizeOf(Context) == 0) {
|
||||
_ = startFn({});
|
||||
return null;
|
||||
|
||||
@ -22,7 +22,7 @@ pub fn main() !void {
|
||||
const elapsed_ns_orig = timer.lap();
|
||||
@fence(.SeqCst);
|
||||
|
||||
var buffer2: [32767] u16 align(4096) = undefined;
|
||||
var buffer2: [32767]u16 align(4096) = undefined;
|
||||
_ = try std.unicode.utf8ToUtf16Le_better(&buffer2, args[1]);
|
||||
|
||||
@fence(.SeqCst);
|
||||
|
||||
@ -860,6 +860,7 @@ pub const Node = struct {
|
||||
lib_name: ?*Node, // populated if this is an extern declaration
|
||||
align_expr: ?*Node, // populated if align(A) is present
|
||||
section_expr: ?*Node, // populated if linksection(A) is present
|
||||
callconv_expr: ?*Node, // populated if callconv(A) is present
|
||||
|
||||
pub const ParamList = SegmentedList(*Node, 2);
|
||||
|
||||
|
||||
@ -311,6 +311,7 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
|
||||
const rparen = try expectToken(it, tree, .RParen);
|
||||
const align_expr = try parseByteAlign(arena, it, tree);
|
||||
const section_expr = try parseLinkSection(arena, it, tree);
|
||||
const callconv_expr = try parseCallconv(arena, it, tree);
|
||||
const exclamation_token = eatToken(it, .Bang);
|
||||
|
||||
const return_type_expr = (try parseVarType(arena, it, tree)) orelse
|
||||
@ -347,6 +348,7 @@ fn parseFnProto(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
|
||||
.lib_name = null,
|
||||
.align_expr = align_expr,
|
||||
.section_expr = section_expr,
|
||||
.callconv_expr = callconv_expr,
|
||||
};
|
||||
|
||||
if (cc) |kind| {
|
||||
@ -1678,6 +1680,17 @@ fn parseLinkSection(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
|
||||
return expr_node;
|
||||
}
|
||||
|
||||
/// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN
|
||||
fn parseCallconv(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
|
||||
_ = eatToken(it, .Keyword_callconv) orelse return null;
|
||||
_ = try expectToken(it, tree, .LParen);
|
||||
const expr_node = try expectNode(arena, it, tree, parseExpr, AstError{
|
||||
.ExpectedExpr = AstError.ExpectedExpr{ .token = it.index },
|
||||
});
|
||||
_ = try expectToken(it, tree, .RParen);
|
||||
return expr_node;
|
||||
}
|
||||
|
||||
/// FnCC
|
||||
/// <- KEYWORD_nakedcc
|
||||
/// / KEYWORD_stdcallcc
|
||||
|
||||
@ -9,6 +9,20 @@ test "zig fmt: change @typeOf to @TypeOf" {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Remove nakedcc/stdcallcc once zig 0.6.0 is released. See https://github.com/ziglang/zig/pull/3977
|
||||
test "zig fmt: convert extern/nakedcc/stdcallcc into callconv(...)" {
|
||||
try testTransform(
|
||||
\\nakedcc fn foo1() void {}
|
||||
\\stdcallcc fn foo2() void {}
|
||||
\\extern fn foo3() void {}
|
||||
,
|
||||
\\fn foo1() callconv(.Naked) void {}
|
||||
\\fn foo2() callconv(.Stdcall) void {}
|
||||
\\fn foo3() callconv(.C) void {}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: comptime struct field" {
|
||||
try testCanonical(
|
||||
\\const Foo = struct {
|
||||
@ -234,7 +248,7 @@ test "zig fmt: threadlocal" {
|
||||
test "zig fmt: linksection" {
|
||||
try testCanonical(
|
||||
\\export var aoeu: u64 linksection(".text.derp") = 1234;
|
||||
\\export nakedcc fn _start() linksection(".text.boot") noreturn {}
|
||||
\\export fn _start() linksection(".text.boot") callconv(.Naked) noreturn {}
|
||||
\\
|
||||
);
|
||||
}
|
||||
@ -2326,7 +2340,7 @@ test "zig fmt: fn type" {
|
||||
\\
|
||||
\\const a: fn (u8) u8 = undefined;
|
||||
\\const b: extern fn (u8) u8 = undefined;
|
||||
\\const c: nakedcc fn (u8) u8 = undefined;
|
||||
\\const c: fn (u8) callconv(.Naked) u8 = undefined;
|
||||
\\const ap: fn (u8) u8 = a;
|
||||
\\
|
||||
);
|
||||
|
||||
@ -1311,8 +1311,16 @@ fn renderExpression(
|
||||
try renderToken(tree, stream, visib_token_index, indent, start_col, Space.Space); // pub
|
||||
}
|
||||
|
||||
// Some extra machinery is needed to rewrite the old-style cc
|
||||
// notation to the new callconv one
|
||||
var cc_rewrite_str: ?[*:0]const u8 = null;
|
||||
if (fn_proto.extern_export_inline_token) |extern_export_inline_token| {
|
||||
try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export
|
||||
const tok = tree.tokens.at(extern_export_inline_token);
|
||||
if (tok.id != .Keyword_extern or fn_proto.body_node == null) {
|
||||
try renderToken(tree, stream, extern_export_inline_token, indent, start_col, Space.Space); // extern/export
|
||||
} else {
|
||||
cc_rewrite_str = ".C";
|
||||
}
|
||||
}
|
||||
|
||||
if (fn_proto.lib_name) |lib_name| {
|
||||
@ -1320,7 +1328,12 @@ fn renderExpression(
|
||||
}
|
||||
|
||||
if (fn_proto.cc_token) |cc_token| {
|
||||
try renderToken(tree, stream, cc_token, indent, start_col, Space.Space); // stdcallcc
|
||||
var str = tree.tokenSlicePtr(tree.tokens.at(cc_token));
|
||||
if (mem.eql(u8, str, "stdcallcc")) {
|
||||
cc_rewrite_str = ".Stdcall";
|
||||
} else if (mem.eql(u8, str, "nakedcc")) {
|
||||
cc_rewrite_str = ".Naked";
|
||||
} else try renderToken(tree, stream, cc_token, indent, start_col, Space.Space); // stdcallcc
|
||||
}
|
||||
|
||||
const lparen = if (fn_proto.name_token) |name_token| blk: {
|
||||
@ -1392,6 +1405,21 @@ fn renderExpression(
|
||||
try renderToken(tree, stream, section_rparen, indent, start_col, Space.Space); // )
|
||||
}
|
||||
|
||||
if (fn_proto.callconv_expr) |callconv_expr| {
|
||||
const callconv_rparen = tree.nextToken(callconv_expr.lastToken());
|
||||
const callconv_lparen = tree.prevToken(callconv_expr.firstToken());
|
||||
const callconv_kw = tree.prevToken(callconv_lparen);
|
||||
|
||||
try renderToken(tree, stream, callconv_kw, indent, start_col, Space.None); // callconv
|
||||
try renderToken(tree, stream, callconv_lparen, indent, start_col, Space.None); // (
|
||||
try renderExpression(allocator, stream, tree, indent, start_col, callconv_expr, Space.None);
|
||||
try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // )
|
||||
} else if (cc_rewrite_str) |str| {
|
||||
try stream.write("callconv(");
|
||||
try stream.write(mem.toSliceConst(u8, str));
|
||||
try stream.write(") ");
|
||||
}
|
||||
|
||||
switch (fn_proto.return_type) {
|
||||
ast.Node.FnProto.ReturnType.Explicit => |node| {
|
||||
return renderExpression(allocator, stream, tree, indent, start_col, node, space);
|
||||
|
||||
@ -30,6 +30,7 @@ pub const Token = struct {
|
||||
Keyword.init("async", .Keyword_async),
|
||||
Keyword.init("await", .Keyword_await),
|
||||
Keyword.init("break", .Keyword_break),
|
||||
Keyword.init("callconv", .Keyword_callconv),
|
||||
Keyword.init("catch", .Keyword_catch),
|
||||
Keyword.init("comptime", .Keyword_comptime),
|
||||
Keyword.init("const", .Keyword_const),
|
||||
@ -162,6 +163,7 @@ pub const Token = struct {
|
||||
Keyword_async,
|
||||
Keyword_await,
|
||||
Keyword_break,
|
||||
Keyword_callconv,
|
||||
Keyword_catch,
|
||||
Keyword_comptime,
|
||||
Keyword_const,
|
||||
@ -286,6 +288,7 @@ pub const Token = struct {
|
||||
.Keyword_async => "async",
|
||||
.Keyword_await => "await",
|
||||
.Keyword_break => "break",
|
||||
.Keyword_callconv => "callconv",
|
||||
.Keyword_catch => "catch",
|
||||
.Keyword_comptime => "comptime",
|
||||
.Keyword_const => "const",
|
||||
|
||||
@ -11,7 +11,7 @@ const CToken = ctok.CToken;
|
||||
const mem = std.mem;
|
||||
const math = std.math;
|
||||
|
||||
const CallingConvention = std.builtin.TypeInfo.CallingConvention;
|
||||
const CallingConvention = std.builtin.CallingConvention;
|
||||
|
||||
pub const ClangErrMsg = Stage2ErrorMsg;
|
||||
|
||||
@ -3690,6 +3690,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
|
||||
.lib_name = null,
|
||||
.align_expr = null,
|
||||
.section_expr = null,
|
||||
.callconv_expr = null,
|
||||
};
|
||||
|
||||
const block = try transCreateNodeBlock(c, null);
|
||||
@ -4141,6 +4142,11 @@ fn transCC(
|
||||
switch (clang_cc) {
|
||||
.C => return CallingConvention.C,
|
||||
.X86StdCall => return CallingConvention.Stdcall,
|
||||
.X86FastCall => return CallingConvention.Fastcall,
|
||||
.X86VectorCall, .AArch64VectorCall => return CallingConvention.Vectorcall,
|
||||
.X86ThisCall => return CallingConvention.Thiscall,
|
||||
.AAPCS => return CallingConvention.AAPCS,
|
||||
.AAPCS_VFP => return CallingConvention.AAPCSVFP,
|
||||
else => return revertAndWarn(
|
||||
rp,
|
||||
error.UnsupportedType,
|
||||
@ -4189,14 +4195,13 @@ fn finishTransFnProto(
|
||||
is_pub: bool,
|
||||
) !*ast.Node.FnProto {
|
||||
const is_export = if (fn_decl_context) |ctx| ctx.is_export else false;
|
||||
const is_extern = if (fn_decl_context) |ctx| !ctx.has_body else true;
|
||||
const is_extern = if (fn_decl_context) |ctx| !ctx.has_body else false;
|
||||
|
||||
// TODO check for always_inline attribute
|
||||
// TODO check for align attribute
|
||||
|
||||
// pub extern fn name(...) T
|
||||
const pub_tok = if (is_pub) try appendToken(rp.c, .Keyword_pub, "pub") else null;
|
||||
const cc_tok = if (cc == .Stdcall) try appendToken(rp.c, .Keyword_stdcallcc, "stdcallcc") else null;
|
||||
const extern_export_inline_tok = if (is_export)
|
||||
try appendToken(rp.c, .Keyword_export, "export")
|
||||
else if (cc == .C and is_extern)
|
||||
@ -4303,6 +4308,14 @@ fn finishTransFnProto(
|
||||
break :blk null;
|
||||
};
|
||||
|
||||
const callconv_expr = if ((is_export or is_extern) and cc == .C) null else blk: {
|
||||
_ = try appendToken(rp.c, .Keyword_callconv, "callconv");
|
||||
_ = try appendToken(rp.c, .LParen, "(");
|
||||
const expr = try transCreateNodeEnumLiteral(rp.c, @tagName(cc));
|
||||
_ = try appendToken(rp.c, .RParen, ")");
|
||||
break :blk expr;
|
||||
};
|
||||
|
||||
const return_type_node = blk: {
|
||||
if (ZigClangFunctionType_getNoReturnAttr(fn_ty)) {
|
||||
break :blk try transCreateNodeIdentifier(rp.c, "noreturn");
|
||||
@ -4333,11 +4346,12 @@ fn finishTransFnProto(
|
||||
.return_type = .{ .Explicit = return_type_node },
|
||||
.var_args_token = null, // TODO this field is broken in the AST data model
|
||||
.extern_export_inline_token = extern_export_inline_tok,
|
||||
.cc_token = cc_tok,
|
||||
.cc_token = null,
|
||||
.body_node = null,
|
||||
.lib_name = null,
|
||||
.align_expr = align_expr,
|
||||
.section_expr = linksection_expr,
|
||||
.callconv_expr = callconv_expr,
|
||||
};
|
||||
return fn_proto;
|
||||
}
|
||||
@ -4686,6 +4700,7 @@ fn transMacroFnDefine(c: *Context, it: *ctok.TokenList.Iterator, name: []const u
|
||||
.lib_name = null,
|
||||
.align_expr = null,
|
||||
.section_expr = null,
|
||||
.callconv_expr = null,
|
||||
};
|
||||
|
||||
const block = try transCreateNodeBlock(c, null);
|
||||
|
||||
@ -337,7 +337,7 @@ pub const Type = struct {
|
||||
}
|
||||
};
|
||||
|
||||
const CallingConvention = builtin.TypeInfo.CallingConvention;
|
||||
const CallingConvention = builtin.CallingConvention;
|
||||
|
||||
pub const Param = struct {
|
||||
is_noalias: bool,
|
||||
@ -352,6 +352,7 @@ pub const Type = struct {
|
||||
.Naked => "nakedcc ",
|
||||
.Stdcall => "stdcallcc ",
|
||||
.Async => "async ",
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +57,23 @@ enum PtrLen {
|
||||
PtrLenC,
|
||||
};
|
||||
|
||||
enum CallingConvention {
|
||||
CallingConventionUnspecified,
|
||||
CallingConventionC,
|
||||
CallingConventionCold,
|
||||
CallingConventionNaked,
|
||||
CallingConventionAsync,
|
||||
CallingConventionInterrupt,
|
||||
CallingConventionSignal,
|
||||
CallingConventionStdcall,
|
||||
CallingConventionFastcall,
|
||||
CallingConventionVectorcall,
|
||||
CallingConventionThiscall,
|
||||
CallingConventionAPCS,
|
||||
CallingConventionAAPCS,
|
||||
CallingConventionAAPCSVFP,
|
||||
};
|
||||
|
||||
// This one corresponds to the builtin.zig enum.
|
||||
enum BuiltinPtrSize {
|
||||
BuiltinPtrSizeOne,
|
||||
@ -398,6 +415,7 @@ struct LazyValueFnType {
|
||||
IrInstruction *align_inst; // can be null
|
||||
IrInstruction *return_type;
|
||||
|
||||
CallingConvention cc;
|
||||
bool is_generic;
|
||||
};
|
||||
|
||||
@ -612,15 +630,6 @@ enum NodeType {
|
||||
NodeTypeVarFieldType,
|
||||
};
|
||||
|
||||
enum CallingConvention {
|
||||
CallingConventionUnspecified,
|
||||
CallingConventionC,
|
||||
CallingConventionCold,
|
||||
CallingConventionNaked,
|
||||
CallingConventionStdcall,
|
||||
CallingConventionAsync,
|
||||
};
|
||||
|
||||
enum FnInline {
|
||||
FnInlineAuto,
|
||||
FnInlineAlways,
|
||||
@ -639,10 +648,12 @@ struct AstNodeFnProto {
|
||||
AstNode *align_expr;
|
||||
// populated if the "section(S)" is present
|
||||
AstNode *section_expr;
|
||||
// populated if the "callconv(S)" is present
|
||||
AstNode *callconv_expr;
|
||||
Buf doc_comments;
|
||||
|
||||
FnInline fn_inline;
|
||||
CallingConvention cc;
|
||||
bool is_async;
|
||||
|
||||
VisibMod visib_mod;
|
||||
bool auto_err_set;
|
||||
@ -3549,6 +3560,7 @@ struct IrInstructionFnProto {
|
||||
|
||||
IrInstruction **param_types;
|
||||
IrInstruction *align_value;
|
||||
IrInstruction *callconv_value;
|
||||
IrInstruction *return_type;
|
||||
bool is_var_args;
|
||||
};
|
||||
|
||||
173
src/analyze.cpp
173
src/analyze.cpp
@ -919,24 +919,20 @@ ZigType *get_bound_fn_type(CodeGen *g, ZigFn *fn_entry) {
|
||||
|
||||
const char *calling_convention_name(CallingConvention cc) {
|
||||
switch (cc) {
|
||||
case CallingConventionUnspecified: return "undefined";
|
||||
case CallingConventionC: return "ccc";
|
||||
case CallingConventionCold: return "coldcc";
|
||||
case CallingConventionNaked: return "nakedcc";
|
||||
case CallingConventionStdcall: return "stdcallcc";
|
||||
case CallingConventionAsync: return "async";
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
static const char *calling_convention_fn_type_str(CallingConvention cc) {
|
||||
switch (cc) {
|
||||
case CallingConventionUnspecified: return "";
|
||||
case CallingConventionC: return "extern ";
|
||||
case CallingConventionCold: return "coldcc ";
|
||||
case CallingConventionNaked: return "nakedcc ";
|
||||
case CallingConventionStdcall: return "stdcallcc ";
|
||||
case CallingConventionAsync: return "async ";
|
||||
case CallingConventionUnspecified: return "Unspecified";
|
||||
case CallingConventionC: return "C";
|
||||
case CallingConventionCold: return "Cold";
|
||||
case CallingConventionNaked: return "Naked";
|
||||
case CallingConventionAsync: return "Async";
|
||||
case CallingConventionInterrupt: return "Interrupt";
|
||||
case CallingConventionSignal: return "Signal";
|
||||
case CallingConventionStdcall: return "Stdcall";
|
||||
case CallingConventionFastcall: return "Fastcall";
|
||||
case CallingConventionVectorcall: return "Vectorcall";
|
||||
case CallingConventionThiscall: return "Thiscall";
|
||||
case CallingConventionAPCS: return "Apcs";
|
||||
case CallingConventionAAPCS: return "Aapcs";
|
||||
case CallingConventionAAPCSVFP: return "Aapcsvfp";
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
@ -949,7 +945,15 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
|
||||
case CallingConventionC:
|
||||
case CallingConventionCold:
|
||||
case CallingConventionNaked:
|
||||
case CallingConventionInterrupt:
|
||||
case CallingConventionSignal:
|
||||
case CallingConventionStdcall:
|
||||
case CallingConventionFastcall:
|
||||
case CallingConventionVectorcall:
|
||||
case CallingConventionThiscall:
|
||||
case CallingConventionAPCS:
|
||||
case CallingConventionAAPCS:
|
||||
case CallingConventionAAPCSVFP:
|
||||
return false;
|
||||
}
|
||||
zig_unreachable();
|
||||
@ -1006,8 +1010,6 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
||||
|
||||
// populate the name of the type
|
||||
buf_resize(&fn_type->name, 0);
|
||||
const char *cc_str = calling_convention_fn_type_str(fn_type->data.fn.fn_type_id.cc);
|
||||
buf_appendf(&fn_type->name, "%s", cc_str);
|
||||
buf_appendf(&fn_type->name, "fn(");
|
||||
for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
|
||||
FnTypeParamInfo *param_info = &fn_type_id->param_info[i];
|
||||
@ -1026,6 +1028,9 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
||||
if (fn_type_id->alignment != 0) {
|
||||
buf_appendf(&fn_type->name, " align(%" PRIu32 ")", fn_type_id->alignment);
|
||||
}
|
||||
if (fn_type_id->cc != CallingConventionUnspecified) {
|
||||
buf_appendf(&fn_type->name, " callconv(.%s)", calling_convention_name(fn_type_id->cc));
|
||||
}
|
||||
buf_appendf(&fn_type->name, " %s", buf_ptr(&fn_type_id->return_type->name));
|
||||
|
||||
// The fn_type is a pointer; not to be confused with the raw function type.
|
||||
@ -1444,8 +1449,6 @@ ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
|
||||
ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
||||
ZigType *fn_type = new_type_table_entry(ZigTypeIdFn);
|
||||
buf_resize(&fn_type->name, 0);
|
||||
const char *cc_str = calling_convention_fn_type_str(fn_type->data.fn.fn_type_id.cc);
|
||||
buf_appendf(&fn_type->name, "%s", cc_str);
|
||||
buf_appendf(&fn_type->name, "fn(");
|
||||
size_t i = 0;
|
||||
for (; i < fn_type_id->next_param_index; i += 1) {
|
||||
@ -1457,7 +1460,11 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
||||
const char *comma_str = (i == 0) ? "" : ",";
|
||||
buf_appendf(&fn_type->name, "%svar", comma_str);
|
||||
}
|
||||
buf_appendf(&fn_type->name, ")var");
|
||||
buf_append_str(&fn_type->name, ")");
|
||||
if (fn_type_id->cc != CallingConventionUnspecified) {
|
||||
buf_appendf(&fn_type->name, " callconv(.%s)", calling_convention_name(fn_type_id->cc));
|
||||
}
|
||||
buf_append_str(&fn_type->name, " var");
|
||||
|
||||
fn_type->data.fn.fn_type_id = *fn_type_id;
|
||||
fn_type->data.fn.is_generic = true;
|
||||
@ -1467,17 +1474,21 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
||||
return fn_type;
|
||||
}
|
||||
|
||||
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc) {
|
||||
CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) {
|
||||
if (fn_proto->is_async)
|
||||
return CallingConventionAsync;
|
||||
// Compatible with the C ABI
|
||||
if (fn_proto->is_extern || fn_proto->is_export)
|
||||
return CallingConventionC;
|
||||
|
||||
return CallingConventionUnspecified;
|
||||
}
|
||||
|
||||
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, CallingConvention cc, size_t param_count_alloc) {
|
||||
assert(proto_node->type == NodeTypeFnProto);
|
||||
AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
|
||||
|
||||
if (fn_proto->cc == CallingConventionUnspecified) {
|
||||
bool extern_abi = fn_proto->is_extern || fn_proto->is_export;
|
||||
fn_type_id->cc = extern_abi ? CallingConventionC : CallingConventionUnspecified;
|
||||
} else {
|
||||
fn_type_id->cc = fn_proto->cc;
|
||||
}
|
||||
|
||||
fn_type_id->cc = cc;
|
||||
fn_type_id->param_count = fn_proto->params.length;
|
||||
fn_type_id->param_info = allocate<FnTypeParamInfo>(param_count_alloc);
|
||||
fn_type_id->next_param_index = 0;
|
||||
@ -1691,8 +1702,7 @@ Error type_allowed_in_extern(CodeGen *g, ZigType *type_entry, bool *result) {
|
||||
case ZigTypeIdArray:
|
||||
return type_allowed_in_extern(g, type_entry->data.array.child_type, result);
|
||||
case ZigTypeIdFn:
|
||||
*result = type_entry->data.fn.fn_type_id.cc == CallingConventionC ||
|
||||
type_entry->data.fn.fn_type_id.cc == CallingConventionStdcall;
|
||||
*result = !calling_convention_allows_zig_types(type_entry->data.fn.fn_type_id.cc);
|
||||
return ErrorNone;
|
||||
case ZigTypeIdPointer:
|
||||
if ((err = type_resolve(g, type_entry, ResolveStatusZeroBitsKnown)))
|
||||
@ -1746,13 +1756,15 @@ ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry) {
|
||||
return err_set_type;
|
||||
}
|
||||
|
||||
static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, ZigFn *fn_entry) {
|
||||
static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, ZigFn *fn_entry,
|
||||
CallingConvention cc)
|
||||
{
|
||||
assert(proto_node->type == NodeTypeFnProto);
|
||||
AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
|
||||
Error err;
|
||||
|
||||
FnTypeId fn_type_id = {0};
|
||||
init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length);
|
||||
init_fn_type_id(&fn_type_id, proto_node, cc, proto_node->data.fn_proto.params.length);
|
||||
|
||||
for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) {
|
||||
AstNode *param_node = fn_proto->params.at(fn_type_id.next_param_index);
|
||||
@ -2164,7 +2176,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
|
||||
ZigType *field_type = resolve_struct_field_type(g, field);
|
||||
if (field_type == nullptr) {
|
||||
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
|
||||
return err;
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
}
|
||||
if ((err = type_resolve(g, field->type_entry, ResolveStatusSizeKnown))) {
|
||||
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
|
||||
@ -2254,7 +2266,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
|
||||
ZigType *field_type = resolve_struct_field_type(g, field);
|
||||
if (field_type == nullptr) {
|
||||
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
|
||||
return err;
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
}
|
||||
|
||||
if ((err = type_resolve(g, field_type, ResolveStatusSizeKnown))) {
|
||||
@ -2324,7 +2336,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {
|
||||
&field->align))
|
||||
{
|
||||
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
|
||||
return err;
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
}
|
||||
add_node_error(g, field->decl_node,
|
||||
buf_create_from_str("TODO implement field alignment syntax for unions. https://github.com/ziglang/zig/issues/3125"));
|
||||
@ -2451,6 +2463,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
|
||||
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
}
|
||||
|
||||
if (is_packed) {
|
||||
if ((err = emit_error_unless_type_allowed_in_packed_union(g, field_type, union_field->decl_node))) {
|
||||
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
|
||||
@ -2909,7 +2922,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
|
||||
&field->align))
|
||||
{
|
||||
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
|
||||
return err;
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
}
|
||||
} else if (packed) {
|
||||
field->align = 1;
|
||||
@ -3395,27 +3408,6 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
|
||||
get_fully_qualified_decl_name(g, &fn_table_entry->symbol_name, &tld_fn->base, false);
|
||||
}
|
||||
|
||||
if (fn_proto->is_export) {
|
||||
switch (fn_proto->cc) {
|
||||
case CallingConventionAsync: {
|
||||
add_node_error(g, fn_def_node,
|
||||
buf_sprintf("exported function cannot be async"));
|
||||
} break;
|
||||
case CallingConventionC:
|
||||
case CallingConventionNaked:
|
||||
case CallingConventionCold:
|
||||
case CallingConventionStdcall:
|
||||
case CallingConventionUnspecified:
|
||||
// An exported function without a specific calling
|
||||
// convention defaults to C
|
||||
CallingConvention cc = (fn_proto->cc != CallingConventionUnspecified) ?
|
||||
fn_proto->cc : CallingConventionC;
|
||||
add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
|
||||
GlobalLinkageIdStrong, cc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_extern) {
|
||||
fn_table_entry->fndef_scope = create_fndef_scope(g,
|
||||
fn_table_entry->body_node, tld_fn->base.parent_scope, fn_table_entry);
|
||||
@ -3434,19 +3426,72 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
|
||||
|
||||
Scope *child_scope = fn_table_entry->fndef_scope ? &fn_table_entry->fndef_scope->base : tld_fn->base.parent_scope;
|
||||
|
||||
fn_table_entry->type_entry = analyze_fn_type(g, source_node, child_scope, fn_table_entry);
|
||||
CallingConvention cc;
|
||||
if (fn_proto->callconv_expr != nullptr) {
|
||||
ZigType *cc_enum_value = get_builtin_type(g, "CallingConvention");
|
||||
|
||||
ZigValue *result_val = analyze_const_value(g, child_scope, fn_proto->callconv_expr,
|
||||
cc_enum_value, nullptr, UndefBad);
|
||||
if (type_is_invalid(result_val->type)) {
|
||||
fn_table_entry->type_entry = g->builtin_types.entry_invalid;
|
||||
tld_fn->base.resolution = TldResolutionInvalid;
|
||||
return;
|
||||
}
|
||||
|
||||
cc = (CallingConvention)bigint_as_u32(&result_val->data.x_enum_tag);
|
||||
} else {
|
||||
cc = cc_from_fn_proto(fn_proto);
|
||||
}
|
||||
|
||||
if (fn_proto->section_expr != nullptr) {
|
||||
if (!analyze_const_string(g, child_scope, fn_proto->section_expr, &fn_table_entry->section_name)) {
|
||||
fn_table_entry->type_entry = g->builtin_types.entry_invalid;
|
||||
tld_fn->base.resolution = TldResolutionInvalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fn_table_entry->type_entry->id == ZigTypeIdInvalid) {
|
||||
fn_table_entry->type_entry = analyze_fn_type(g, source_node, child_scope, fn_table_entry, cc);
|
||||
|
||||
if (type_is_invalid(fn_table_entry->type_entry)) {
|
||||
tld_fn->base.resolution = TldResolutionInvalid;
|
||||
return;
|
||||
}
|
||||
|
||||
const CallingConvention fn_cc = fn_table_entry->type_entry->data.fn.fn_type_id.cc;
|
||||
|
||||
if (fn_proto->is_export) {
|
||||
switch (fn_cc) {
|
||||
case CallingConventionAsync:
|
||||
add_node_error(g, fn_def_node,
|
||||
buf_sprintf("exported function cannot be async"));
|
||||
fn_table_entry->type_entry = g->builtin_types.entry_invalid;
|
||||
tld_fn->base.resolution = TldResolutionInvalid;
|
||||
return;
|
||||
case CallingConventionC:
|
||||
case CallingConventionCold:
|
||||
case CallingConventionNaked:
|
||||
case CallingConventionInterrupt:
|
||||
case CallingConventionSignal:
|
||||
case CallingConventionStdcall:
|
||||
case CallingConventionFastcall:
|
||||
case CallingConventionVectorcall:
|
||||
case CallingConventionThiscall:
|
||||
case CallingConventionAPCS:
|
||||
case CallingConventionAAPCS:
|
||||
case CallingConventionAAPCSVFP:
|
||||
add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
|
||||
GlobalLinkageIdStrong, fn_cc);
|
||||
break;
|
||||
case CallingConventionUnspecified:
|
||||
// An exported function without a specific calling
|
||||
// convention defaults to C
|
||||
add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name),
|
||||
GlobalLinkageIdStrong, CallingConventionC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fn_table_entry->type_entry->data.fn.is_generic) {
|
||||
if (fn_def_node)
|
||||
g->fn_defs.append(fn_table_entry);
|
||||
@ -3455,7 +3500,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
|
||||
// if the calling convention implies that it cannot be async, we save that for later
|
||||
// and leave the value to be nullptr to indicate that we have not emitted possible
|
||||
// compile errors for improperly calling async functions.
|
||||
if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync) {
|
||||
if (fn_cc == CallingConventionAsync) {
|
||||
fn_table_entry->inferred_async_node = fn_table_entry->proto_node;
|
||||
}
|
||||
} else if (source_node->type == NodeTypeTestDecl) {
|
||||
@ -4338,7 +4383,7 @@ uint32_t get_ptr_align(CodeGen *g, ZigType *type) {
|
||||
} else if (ptr_type->id == ZigTypeIdFn) {
|
||||
// I tried making this use LLVMABIAlignmentOfType but it trips this assertion in LLVM:
|
||||
// "Cannot getTypeInfo() on a type that is unsized!"
|
||||
// when getting the alignment of `?extern fn() void`.
|
||||
// when getting the alignment of `?fn() callconv(.C) void`.
|
||||
// See http://lists.llvm.org/pipermail/llvm-dev/2018-September/126142.html
|
||||
return (ptr_type->data.fn.fn_type_id.alignment == 0) ? 1 : ptr_type->data.fn.fn_type_id.alignment;
|
||||
} else if (ptr_type->id == ZigTypeIdAnyFrame) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user