mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 00:26:57 +00:00
zig fmt and update extern fn
to callconv(.C)
This commit is contained in:
parent
5951b79af4
commit
53913acaf7
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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,7 +91,7 @@ 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)
|
||||
);
|
||||
|
@ -166,7 +166,7 @@ test "sigaltstack" {
|
||||
// analyzed
|
||||
const dl_phdr_info = if (@hasDecl(os, "dl_phdr_info")) os.dl_phdr_info else c_void;
|
||||
|
||||
extern 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;
|
||||
|
||||
|
@ -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,7 +188,7 @@ comptime {
|
||||
@export("clone", clone, builtin.GlobalLinkage.Strong);
|
||||
}
|
||||
}
|
||||
extern fn __stack_chk_fail() noreturn {
|
||||
fn __stack_chk_fail() callconv(.C) noreturn {
|
||||
@panic("stack smashing detected");
|
||||
}
|
||||
|
||||
@ -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,
|
||||
} {
|
||||
@ -635,7 +635,7 @@ fn __aeabi_memcmp() callconv(.Naked) 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);
|
||||
}
|
||||
|
@ -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 fn _alldiv(a: i64, b: i64) callconv(.Stdcall) 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);
|
||||
|
@ -1,6 +1,6 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub extern fn _allrem(a: i64, b: i64) callconv(.Stdcall) 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);
|
||||
|
@ -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,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),
|
||||
|
@ -43,11 +43,7 @@ comptime {
|
||||
}
|
||||
}
|
||||
|
||||
fn _DllMainCRTStartup(
|
||||
hinstDLL: std.os.windows.HINSTANCE,
|
||||
fdwReason: std.os.windows.DWORD,
|
||||
lpReserved: std.os.windows.LPVOID,
|
||||
) callconv(.Stdcall) 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 @@ 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;
|
||||
@ -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);
|
||||
|
@ -2972,7 +2972,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\ foo(bar);
|
||||
\\}
|
||||
\\
|
||||
\\extern fn bar(x: *void) void { }
|
||||
\\fn bar(x: *void) callconv(.C) void { }
|
||||
\\export fn entry2() void {
|
||||
\\ bar(&{});
|
||||
\\}
|
||||
@ -3871,7 +3871,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:1:37: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
|
||||
"tmp.zig:1:37: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'",
|
||||
});
|
||||
|
||||
cases.add("colliding invalid top level functions",
|
||||
@ -5618,7 +5618,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
});
|
||||
|
||||
cases.add("wrong types given to @export",
|
||||
\\extern fn entry() void { }
|
||||
\\fn entry() callconv(.C) void { }
|
||||
\\comptime {
|
||||
\\ @export("entry", entry, @as(u32, 1234));
|
||||
\\}
|
||||
|
@ -221,14 +221,14 @@ test "alignment of structs" {
|
||||
}) == @alignOf(usize));
|
||||
}
|
||||
|
||||
test "alignment of extern() void" {
|
||||
test "alignment of function with c calling convention" {
|
||||
var runtime_nothing = nothing;
|
||||
const casted1 = @ptrCast(*const u8, runtime_nothing);
|
||||
const casted2 = @ptrCast(extern fn () void, casted1);
|
||||
const casted2 = @ptrCast(fn () callconv(.C) void, casted1);
|
||||
casted2();
|
||||
}
|
||||
|
||||
extern fn nothing() void {}
|
||||
fn nothing() callconv(.C) void {}
|
||||
|
||||
test "return error union with 128-bit integer" {
|
||||
expect(3 == try give());
|
||||
|
@ -3,7 +3,7 @@ const expect = std.testing.expect;
|
||||
|
||||
pub const VM = ?[*]const struct_InvocationTable_;
|
||||
pub const struct_InvocationTable_ = extern struct {
|
||||
GetVM: ?extern fn (?[*]VM) c_int,
|
||||
GetVM: ?fn (?[*]VM) callconv(.C) c_int,
|
||||
};
|
||||
|
||||
pub const struct_VM_ = extern struct {
|
||||
@ -15,7 +15,7 @@ pub const struct_VM_ = extern struct {
|
||||
pub const InvocationTable_ = struct_InvocationTable_;
|
||||
pub const VM_ = struct_VM_;
|
||||
|
||||
extern fn agent_callback(_vm: [*]VM, options: [*]u8) i32 {
|
||||
fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 {
|
||||
return 11;
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ test "compile time int to ptr of function" {
|
||||
}
|
||||
|
||||
pub const FUNCTION_CONSTANT = @intToPtr(PFN_void, maxInt(usize));
|
||||
pub const PFN_void = extern fn (*c_void) void;
|
||||
pub const PFN_void = fn (*c_void) callconv(.C) void;
|
||||
|
||||
fn foobar(func: PFN_void) void {
|
||||
std.testing.expect(@ptrToInt(func) == maxInt(usize));
|
||||
@ -587,7 +587,7 @@ test "peer cast *[0]T to []const T" {
|
||||
|
||||
var global_array: [4]u8 = undefined;
|
||||
test "cast from array reference to fn" {
|
||||
const f = @ptrCast(extern fn () void, &global_array);
|
||||
const f = @ptrCast(fn () callconv(.C) void, &global_array);
|
||||
expect(@ptrToInt(f) == @ptrToInt(&global_array));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ comptime {
|
||||
@export("disabledExternFn", disabledExternFn, builtin.GlobalLinkage.Internal);
|
||||
}
|
||||
|
||||
extern fn disabledExternFn() void {}
|
||||
fn disabledExternFn() callconv(.C) void {}
|
||||
|
||||
test "call disabled extern fn" {
|
||||
disabledExternFn();
|
||||
|
@ -580,7 +580,7 @@ test "default struct initialization fields" {
|
||||
expectEqual(1239, x.a + x.b);
|
||||
}
|
||||
|
||||
test "extern fn returns struct by value" {
|
||||
test "fn with C calling convention returns struct by value" {
|
||||
const S = struct {
|
||||
fn entry() void {
|
||||
var x = makeBar(10);
|
||||
@ -591,7 +591,7 @@ test "extern fn returns struct by value" {
|
||||
handle: i32,
|
||||
};
|
||||
|
||||
extern fn makeBar(t: i32) ExternBar {
|
||||
fn makeBar(t: i32) callconv(.C) ExternBar {
|
||||
return ExternBar{
|
||||
.handle = t,
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ pub fn main() !void {
|
||||
var lib = try std.DynLib.open(dynlib_name);
|
||||
defer lib.close();
|
||||
|
||||
const addFn = lib.lookup(extern fn (i32, i32) i32, "add") orelse return error.SymbolNotFound;
|
||||
const addFn = lib.lookup(fn (i32, i32) callconv(.C) i32, "add") orelse return error.SymbolNotFound;
|
||||
|
||||
const result = addFn(12, 34);
|
||||
std.debug.assert(result == 46);
|
||||
|
@ -238,7 +238,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\pub extern fn foo() void;
|
||||
\\pub export fn bar() void {
|
||||
\\ var func_ptr: ?*c_void = @ptrCast(?*c_void, foo);
|
||||
\\ var typed_func_ptr: ?extern fn () void = @intToPtr(?extern fn () void, @intCast(c_ulong, @ptrToInt(func_ptr)));
|
||||
\\ var typed_func_ptr: ?fn () callconv(.C) void = @intToPtr(?fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr)));
|
||||
\\}
|
||||
});
|
||||
|
||||
@ -2297,7 +2297,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
\\pub fn bar() callconv(.C) void {}
|
||||
\\pub export fn foo(arg_baz: ?extern fn () [*c]c_int) void {
|
||||
\\pub export fn foo(arg_baz: ?fn () callconv(.C) [*c]c_int) void {
|
||||
\\ var baz = arg_baz;
|
||||
\\ bar();
|
||||
\\ _ = baz.?();
|
||||
|
Loading…
Reference in New Issue
Block a user