Skip to content

Commit 8e08d81

Browse files
Lenny222brson
Lenny222
authored andcommitted
---
yaml --- r: 6980 b: refs/heads/master c: f8d7a1c h: refs/heads/master v: v3
1 parent 55d474a commit 8e08d81

File tree

15 files changed

+748
-408
lines changed

15 files changed

+748
-408
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: 16405386f0a843167e234d8d54855a537b0f261d
2+
refs/heads/master: f8d7a1c2586ad1fda7358b445114c02b048149f5

trunk/src/libcore/bessel.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

trunk/src/libcore/char.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export is_alphabetic,
4141
is_XID_start, is_XID_continue,
4242
is_lowercase, is_uppercase,
4343
is_whitespace, is_alphanumeric,
44-
to_digit, maybe_digit, cmp;
44+
to_digit, to_lowercase, to_uppercase, maybe_digit, cmp;
4545

4646
import is_alphabetic = unicode::derived_property::Alphabetic;
4747
import is_XID_start = unicode::derived_property::XID_Start;
@@ -136,6 +136,34 @@ pure fn maybe_digit(c: char) -> option::t<u8> {
136136
}
137137
}
138138

139+
/*
140+
Function: to_lowercase
141+
142+
Convert a char to the corresponding lower case.
143+
144+
FIXME: works only on ASCII
145+
*/
146+
pure fn to_lowercase(c: char) -> char {
147+
alt c {
148+
'A' to 'Z' { ((c as u8) + 32u8) as char }
149+
_ { c }
150+
}
151+
}
152+
153+
/*
154+
Function: to_uppercase
155+
156+
Convert a char to the corresponding upper case.
157+
158+
FIXME: works only on ASCII
159+
*/
160+
pure fn to_uppercase(c: char) -> char {
161+
alt c {
162+
'a' to 'z' { ((c as u8) - 32u8) as char }
163+
_ { c }
164+
}
165+
}
166+
139167
/*
140168
Function: cmp
141169

trunk/src/libcore/cmath.rs

Lines changed: 56 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,73 @@
1-
export c_double;
2-
export c_float;
3-
41
import ctypes::c_int;
5-
import ctypes::c_float;
6-
import ctypes::c_double;
72

83
#[link_name = "m"]
94
#[abi = "cdecl"]
10-
native mod c_double {
5+
native mod f64 {
116

127
// Alpabetically sorted by link_name
138

14-
pure fn acos(n: c_double) -> c_double;
15-
pure fn asin(n: c_double) -> c_double;
16-
pure fn atan(n: c_double) -> c_double;
17-
pure fn atan2(a: c_double, b: c_double) -> c_double;
18-
pure fn cbrt(n: c_double) -> c_double;
19-
pure fn ceil(n: c_double) -> c_double;
20-
pure fn copysign(x: c_double, y: c_double) -> c_double;
21-
pure fn cos(n: c_double) -> c_double;
22-
pure fn cosh(n: c_double) -> c_double;
23-
pure fn erf(n: c_double) -> c_double;
24-
pure fn erfc(n: c_double) -> c_double;
25-
pure fn exp(n: c_double) -> c_double;
26-
pure fn expm1(n: c_double) -> c_double;
27-
pure fn exp2(n: c_double) -> c_double;
28-
#[link_name="fabs"] pure fn abs(n: c_double) -> c_double;
29-
#[link_name="fdim"] pure fn sub_pos(a: c_double, b: c_double) -> c_double;
30-
pure fn floor(n: c_double) -> c_double;
31-
#[link_name="fma"] pure fn mul_add(a: c_double, b: c_double,
32-
c: c_double) -> c_double;
33-
#[link_name="fmax"] pure fn fmax(a: c_double, b: c_double) -> c_double;
34-
#[link_name="fmin"] pure fn fmin(a: c_double, b: c_double) -> c_double;
35-
pure fn nextafter(x: c_double, y: c_double) -> c_double;
36-
pure fn frexp(n: c_double, &value: c_int) -> c_double;
37-
pure fn hypot(x: c_double, y: c_double) -> c_double;
38-
pure fn ldexp(x: c_double, n: c_int) -> c_double;
39-
#[link_name="lgamma_r"] pure fn lgamma(n: c_double,
40-
&sign: c_int) -> c_double;
41-
#[link_name="log"] pure fn ln(n: c_double) -> c_double;
42-
pure fn logb(n: c_double) -> c_double;
43-
#[link_name="log1p"] pure fn ln1p(n: c_double) -> c_double;
44-
pure fn log10(n: c_double) -> c_double;
45-
pure fn log2(n: c_double) -> c_double;
46-
pure fn ilogb(n: c_double) -> c_int;
47-
pure fn modf(n: c_double, &iptr: c_double) -> c_double;
48-
pure fn pow(n: c_double, e: c_double) -> c_double;
49-
pure fn rint(n: c_double) -> c_double;
50-
pure fn round(n: c_double) -> c_double;
51-
pure fn scalbn(n: c_double, i: c_int) -> c_double;
52-
pure fn sin(n: c_double) -> c_double;
53-
pure fn sinh(n: c_double) -> c_double;
54-
pure fn sqrt(n: c_double) -> c_double;
55-
pure fn tan(n: c_double) -> c_double;
56-
pure fn tanh(n: c_double) -> c_double;
57-
pure fn tgamma(n: c_double) -> c_double;
58-
pure fn trunc(n: c_double) -> c_double;
59-
60-
// These are commonly only available for doubles
61-
62-
pure fn j0(n: c_double) -> c_double;
63-
pure fn j1(n: c_double) -> c_double;
64-
pure fn jn(i: c_int, n: c_double) -> c_double;
65-
66-
pure fn y0(n: c_double) -> c_double;
67-
pure fn y1(n: c_double) -> c_double;
68-
pure fn yn(i: c_int, n: c_double) -> c_double;
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;
6936
}
7037

7138
#[link_name = "m"]
7239
#[abi = "cdecl"]
73-
native mod c_float {
40+
native mod f32 {
7441

7542
// Alpabetically sorted by link_name
7643

77-
#[link_name="acosf"] pure fn acos(n: c_float) -> c_float;
78-
#[link_name="asinf"] pure fn asin(n: c_float) -> c_float;
79-
#[link_name="atanf"] pure fn atan(n: c_float) -> c_float;
80-
#[link_name="atan2f"] pure fn atan2(a: c_float, b: c_float) -> c_float;
81-
#[link_name="cbrtf"] pure fn cbrt(n: c_float) -> c_float;
82-
#[link_name="ceilf"] pure fn ceil(n: c_float) -> c_float;
83-
#[link_name="copysignf"] pure fn copysign(x: c_float,
84-
y: c_float) -> c_float;
85-
#[link_name="cosf"] pure fn cos(n: c_float) -> c_float;
86-
#[link_name="coshf"] pure fn cosh(n: c_float) -> c_float;
87-
#[link_name="erff"] pure fn erf(n: c_float) -> c_float;
88-
#[link_name="erfcf"] pure fn erfc(n: c_float) -> c_float;
89-
#[link_name="expf"] pure fn exp(n: c_float) -> c_float;
90-
#[link_name="expm1f"]pure fn expm1(n: c_float) -> c_float;
91-
#[link_name="exp2f"] pure fn exp2(n: c_float) -> c_float;
92-
#[link_name="fabsf"] pure fn abs(n: c_float) -> c_float;
93-
#[link_name="fdimf"] pure fn sub_pos(a: c_float, b: c_float) -> c_float;
94-
#[link_name="floorf"] pure fn floor(n: c_float) -> c_float;
95-
#[link_name="frexpf"] pure fn frexp(n: c_float,
96-
&value: c_int) -> c_float;
97-
#[link_name="fmaf"] pure fn mul_add(a: c_float,
98-
b: c_float, c: c_float) -> c_float;
99-
#[link_name="fmaxf"] pure fn fmax(a: c_float, b: c_float) -> c_float;
100-
#[link_name="fminf"] pure fn fmin(a: c_float, b: c_float) -> c_float;
101-
#[link_name="nextafterf"] pure fn nextafter(x: c_float,
102-
y: c_float) -> c_float;
103-
#[link_name="hypotf"] pure fn hypot(x: c_float, y: c_float) -> c_float;
104-
#[link_name="ldexpf"] pure fn ldexp(x: c_float, n: c_int) -> c_float;
105-
#[link_name="lgammaf_r"] pure fn lgamma(n: c_float,
106-
&sign: c_int) -> c_float;
107-
#[link_name="logf"] pure fn ln(n: c_float) -> c_float;
108-
#[link_name="logbf"] pure fn logb(n: c_float) -> c_float;
109-
#[link_name="log1pf"] pure fn ln1p(n: c_float) -> c_float;
110-
#[link_name="log2f"] pure fn log2(n: c_float) -> c_float;
111-
#[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
112-
#[link_name="ilogbf"] pure fn ilogb(n: c_float) -> c_int;
113-
#[link_name="modff"] pure fn modf(n: c_float,
114-
&iptr: c_float) -> c_float;
115-
#[link_name="powf"] pure fn pow(n: c_float, e: c_float) -> c_float;
116-
#[link_name="rintf"] pure fn rint(n: c_float) -> c_float;
117-
#[link_name="roundf"] pure fn round(n: c_float) -> c_float;
118-
#[link_name="scalbnf"] pure fn scalbn(n: c_float, i: c_int) -> c_float;
119-
#[link_name="sinf"] pure fn sin(n: c_float) -> c_float;
120-
#[link_name="sinhf"] pure fn sinh(n: c_float) -> c_float;
121-
#[link_name="sqrtf"] pure fn sqrt(n: c_float) -> c_float;
122-
#[link_name="tanf"] pure fn tan(n: c_float) -> c_float;
123-
#[link_name="tanhf"] pure fn tanh(n: c_float) -> c_float;
124-
#[link_name="tgammaf"] pure fn tgamma(n: c_float) -> c_float;
125-
#[link_name="truncf"] pure fn trunc(n: c_float) -> c_float;
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;
12671
}
12772

12873
//

trunk/src/libcore/core.rc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
#[license = "BSD"];
88
#[crate_type = "lib"];
99

10-
export box, char, float, bessel, f32, f64, int, str, ptr;
10+
export box, char, float, f32, f64, int, str, ptr;
1111
export uint, u8, u32, u64, vec, bool;
1212
export either, option, result;
13-
export ctypes, sys, unsafe, comm, task;
13+
export ctypes, mtypes, sys, unsafe, comm, task;
1414
export extfmt;
1515

1616
// Built-in-type support modules
1717

1818
mod box;
1919
mod char;
2020
mod float;
21-
mod bessel;
2221
mod f32;
2322
mod f64;
2423
mod int;
@@ -45,6 +44,7 @@ mod result;
4544
// Runtime and language-primitive support
4645

4746
mod ctypes;
47+
mod mtypes;
4848
mod cmath;
4949
mod sys;
5050
mod unsafe;

trunk/src/libcore/ctypes.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ FIXME: Add a test that uses some native code to verify these sizes,
99
which are not obviously correct for all potential platforms.
1010
*/
1111

12-
// PORT adapt to architecture
13-
1412
/*
1513
Type: c_int
1614

@@ -74,20 +72,6 @@ when interoperating with C void pointers can help in documentation.
7472
*/
7573
type void = int;
7674

77-
/*
78-
Type: c_float
79-
80-
A float value with the same size as a C `float`
81-
*/
82-
type c_float = f32;
83-
84-
/*
85-
Type: c_float
86-
87-
A float value with the same size as a C `double`
88-
*/
89-
type c_double = f64;
90-
9175
/*
9276
Type: size_t
9377

@@ -130,4 +114,3 @@ Type: enum
130114
An unsigned integer with the same size as a C enum
131115
*/
132116
type enum = u32;
133-

0 commit comments

Comments
 (0)