| author | |
| committer | |
| log | 9399fcddce0bcd8e987b053f3946aa1b0ff2ef0a |
| tree | d72180f3ea1097a78cb52fc6567a1d7762efee41 |
| parent | aae5560712fb67cea2b1405c4e2b03e9be236678 |
6 files changed, 27 insertions(+), 93 deletions(-)
lib/c.zig+1| ... | @@ -16,6 +16,7 @@ else | ... | @@ -16,6 +16,7 @@ else |
| 16 | comptime { | 16 | comptime { |
| 17 | _ = @import("c/inttypes.zig"); | 17 | _ = @import("c/inttypes.zig"); |
| 18 | _ = @import("c/stdlib.zig"); | 18 | _ = @import("c/stdlib.zig"); |
| 19 | _ = @import("c/math.zig"); | ||
| 19 | 20 | ||
| 20 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 21 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 21 | // Files specific to musl and wasi-libc. | 22 | // Files specific to musl and wasi-libc. |
lib/c/math.zig created+26| ... | @@ -0,0 +1,26 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | |||
| 5 | comptime { | ||
| 6 | if (builtin.target.isMinGW()) { | ||
| 7 | @export(&isnan, .{ .name = "isnan", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 8 | @export(&isnan, .{ .name = "__isnan", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 9 | @export(&isnanf, .{ .name = "isnanf", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 10 | @export(&isnanf, .{ .name = "__isnanf", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 11 | @export(&isnanl, .{ .name = "isnanl", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 12 | @export(&isnanl, .{ .name = "__isnanl", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 13 | } | ||
| 14 | } | ||
| 15 | |||
| 16 | fn isnan(x: f64) callconv(.c) c_int { | ||
| 17 | return if (std.math.isNan(x)) 1 else 0; | ||
| 18 | } | ||
| 19 | |||
| 20 | fn isnanf(x: f32) callconv(.c) c_int { | ||
| 21 | return if (std.math.isNan(x)) 1 else 0; | ||
| 22 | } | ||
| 23 | |||
| 24 | fn isnanl(x: c_longdouble) callconv(.c) c_int { | ||
| 25 | return if (std.math.isNan(x)) 1 else 0; | ||
| 26 | } | ||
lib/libc/mingw/math/isnan.c deleted-31| ... | @@ -1,31 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | #include <math.h> | ||
| 7 | |||
| 8 | int | ||
| 9 | __isnan (double _x) | ||
| 10 | { | ||
| 11 | #if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | __mingw_dbl_type_t hlp; | ||
| 13 | int l, h; | ||
| 14 | |||
| 15 | hlp.x = _x; | ||
| 16 | l = hlp.lh.low; | ||
| 17 | h = hlp.lh.high & 0x7fffffff; | ||
| 18 | h |= (unsigned int) (l | -l) >> 31; | ||
| 19 | h = 0x7ff00000 - h; | ||
| 20 | return (int) ((unsigned int) h) >> 31; | ||
| 21 | #elif defined(__i386__) || defined(_X86_) | ||
| 22 | unsigned short _sw; | ||
| 23 | __asm__ __volatile__ ("fxam;" | ||
| 24 | 	 "fstsw %%ax": "=a" (_sw) : "t" (_x)); | ||
| 25 | return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) | ||
| 26 | == FP_NAN; | ||
| 27 | #endif | ||
| 28 | } | ||
| 29 | |||
| 30 | #undef isnan | ||
| 31 | int __attribute__ ((alias ("__isnan"))) isnan (double); | ||
lib/libc/mingw/math/isnanf.c deleted-27| ... | @@ -1,27 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | #include <math.h> | ||
| 7 | int | ||
| 8 | __isnanf (float _x) | ||
| 9 | { | ||
| 10 | #if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 11 | __mingw_flt_type_t hlp; | ||
| 12 | int i; | ||
| 13 | |||
| 14 | hlp.x = _x; | ||
| 15 | i = hlp.val & 0x7fffffff; | ||
| 16 | i = 0x7f800000 - i; | ||
| 17 | return (int) (((unsigned int) i) >> 31); | ||
| 18 | #elif defined(__i386__) || defined(_X86_) | ||
| 19 | unsigned short _sw; | ||
| 20 | __asm__ __volatile__ ("fxam;" | ||
| 21 | 	 "fstsw %%ax": "=a" (_sw) : "t" (_x) ); | ||
| 22 | return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) | ||
| 23 | == FP_NAN; | ||
| 24 | #endif | ||
| 25 | } | ||
| 26 | |||
| 27 | int __attribute__ ((alias ("__isnanf"))) isnanf (float); | ||
lib/libc/mingw/math/isnanl.c deleted-32| ... | @@ -1,32 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | #include <math.h> | ||
| 7 | |||
| 8 | int | ||
| 9 | __isnanl (long double _x) | ||
| 10 | { | ||
| 11 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ | ||
| 12 | return __isnan(_x); | ||
| 13 | #elif defined(__x86_64__) || defined(_AMD64_) | ||
| 14 | __mingw_ldbl_type_t ld; | ||
| 15 | int xx, signexp; | ||
| 16 | |||
| 17 | ld.x = _x; | ||
| 18 | signexp = (ld.lh.sign_exponent & 0x7fff) << 1; | ||
| 19 | xx = (int) (ld.lh.low | (ld.lh.high & 0x7fffffffu)); /* explicit */ | ||
| 20 | signexp |= (unsigned int) (xx | (-xx)) >> 31; | ||
| 21 | signexp = 0xfffe - signexp; | ||
| 22 | return (int) ((unsigned int) signexp) >> 16; | ||
| 23 | #elif defined(__i386__) || defined(_X86_) | ||
| 24 | unsigned short _sw; | ||
| 25 | __asm__ __volatile__ ("fxam;" | ||
| 26 | 	 "fstsw %%ax": "=a" (_sw) : "t" (_x)); | ||
| 27 | return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) | ||
| 28 | == FP_NAN; | ||
| 29 | #endif | ||
| 30 | } | ||
| 31 | |||
| 32 | int __attribute__ ((alias ("__isnanl"))) isnanl (long double); | ||
src/libs/mingw.zig-3| ... | @@ -577,9 +577,6 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -577,9 +577,6 @@ const mingw32_generic_src = [_][]const u8{ |
| 577 | "math" ++ path.sep_str ++ "frexpl.c", | 577 | "math" ++ path.sep_str ++ "frexpl.c", |
| 578 | "math" ++ path.sep_str ++ "hypotf.c", | 578 | "math" ++ path.sep_str ++ "hypotf.c", |
| 579 | "math" ++ path.sep_str ++ "hypotl.c", | 579 | "math" ++ path.sep_str ++ "hypotl.c", |
| 580 | "math" ++ path.sep_str ++ "isnan.c", | ||
| 581 | "math" ++ path.sep_str ++ "isnanf.c", | ||
| 582 | "math" ++ path.sep_str ++ "isnanl.c", | ||
| 583 | "math" ++ path.sep_str ++ "ldexpf.c", | 580 | "math" ++ path.sep_str ++ "ldexpf.c", |
| 584 | "math" ++ path.sep_str ++ "lgamma.c", | 581 | "math" ++ path.sep_str ++ "lgamma.c", |
| 585 | "math" ++ path.sep_str ++ "lgammaf.c", | 582 | "math" ++ path.sep_str ++ "lgammaf.c", |