C3_MATH feature (#1709)

* C3_MATH feature

This feature allows the usage of noclib math files even when libc is in use.
If a nolibc symbol exists, it will be used in place of libc, otherwise
it will default to libc.

* Added MIT License notices to atan.c3
This commit is contained in:
Taylor W
2024-12-23 16:42:57 -06:00
committed by GitHub
parent f34eb7d9f3
commit 5020caa9c3
22 changed files with 77 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/k_cos.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/k_cosf.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
union DoubleInternal
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/k_sin.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/k_sinf.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/k_tan.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/k_tanf.c */
/*

View File

@@ -1,4 +1,16 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/s_atan.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
const double[*] ATANHI @private = {
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
@@ -89,6 +101,21 @@ fn double _atan(double x) @weak @extern("atan") @nostrip
return sign ? -z : z;
}
/* origin: FreeBSD /usr/src/lib/msun/src/s_atanf.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
const float[*] ATANHIF @private = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
@@ -175,6 +202,19 @@ fn float _atanf(float x) @weak @extern("atanf") @nostrip
return sign ? -z : z;
}
/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
const PI_LO @private = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
macro void extract_words(double d, uint* hi, uint* lo) @private
@@ -252,6 +292,21 @@ fn double _atan2(double y, double x) @weak @extern("atan2") @nostrip
}
}
/* origin: FreeBSD /usr/src/lib/msun/src/e_atan2f.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
const float PI_F @private = 3.1415927410e+00; /* 0x40490fdb */
const float PI_LO_F @private = -8.7422776573e-08; /* 0xb3bbbd2e */

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _ceil(double x) @weak @extern("ceil") @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn float _cosf(float x) @extern("cosf") @weak @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
macro uint _top12f(float x) @private => bitcast(x, uint) >> 20;

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _floor(double x) @weak @extern("floor") @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc;
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
const double TOINT = 1 / math::DOUBLE_EPSILON;
const double TOINT15 = 1.5 / math::DOUBLE_EPSILON;

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn float powf_broken(float x, float f) @extern("powf") @weak @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
import std::math;
/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2f.c */

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _round(double x) @extern("round") @weak @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _scalbn(double x, int n) @weak @extern("scalbn") @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */
/*

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double sincos_broken(double x) @extern("sincos") @weak @nostrip
{

View File

@@ -1,4 +1,4 @@
module std::math::nolibc @if(env::NO_LIBC);
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _trunc(double x) @weak @extern("trunc") @nostrip
{