Skip to content

std.zig.c_translation.builtins

Standard libraryZig 0.17.0Official documentation
Sourcestd/zig/c_translation/builtins.zig

Source line 1

std.zig.c_translation.builtins.@"unreachable"

function

Source line 425

pub inline fn @"unreachable"() noreturn

std.zig.c_translation.builtins.abs

function

Source line 4

Standard C Library bug: The absolute value of the most negative integer remains negative.

pub inline fn abs(val: c_int) c_int

Parameters

val: c_int

std.zig.c_translation.builtins.add_overflow

function

Source line 8

pub fn add_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) bool

Parameters

result: *@TypeOf(a, b)

std.zig.c_translation.builtins.assume

function

Source line 14

pub inline fn assume(cond: bool) void

Parameters

cond: bool

std.zig.c_translation.builtins.bswap16

function

Source line 18

pub inline fn bswap16(val: u16) u16

Parameters

val: u16

std.zig.c_translation.builtins.bswap32

function

Source line 22

pub inline fn bswap32(val: u32) u32

Parameters

val: u32

std.zig.c_translation.builtins.bswap64

function

Source line 26

pub inline fn bswap64(val: u64) u64

Parameters

val: u64

std.zig.c_translation.builtins.ceil

function

Source line 34

pub inline fn ceil(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.ceilf

function

Source line 30

pub inline fn ceilf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.clz

function

Source line 40

Returns the number of leading 0-bits in x, starting at the most significant bit position. In C if val is 0, the result is undefined; in zig it's the number of bits in a c_uint

pub inline fn clz(val: c_uint) c_int

Parameters

val: c_uint

std.zig.c_translation.builtins.constant_p

function

Source line 45

pub inline fn constant_p(expr: anytype) c_int

std.zig.c_translation.builtins.cos

function

Source line 54

pub inline fn cos(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.cosf

function

Source line 50

pub inline fn cosf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.ctz

function

Source line 60

Returns the number of trailing 0-bits in val, starting at the least significant bit position. In C if val is 0, the result is undefined; in zig it's the number of bits in a c_uint

pub inline fn ctz(val: c_uint) c_int

Parameters

val: c_uint

std.zig.c_translation.builtins.elementwise_clzg

function

Source line 105

pub inline fn elementwise_clzg(x: anytype, y: anytype) @TypeOf(x, y)

std.zig.c_translation.builtins.elementwise_ctzg

function

Source line 130

pub inline fn elementwise_ctzg(x: anytype, y: anytype) @TypeOf(x, y)

std.zig.c_translation.builtins.elementwise_fshl

function

Source line 154

pub inline fn elementwise_fshl(a: anytype, b: anytype, c: anytype) @TypeOf(a, b, c)

std.zig.c_translation.builtins.elementwise_fshr

function

Source line 186

pub inline fn elementwise_fshr(a: anytype, b: anytype, c: anytype) @TypeOf(a, b, c)

std.zig.c_translation.builtins.exp

function

Source line 77

pub inline fn exp(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.exp2

function

Source line 69

pub inline fn exp2(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.exp2f

function

Source line 65

pub inline fn exp2f(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.expect

function

Source line 83

The return value of __builtin_expect is expr. c is the expected value of expr and is used as a hint to the compiler in C. Here it is unused.

pub inline fn expect(expr: c_long, c: c_long) c_long

Parameters

expr: c_long
c: c_long

std.zig.c_translation.builtins.expf

function

Source line 73

pub inline fn expf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.fabs

function

Source line 92

pub inline fn fabs(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.fabsf

function

Source line 88

pub inline fn fabsf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.floor

function

Source line 100

pub inline fn floor(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.floorf

function

Source line 96

pub inline fn floorf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.has_builtin

function

Source line 218

pub inline fn has_builtin(func: anytype) c_int

std.zig.c_translation.builtins.huge_valf

function

Source line 223

pub inline fn huge_valf() f32

std.zig.c_translation.builtins.inff

function

Source line 227

pub inline fn inff() f32

std.zig.c_translation.builtins.isinf

function

Source line 237

pub inline fn isinf(x: anytype) c_int

std.zig.c_translation.builtins.isinf_sign

function

Source line 232

Similar to isinf, except the return value is -1 for an argument of -Inf and 1 for an argument of +Inf.

pub inline fn isinf_sign(x: anytype) c_int

std.zig.c_translation.builtins.isnan

function

Source line 241

pub inline fn isnan(x: anytype) c_int

std.zig.c_translation.builtins.labs

function

Source line 246

Standard C Library bug: The absolute value of the most negative integer remains negative.

pub inline fn labs(val: c_long) c_long

Parameters

val: c_long

std.zig.c_translation.builtins.llabs

function

Source line 251

Standard C Library bug: The absolute value of the most negative integer remains negative.

pub inline fn llabs(val: c_longlong) c_longlong

Parameters

val: c_longlong

std.zig.c_translation.builtins.log

function

Source line 275

pub inline fn log(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.log10

function

Source line 259

pub inline fn log10(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.log10f

function

Source line 255

pub inline fn log10f(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.log2

function

Source line 267

pub inline fn log2(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.log2f

function

Source line 263

pub inline fn log2f(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.logf

function

Source line 271

pub inline fn logf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.memcpy

function

Source line 293

pub inline fn memcpy( noalias dst: ?*anyopaque, noalias src: ?*const anyopaque, len: usize, ) ?*anyopaque

Parameters

dst: ?*anyopaque
src: ?*const anyopaque
len: usize

std.zig.c_translation.builtins.memcpy_chk

function

Source line 279

pub inline fn memcpy_chk( noalias dst: ?*anyopaque, noalias src: ?*const anyopaque, len: usize, remaining: usize, ) ?*anyopaque

Parameters

dst: ?*anyopaque
src: ?*const anyopaque
len: usize
remaining: usize

std.zig.c_translation.builtins.memset

function

Source line 317

pub inline fn memset(dst: ?*anyopaque, val: c_int, len: usize) ?*anyopaque

Parameters

dst: ?*anyopaque
val: c_int
len: usize

std.zig.c_translation.builtins.memset_chk

function

Source line 305

pub inline fn memset_chk( dst: ?*anyopaque, val: c_int, len: usize, remaining: usize, ) ?*anyopaque

Parameters

dst: ?*anyopaque
val: c_int
len: usize
remaining: usize

std.zig.c_translation.builtins.mul_overflow

function

Source line 323

pub fn mul_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) bool

Parameters

result: *@TypeOf(a, b)

std.zig.c_translation.builtins.nanf

function

Source line 344

returns a quiet NaN. Quiet NaNs have many representations; tagp is used to select one in an implementation-defined way. This implementation is based on the description for nan provided in the GCC docs at https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fnan Comment is reproduced below: Since ISO C99 defines this function in terms of strtod, which we do not implement, a description of the parsing is in order. The string is parsed as by strtol; that is, the base is recognized by leading ‘0’ or ‘0x’ prefixes. The number parsed is placed in the significand such that the least significant bit of the number is at the least significant bit of the significand. The number is truncated to fit the significand field provided. The significand is forced to be a quiet NaN.

If tagp contains any non-numeric characters, the function returns a NaN whose significand is zero. If tagp is empty, the function returns a NaN whose significand is zero.

pub inline fn nanf(tagp: []const u8) f32

Parameters

tagp: []const u8

std.zig.c_translation.builtins.object_size

function

Source line 350

pub inline fn object_size(ptr: ?*const anyopaque, ty: c_int) usize

Parameters

ptr: ?*const anyopaque
ty: c_int

std.zig.c_translation.builtins.popcount

function

Source line 362

popcount of a c_uint will never exceed the capacity of a c_int

pub inline fn popcount(val: c_uint) c_int

Parameters

val: c_uint

std.zig.c_translation.builtins.round

function

Source line 371

pub inline fn round(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.roundf

function

Source line 367

pub inline fn roundf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.signbit

function

Source line 379

pub inline fn signbit(val: f64) c_int

Parameters

val: f64

std.zig.c_translation.builtins.signbitf

function

Source line 375

pub inline fn signbitf(val: f32) c_int

Parameters

val: f32

std.zig.c_translation.builtins.sin

function

Source line 387

pub inline fn sin(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.sinf

function

Source line 383

pub inline fn sinf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.sqrt

function

Source line 395

pub inline fn sqrt(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.sqrtf

function

Source line 391

pub inline fn sqrtf(val: f32) f32

Parameters

val: f32

std.zig.c_translation.builtins.std

alias

Source line 1

Alias of std

std.zig.c_translation.builtins.strcmp

function

Source line 399

pub inline fn strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int

Parameters

s1: [*c]const u8
s2: [*c]const u8

std.zig.c_translation.builtins.strlen

function

Source line 407

pub inline fn strlen(s: [*c]const u8) usize

Parameters

s: [*c]const u8

std.zig.c_translation.builtins.sub_overflow

function

Source line 411

pub fn sub_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) bool

Parameters

result: *@TypeOf(a, b)

std.zig.c_translation.builtins.trunc

function

Source line 421

pub inline fn trunc(val: f64) f64

Parameters

val: f64

std.zig.c_translation.builtins.truncf

function

Source line 417

pub inline fn truncf(val: f32) f32

Parameters

val: f32
Source code

std/zig/c_translation/builtins.zig

const std = @import("std");

/// Standard C Library bug: The absolute value of the most negative integer remains negative.
pub inline fn abs(val: c_int) c_int {
    return if (val == std.math.minInt(c_int)) val else @intCast(@abs(val));
}

pub fn add_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) bool {
    const res = @addWithOverflow(a, b);
    result.* = res[0];
    return res[1] == 1;
}

pub inline fn assume(cond: bool) void {
    if (!cond) unreachable;
}

pub inline fn bswap16(val: u16) u16 {
    return @byteSwap(val);
}

pub inline fn bswap32(val: u32) u32 {
    return @byteSwap(val);
}

pub inline fn bswap64(val: u64) u64 {
    return @byteSwap(val);
}

pub inline fn ceilf(val: f32) f32 {
    return @ceil(val);
}

pub inline fn ceil(val: f64) f64 {
    return @ceil(val);
}

/// Returns the number of leading 0-bits in x, starting at the most significant bit position.
/// In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
pub inline fn clz(val: c_uint) c_int {
    @setRuntimeSafety(false);
    return @as(c_int, @bitCast(@as(c_uint, @clz(val))));
}

pub inline fn constant_p(expr: anytype) c_int {
    _ = expr;
    return @intFromBool(false);
}

pub inline fn cosf(val: f32) f32 {
    return @cos(val);
}

pub inline fn cos(val: f64) f64 {
    return @cos(val);
}

/// Returns the number of trailing 0-bits in val, starting at the least significant bit position.
/// In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
pub inline fn ctz(val: c_uint) c_int {
    @setRuntimeSafety(false);
    return @as(c_int, @bitCast(@as(c_uint, @ctz(val))));
}

pub inline fn exp2f(val: f32) f32 {
    return @exp2(val);
}

pub inline fn exp2(val: f64) f64 {
    return @exp2(val);
}

pub inline fn expf(val: f32) f32 {
    return @exp(val);
}

pub inline fn exp(val: f64) f64 {
    return @exp(val);
}

/// The return value of __builtin_expect is `expr`. `c` is the expected value
/// of `expr` and is used as a hint to the compiler in C. Here it is unused.
pub inline fn expect(expr: c_long, c: c_long) c_long {
    _ = c;
    return expr;
}

pub inline fn fabsf(val: f32) f32 {
    return @abs(val);
}

pub inline fn fabs(val: f64) f64 {
    return @abs(val);
}

pub inline fn floorf(val: f32) f32 {
    return @floor(val);
}

pub inline fn floor(val: f64) f64 {
    return @floor(val);
}

// Single argument variant is mapped to @clz
pub inline fn elementwise_clzg(x: anytype, y: anytype) @TypeOf(x, y) {
    switch (@typeInfo(@TypeOf(x, y))) {
        .int => |int| {
            const U = @Int(.unsigned, int.bits);
            const value: U = @bitCast(x);
            if (value == 0) return y;

            const result: U = @clz(value);
            return @bitCast(result);
        },
        .vector => |vector| {
            const Elem = @Int(.unsigned, @bitSizeOf(vector.child));
            const U = @Vector(vector.len, Elem);
            const value: U = @bitCast(x);
            const fallback: U = @bitCast(y);
            const zero: U = @splat(0);
            const count: U = @clz(value);
            const result: U = @select(Elem, value == zero, fallback, count);
            return @bitCast(result);
        },
        else => unreachable,
    }
}

// Single argument variant is mapped to @ctz
pub inline fn elementwise_ctzg(x: anytype, y: anytype) @TypeOf(x, y) {
    switch (@typeInfo(@TypeOf(x, y))) {
        .int => |int| {
            const U = @Int(.unsigned, int.bits);
            const value: U = @bitCast(x);
            if (value == 0) return y;

            const result: U = @ctz(value);
            return @bitCast(result);
        },
        .vector => |vector| {
            const Elem = @Int(.unsigned, @bitSizeOf(vector.child));
            const U = @Vector(vector.len, Elem);
            const value: U = @bitCast(x);
            const fallback: U = @bitCast(y);
            const zero: U = @splat(0);
            const count: U = @ctz(value);
            const result: U = @select(Elem, value == zero, fallback, count);
            return @bitCast(result);
        },
        else => unreachable,
    }
}

pub inline fn elementwise_fshl(a: anytype, b: anytype, c: anytype) @TypeOf(a, b, c) {
    switch (@typeInfo(@TypeOf(a, b, c))) {
        .int => |int| {
            const U = @Int(.unsigned, int.bits);
            const lhs: U = @bitCast(a);
            const rhs: U = @bitCast(b);
            const bits = @bitSizeOf(U);
            const shift = @as(U, @bitCast(c)) % bits;
            if (shift == 0) return a;

            const inverse_shift: U = @as(U, bits) - shift;
            const result: U = (lhs << @intCast(shift)) | (rhs >> @intCast(inverse_shift));
            return @bitCast(result);
        },
        .vector => |vector| {
            const Elem = @Int(.unsigned, @bitSizeOf(vector.child));
            const U = @Vector(vector.len, Elem);
            const lhs: U = @bitCast(a);
            const rhs: U = @bitCast(b);
            const bits: U = @splat(@bitSizeOf(vector.child));
            const zero: U = @splat(0);
            const shift = @as(U, @bitCast(c)) % bits;
            const inverse_shift = @select(Elem, shift == zero, zero, bits - shift);

            const rhs_term = @select(Elem, shift == zero, zero, rhs >> @intCast(inverse_shift));
            const result: U = (lhs << @intCast(shift)) | rhs_term;
            return @bitCast(result);
        },
        else => unreachable,
    }
}

pub inline fn elementwise_fshr(a: anytype, b: anytype, c: anytype) @TypeOf(a, b, c) {
    switch (@typeInfo(@TypeOf(a, b, c))) {
        .int => |int| {
            const U = @Int(.unsigned, int.bits);
            const lhs: U = @bitCast(a);
            const rhs: U = @bitCast(b);
            const bits = @bitSizeOf(U);
            const shift = @as(U, @bitCast(c)) % bits;
            if (shift == 0) return b;

            const inverse_shift: U = @as(U, bits) - shift;
            const result: U = (lhs << @intCast(inverse_shift)) | (rhs >> @intCast(shift));
            return @bitCast(result);
        },
        .vector => |vector| {
            const Elem = @Int(.unsigned, @bitSizeOf(vector.child));
            const U = @Vector(vector.len, Elem);
            const lhs: U = @bitCast(a);
            const rhs: U = @bitCast(b);
            const bits: U = @splat(@bitSizeOf(vector.child));
            const zero: U = @splat(0);
            const shift = @as(U, @bitCast(c)) % bits;
            const inverse_shift = @select(Elem, shift == zero, zero, bits - shift);

            const lhs_term = @select(Elem, shift == zero, zero, lhs << @intCast(inverse_shift));
            const result: U = lhs_term | (rhs >> @intCast(shift));
            return @bitCast(result);
        },
        else => unreachable,
    }
}

pub inline fn has_builtin(func: anytype) c_int {
    _ = func;
    return @intFromBool(true);
}

pub inline fn huge_valf() f32 {
    return std.math.inf(f32);
}

pub inline fn inff() f32 {
    return std.math.inf(f32);
}

/// Similar to isinf, except the return value is -1 for an argument of -Inf and 1 for an argument of +Inf.
pub inline fn isinf_sign(x: anytype) c_int {
    if (!std.math.isInf(x)) return 0;
    return if (std.math.isPositiveInf(x)) 1 else -1;
}

pub inline fn isinf(x: anytype) c_int {
    return @intFromBool(std.math.isInf(x));
}

pub inline fn isnan(x: anytype) c_int {
    return @intFromBool(std.math.isNan(x));
}

/// Standard C Library bug: The absolute value of the most negative integer remains negative.
pub inline fn labs(val: c_long) c_long {
    return if (val == std.math.minInt(c_long)) val else @intCast(@abs(val));
}

/// Standard C Library bug: The absolute value of the most negative integer remains negative.
pub inline fn llabs(val: c_longlong) c_longlong {
    return if (val == std.math.minInt(c_longlong)) val else @intCast(@abs(val));
}

pub inline fn log10f(val: f32) f32 {
    return @log10(val);
}

pub inline fn log10(val: f64) f64 {
    return @log10(val);
}

pub inline fn log2f(val: f32) f32 {
    return @log2(val);
}

pub inline fn log2(val: f64) f64 {
    return @log2(val);
}

pub inline fn logf(val: f32) f32 {
    return @log(val);
}

pub inline fn log(val: f64) f64 {
    return @log(val);
}

pub inline fn memcpy_chk(
    noalias dst: ?*anyopaque,
    noalias src: ?*const anyopaque,
    len: usize,
    remaining: usize,
) ?*anyopaque {
    if (len > remaining) @panic("__builtin___memcpy_chk called with len > remaining");
    if (len > 0) @memcpy(
        @as([*]u8, @ptrCast(dst.?))[0..len],
        @as([*]const u8, @ptrCast(src.?)),
    );
    return dst;
}

pub inline fn memcpy(
    noalias dst: ?*anyopaque,
    noalias src: ?*const anyopaque,
    len: usize,
) ?*anyopaque {
    if (len > 0) @memcpy(
        @as([*]u8, @ptrCast(dst.?))[0..len],
        @as([*]const u8, @ptrCast(src.?)),
    );
    return dst;
}

pub inline fn memset_chk(
    dst: ?*anyopaque,
    val: c_int,
    len: usize,
    remaining: usize,
) ?*anyopaque {
    if (len > remaining) @panic("__builtin___memset_chk called with len > remaining");
    const dst_cast = @as([*c]u8, @ptrCast(dst));
    @memset(dst_cast[0..len], @as(u8, @bitCast(@as(i8, @truncate(val)))));
    return dst;
}

pub inline fn memset(dst: ?*anyopaque, val: c_int, len: usize) ?*anyopaque {
    const dst_cast = @as([*c]u8, @ptrCast(dst));
    @memset(dst_cast[0..len], @as(u8, @bitCast(@as(i8, @truncate(val)))));
    return dst;
}

pub fn mul_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) bool {
    const res = @mulWithOverflow(a, b);
    result.* = res[0];
    return res[1] == 1;
}

/// returns a quiet NaN. Quiet NaNs have many representations; tagp is used to select one in an
/// implementation-defined way.
/// This implementation is based on the description for nan provided in the GCC docs at
/// https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fnan
/// Comment is reproduced below:
/// Since ISO C99 defines this function in terms of strtod, which we do not implement, a description
/// of the parsing is in order.
/// The string is parsed as by strtol; that is, the base is recognized by leading ‘0’ or ‘0x’ prefixes.
/// The number parsed is placed in the significand such that the least significant bit of the number is
///    at the least significant bit of the significand.
/// The number is truncated to fit the significand field provided.
/// The significand is forced to be a quiet NaN.
///
/// If tagp contains any non-numeric characters, the function returns a NaN whose significand is zero.
/// If tagp is empty, the function returns a NaN whose significand is zero.
pub inline fn nanf(tagp: []const u8) f32 {
    const parsed = std.fmt.parseUnsigned(c_ulong, tagp, 0) catch 0;
    const bits: u23 = @truncate(parsed); // single-precision float trailing significand is 23 bits
    return @bitCast(@as(u32, bits) | @as(u32, @bitCast(std.math.nan(f32))));
}

pub inline fn object_size(ptr: ?*const anyopaque, ty: c_int) usize {
    _ = ptr;
    // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
    // If it is not possible to determine which objects ptr points to at compile time,
    // object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0
    // for type 2 or 3.
    if (ty == 0 or ty == 1) return @as(usize, @bitCast(-@as(isize, 1)));
    if (ty == 2 or ty == 3) return 0;
    unreachable;
}

/// popcount of a c_uint will never exceed the capacity of a c_int
pub inline fn popcount(val: c_uint) c_int {
    @setRuntimeSafety(false);
    return @as(c_int, @bitCast(@as(c_uint, @popCount(val))));
}

pub inline fn roundf(val: f32) f32 {
    return @round(val);
}

pub inline fn round(val: f64) f64 {
    return @round(val);
}

pub inline fn signbitf(val: f32) c_int {
    return @intFromBool(std.math.signbit(val));
}

pub inline fn signbit(val: f64) c_int {
    return @intFromBool(std.math.signbit(val));
}

pub inline fn sinf(val: f32) f32 {
    return @sin(val);
}

pub inline fn sin(val: f64) f64 {
    return @sin(val);
}

pub inline fn sqrtf(val: f32) f32 {
    return @sqrt(val);
}

pub inline fn sqrt(val: f64) f64 {
    return @sqrt(val);
}

pub inline fn strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int {
    return switch (std.mem.orderZ(u8, s1, s2)) {
        .lt => -1,
        .eq => 0,
        .gt => 1,
    };
}

pub inline fn strlen(s: [*c]const u8) usize {
    return std.mem.sliceTo(s, 0).len;
}

pub fn sub_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) bool {
    const res = @subWithOverflow(a, b);
    result.* = res[0];
    return res[1] == 1;
}

pub inline fn truncf(val: f32) f32 {
    return @trunc(val);
}

pub inline fn trunc(val: f64) f64 {
    return @trunc(val);
}

pub inline fn @"unreachable"() noreturn {
    unreachable;
}