diff --git a/src/comp/back/rpath.rs b/src/comp/back/rpath.rs index 7aa271090dd..1e32794da5f 100644 --- a/src/comp/back/rpath.rs +++ b/src/comp/back/rpath.rs @@ -3,7 +3,6 @@ import std::fs; import std::os_fs; import vec; import std::map; -import std::math; import str; import uint; import metadata::cstore; @@ -129,7 +128,7 @@ fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path { assert len1 > 0u; assert len2 > 0u; - let max_common_path = math::min(len1, len2) - 1u; + let max_common_path = float::min(len1, len2) - 1u; let start_idx = 0u; while start_idx < max_common_path && split1[start_idx] == split2[start_idx] { diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 9b031c8fb3a..ca63fdb6dd8 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -4,7 +4,6 @@ import uint; import std::ufind; import std::map; import std::map::hashmap; -import std::math; import option; import option::none; import option::some; @@ -1755,7 +1754,7 @@ mod unify { // Unifies two sets. fn union(cx: @ctxt, set_a: uint, set_b: uint, variance: variance) -> union_result { - ufind::grow(cx.vb.sets, math::max(set_a, set_b) + 1u); + ufind::grow(cx.vb.sets, float::max(set_a, set_b) + 1u); let root_a = ufind::find(cx.vb.sets, set_a); let root_b = ufind::find(cx.vb.sets, set_b); diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index c9bf34d69c7..6c436dbe8fb 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -1,5 +1,5 @@ import core::{str, option}; -import std::math::{max, min}; +import core::float::{max, min}; import std::map::hashmap; import option::{some}; import syntax::ast; diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 76e5b8d18f9..43208bbcb0c 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -1,5 +1,5 @@ import core::{vec, str, int, uint, option, result}; -import std::{fs, io, math}; +import std::{fs, io}; import rustc::syntax::{ast, ast_util, fold, visit, codemap}; import rustc::syntax::parse::parser; @@ -241,9 +241,9 @@ fn check_variants_T( let L = vec::len(things); if L < 100u { - under(math::min(L, 20u)) {|i| + under(float::min(L, 20u)) {|i| log_err "Replacing... #" + uint::str(i); - under(math::min(L, 30u)) {|j| + under(float::min(L, 30u)) {|j| log_err "With... " + stringifier(@things[j]); let crate2 = @replacer(crate, i, things[j], cx.mode); // It would be best to test the *crate* for stability, but testing the diff --git a/src/libstd/cmath.rs b/src/libstd/cmath.rs deleted file mode 100644 index 1e4ee49763e..00000000000 --- a/src/libstd/cmath.rs +++ /dev/null @@ -1,71 +0,0 @@ -import ctypes::c_int; - -#[link_name = "m"] -#[abi = "cdecl"] -native mod f64 { - - // Alpabetically sorted by link_name - - pure fn acos(n: f64) -> f64; - pure fn asin(n: f64) -> f64; - pure fn atan(n: f64) -> f64; - pure fn atan2(a: f64, b: f64) -> f64; - pure fn ceil(n: f64) -> f64; - pure fn cos(n: f64) -> f64; - pure fn cosh(n: f64) -> f64; - pure fn exp(n: f64) -> f64; - #[link_name="fabs"] pure fn abs(n: f64) -> f64; - pure fn floor(n: f64) -> f64; - pure fn fmod(x: f64, y: f64) -> f64; - pure fn frexp(n: f64, &value: c_int) -> f64; - pure fn ldexp(x: f64, n: c_int) -> f64; - #[link_name="log"] pure fn ln(n: f64) -> f64; - #[link_name="log1p"] pure fn ln1p(n: f64) -> f64; - pure fn log10(n: f64) -> f64; - pure fn log2(n: f64) -> f64; - pure fn modf(n: f64, iptr: *f64) -> f64; - pure fn pow(n: f64, e: f64) -> f64; - pure fn rint(n: f64) -> f64; - pure fn round(n: f64) -> f64; - pure fn sin(n: f64) -> f64; - pure fn sinh(n: f64) -> f64; - pure fn sqrt(n: f64) -> f64; - pure fn tan(n: f64) -> f64; - pure fn tanh(n: f64) -> f64; - pure fn trunc(n: f64) -> f64; -} - -#[link_name = "m"] -#[abi = "cdecl"] -native mod f32 { - - // Alpabetically sorted by link_name - - #[link_name="acosf"] pure fn acos(n: f32) -> f32; - #[link_name="asinf"] pure fn asin(n: f32) -> f32; - #[link_name="atanf"] pure fn atan(n: f32) -> f32; - #[link_name="atan2f"] pure fn atan2(a: f32, b: f32) -> f32; - #[link_name="ceilf"] pure fn ceil(n: f32) -> f32; - #[link_name="cosf"] pure fn cos(n: f32) -> f32; - #[link_name="coshf"] pure fn cosh(n: f32) -> f32; - #[link_name="expf"] pure fn exp(n: f32) -> f32; - #[link_name="fabsf"] pure fn abs(n: f32) -> f32; - #[link_name="floorf"] pure fn floor(n: f32) -> f32; - #[link_name="frexpf"] pure fn frexp(n: f64, &value: c_int) -> f32; - #[link_name="fmodf"] pure fn fmod(x: f32, y: f32) -> f32; - #[link_name="ldexpf"] pure fn ldexp(x: f32, n: c_int) -> f32; - #[link_name="logf"] pure fn ln(n: f32) -> f32; - #[link_name="log1p"] pure fn ln1p(n: f64) -> f64; - #[link_name="log2f"] pure fn log2(n: f32) -> f32; - #[link_name="log10f"] pure fn log10(n: f32) -> f32; - #[link_name="modff"] pure fn modf(n: f32, iptr: *f32) -> f32; - #[link_name="powf"] pure fn pow(n: f32, e: f32) -> f32; - #[link_name="rintf"] pure fn rint(n: f32) -> f32; - #[link_name="roundf"] pure fn round(n: f32) -> f32; - #[link_name="sinf"] pure fn sin(n: f32) -> f32; - #[link_name="sinhf"] pure fn sinh(n: f32) -> f32; - #[link_name="sqrtf"] pure fn sqrt(n: f32) -> f32; - #[link_name="tanf"] pure fn tan(n: f32) -> f32; - #[link_name="tanhf"] pure fn tanh(n: f32) -> f32; - #[link_name="truncf"] pure fn trunc(n: f32) -> f32; -} diff --git a/src/libstd/ctypes.rs b/src/libstd/ctypes.rs deleted file mode 100644 index 509eb3ef057..00000000000 --- a/src/libstd/ctypes.rs +++ /dev/null @@ -1,146 +0,0 @@ -/* -Module: ctypes - -Definitions useful for C interop -*/ - -/* -FIXME: Add a test that uses some native code to verify these sizes, -which are not obviously correct for all potential platforms. -*/ - -/* -Type: c_int - -A signed integer with the same size as a C `int` -*/ -type c_int = i32; - -/* -Type: c_uint - -An unsigned integer with the same size as a C `unsigned int` -*/ -type c_uint = u32; - -/* -Type: long - -A signed integer with the same size as a C `long` -*/ -type long = int; - -/* -Type: unsigned - -An unsigned integer with the same size as a C `unsigned int` -*/ -type unsigned = u32; - -/* -Type: ulong - -An unsigned integer with the same size as a C `unsigned long` -*/ -type ulong = uint; - -/* -Type: intptr_t - -A signed integer with the same size as a pointer. This is -guaranteed to always be the same type as a Rust `int` -*/ -type intptr_t = uint; // FIXME: int - -/* -Type: uintptr_t - -An unsigned integer with the same size as a pointer. This is -guaranteed to always be the same type as a Rust `uint`. -*/ -type uintptr_t = uint; -type uint32_t = u32; - -/* -Type: void - -A type, a pointer to which can be used as C `void *` - -Note that this does not directly correspond to the C `void` type, -which is an incomplete type. Using pointers to this type -when interoperating with C void pointers can help in documentation. -*/ -type void = int; - -// machine type equivalents of rust int, uint, float - -/* -Type: m_int - -FIXME: What C type does this represent? -*/ -#[cfg(target_arch="x86")] -type m_int = i32; -#[cfg(target_arch="x86_64")] -type m_int = i64; - -/* -Type: m_uint - -FIXME: What C type does this represent? -*/ -#[cfg(target_arch="x86")] -type m_uint = u32; -#[cfg(target_arch="x86_64")] -type m_uint = u64; - -// This *must* match with "import m_float = fXX" in std::math per arch -/* -Type: m_float - -FIXME: What C type does this represent? -*/ -type m_float = f64; - -/* -Type: size_t - -An unsigned integer corresponding to the C `size_t` -*/ -type size_t = uint; - -/* -Type: ssize_t - -A signed integer correpsonding to the C `ssize_t` -*/ -type ssize_t = int; - -/* -Type: off_t - -An unsigned integer corresponding to the C `off_t` -*/ -type off_t = uint; - -/* -Type: fd_t - -A type that can be used for C file descriptors -*/ -type fd_t = i32; // not actually a C type, but should be. - -/* -Type: pid_t - -A type for representing process ID's, corresponding to C `pid_t` -*/ -type pid_t = i32; - -// enum is implementation-defined, but is 32-bits in practice -/* -Type: enum - -An unsigned integer with the same size as a C enum -*/ -type enum = u32; diff --git a/src/libstd/math.rs b/src/libstd/math.rs deleted file mode 100644 index 4dba290b6a4..00000000000 --- a/src/libstd/math.rs +++ /dev/null @@ -1,390 +0,0 @@ -/* - -Module: math - -Floating point operations and constants for `float`s -*/ - -export consts; -export min, max; - -// Currently this module supports from -lmath: -// C95 + log2 + log1p + trunc + round + rint - -export - acos, asin, atan, atan2, ceil, cos, cosh, exp, abs, floor, fmod, frexp, - ldexp, ln, ln1p, log10, log2, modf, rint, round, pow, sin, sinh, sqrt, - tan, tanh, trunc; - -export f64, f32; - -import f64 = math_f64; -import f32 = math_f32; - -// These two must match in width according to architecture - -import core::mtypes::m_float; -import core::ctypes::c_int; -import core::ptr; -import m_float = math_f64; - -/* -Module: consts -*/ -mod consts { - /* - Const: pi - - Archimedes' constant - */ - const pi: float = 3.14159265358979323846264338327950288; - - /* - Const: frac_pi_2 - - pi/2.0 - */ - const frac_pi_2: float = 1.57079632679489661923132169163975144; - - /* - Const: frac_pi_4 - - pi/4.0 - */ - const frac_pi_4: float = 0.785398163397448309615660845819875721; - - /* - Const: frac_1_pi - - 1.0/pi - */ - const frac_1_pi: float = 0.318309886183790671537767526745028724; - - /* - Const: frac_2_pi - - 2.0/pi - */ - const frac_2_pi: float = 0.636619772367581343075535053490057448; - - /* - Const: frac_2_sqrtpi - - 2.0/sqrt(pi) - */ - const frac_2_sqrtpi: float = 1.12837916709551257389615890312154517; - - /* - Const: sqrt2 - - sqrt(2.0) - */ - const sqrt2: float = 1.41421356237309504880168872420969808; - - /* - Const: frac_1_sqrt2 - - 1.0/sqrt(2.0) - */ - const frac_1_sqrt2: float = 0.707106781186547524400844362104849039; - - /* - Const: e - - Euler's number - */ - const e: float = 2.71828182845904523536028747135266250; - - /* - Const: log2_e - - log2(e) - */ - const log2_e: float = 1.44269504088896340735992468100189214; - - /* - Const: log10_e - - log10(e) - */ - const log10_e: float = 0.434294481903251827651128918916605082; - - /* - Const: ln_2 - - ln(2.0) - */ - const ln_2: float = 0.693147180559945309417232121458176568; - - /* - Const: ln_10 - - ln(10.0) - */ - const ln_10: float = 2.30258509299404568401799145468436421; -} - - -// FIXME min/max type specialize via libm when overloading works -// (in theory fmax/fmin, fmaxf, fminf /should/ be faster) - -/* -Function: min - -Returns the minimum of two values -*/ -pure fn min(x: T, y: T) -> T { x < y ? x : y } - -/* -Function: max - -Returns the maximum of two values -*/ -pure fn max(x: T, y: T) -> T { x < y ? y : x } - -/* -Function: acos - -Returns the arccosine of an angle (measured in rad) -*/ -pure fn acos(x: float) -> float - { be m_float::acos(x as m_float) as float } - -/* -Function: asin - -Returns the arcsine of an angle (measured in rad) -*/ -pure fn asin(x: float) -> float - { be m_float::asin(x as m_float) as float } - -/* -Function: atan - -Returns the arctangents of an angle (measured in rad) -*/ -pure fn atan(x: float) -> float - { be m_float::atan(x as m_float) as float } - - -/* -Function: atan2 - -Returns the arctangent of an angle (measured in rad) -*/ -pure fn atan2(y: float, x: float) -> float - { be m_float::atan2(y as m_float, x as m_float) as float } - -/* -Function: ceil - -Returns the smallest integral value less than or equal to `n` -*/ -pure fn ceil(n: float) -> float - { be m_float::ceil(n as m_float) as float } - -/* -Function: cos - -Returns the cosine of an angle `x` (measured in rad) -*/ -pure fn cos(x: float) -> float - { be m_float::cos(x as m_float) as float } - -/* -Function: cosh - -Returns the hyperbolic cosine of `x` - -*/ -pure fn cosh(x: float) -> float - { be m_float::cosh(x as m_float) as float } - - -/* -Function: exp - -Returns `consts::e` to the power of `n* -*/ -pure fn exp(n: float) -> float - { be m_float::exp(n as m_float) as float } - -/* -Function: abs - -Returns the absolute value of `n` -*/ -pure fn abs(n: float) -> float - { be m_float::abs(n as m_float) as float } - -/* -Function: floor - -Returns the largest integral value less than or equal to `n` -*/ -pure fn floor(n: float) -> float - { be m_float::floor(n as m_float) as float } - -/* -Function: fmod - -Returns the floating-point remainder of `x/y` -*/ -pure fn fmod(x: float, y: float) -> float - { be m_float::fmod(x as m_float, y as m_float) as float } - -/* -Function: ln - -Returns the natural logaritm of `n` -*/ -pure fn ln(n: float) -> float - { be m_float::ln(n as m_float) as float } - -/* -Function: ldexp - -Returns `x` multiplied by 2 to the power of `n` -*/ -pure fn ldexp(n: float, i: int) -> float - { be m_float::ldexp(n as m_float, i as c_int) as float } - -/* -Function: ln1p - -Returns the natural logarithm of `1+n` accurately, -even for very small values of `n` -*/ -pure fn ln1p(n: float) -> float - { be m_float::ln1p(n as m_float) as float } - -/* -Function: log10 - -Returns the logarithm to base 10 of `n` -*/ -pure fn log10(n: float) -> float - { be m_float::log10(n as m_float) as float } - -/* -Function: log2 - -Returns the logarithm to base 2 of `n` -*/ -pure fn log2(n: float) -> float - { be m_float::log2(n as m_float) as float } - -/* -Function: modf - -Breaks `n` into integral and fractional parts such that both -have the same sign as `n` - -The integral part is stored in `iptr`. - -Returns: - -The fractional part of `n` -*/ -#[no(warn_trivial_casts)] // FIXME Implement -pure fn modf(n: float, &iptr: float) -> float { unsafe { - be m_float::modf(n as m_float, ptr::addr_of(iptr) as *m_float) as float -} } - -/* -Function: frexp - -Breaks `n` into a normalized fraction and an integral power of 2 - -The inegral part is stored in iptr. - -The functions return a number x such that x has a magnitude in the interval -[1/2, 1) or 0, and `n == x*(2 to the power of exp)`. - -Returns: - -The fractional part of `n` -*/ -pure fn frexp(n: float, &exp: c_int) -> float - { be m_float::frexp(n as m_float, exp) as float } - -/* -Function: pow -*/ -pure fn pow(v: float, e: float) -> float - { be m_float::pow(v as m_float, e as m_float) as float } - - -/* -Function: rint - -Returns the integral value nearest to `x` (according to the -prevailing rounding mode) in floating-point format -*/ -pure fn rint(x: float) -> float - { be m_float::rint(x as m_float) as float } - -/* -Function: round - - -Return the integral value nearest to `x` rounding half-way -cases away from zero, regardless of the current rounding direction. -*/ -pure fn round(x: float) -> float - { be m_float::round(x as m_float) as float } - -/* -Function: sin - -Returns the sine of an angle `x` (measured in rad) -*/ -pure fn sin(x: float) -> float - { be m_float::sin(x as m_float) as float } - -/* -Function: sinh - -Returns the hyperbolic sine of an angle `x` (measured in rad) -*/ -pure fn sinh(x: float) -> float - { be m_float::sinh(x as m_float) as float } - -/* -Function: sqrt - -Returns the square root of `x` -*/ -pure fn sqrt(x: float) -> float - { be m_float::sqrt(x as m_float) as float } - -/* -Function: tan - -Returns the tangent of an angle `x` (measured in rad) - -*/ -pure fn tan(x: float) -> float - { be m_float::tan(x as m_float) as float } - -/* -Function: tanh - -Returns the hyperbolic tangent of an angle `x` (measured in rad) - -*/ -pure fn tanh(x: float) -> float - { be m_float::tanh(x as m_float) as float } - -/* -Function: trunc - -Returns the integral value nearest to but no larger in magnitude than `x` - -*/ -pure fn trunc(x: float) -> float - { be m_float::trunc(x as m_float) as float } - - - - diff --git a/src/libstd/math_f32.rs b/src/libstd/math_f32.rs deleted file mode 100644 index 6c36db51a67..00000000000 --- a/src/libstd/math_f32.rs +++ /dev/null @@ -1,113 +0,0 @@ - -/* -Module: math_f32 - -Floating point operations and constants for `f32` - -This exposes the same operations as `math`, just for `f32` even though -they do not show up in the docs right now! -*/ - -import cmath::f32::*; - -export - acos, asin, atan, atan2, ceil, cos, cosh, exp, abs, floor, fmod, - frexp, ldexp, ln, ln1p, log10, log2, modf, rint, round, pow, sin, - sinh, sqrt, tan, tanh, trunc; - -export consts; - -/* Module: consts */ -mod consts { - - /* - Const: pi - - Archimedes' constant - */ - const pi: f32 = 3.14159265358979323846264338327950288f32; - - /* - Const: frac_pi_2 - - pi/2.0 - */ - const frac_pi_2: f32 = 1.57079632679489661923132169163975144f32; - - /* - Const: frac_pi_4 - - pi/4.0 - */ - const frac_pi_4: f32 = 0.785398163397448309615660845819875721f32; - - /* - Const: frac_1_pi - - 1.0/pi - */ - const frac_1_pi: f32 = 0.318309886183790671537767526745028724f32; - - /* - Const: frac_2_pi - - 2.0/pi - */ - const frac_2_pi: f32 = 0.636619772367581343075535053490057448f32; - - /* - Const: frac_2_sqrtpi - - 2.0/sqrt(pi) - */ - const frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517f32; - - /* - Const: sqrt2 - - sqrt(2.0) - */ - const sqrt2: f32 = 1.41421356237309504880168872420969808f32; - - /* - Const: frac_1_sqrt2 - - 1.0/sqrt(2.0) - */ - const frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039f32; - - /* - Const: e - - Euler's number - */ - const e: f32 = 2.71828182845904523536028747135266250f32; - - /* - Const: log2_e - - log2(e) - */ - const log2_e: f32 = 1.44269504088896340735992468100189214f32; - - /* - Const: log10_e - - log10(e) - */ - const log10_e: f32 = 0.434294481903251827651128918916605082f32; - - /* - Const: ln_2 - - ln(2.0) - */ - const ln_2: f32 = 0.693147180559945309417232121458176568f32; - - /* - Const: ln_10 - - ln(10.0) - */ - const ln_10: f32 = 2.30258509299404568401799145468436421f32; -} \ No newline at end of file diff --git a/src/libstd/math_f64.rs b/src/libstd/math_f64.rs deleted file mode 100644 index 659bf2c5b14..00000000000 --- a/src/libstd/math_f64.rs +++ /dev/null @@ -1,114 +0,0 @@ - -/* -Module: math_f64 - -Floating point operations and constants for `f64`s - -This exposes the same operations as `math`, just for `f64` even though -they do not show up in the docs right now! -*/ - -import cmath::f64::*; - -export - acos, asin, atan, atan2, ceil, cos, cosh, exp, abs, floor, fmod, - frexp, ldexp, ln, ln1p, log10, log2, modf, rint, round, pow, sin, - sinh, sqrt, tan, tanh, trunc; - -export consts; - - -/* Module: consts */ -mod consts { - - /* - Const: pi - - Archimedes' constant - */ - const pi: f64 = 3.14159265358979323846264338327950288f64; - - /* - Const: frac_pi_2 - - pi/2.0 - */ - const frac_pi_2: f64 = 1.57079632679489661923132169163975144f64; - - /* - Const: frac_pi_4 - - pi/4.0 - */ - const frac_pi_4: f64 = 0.785398163397448309615660845819875721f64; - - /* - Const: frac_1_pi - - 1.0/pi - */ - const frac_1_pi: f64 = 0.318309886183790671537767526745028724f64; - - /* - Const: frac_2_pi - - 2.0/pi - */ - const frac_2_pi: f64 = 0.636619772367581343075535053490057448f64; - - /* - Const: frac_2_sqrtpi - - 2.0/sqrt(pi) - */ - const frac_2_sqrtpi: f64 = 1.12837916709551257389615890312154517f64; - - /* - Const: sqrt2 - - sqrt(2.0) - */ - const sqrt2: f64 = 1.41421356237309504880168872420969808f64; - - /* - Const: frac_1_sqrt2 - - 1.0/sqrt(2.0) - */ - const frac_1_sqrt2: f64 = 0.707106781186547524400844362104849039f64; - - /* - Const: e - - Euler's number - */ - const e: f64 = 2.71828182845904523536028747135266250f64; - - /* - Const: log2_e - - log2(e) - */ - const log2_e: f64 = 1.44269504088896340735992468100189214f64; - - /* - Const: log10_e - - log10(e) - */ - const log10_e: f64 = 0.434294481903251827651128918916605082f64; - - /* - Const: ln_2 - - ln(2.0) - */ - const ln_2: f64 = 0.693147180559945309417232121458176568f64; - - /* - Const: ln_10 - - ln(10.0) - */ - const ln_10: f64 = 2.30258509299404568401799145468436421f64; -} \ No newline at end of file diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 5fc310deca5..bcd2b82cf1a 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -8,10 +8,9 @@ #[crate_type = "lib"]; export comm, fs, io, net, run, uv; -export c_vec, ctypes, four, tri, util; +export c_vec, four, tri, util; export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind; export rope; -export math; export ebml, dbg, getopts, json, rand, sha1, term, time; export extfmt, test, tempfile; // FIXME: generic_os and os_fs shouldn't be exported @@ -32,10 +31,6 @@ mod uv; // Utility modules mod c_vec; -mod ctypes; -mod cmath; /* unexported */ -mod math_f32; -mod math_f64; mod four; mod tri; mod util; @@ -61,7 +56,6 @@ mod ebml; mod dbg; mod getopts; mod json; -mod math; mod rand; mod sha1; mod tempfile; diff --git a/src/test/stdtest/math.rs b/src/test/stdtest/math.rs index cdcb581e765..51531f0863d 100644 --- a/src/test/stdtest/math.rs +++ b/src/test/stdtest/math.rs @@ -251,7 +251,7 @@ fn test_angle() { alt vec { (0f, y) when y < 0f { 1.5 * consts::pi } (0f, y) { 0.5 * consts::pi } - (x, y) { std::math::atan(y / x) } + (x, y) { float::atan(y / x) } } } assert angle((1f, 0f)) == 0f;