Skip to content

Commit 085faec

Browse files
committed
---
yaml --- r: 6867 b: refs/heads/master c: 56ec9cb h: refs/heads/master i: 6865: c47a1ee 6863: 3d007a5 v: v3
1 parent bada65d commit 085faec

File tree

13 files changed

+884
-26
lines changed

13 files changed

+884
-26
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b957916e06ea70b70aef1e404b089292aad42d7b
2+
refs/heads/master: 56ec9cb2789a7ece225cf224a2713618e2078172

trunk/src/comp/back/rpath.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import std::fs;
33
import std::os_fs;
44
import vec;
55
import std::map;
6+
import std::math;
67
import str;
78
import uint;
89
import metadata::cstore;
@@ -128,7 +129,7 @@ fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path {
128129
assert len1 > 0u;
129130
assert len2 > 0u;
130131

131-
let max_common_path = float::min(len1, len2) - 1u;
132+
let max_common_path = math::min(len1, len2) - 1u;
132133
let start_idx = 0u;
133134
while start_idx < max_common_path
134135
&& split1[start_idx] == split2[start_idx] {

trunk/src/comp/middle/ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import uint;
44
import std::ufind;
55
import std::map;
66
import std::map::hashmap;
7+
import std::math;
78
import option;
89
import option::none;
910
import option::some;
@@ -1753,7 +1754,7 @@ mod unify {
17531754
// Unifies two sets.
17541755
fn union(cx: @ctxt, set_a: uint, set_b: uint,
17551756
variance: variance) -> union_result {
1756-
ufind::grow(cx.vb.sets, float::max(set_a, set_b) + 1u);
1757+
ufind::grow(cx.vb.sets, math::max(set_a, set_b) + 1u);
17571758
let root_a = ufind::find(cx.vb.sets, set_a);
17581759
let root_b = ufind::find(cx.vb.sets, set_b);
17591760

trunk/src/comp/util/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import core::{str, option};
2-
import core::float::{max, min};
2+
import std::math::{max, min};
33
import std::map::hashmap;
44
import option::{some};
55
import syntax::ast;

trunk/src/fuzzer/fuzzer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import core::{vec, str, int, uint, option, result};
2-
import std::{fs, io};
2+
import std::{fs, io, math};
33

44
import rustc::syntax::{ast, ast_util, fold, visit, codemap};
55
import rustc::syntax::parse::parser;
@@ -241,9 +241,9 @@ fn check_variants_T<copy T>(
241241
let L = vec::len(things);
242242

243243
if L < 100u {
244-
under(float::min(L, 20u)) {|i|
244+
under(math::min(L, 20u)) {|i|
245245
log_err "Replacing... #" + uint::str(i);
246-
under(float::min(L, 30u)) {|j|
246+
under(math::min(L, 30u)) {|j|
247247
log_err "With... " + stringifier(@things[j]);
248248
let crate2 = @replacer(crate, i, things[j], cx.mode);
249249
// It would be best to test the *crate* for stability, but testing the

trunk/src/libstd/cmath.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import ctypes::c_int;
2+
3+
#[link_name = "m"]
4+
#[abi = "cdecl"]
5+
native mod f64 {
6+
7+
// Alpabetically sorted by link_name
8+
9+
pure fn acos(n: f64) -> f64;
10+
pure fn asin(n: f64) -> f64;
11+
pure fn atan(n: f64) -> f64;
12+
pure fn atan2(a: f64, b: f64) -> f64;
13+
pure fn ceil(n: f64) -> f64;
14+
pure fn cos(n: f64) -> f64;
15+
pure fn cosh(n: f64) -> f64;
16+
pure fn exp(n: f64) -> f64;
17+
#[link_name="fabs"] pure fn abs(n: f64) -> f64;
18+
pure fn floor(n: f64) -> f64;
19+
pure fn fmod(x: f64, y: f64) -> f64;
20+
pure fn frexp(n: f64, &value: c_int) -> f64;
21+
pure fn ldexp(x: f64, n: c_int) -> f64;
22+
#[link_name="log"] pure fn ln(n: f64) -> f64;
23+
#[link_name="log1p"] pure fn ln1p(n: f64) -> f64;
24+
pure fn log10(n: f64) -> f64;
25+
pure fn log2(n: f64) -> f64;
26+
pure fn modf(n: f64, iptr: *f64) -> f64;
27+
pure fn pow(n: f64, e: f64) -> f64;
28+
pure fn rint(n: f64) -> f64;
29+
pure fn round(n: f64) -> f64;
30+
pure fn sin(n: f64) -> f64;
31+
pure fn sinh(n: f64) -> f64;
32+
pure fn sqrt(n: f64) -> f64;
33+
pure fn tan(n: f64) -> f64;
34+
pure fn tanh(n: f64) -> f64;
35+
pure fn trunc(n: f64) -> f64;
36+
}
37+
38+
#[link_name = "m"]
39+
#[abi = "cdecl"]
40+
native mod f32 {
41+
42+
// Alpabetically sorted by link_name
43+
44+
#[link_name="acosf"] pure fn acos(n: f32) -> f32;
45+
#[link_name="asinf"] pure fn asin(n: f32) -> f32;
46+
#[link_name="atanf"] pure fn atan(n: f32) -> f32;
47+
#[link_name="atan2f"] pure fn atan2(a: f32, b: f32) -> f32;
48+
#[link_name="ceilf"] pure fn ceil(n: f32) -> f32;
49+
#[link_name="cosf"] pure fn cos(n: f32) -> f32;
50+
#[link_name="coshf"] pure fn cosh(n: f32) -> f32;
51+
#[link_name="expf"] pure fn exp(n: f32) -> f32;
52+
#[link_name="fabsf"] pure fn abs(n: f32) -> f32;
53+
#[link_name="floorf"] pure fn floor(n: f32) -> f32;
54+
#[link_name="frexpf"] pure fn frexp(n: f64, &value: c_int) -> f32;
55+
#[link_name="fmodf"] pure fn fmod(x: f32, y: f32) -> f32;
56+
#[link_name="ldexpf"] pure fn ldexp(x: f32, n: c_int) -> f32;
57+
#[link_name="logf"] pure fn ln(n: f32) -> f32;
58+
#[link_name="log1p"] pure fn ln1p(n: f64) -> f64;
59+
#[link_name="log2f"] pure fn log2(n: f32) -> f32;
60+
#[link_name="log10f"] pure fn log10(n: f32) -> f32;
61+
#[link_name="modff"] pure fn modf(n: f32, iptr: *f32) -> f32;
62+
#[link_name="powf"] pure fn pow(n: f32, e: f32) -> f32;
63+
#[link_name="rintf"] pure fn rint(n: f32) -> f32;
64+
#[link_name="roundf"] pure fn round(n: f32) -> f32;
65+
#[link_name="sinf"] pure fn sin(n: f32) -> f32;
66+
#[link_name="sinhf"] pure fn sinh(n: f32) -> f32;
67+
#[link_name="sqrtf"] pure fn sqrt(n: f32) -> f32;
68+
#[link_name="tanf"] pure fn tan(n: f32) -> f32;
69+
#[link_name="tanhf"] pure fn tanh(n: f32) -> f32;
70+
#[link_name="truncf"] pure fn trunc(n: f32) -> f32;
71+
}

trunk/src/libstd/ctypes.rs

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
Module: ctypes
3+
4+
Definitions useful for C interop
5+
*/
6+
7+
/*
8+
FIXME: Add a test that uses some native code to verify these sizes,
9+
which are not obviously correct for all potential platforms.
10+
*/
11+
12+
/*
13+
Type: c_int
14+
15+
A signed integer with the same size as a C `int`
16+
*/
17+
type c_int = i32;
18+
19+
/*
20+
Type: c_uint
21+
22+
An unsigned integer with the same size as a C `unsigned int`
23+
*/
24+
type c_uint = u32;
25+
26+
/*
27+
Type: long
28+
29+
A signed integer with the same size as a C `long`
30+
*/
31+
type long = int;
32+
33+
/*
34+
Type: unsigned
35+
36+
An unsigned integer with the same size as a C `unsigned int`
37+
*/
38+
type unsigned = u32;
39+
40+
/*
41+
Type: ulong
42+
43+
An unsigned integer with the same size as a C `unsigned long`
44+
*/
45+
type ulong = uint;
46+
47+
/*
48+
Type: intptr_t
49+
50+
A signed integer with the same size as a pointer. This is
51+
guaranteed to always be the same type as a Rust `int`
52+
*/
53+
type intptr_t = uint; // FIXME: int
54+
55+
/*
56+
Type: uintptr_t
57+
58+
An unsigned integer with the same size as a pointer. This is
59+
guaranteed to always be the same type as a Rust `uint`.
60+
*/
61+
type uintptr_t = uint;
62+
type uint32_t = u32;
63+
64+
/*
65+
Type: void
66+
67+
A type, a pointer to which can be used as C `void *`
68+
69+
Note that this does not directly correspond to the C `void` type,
70+
which is an incomplete type. Using pointers to this type
71+
when interoperating with C void pointers can help in documentation.
72+
*/
73+
type void = int;
74+
75+
// machine type equivalents of rust int, uint, float
76+
77+
/*
78+
Type: m_int
79+
80+
FIXME: What C type does this represent?
81+
*/
82+
#[cfg(target_arch="x86")]
83+
type m_int = i32;
84+
#[cfg(target_arch="x86_64")]
85+
type m_int = i64;
86+
87+
/*
88+
Type: m_uint
89+
90+
FIXME: What C type does this represent?
91+
*/
92+
#[cfg(target_arch="x86")]
93+
type m_uint = u32;
94+
#[cfg(target_arch="x86_64")]
95+
type m_uint = u64;
96+
97+
// This *must* match with "import m_float = fXX" in std::math per arch
98+
/*
99+
Type: m_float
100+
101+
FIXME: What C type does this represent?
102+
*/
103+
type m_float = f64;
104+
105+
/*
106+
Type: size_t
107+
108+
An unsigned integer corresponding to the C `size_t`
109+
*/
110+
type size_t = uint;
111+
112+
/*
113+
Type: ssize_t
114+
115+
A signed integer correpsonding to the C `ssize_t`
116+
*/
117+
type ssize_t = int;
118+
119+
/*
120+
Type: off_t
121+
122+
An unsigned integer corresponding to the C `off_t`
123+
*/
124+
type off_t = uint;
125+
126+
/*
127+
Type: fd_t
128+
129+
A type that can be used for C file descriptors
130+
*/
131+
type fd_t = i32; // not actually a C type, but should be.
132+
133+
/*
134+
Type: pid_t
135+
136+
A type for representing process ID's, corresponding to C `pid_t`
137+
*/
138+
type pid_t = i32;
139+
140+
// enum is implementation-defined, but is 32-bits in practice
141+
/*
142+
Type: enum
143+
144+
An unsigned integer with the same size as a C enum
145+
*/
146+
type enum = u32;

0 commit comments

Comments
 (0)