all: zig fmt and rename "@XToY" to "@YFromX"

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
Eric Joldasov 2023-06-15 13:14:16 +06:00 committed by Andrew Kelley
parent a6c8ee5231
commit 50339f595a
665 changed files with 6204 additions and 5889 deletions

View File

@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_from_float.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig"
@ -417,7 +417,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_from_int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig"

View File

@ -487,7 +487,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
.cpu_arch = .wasm32,
.os_tag = .wasi,
};
target.cpu_features_add.addFeature(@enumToInt(std.Target.wasm.Feature.bulk_memory));
target.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory));
const exe = addCompilerStep(b, .ReleaseSmall, target);

View File

@ -2763,14 +2763,14 @@ test "comptime pointers" {
}
}
{#code_end#}
<p>To convert an integer address into a pointer, use {#syntax#}@intToPtr{#endsyntax#}.
To convert a pointer to an integer, use {#syntax#}@ptrToInt{#endsyntax#}:</p>
<p>To convert an integer address into a pointer, use {#syntax#}@ptrFromInt{#endsyntax#}.
To convert a pointer to an integer, use {#syntax#}@intFromPtr{#endsyntax#}:</p>
{#code_begin|test|test_integer_pointer_conversion#}
const expect = @import("std").testing.expect;
test "@ptrToInt and @intToPtr" {
const ptr = @intToPtr(*i32, 0xdeadbee0);
const addr = @ptrToInt(ptr);
test "@intFromPtr and @ptrFromInt" {
const ptr = @ptrFromInt(*i32, 0xdeadbee0);
const addr = @intFromPtr(ptr);
try expect(@TypeOf(addr) == usize);
try expect(addr == 0xdeadbee0);
}
@ -2780,18 +2780,18 @@ test "@ptrToInt and @intToPtr" {
{#code_begin|test|test_comptime_pointer_conversion#}
const expect = @import("std").testing.expect;
test "comptime @intToPtr" {
test "comptime @ptrFromInt" {
comptime {
// Zig is able to do this at compile-time, as long as
// ptr is never dereferenced.
const ptr = @intToPtr(*i32, 0xdeadbee0);
const addr = @ptrToInt(ptr);
const ptr = @ptrFromInt(*i32, 0xdeadbee0);
const addr = @intFromPtr(ptr);
try expect(@TypeOf(addr) == usize);
try expect(addr == 0xdeadbee0);
}
}
{#code_end#}
{#see_also|Optional Pointers|@intToPtr|@ptrToInt|C Pointers#}
{#see_also|Optional Pointers|@ptrFromInt|@intFromPtr|C Pointers#}
{#header_open|volatile#}
<p>Loads and stores are assumed to not have side effects. If a given load or store
should have side effects, such as Memory Mapped Input/Output (MMIO), use {#syntax#}volatile{#endsyntax#}.
@ -2801,7 +2801,7 @@ test "comptime @intToPtr" {
const expect = @import("std").testing.expect;
test "volatile" {
const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);
const mmio_ptr = @ptrFromInt(*volatile u8, 0x12345678);
try expect(@TypeOf(mmio_ptr) == *volatile u8);
}
{#code_end#}
@ -2942,8 +2942,8 @@ const expect = std.testing.expect;
test "allowzero" {
var zero: usize = 0;
var ptr = @intToPtr(*allowzero i32, zero);
try expect(@ptrToInt(ptr) == 0);
var ptr = @ptrFromInt(*allowzero i32, zero);
try expect(@intFromPtr(ptr) == 0);
}
{#code_end#}
{#header_close#}
@ -3006,7 +3006,7 @@ test "basic slices" {
// while using the `ptr` field gives a many-item pointer.
try expect(@TypeOf(slice.ptr) == [*]i32);
try expect(@TypeOf(&slice[0]) == *i32);
try expect(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));
try expect(@intFromPtr(slice.ptr) == @intFromPtr(&slice[0]));
// Slices have array bounds checking. If you try to access something out
// of bounds, you'll get a safety check failure:
@ -3448,8 +3448,8 @@ var bit_field = BitField{
};
test "pointers of sub-byte-aligned fields share addresses" {
try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.b));
try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.c));
try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.b));
try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.c));
}
{#code_end#}
<p>
@ -3664,9 +3664,9 @@ const Value = enum(u2) {
// Now you can cast between u2 and Value.
// The ordinal value starts from 0, counting up by 1 from the previous member.
test "enum ordinal value" {
try expect(@enumToInt(Value.zero) == 0);
try expect(@enumToInt(Value.one) == 1);
try expect(@enumToInt(Value.two) == 2);
try expect(@intFromEnum(Value.zero) == 0);
try expect(@intFromEnum(Value.one) == 1);
try expect(@intFromEnum(Value.two) == 2);
}
// You can override the ordinal value for an enum.
@ -3676,9 +3676,9 @@ const Value2 = enum(u32) {
million = 1000000,
};
test "set enum ordinal value" {
try expect(@enumToInt(Value2.hundred) == 100);
try expect(@enumToInt(Value2.thousand) == 1000);
try expect(@enumToInt(Value2.million) == 1000000);
try expect(@intFromEnum(Value2.hundred) == 100);
try expect(@intFromEnum(Value2.thousand) == 1000);
try expect(@intFromEnum(Value2.million) == 1000000);
}
// You can also override only some values.
@ -3690,11 +3690,11 @@ const Value3 = enum(u4) {
e,
};
test "enum implicit ordinal values and overridden values" {
try expect(@enumToInt(Value3.a) == 0);
try expect(@enumToInt(Value3.b) == 8);
try expect(@enumToInt(Value3.c) == 9);
try expect(@enumToInt(Value3.d) == 4);
try expect(@enumToInt(Value3.e) == 5);
try expect(@intFromEnum(Value3.a) == 0);
try expect(@intFromEnum(Value3.b) == 8);
try expect(@intFromEnum(Value3.c) == 9);
try expect(@intFromEnum(Value3.d) == 4);
try expect(@intFromEnum(Value3.e) == 5);
}
// Enums can have methods, the same as structs and unions.
@ -3811,7 +3811,7 @@ test "switch using enum literals" {
It must specify a tag type and cannot consume every enumeration value.
</p>
<p>
{#link|@intToEnum#} on a non-exhaustive enum involves the safety semantics
{#link|@enumFromInt#} on a non-exhaustive enum involves the safety semantics
of {#link|@intCast#} to the integer tag type, but beyond that always results in
a well-defined enum value.
</p>
@ -4385,7 +4385,7 @@ fn withFor(any: AnySlice) usize {
// With `inline for` the function gets generated as
// a series of `if` statements relying on the optimizer
// to convert it to a switch.
if (field.value == @enumToInt(any)) {
if (field.value == @intFromEnum(any)) {
return @field(any, field.name).len;
}
}
@ -4428,7 +4428,7 @@ fn getNum(u: U) u32 {
// `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value.
inline else => |num, tag| {
if (tag == .b) {
return @floatToInt(u32, num);
return @intFromFloat(u32, num);
}
return num;
}
@ -6625,19 +6625,19 @@ test "coercion from homogenous tuple to array" {
<ul>
<li>{#link|@bitCast#} - change type but maintain bit representation</li>
<li>{#link|@alignCast#} - make a pointer have more alignment</li>
<li>{#link|@boolToInt#} - convert true to 1 and false to 0</li>
<li>{#link|@enumToInt#} - obtain the integer tag value of an enum or tagged union</li>
<li>{#link|@intFromBool#} - convert true to 1 and false to 0</li>
<li>{#link|@intFromEnum#} - obtain the integer tag value of an enum or tagged union</li>
<li>{#link|@errSetCast#} - convert to a smaller error set</li>
<li>{#link|@errorToInt#} - obtain the integer value of an error code</li>
<li>{#link|@intFromError#} - obtain the integer value of an error code</li>
<li>{#link|@floatCast#} - convert a larger float to a smaller float</li>
<li>{#link|@floatToInt#} - obtain the integer part of a float value</li>
<li>{#link|@intFromFloat#} - obtain the integer part of a float value</li>
<li>{#link|@intCast#} - convert between integer types</li>
<li>{#link|@intToEnum#} - obtain an enum value based on its integer tag value</li>
<li>{#link|@intToError#} - obtain an error code based on its integer value</li>
<li>{#link|@intToFloat#} - convert an integer to a float value</li>
<li>{#link|@intToPtr#} - convert an address to a pointer</li>
<li>{#link|@enumFromInt#} - obtain an enum value based on its integer tag value</li>
<li>{#link|@errorFromInt#} - obtain an error code based on its integer value</li>
<li>{#link|@floatFromInt#} - convert an integer to a float value</li>
<li>{#link|@ptrFromInt#} - convert an address to a pointer</li>
<li>{#link|@ptrCast#} - convert between pointer types</li>
<li>{#link|@ptrToInt#} - obtain the address of a pointer</li>
<li>{#link|@intFromPtr#} - obtain the address of a pointer</li>
<li>{#link|@truncate#} - convert between integer types, chopping off bits</li>
</ul>
{#header_close#}
@ -6744,8 +6744,8 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
}
test "peer type resolution: *const T and ?*T" {
const a = @intToPtr(*const usize, 0x123456780);
const b = @intToPtr(?*usize, 0x123456780);
const a = @ptrFromInt(*const usize, 0x123456780);
const b = @ptrFromInt(?*usize, 0x123456780);
try expect(a == b);
try expect(b == a);
}
@ -7542,7 +7542,7 @@ pub fn main() void {
{#target_linux_x86_64#}
pub fn main() noreturn {
const msg = "hello world\n";
_ = syscall3(SYS_write, STDOUT_FILENO, @ptrToInt(msg), msg.len);
_ = syscall3(SYS_write, STDOUT_FILENO, @intFromPtr(msg), msg.len);
_ = syscall1(SYS_exit, 0);
unreachable;
}
@ -7857,7 +7857,7 @@ comptime {
Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
</p>
<p>
Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
</p>
<p>
Can be used for these things for example:
@ -7884,8 +7884,8 @@ comptime {
{#see_also|@offsetOf#}
{#header_close#}
{#header_open|@boolToInt#}
<pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre>
{#header_open|@intFromBool#}
<pre>{#syntax#}@intFromBool(value: bool) u1{#endsyntax#}</pre>
<p>
Converts {#syntax#}true{#endsyntax#} to {#syntax#}@as(u1, 1){#endsyntax#} and {#syntax#}false{#endsyntax#} to
{#syntax#}@as(u1, 0){#endsyntax#}.
@ -8348,8 +8348,8 @@ test "main" {
{#see_also|@import#}
{#header_close#}
{#header_open|@enumToInt#}
<pre>{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
{#header_open|@intFromEnum#}
<pre>{#syntax#}@intFromEnum(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
<p>
Converts an enumeration value into its integer tag type. When a tagged union is passed,
the tag value is used as the enumeration value.
@ -8358,7 +8358,7 @@ test "main" {
If there is only one possible enum value, the result is a {#syntax#}comptime_int{#endsyntax#}
known at {#link|comptime#}.
</p>
{#see_also|@intToEnum#}
{#see_also|@enumFromInt#}
{#header_close#}
{#header_open|@errorName#}
@ -8383,8 +8383,8 @@ test "main" {
</p>
{#header_close#}
{#header_open|@errorToInt#}
<pre>{#syntax#}@errorToInt(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
{#header_open|@intFromError#}
<pre>{#syntax#}@intFromError(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
<p>
Supports the following types:
</p>
@ -8400,7 +8400,7 @@ test "main" {
It is generally recommended to avoid this
cast, as the integer representation of an error is not stable across source code changes.
</p>
{#see_also|@intToError#}
{#see_also|@errorFromInt#}
{#header_close#}
{#header_open|@errSetCast#}
@ -8526,8 +8526,8 @@ test "decl access by string" {
</p>
{#header_close#}
{#header_open|@floatToInt#}
<pre>{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
{#header_open|@intFromFloat#}
<pre>{#syntax#}@intFromFloat(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
<p>
Converts the integer part of a floating point number to the destination type.
</p>
@ -8535,7 +8535,7 @@ test "decl access by string" {
If the integer part of the floating point number cannot fit in the destination type,
it invokes safety-checked {#link|Undefined Behavior#}.
</p>
{#see_also|@intToFloat#}
{#see_also|@floatFromInt#}
{#header_close#}
{#header_open|@frameAddress#}
@ -8666,8 +8666,8 @@ test "integer cast panic" {
</p>
{#header_close#}
{#header_open|@intToEnum#}
<pre>{#syntax#}@intToEnum(comptime DestType: type, integer: anytype) DestType{#endsyntax#}</pre>
{#header_open|@enumFromInt#}
<pre>{#syntax#}@enumFromInt(comptime DestType: type, integer: anytype) DestType{#endsyntax#}</pre>
<p>
Converts an integer into an {#link|enum#} value.
</p>
@ -8675,11 +8675,11 @@ test "integer cast panic" {
Attempting to convert an integer which represents no value in the chosen enum type invokes
safety-checked {#link|Undefined Behavior#}.
</p>
{#see_also|@enumToInt#}
{#see_also|@intFromEnum#}
{#header_close#}
{#header_open|@intToError#}
<pre>{#syntax#}@intToError(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
{#header_open|@errorFromInt#}
<pre>{#syntax#}@errorFromInt(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
<p>
Converts from the integer representation of an error into {#link|The Global Error Set#} type.
</p>
@ -8691,20 +8691,20 @@ test "integer cast panic" {
Attempting to convert an integer that does not correspond to any error results in
safety-protected {#link|Undefined Behavior#}.
</p>
{#see_also|@errorToInt#}
{#see_also|@intFromError#}
{#header_close#}
{#header_open|@intToFloat#}
<pre>{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
{#header_open|@floatFromInt#}
<pre>{#syntax#}@floatFromInt(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
<p>
Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe.
Converts an integer to the closest floating point representation. To convert the other way, use {#link|@intFromFloat#}. This cast is always safe.
</p>
{#header_close#}
{#header_open|@intToPtr#}
<pre>{#syntax#}@intToPtr(comptime DestType: type, address: usize) DestType{#endsyntax#}</pre>
{#header_open|@ptrFromInt#}
<pre>{#syntax#}@ptrFromInt(comptime DestType: type, address: usize) DestType{#endsyntax#}</pre>
<p>
Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@ptrToInt#}. Casting an address of 0 to a destination type
Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@intFromPtr#}. Casting an address of 0 to a destination type
which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a
{#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled.
</p>
@ -8928,13 +8928,13 @@ pub const PrefetchOptions = struct {
</ul>
{#header_close#}
{#header_open|@ptrToInt#}
<pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre>
{#header_open|@intFromPtr#}
<pre>{#syntax#}@intFromPtr(value: anytype) usize{#endsyntax#}</pre>
<p>
Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer.
{#syntax#}value{#endsyntax#} can be {#syntax#}*T{#endsyntax#} or {#syntax#}?*T{#endsyntax#}.
</p>
<p>To convert the other way, use {#link|@intToPtr#}</p>
<p>To convert the other way, use {#link|@ptrFromInt#}</p>
{#header_close#}
@ -10165,8 +10165,8 @@ fn getNumberOrFail() !i32 {
{#code_begin|test_err|test_comptime_invalid_error_code|integer value '11' represents no error#}
comptime {
const err = error.AnError;
const number = @errorToInt(err) + 10;
const invalid_err = @intToError(number);
const number = @intFromError(err) + 10;
const invalid_err = @errorFromInt(number);
_ = invalid_err;
}
{#code_end#}
@ -10176,8 +10176,8 @@ const std = @import("std");
pub fn main() void {
var err = error.AnError;
var number = @errorToInt(err) + 500;
var invalid_err = @intToError(number);
var number = @intFromError(err) + 500;
var invalid_err = @errorFromInt(number);
std.debug.print("value: {}\n", .{invalid_err});
}
{#code_end#}
@ -10192,7 +10192,7 @@ const Foo = enum {
};
comptime {
const a: u2 = 3;
const b = @intToEnum(Foo, a);
const b = @enumFromInt(Foo, a);
_ = b;
}
{#code_end#}
@ -10208,7 +10208,7 @@ const Foo = enum {
pub fn main() void {
var a: u2 = 3;
var b = @intToEnum(Foo, a);
var b = @enumFromInt(Foo, a);
std.debug.print("value: {s}\n", .{@tagName(b)});
}
{#code_end#}
@ -10255,7 +10255,7 @@ fn foo(set1: Set1) void {
<p>At compile-time:</p>
{#code_begin|test_err|test_comptime_incorrect_pointer_alignment|pointer address 0x1 is not aligned to 4 bytes#}
comptime {
const ptr = @intToPtr(*align(1) i32, 0x1);
const ptr = @ptrFromInt(*align(1) i32, 0x1);
const aligned = @alignCast(4, ptr);
_ = aligned;
}

View File

@ -55,7 +55,7 @@ comptime {
_ = @import("compiler_rt/trunctfdf2.zig");
_ = @import("compiler_rt/trunctfxf2.zig");
_ = @import("compiler_rt/float_to_int.zig");
_ = @import("compiler_rt/int_from_float.zig");
_ = @import("compiler_rt/fixhfsi.zig");
_ = @import("compiler_rt/fixhfdi.zig");
_ = @import("compiler_rt/fixhfti.zig");
@ -87,7 +87,7 @@ comptime {
_ = @import("compiler_rt/fixunsxfdi.zig");
_ = @import("compiler_rt/fixunsxfti.zig");
_ = @import("compiler_rt/int_to_float.zig");
_ = @import("compiler_rt/float_from_int.zig");
_ = @import("compiler_rt/floatsihf.zig");
_ = @import("compiler_rt/floatsisf.zig");
_ = @import("compiler_rt/floatsidf.zig");

View File

@ -8,7 +8,7 @@ const always_has_lse = std.Target.aarch64.featureSetHas(builtin.cpu.features, .l
/// It is intentionally not exported in order to make the machine code that
/// uses it a statically predicted direct branch rather than using the PLT,
/// which ARM is concerned would have too much overhead.
var __aarch64_have_lse_atomics: u8 = @boolToInt(always_has_lse);
var __aarch64_have_lse_atomics: u8 = @intFromBool(always_has_lse);
fn __aarch64_cas1_relax() align(16) callconv(.Naked) void {
@setRuntimeSafety(false);

View File

@ -119,21 +119,21 @@ var spinlocks: SpinlockTable = SpinlockTable{};
fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
_ = model;
var sl = spinlocks.get(@ptrToInt(src));
var sl = spinlocks.get(@intFromPtr(src));
defer sl.release();
@memcpy(dest[0..size], src);
}
fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
_ = model;
var sl = spinlocks.get(@ptrToInt(dest));
var sl = spinlocks.get(@intFromPtr(dest));
defer sl.release();
@memcpy(dest[0..size], src);
}
fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
_ = model;
var sl = spinlocks.get(@ptrToInt(ptr));
var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release();
@memcpy(old[0..size], ptr);
@memcpy(ptr[0..size], val);
@ -149,7 +149,7 @@ fn __atomic_compare_exchange(
) callconv(.C) i32 {
_ = success;
_ = failure;
var sl = spinlocks.get(@ptrToInt(ptr));
var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release();
for (ptr[0..size], 0..) |b, i| {
if (expected[i] != b) break;
@ -168,7 +168,7 @@ fn __atomic_compare_exchange(
inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
_ = model;
if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(src));
var sl = spinlocks.get(@intFromPtr(src));
defer sl.release();
return src.*;
} else {
@ -199,7 +199,7 @@ fn __atomic_load_16(src: *u128, model: i32) callconv(.C) u128 {
inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
_ = model;
if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(dst));
var sl = spinlocks.get(@intFromPtr(dst));
defer sl.release();
dst.* = value;
} else {
@ -230,9 +230,9 @@ fn __atomic_store_16(dst: *u128, value: u128, model: i32) callconv(.C) void {
fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8);
const addr = @ptrToInt(ptr);
const addr = @intFromPtr(ptr);
const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1);
const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @intToPtr(*WideAtomic, wide_addr));
const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @ptrFromInt(*WideAtomic, wide_addr));
const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1);
const inner_shift = @intCast(std.math.Log2Int(T), inner_offset * 8);
@ -255,7 +255,7 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
_ = model;
if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(ptr));
var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release();
const value = ptr.*;
ptr.* = val;
@ -305,7 +305,7 @@ inline fn atomic_compare_exchange_N(
_ = success;
_ = failure;
if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(ptr));
var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release();
const value = ptr.*;
if (value == expected.*) {
@ -362,7 +362,7 @@ inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr
};
if (@sizeOf(T) > largest_atomic_size) {
var sl = spinlocks.get(@ptrToInt(ptr));
var sl = spinlocks.get(@intFromPtr(ptr));
defer sl.release();
const value = ptr.*;

View File

@ -63,7 +63,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
.addr = start,
.len = end - start,
};
const result = sysarch(ARM_SYNC_ICACHE, @ptrToInt(&arg));
const result = sysarch(ARM_SYNC_ICACHE, @intFromPtr(&arg));
std.debug.assert(result == 0);
exportIt();
},

View File

@ -26,7 +26,7 @@ comptime {
/// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`,
/// and `__ltdf2`.
fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f64, comparef.LE, a, b));
return @intFromEnum(comparef.cmpf2(f64, comparef.LE, a, b));
}
/// "These functions return a value less than or equal to zero if neither argument is NaN,
@ -56,13 +56,13 @@ pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 {
}
fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
}
fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
}
fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
}

View File

@ -20,7 +20,7 @@ comptime {
/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
/// and `__lthf2`.
fn __cmphf2(a: f16, b: f16) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f16, comparef.LE, a, b));
return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b));
}
/// "These functions return a value less than or equal to zero if neither argument is NaN,

View File

@ -26,7 +26,7 @@ comptime {
/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
/// and `__ltsf2`.
fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f32, comparef.LE, a, b));
return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b));
}
/// "These functions return a value less than or equal to zero if neither argument is NaN,
@ -56,13 +56,13 @@ pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 {
}
fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
}
fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
}
fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
}

View File

@ -34,7 +34,7 @@ comptime {
/// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`,
/// and `__lttf2`.
fn __cmptf2(a: f128, b: f128) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f128, comparef.LE, a, b));
return @intFromEnum(comparef.cmpf2(f128, comparef.LE, a, b));
}
/// "These functions return a value less than or equal to zero if neither argument is NaN,
@ -71,34 +71,34 @@ const SparcFCMP = enum(i32) {
};
fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
return @intFromEnum(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
}
fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
}
fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
}
fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less;
return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Less;
}
fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool {
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
}
fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool {
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) {
.Equal, .Greater => true,
.Less, .Unordered => false,
};
}
fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool {
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) {
.Equal, .Less => true,
.Greater, .Unordered => false,
};

View File

@ -20,7 +20,7 @@ comptime {
/// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`,
/// and `__ltxf2`.
fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 {
return @enumToInt(comparef.cmp_f80(comparef.LE, a, b));
return @intFromEnum(comparef.cmp_f80(comparef.LE, a, b));
}
/// "These functions return a value less than or equal to zero if neither argument is NaN,

View File

@ -77,7 +77,7 @@ pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT {
if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0)
return .Equal;
if (@boolToInt(a_rep.exp == b_rep.exp) & @boolToInt(a_rep.fraction == b_rep.fraction) != 0) {
if (@intFromBool(a_rep.exp == b_rep.exp) & @intFromBool(a_rep.fraction == b_rep.fraction) != 0) {
return .Equal;
} else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) {
// signs are different
@ -109,7 +109,7 @@ pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
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);
return @intFromBool(aAbs > infRep or bAbs > infRep);
}
test {

View File

@ -199,7 +199,7 @@ inline fn div(a: f64, b: f64) f64 {
} else if (writtenExponent < 1) {
if (writtenExponent == 0) {
// Check whether the rounded result is normal.
const round = @boolToInt((residual << 1) > bSignificand);
const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit.
var absResult = quotient & significandMask;
// Round.
@ -213,7 +213,7 @@ inline fn div(a: f64, b: f64) f64 {
// code to round them correctly.
return @bitCast(f64, quotientSign);
} else {
const round = @boolToInt((residual << 1) > bSignificand);
const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit
var absResult = quotient & significandMask;
// Insert the exponent

View File

@ -179,7 +179,7 @@ inline fn div(a: f32, b: f32) f32 {
} else if (writtenExponent < 1) {
if (writtenExponent == 0) {
// Check whether the rounded result is normal.
const round = @boolToInt((residual << 1) > bSignificand);
const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit.
var absResult = quotient & significandMask;
// Round.
@ -193,7 +193,7 @@ inline fn div(a: f32, b: f32) f32 {
// code to round them correctly.
return @bitCast(f32, quotientSign);
} else {
const round = @boolToInt((residual << 1) > bSignificand);
const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit
var absResult = quotient & significandMask;
// Insert the exponent

View File

@ -214,7 +214,7 @@ inline fn div(a: f128, b: f128) f128 {
} else if (writtenExponent < 1) {
if (writtenExponent == 0) {
// Check whether the rounded result is normal.
const round = @boolToInt((residual << 1) > bSignificand);
const round = @intFromBool((residual << 1) > bSignificand);
// Clear the implicit bit.
var absResult = quotient & significandMask;
// Round.
@ -228,7 +228,7 @@ inline fn div(a: f128, b: f128) f128 {
// code to round them correctly.
return @bitCast(f128, quotientSign);
} else {
const round = @boolToInt((residual << 1) >= bSignificand);
const round = @intFromBool((residual << 1) >= bSignificand);
// Clear the implicit bit
var absResult = quotient & significandMask;
// Insert the exponent

View File

@ -195,7 +195,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
// code to round them correctly.
return @bitCast(T, quotientSign);
} else {
const round = @boolToInt(residual > (bSignificand >> 1));
const round = @intFromBool(residual > (bSignificand >> 1));
// Insert the exponent
var absResult = quotient | (@intCast(Z, writtenExponent) << significandBits);
// Round

View File

@ -74,12 +74,12 @@ pub fn expf(x_: f32) callconv(.C) f32 {
if (hx > 0x3EB17218) {
// |x| > 1.5 * ln2
if (hx > 0x3F851592) {
k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]);
k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]);
} else {
k = 1 - sign - sign;
}
const fk = @intToFloat(f32, k);
const fk = @floatFromInt(f32, k);
hi = x - fk * ln2hi;
lo = fk * ln2lo;
x = hi - lo;
@ -157,12 +157,12 @@ pub fn exp(x_: f64) callconv(.C) f64 {
if (hx > 0x3FD62E42) {
// |x| >= 1.5 * ln2
if (hx > 0x3FF0A2B2) {
k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]);
k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]);
} else {
k = 1 - sign - sign;
}
const dk = @intToFloat(f64, k);
const dk = @floatFromInt(f64, k);
hi = x - dk * ln2hi;
lo = dk * ln2lo;
x = hi - lo;

View File

@ -32,7 +32,7 @@ pub fn __exp2h(x: f16) callconv(.C) f16 {
pub fn exp2f(x: f32) callconv(.C) f32 {
const tblsiz = @intCast(u32, exp2ft.len);
const redux: f32 = 0x1.8p23 / @intToFloat(f32, tblsiz);
const redux: f32 = 0x1.8p23 / @floatFromInt(f32, tblsiz);
const P1: f32 = 0x1.62e430p-1;
const P2: f32 = 0x1.ebfbe0p-3;
const P3: f32 = 0x1.c6b348p-5;
@ -89,7 +89,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 {
pub fn exp2(x: f64) callconv(.C) f64 {
const tblsiz: u32 = @intCast(u32, exp2dt.len / 2);
const redux: f64 = 0x1.8p52 / @intToFloat(f64, tblsiz);
const redux: f64 = 0x1.8p52 / @floatFromInt(f64, tblsiz);
const P1: f64 = 0x1.62e42fefa39efp-1;
const P2: f64 = 0x1.ebfbdff82c575p-3;
const P3: f64 = 0x1.c6b08d704a0a6p-5;

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixdfdi(a: f64) callconv(.C) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}
fn __aeabi_d2lz(a: f64) callconv(.AAPCS) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixdfsi(a: f64) callconv(.C) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}
fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixdfti(a: f64) callconv(.C) i128 {
return floatToInt(i128, a);
return intFromFloat(i128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a));
return @bitCast(v2u64, intFromFloat(i128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixhfdi(a: f16) callconv(.C) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixhfsi(a: f16) callconv(.C) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixhfti(a: f16) callconv(.C) i128 {
return floatToInt(i128, a);
return intFromFloat(i128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a));
return @bitCast(v2u64, intFromFloat(i128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixsfdi(a: f32) callconv(.C) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}
fn __aeabi_f2lz(a: f32) callconv(.AAPCS) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixsfsi(a: f32) callconv(.C) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}
fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixsfti(a: f32) callconv(.C) i128 {
return floatToInt(i128, a);
return intFromFloat(i128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixsfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a));
return @bitCast(v2u64, intFromFloat(i128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __fixtfdi(a: f128) callconv(.C) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}
fn _Qp_qtox(a: *const f128) callconv(.C) i64 {
return floatToInt(i64, a.*);
return intFromFloat(i64, a.*);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __fixtfsi(a: f128) callconv(.C) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}
fn _Qp_qtoi(a: *const f128) callconv(.C) i32 {
return floatToInt(i32, a.*);
return intFromFloat(i32, a.*);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -15,11 +15,11 @@ comptime {
}
pub fn __fixtfti(a: f128) callconv(.C) i128 {
return floatToInt(i128, a);
return intFromFloat(i128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixtfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a));
return @bitCast(v2u64, intFromFloat(i128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixunsdfdi(a: f64) callconv(.C) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}
fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixunsdfsi(a: f64) callconv(.C) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}
fn __aeabi_d2uiz(a: f64) callconv(.AAPCS) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixunsdfti(a: f64) callconv(.C) u128 {
return floatToInt(u128, a);
return intFromFloat(u128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixunsdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a));
return @bitCast(v2u64, intFromFloat(u128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixunshfdi(a: f16) callconv(.C) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixunshfsi(a: f16) callconv(.C) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixunshfti(a: f16) callconv(.C) u128 {
return floatToInt(u128, a);
return intFromFloat(u128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a));
return @bitCast(v2u64, intFromFloat(u128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixunssfdi(a: f32) callconv(.C) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}
fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __fixunssfsi(a: f32) callconv(.C) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}
fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixunssfti(a: f32) callconv(.C) u128 {
return floatToInt(u128, a);
return intFromFloat(u128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixunssfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a));
return @bitCast(v2u64, intFromFloat(u128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}
fn _Qp_qtoux(a: *const f128) callconv(.C) u64 {
return floatToInt(u64, a.*);
return intFromFloat(u64, a.*);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}
fn _Qp_qtoui(a: *const f128) callconv(.C) u32 {
return floatToInt(u32, a.*);
return intFromFloat(u32, a.*);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -15,11 +15,11 @@ comptime {
}
pub fn __fixunstfti(a: f128) callconv(.C) u128 {
return floatToInt(u128, a);
return intFromFloat(u128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixunstfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a));
return @bitCast(v2u64, intFromFloat(u128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixunsxfdi(a: f80) callconv(.C) u64 {
return floatToInt(u64, a);
return intFromFloat(u64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixunsxfsi(a: f80) callconv(.C) u32 {
return floatToInt(u32, a);
return intFromFloat(u32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixunsxfti(a: f80) callconv(.C) u128 {
return floatToInt(u128, a);
return intFromFloat(u128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixunsxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(u128, a));
return @bitCast(v2u64, intFromFloat(u128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixxfdi(a: f80) callconv(.C) i64 {
return floatToInt(i64, a);
return intFromFloat(i64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __fixxfsi(a: f80) callconv(.C) i32 {
return floatToInt(i32, a);
return intFromFloat(i32, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const floatToInt = @import("./float_to_int.zig").floatToInt;
const intFromFloat = @import("./int_from_float.zig").intFromFloat;
pub const panic = common.panic;
@ -13,11 +13,11 @@ comptime {
}
pub fn __fixxfti(a: f80) callconv(.C) i128 {
return floatToInt(i128, a);
return intFromFloat(i128, a);
}
const v2u64 = @Vector(2, u64);
fn __fixxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
return @bitCast(v2u64, floatToInt(i128, a));
return @bitCast(v2u64, intFromFloat(i128, a));
}

View File

@ -1,7 +1,7 @@
const Int = @import("std").meta.Int;
const math = @import("std").math;
pub fn intToFloat(comptime T: type, x: anytype) T {
pub fn floatFromInt(comptime T: type, x: anytype) T {
if (x == 0) return 0;
// Various constants whose values follow from the type parameters.
@ -38,7 +38,7 @@ pub fn intToFloat(comptime T: type, x: anytype) T {
result = @intCast(uT, (abs_val >> (shift_amt - 1))) ^ (implicit_bit << 1);
// Round result, including round-to-even for exact ties
result = ((result + 1) >> 1) & ~@as(uT, @boolToInt(exact_tie));
result = ((result + 1) >> 1) & ~@as(uT, @intFromBool(exact_tie));
}
// Compute exponent
@ -54,5 +54,5 @@ pub fn intToFloat(comptime T: type, x: anytype) T {
}
test {
_ = @import("int_to_float_test.zig");
_ = @import("float_from_int_test.zig");
}

View File

@ -812,25 +812,25 @@ test "conversion to f32" {
test "conversion to f80" {
if (std.debug.runtime_safety) return error.SkipZigTest;
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
try testing.expect(intToFloat(f80, @as(i80, -12)) == -12);
try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0);
try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1);
try testing.expect(floatFromInt(f80, @as(i80, -12)) == -12);
try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0);
try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1);
try testing.expect(intToFloat(f80, @as(u32, 0)) == 0.0);
try testing.expect(intToFloat(f80, @as(u32, 1)) == 1.0);
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24));
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64));
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up
try testing.expect(floatFromInt(f80, @as(u32, 0)) == 0.0);
try testing.expect(floatFromInt(f80, @as(u32, 1)) == 1.0);
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24));
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64));
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up
try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up
try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatdidf(a: i64) callconv(.C) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}
fn __aeabi_l2d(a: i64) callconv(.AAPCS) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatdihf(a: i64) callconv(.C) f16 {
return intToFloat(f16, a);
return floatFromInt(f16, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatdisf(a: i64) callconv(.C) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}
fn __aeabi_l2f(a: i64) callconv(.AAPCS) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatditf(a: i64) callconv(.C) f128 {
return intToFloat(f128, a);
return floatFromInt(f128, a);
}
fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
c.* = intToFloat(f128, a);
c.* = floatFromInt(f128, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatdixf(a: i64) callconv(.C) f80 {
return intToFloat(f80, a);
return floatFromInt(f80, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatsidf(a: i32) callconv(.C) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}
fn __aeabi_i2d(a: i32) callconv(.AAPCS) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatsihf(a: i32) callconv(.C) f16 {
return intToFloat(f16, a);
return floatFromInt(f16, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatsisf(a: i32) callconv(.C) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}
fn __aeabi_i2f(a: i32) callconv(.AAPCS) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatsitf(a: i32) callconv(.C) f128 {
return intToFloat(f128, a);
return floatFromInt(f128, a);
}
fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
c.* = intToFloat(f128, a);
c.* = floatFromInt(f128, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatsixf(a: i32) callconv(.C) f80 {
return intToFloat(f80, a);
return floatFromInt(f80, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floattidf(a: i128) callconv(.C) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}
fn __floattidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 {
return intToFloat(f64, @bitCast(i128, a));
return floatFromInt(f64, @bitCast(i128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floattihf(a: i128) callconv(.C) f16 {
return intToFloat(f16, a);
return floatFromInt(f16, a);
}
fn __floattihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 {
return intToFloat(f16, @bitCast(i128, a));
return floatFromInt(f16, @bitCast(i128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floattisf(a: i128) callconv(.C) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}
fn __floattisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 {
return intToFloat(f32, @bitCast(i128, a));
return floatFromInt(f32, @bitCast(i128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -15,9 +15,9 @@ comptime {
}
pub fn __floattitf(a: i128) callconv(.C) f128 {
return intToFloat(f128, a);
return floatFromInt(f128, a);
}
fn __floattitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 {
return intToFloat(f128, @bitCast(i128, a));
return floatFromInt(f128, @bitCast(i128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floattixf(a: i128) callconv(.C) f80 {
return intToFloat(f80, a);
return floatFromInt(f80, a);
}
fn __floattixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 {
return intToFloat(f80, @bitCast(i128, a));
return floatFromInt(f80, @bitCast(i128, a));
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatundidf(a: u64) callconv(.C) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}
fn __aeabi_ul2d(a: u64) callconv(.AAPCS) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatundihf(a: u64) callconv(.C) f16 {
return intToFloat(f16, a);
return floatFromInt(f16, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatundisf(a: u64) callconv(.C) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}
fn __aeabi_ul2f(a: u64) callconv(.AAPCS) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatunditf(a: u64) callconv(.C) f128 {
return intToFloat(f128, a);
return floatFromInt(f128, a);
}
fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
c.* = intToFloat(f128, a);
c.* = floatFromInt(f128, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatundixf(a: u64) callconv(.C) f80 {
return intToFloat(f80, a);
return floatFromInt(f80, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatunsidf(a: u32) callconv(.C) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}
fn __aeabi_ui2d(a: u32) callconv(.AAPCS) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
pub fn __floatunsihf(a: u32) callconv(.C) f16 {
return intToFloat(f16, a);
return floatFromInt(f16, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -12,9 +12,9 @@ comptime {
}
pub fn __floatunsisf(a: u32) callconv(.C) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}
fn __aeabi_ui2f(a: u32) callconv(.AAPCS) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatunsitf(a: u32) callconv(.C) f128 {
return intToFloat(f128, a);
return floatFromInt(f128, a);
}
fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
c.* = intToFloat(f128, a);
c.* = floatFromInt(f128, a);
}

View File

@ -1,5 +1,5 @@
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -8,5 +8,5 @@ comptime {
}
fn __floatunsixf(a: u32) callconv(.C) f80 {
return intToFloat(f80, a);
return floatFromInt(f80, a);
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatuntidf(a: u128) callconv(.C) f64 {
return intToFloat(f64, a);
return floatFromInt(f64, a);
}
fn __floatuntidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 {
return intToFloat(f64, @bitCast(u128, a));
return floatFromInt(f64, @bitCast(u128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatuntihf(a: u128) callconv(.C) f16 {
return intToFloat(f16, a);
return floatFromInt(f16, a);
}
fn __floatuntihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 {
return intToFloat(f16, @bitCast(u128, a));
return floatFromInt(f16, @bitCast(u128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatuntisf(a: u128) callconv(.C) f32 {
return intToFloat(f32, a);
return floatFromInt(f32, a);
}
fn __floatuntisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 {
return intToFloat(f32, @bitCast(u128, a));
return floatFromInt(f32, @bitCast(u128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -15,9 +15,9 @@ comptime {
}
pub fn __floatuntitf(a: u128) callconv(.C) f128 {
return intToFloat(f128, a);
return floatFromInt(f128, a);
}
fn __floatuntitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 {
return intToFloat(f128, @bitCast(u128, a));
return floatFromInt(f128, @bitCast(u128, a));
}

View File

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const common = @import("./common.zig");
const intToFloat = @import("./int_to_float.zig").intToFloat;
const floatFromInt = @import("./float_from_int.zig").floatFromInt;
pub const panic = common.panic;
@ -13,9 +13,9 @@ comptime {
}
pub fn __floatuntixf(a: u128) callconv(.C) f80 {
return intToFloat(f80, a);
return floatFromInt(f80, a);
}
fn __floatuntixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 {
return intToFloat(f80, @bitCast(u128, a));
return floatFromInt(f80, @bitCast(u128, a));
}

View File

@ -18,7 +18,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b."
pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f64, comparef.GE, a, b));
return @intFromEnum(comparef.cmpf2(f64, comparef.GE, a, b));
}
/// "These functions return a value greater than zero if neither argument is NaN,
@ -28,9 +28,9 @@ pub fn __gtdf2(a: f64, b: f64) callconv(.C) i32 {
}
fn __aeabi_dcmpge(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) != .Less);
return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) != .Less);
}
fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater);
return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater);
}

View File

@ -13,7 +13,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b."
pub fn __gehf2(a: f16, b: f16) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f16, comparef.GE, a, b));
return @intFromEnum(comparef.cmpf2(f16, comparef.GE, a, b));
}
/// "These functions return a value greater than zero if neither argument is NaN,

View File

@ -18,7 +18,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b."
pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f32, comparef.GE, a, b));
return @intFromEnum(comparef.cmpf2(f32, comparef.GE, a, b));
}
/// "These functions return a value greater than zero if neither argument is NaN,
@ -28,9 +28,9 @@ pub fn __gtsf2(a: f32, b: f32) callconv(.C) i32 {
}
fn __aeabi_fcmpge(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.GE, a, b) != .Less);
return @intFromBool(comparef.cmpf2(f32, comparef.GE, a, b) != .Less);
}
fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.AAPCS) i32 {
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater);
return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater);
}

View File

@ -20,7 +20,7 @@ comptime {
/// "These functions return a value greater than or equal to zero if neither
/// argument is NaN, and a is greater than or equal to b."
fn __getf2(a: f128, b: f128) callconv(.C) i32 {
return @enumToInt(comparef.cmpf2(f128, comparef.GE, a, b));
return @intFromEnum(comparef.cmpf2(f128, comparef.GE, a, b));
}
/// "These functions return a value greater than zero if neither argument is NaN,

View File

@ -9,7 +9,7 @@ comptime {
}
fn __gexf2(a: f80, b: f80) callconv(.C) i32 {
return @enumToInt(comparef.cmp_f80(comparef.GE, a, b));
return @intFromEnum(comparef.cmp_f80(comparef.GE, a, b));
}
fn __gtxf2(a: f80, b: f80) callconv(.C) i32 {

View File

@ -2,7 +2,7 @@ const Int = @import("std").meta.Int;
const math = @import("std").math;
const Log2Int = math.Log2Int;
pub inline fn floatToInt(comptime I: type, a: anytype) I {
pub inline fn intFromFloat(comptime I: type, a: anytype) I {
const F = @TypeOf(a);
const float_bits = @typeInfo(F).Float.bits;
const int_bits = @typeInfo(I).Int.bits;
@ -51,5 +51,5 @@ pub inline fn floatToInt(comptime I: type, a: anytype) I {
}
test {
_ = @import("float_to_int_test.zig");
_ = @import("int_from_float_test.zig");
}

View File

@ -77,7 +77,7 @@ pub fn logf(x_: f32) callconv(.C) f32 {
const t2 = z * (Lg1 + w * Lg3);
const R = t2 + t1;
const hfsq = 0.5 * f * f;
const dk = @intToFloat(f32, k);
const dk = @floatFromInt(f32, k);
return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
}
@ -133,7 +133,7 @@ pub fn log(x_: f64) callconv(.C) f64 {
const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
const R = t2 + t1;
const dk = @intToFloat(f64, k);
const dk = @floatFromInt(f64, k);
return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
}

View File

@ -86,7 +86,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 {
u &= 0xFFFFF000;
hi = @bitCast(f32, u);
const lo = f - hi - hfsq + s * (hfsq + R);
const dk = @intToFloat(f32, k);
const dk = @floatFromInt(f32, k);
return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;
}
@ -154,7 +154,7 @@ pub fn log10(x_: f64) callconv(.C) f64 {
// val_hi + val_lo ~ log10(1 + f) + k * log10(2)
var val_hi = hi * ivln10hi;
const dk = @intToFloat(f64, k);
const dk = @floatFromInt(f64, k);
const y = dk * log10_2hi;
var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;

View File

@ -84,7 +84,7 @@ pub fn log2f(x_: f32) callconv(.C) f32 {
u &= 0xFFFFF000;
hi = @bitCast(f32, u);
const lo = f - hi - hfsq + s * (hfsq + R);
return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @intToFloat(f32, k);
return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @floatFromInt(f32, k);
}
pub fn log2(x_: f64) callconv(.C) f64 {
@ -150,7 +150,7 @@ pub fn log2(x_: f64) callconv(.C) f64 {
var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;
// spadd(val_hi, val_lo, y)
const y = @intToFloat(f64, k);
const y = @floatFromInt(f64, k);
const ww = y + val_hi;
val_lo += (y - ww) + val_hi;
val_hi = ww;

View File

@ -8,7 +8,7 @@ comptime {
pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 {
@setRuntimeSafety(false);
if (@ptrToInt(dest) < @ptrToInt(src)) {
if (@intFromPtr(dest) < @intFromPtr(src)) {
var index: usize = 0;
while (index != n) : (index += 1) {
dest.?[index] = src.?[index];

View File

@ -126,7 +126,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
// Otherwise, shift the significand of the result so that the round
// bit is the high bit of productLo.
const sticky = wideShrWithTruncation(ZSignificand, &productHi, &productLo, shift);
productLo |= @boolToInt(sticky);
productLo |= @intFromBool(sticky);
result = productHi;
// We include the integer bit so that rounding will carry to the exponent,

View File

@ -36,7 +36,7 @@ const __isPlatformVersionAtLeast = if (builtin.os.tag.isDarwin()) struct {
.platform = platform,
.version = constructVersion(major, minor, subminor),
};
return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
return @intFromBool(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
}
// _availability_version_check darwin API support.

View File

@ -9,7 +9,7 @@ fn paritydi2Naive(a: i64) i32 {
has_parity = !has_parity;
x = x & (x - 1);
}
return @intCast(i32, @boolToInt(has_parity));
return @intCast(i32, @intFromBool(has_parity));
}
fn test__paritydi2(a: i64) !void {

View File

@ -9,7 +9,7 @@ fn paritysi2Naive(a: i32) i32 {
has_parity = !has_parity;
x = x & (x - 1);
}
return @intCast(i32, @boolToInt(has_parity));
return @intCast(i32, @intFromBool(has_parity));
}
fn test__paritysi2(a: i32) !void {

View File

@ -9,7 +9,7 @@ fn parityti2Naive(a: i128) i32 {
has_parity = !has_parity;
x = x & (x - 1);
}
return @intCast(i32, @boolToInt(has_parity));
return @intCast(i32, @intFromBool(has_parity));
}
fn test__parityti2(a: i128) !void {

View File

@ -41,7 +41,7 @@ fn medium(ix: u32, x: f64, y: *[2]f64) i32 {
// rint(x/(pi/2))
@"fn" = x * invpio2 + toint - toint;
n = @floatToInt(i32, @"fn");
n = @intFromFloat(i32, @"fn");
r = x - @"fn" * pio2_1;
w = @"fn" * pio2_1t; // 1st round, good to 85 bits
// Matters with directed rounding.
@ -178,7 +178,7 @@ pub fn rem_pio2(x: f64, y: *[2]f64) i32 {
i = 0;
while (i < 2) : (i += 1) {
tx[U(i)] = @intToFloat(f64, @floatToInt(i32, z));
tx[U(i)] = @floatFromInt(f64, @intFromFloat(i32, z));
z = (z - tx[U(i)]) * 0x1p24;
}
tx[U(i)] = z;

View File

@ -295,7 +295,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
i += 1;
j += 1;
}) {
f[U(i)] = if (j < 0) 0.0 else @intToFloat(f64, ipio2[U(j)]);
f[U(i)] = if (j < 0) 0.0 else @floatFromInt(f64, ipio2[U(j)]);
}
// compute q[0],q[1],...q[jk]
@ -322,16 +322,16 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
i += 1;
j -= 1;
}) {
fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z));
iq[U(i)] = @floatToInt(i32, z - 0x1p24 * fw);
fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z));
iq[U(i)] = @intFromFloat(i32, z - 0x1p24 * fw);
z = q[U(j - 1)] + fw;
}
// compute n
z = math.scalbn(z, q0); // actual value of z
z -= 8.0 * @floor(z * 0.125); // trim off integer >= 8
n = @floatToInt(i32, z);
z -= @intToFloat(f64, n);
n = @intFromFloat(i32, z);
z -= @floatFromInt(f64, n);
ih = 0;
if (q0 > 0) { // need iq[jz-1] to determine n
i = iq[U(jz - 1)] >> @intCast(u5, 24 - q0);
@ -390,7 +390,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
i = jz + 1;
while (i <= jz + k) : (i += 1) { // add q[jz+1] to q[jz+k]
f[U(jx + i)] = @intToFloat(f64, ipio2[U(jv + i)]);
f[U(jx + i)] = @floatFromInt(f64, ipio2[U(jv + i)]);
j = 0;
fw = 0;
while (j <= jx) : (j += 1) {
@ -414,13 +414,13 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
} else { // break z into 24-bit if necessary
z = math.scalbn(z, -q0);
if (z >= 0x1p24) {
fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z));
iq[U(jz)] = @floatToInt(i32, z - 0x1p24 * fw);
fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z));
iq[U(jz)] = @intFromFloat(i32, z - 0x1p24 * fw);
jz += 1;
q0 += 24;
iq[U(jz)] = @floatToInt(i32, fw);
iq[U(jz)] = @intFromFloat(i32, fw);
} else {
iq[U(jz)] = @floatToInt(i32, z);
iq[U(jz)] = @intFromFloat(i32, z);
}
}
@ -428,7 +428,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
fw = math.scalbn(@as(f64, 1.0), q0);
i = jz;
while (i >= 0) : (i -= 1) {
q[U(i)] = fw * @intToFloat(f64, iq[U(i)]);
q[U(i)] = fw * @floatFromInt(f64, iq[U(i)]);
fw *= 0x1p-24;
}

View File

@ -37,7 +37,7 @@ pub fn rem_pio2f(x: f32, y: *f64) i32 {
if (ix < 0x4dc90fdb) { // |x| ~< 2^28*(pi/2), medium size
// Use a specialized rint() to get fn.
@"fn" = @floatCast(f64, x) * invpio2 + toint - toint;
n = @floatToInt(i32, @"fn");
n = @intFromFloat(i32, @"fn");
y.* = x - @"fn" * pio2_1 - @"fn" * pio2_1t;
// Matters with directed rounding.
if (y.* < -pio4) {

Some files were not shown because too many files have changed in this diff Show More