Skip to content

Commit 9438b27

Browse files
committed
---
yaml --- r: 7032 b: refs/heads/master c: 6284190 h: refs/heads/master v: v3
1 parent ec79dec commit 9438b27

File tree

16 files changed

+483
-811
lines changed

16 files changed

+483
-811
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: 1dec1c8813768f86e6c0f581fb0bea07fa70a4c8
2+
refs/heads/master: 6284190ef9918e05cb9147a2a81100ddcb06fea8

trunk/src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ mod util;
55
mod header;
66
mod runtest;
77
mod common;
8-
mod errors;
98

109
// Local Variables:
1110
// fill-column: 78;
1211
// indent-tabs-mode: nil
1312
// c-basic-offset: 4
1413
// buffer-file-coding-system: utf-8-unix
14+
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
1515
// End:

trunk/src/compiletest/errors.rs

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

trunk/src/compiletest/runtest.rs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,7 @@ fn run_cfail_test(cx: cx, props: test_props, testfile: str) {
4242
}
4343

4444
check_correct_failure_status(procres);
45-
46-
let expected_errors = errors::load_errors(testfile);
47-
if vec::is_not_empty(expected_errors) {
48-
if vec::is_not_empty(props.error_patterns) {
49-
fatal("both error pattern and expected errors specified");
50-
}
51-
check_expected_errors(expected_errors, testfile, procres);
52-
} else {
53-
check_error_patterns(props, testfile, procres);
54-
}
45+
check_error_patterns(props, testfile, procres);
5546
}
5647

5748
fn run_rfail_test(cx: cx, props: test_props, testfile: str) {
@@ -190,9 +181,7 @@ actual:\n\
190181
}
191182
}
192183

193-
fn check_error_patterns(props: test_props,
194-
testfile: str,
195-
procres: procres) {
184+
fn check_error_patterns(props: test_props, testfile: str, procres: procres) {
196185
if vec::is_empty(props.error_patterns) {
197186
fatal("no error pattern specified in " + testfile);
198187
}
@@ -229,63 +218,6 @@ fn check_error_patterns(props: test_props,
229218
}
230219
}
231220

232-
fn check_expected_errors(expected_errors: [errors::expected_error],
233-
testfile: str,
234-
procres: procres) {
235-
236-
// true if we found the error in question
237-
let found_flags = vec::init_elt_mut(false, vec::len(expected_errors));
238-
239-
if procres.status == 0 {
240-
fatal("process did not return an error status");
241-
}
242-
243-
let prefixes = vec::map(expected_errors, {|ee|
244-
#fmt("%s:%u:", testfile, ee.line)
245-
});
246-
247-
// Scan and extract our error/warning messages,
248-
// which look like:
249-
// filename:line1:col1: line2:col2: *error:* msg
250-
// filename:line1:col1: line2:col2: *warning:* msg
251-
// where line1:col1: is the starting point, line2:col2:
252-
// is the ending point, and * represents ANSI color codes.
253-
for line: str in str::split(procres.stdout, '\n' as u8) {
254-
let was_expected = false;
255-
vec::iteri(expected_errors) {|i, ee|
256-
if !found_flags[i] {
257-
#debug["prefix=%s ee.kind=%s ee.msg=%s line=%s",
258-
prefixes[i], ee.kind, ee.msg, line];
259-
if (str::starts_with(line, prefixes[i]) &&
260-
str::contains(line, ee.kind) &&
261-
str::contains(line, ee.msg)) {
262-
found_flags[i] = true;
263-
was_expected = true;
264-
}
265-
}
266-
}
267-
268-
// ignore this msg which gets printed at the end
269-
if str::contains(line, "aborting due to previous errors") {
270-
was_expected = true;
271-
}
272-
273-
if !was_expected && (str::contains(line, "error") ||
274-
str::contains(line, "warning")) {
275-
fatal_procres(#fmt["unexpected error pattern '%s'!", line],
276-
procres);
277-
}
278-
}
279-
280-
uint::range(0u, vec::len(found_flags)) {|i|
281-
if !found_flags[i] {
282-
let ee = expected_errors[i];
283-
fatal_procres(#fmt["expected %s on line %u not found: %s",
284-
ee.kind, ee.line, ee.msg], procres);
285-
}
286-
}
287-
}
288-
289221
type procargs = {prog: str, args: [str]};
290222

291223
type procres = {status: int, stdout: str, stderr: str, cmdline: str};

trunk/src/libcore/bessel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// PORT import module that is based on cmath::c_double here
2+
// (cant do better via libm; bessel functions only exist for c_double)
3+
4+
// code that wants to use bessel functions should use
5+
// values of type bessel::t and cast from/to float/f32/f64
6+
// when working with them at the peril of precision loss
7+
// for platform neutrality
8+
9+
import f64::*;
10+

trunk/src/libcore/cmath.rs

Lines changed: 123 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,146 @@
1+
export c_double;
2+
export c_float;
3+
14
import ctypes::c_int;
5+
import ctypes::c_float;
6+
import ctypes::c_double;
7+
8+
// function names are almost identical to C's libmath, a few have been
9+
// renamed, grep for "rename:"
210

311
#[link_name = "m"]
412
#[abi = "cdecl"]
5-
native mod f64 {
13+
native mod c_double {
614

715
// Alpabetically sorted by link_name
816

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;
17+
pure fn acos(n: c_double) -> c_double;
18+
pure fn asin(n: c_double) -> c_double;
19+
pure fn atan(n: c_double) -> c_double;
20+
pure fn atan2(a: c_double, b: c_double) -> c_double;
21+
pure fn cbrt(n: c_double) -> c_double;
22+
pure fn ceil(n: c_double) -> c_double;
23+
pure fn copysign(x: c_double, y: c_double) -> c_double;
24+
pure fn cos(n: c_double) -> c_double;
25+
pure fn cosh(n: c_double) -> c_double;
26+
pure fn erf(n: c_double) -> c_double;
27+
pure fn erfc(n: c_double) -> c_double;
28+
pure fn exp(n: c_double) -> c_double;
29+
pure fn expm1(n: c_double) -> c_double;
30+
pure fn exp2(n: c_double) -> c_double;
31+
#[link_name="fabs"] pure fn abs(n: c_double) -> c_double;
32+
// rename: for clarity and consistency with add/sub/mul/div
33+
#[link_name="fdim"] pure fn abs_sub(a: c_double, b: c_double) -> c_double;
34+
pure fn floor(n: c_double) -> c_double;
35+
// rename: for clarity and consistency with add/sub/mul/div
36+
#[link_name="fma"] pure fn mul_add(a: c_double, b: c_double,
37+
c: c_double) -> c_double;
38+
#[link_name="fmax"] pure fn fmax(a: c_double, b: c_double) -> c_double;
39+
#[link_name="fmin"] pure fn fmin(a: c_double, b: c_double) -> c_double;
40+
pure fn nextafter(x: c_double, y: c_double) -> c_double;
41+
pure fn frexp(n: c_double, &value: c_int) -> c_double;
42+
pure fn hypot(x: c_double, y: c_double) -> c_double;
43+
pure fn ldexp(x: c_double, n: c_int) -> c_double;
44+
#[link_name="lgamma_r"] pure fn lgamma(n: c_double,
45+
&sign: c_int) -> c_double;
46+
// renamed: log is a reserved keyword; ln seems more natural, too
47+
#[link_name="log"] pure fn ln(n: c_double) -> c_double;
48+
// renamed: "logb" /often/ is confused for log2 by beginners
49+
#[link_name="logb"] pure fn log_radix(n: c_double) -> c_double;
50+
// renamed: to be consitent with log as ln
51+
#[link_name="log1p"] pure fn ln1p(n: c_double) -> c_double;
52+
pure fn log10(n: c_double) -> c_double;
2553
#[cfg(target_os="linux")]
2654
#[cfg(target_os="macos")]
2755
#[cfg(target_os="win32")]
28-
pure fn log2(n: f64) -> f64;
29-
pure fn modf(n: f64, iptr: *f64) -> f64;
30-
pure fn pow(n: f64, e: f64) -> f64;
31-
pure fn rint(n: f64) -> f64;
32-
pure fn round(n: f64) -> f64;
33-
pure fn sin(n: f64) -> f64;
34-
pure fn sinh(n: f64) -> f64;
35-
pure fn sqrt(n: f64) -> f64;
36-
pure fn tan(n: f64) -> f64;
37-
pure fn tanh(n: f64) -> f64;
38-
pure fn trunc(n: f64) -> f64;
56+
pure fn log2(n: c_double) -> c_double;
57+
#[link_name="ilogb"] pure fn ilogradix(n: c_double) -> c_int;
58+
pure fn modf(n: c_double, &iptr: c_double) -> c_double;
59+
pure fn pow(n: c_double, e: c_double) -> c_double;
60+
// FIXME enable when rounding modes become available
61+
// pure fn rint(n: c_double) -> c_double;
62+
pure fn round(n: c_double) -> c_double;
63+
// rename: for consistency with logradix
64+
#[link_name="scalbn"] pure fn ldexp_radix(n: c_double, i: c_int) ->
65+
c_double;
66+
pure fn sin(n: c_double) -> c_double;
67+
pure fn sinh(n: c_double) -> c_double;
68+
pure fn sqrt(n: c_double) -> c_double;
69+
pure fn tan(n: c_double) -> c_double;
70+
pure fn tanh(n: c_double) -> c_double;
71+
pure fn tgamma(n: c_double) -> c_double;
72+
pure fn trunc(n: c_double) -> c_double;
73+
74+
// These are commonly only available for doubles
75+
76+
pure fn j0(n: c_double) -> c_double;
77+
pure fn j1(n: c_double) -> c_double;
78+
pure fn jn(i: c_int, n: c_double) -> c_double;
79+
80+
pure fn y0(n: c_double) -> c_double;
81+
pure fn y1(n: c_double) -> c_double;
82+
pure fn yn(i: c_int, n: c_double) -> c_double;
3983
}
4084

4185
#[link_name = "m"]
4286
#[abi = "cdecl"]
43-
native mod f32 {
87+
native mod c_float {
4488

4589
// Alpabetically sorted by link_name
4690

47-
#[link_name="acosf"] pure fn acos(n: f32) -> f32;
48-
#[link_name="asinf"] pure fn asin(n: f32) -> f32;
49-
#[link_name="atanf"] pure fn atan(n: f32) -> f32;
50-
#[link_name="atan2f"] pure fn atan2(a: f32, b: f32) -> f32;
51-
#[link_name="ceilf"] pure fn ceil(n: f32) -> f32;
52-
#[link_name="cosf"] pure fn cos(n: f32) -> f32;
53-
#[link_name="coshf"] pure fn cosh(n: f32) -> f32;
54-
#[link_name="expf"] pure fn exp(n: f32) -> f32;
55-
#[link_name="fabsf"] pure fn abs(n: f32) -> f32;
56-
#[link_name="floorf"] pure fn floor(n: f32) -> f32;
57-
#[link_name="frexpf"] pure fn frexp(n: f64, &value: c_int) -> f32;
58-
#[link_name="fmodf"] pure fn fmod(x: f32, y: f32) -> f32;
59-
#[link_name="ldexpf"] pure fn ldexp(x: f32, n: c_int) -> f32;
60-
#[link_name="logf"] pure fn ln(n: f32) -> f32;
61-
#[link_name="log1p"] pure fn ln1p(n: f64) -> f64;
91+
#[link_name="acosf"] pure fn acos(n: c_float) -> c_float;
92+
#[link_name="asinf"] pure fn asin(n: c_float) -> c_float;
93+
#[link_name="atanf"] pure fn atan(n: c_float) -> c_float;
94+
#[link_name="atan2f"] pure fn atan2(a: c_float, b: c_float) -> c_float;
95+
#[link_name="cbrtf"] pure fn cbrt(n: c_float) -> c_float;
96+
#[link_name="ceilf"] pure fn ceil(n: c_float) -> c_float;
97+
#[link_name="copysignf"] pure fn copysign(x: c_float,
98+
y: c_float) -> c_float;
99+
#[link_name="cosf"] pure fn cos(n: c_float) -> c_float;
100+
#[link_name="coshf"] pure fn cosh(n: c_float) -> c_float;
101+
#[link_name="erff"] pure fn erf(n: c_float) -> c_float;
102+
#[link_name="erfcf"] pure fn erfc(n: c_float) -> c_float;
103+
#[link_name="expf"] pure fn exp(n: c_float) -> c_float;
104+
#[link_name="expm1f"]pure fn expm1(n: c_float) -> c_float;
105+
#[link_name="exp2f"] pure fn exp2(n: c_float) -> c_float;
106+
#[link_name="fabsf"] pure fn abs(n: c_float) -> c_float;
107+
#[link_name="fdimf"] pure fn abs_sub(a: c_float, b: c_float) -> c_float;
108+
#[link_name="floorf"] pure fn floor(n: c_float) -> c_float;
109+
#[link_name="frexpf"] pure fn frexp(n: c_float,
110+
&value: c_int) -> c_float;
111+
#[link_name="fmaf"] pure fn mul_add(a: c_float,
112+
b: c_float, c: c_float) -> c_float;
113+
#[link_name="fmaxf"] pure fn fmax(a: c_float, b: c_float) -> c_float;
114+
#[link_name="fminf"] pure fn fmin(a: c_float, b: c_float) -> c_float;
115+
#[link_name="nextafterf"] pure fn nextafter(x: c_float,
116+
y: c_float) -> c_float;
117+
#[link_name="hypotf"] pure fn hypot(x: c_float, y: c_float) -> c_float;
118+
#[link_name="ldexpf"] pure fn ldexp(x: c_float, n: c_int) -> c_float;
119+
#[link_name="lgammaf_r"] pure fn lgamma(n: c_float,
120+
&sign: c_int) -> c_float;
121+
#[link_name="logf"] pure fn ln(n: c_float) -> c_float;
122+
#[link_name="logbf"] pure fn log_radix(n: c_float) -> c_float;
123+
#[link_name="log1pf"] pure fn ln1p(n: c_float) -> c_float;
62124
#[cfg(target_os="linux")]
63125
#[cfg(target_os="macos")]
64126
#[cfg(target_os="win32")]
65-
#[link_name="log2f"] pure fn log2(n: f32) -> f32;
66-
#[link_name="log10f"] pure fn log10(n: f32) -> f32;
67-
#[link_name="modff"] pure fn modf(n: f32, iptr: *f32) -> f32;
68-
#[link_name="powf"] pure fn pow(n: f32, e: f32) -> f32;
69-
#[link_name="rintf"] pure fn rint(n: f32) -> f32;
70-
#[link_name="roundf"] pure fn round(n: f32) -> f32;
71-
#[link_name="sinf"] pure fn sin(n: f32) -> f32;
72-
#[link_name="sinhf"] pure fn sinh(n: f32) -> f32;
73-
#[link_name="sqrtf"] pure fn sqrt(n: f32) -> f32;
74-
#[link_name="tanf"] pure fn tan(n: f32) -> f32;
75-
#[link_name="tanhf"] pure fn tanh(n: f32) -> f32;
76-
#[link_name="truncf"] pure fn trunc(n: f32) -> f32;
127+
#[link_name="log2f"] pure fn log2(n: c_float) -> c_float;
128+
#[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
129+
#[link_name="ilogbf"] pure fn ilog_radix(n: c_float) -> c_int;
130+
#[link_name="modff"] pure fn modf(n: c_float,
131+
&iptr: c_float) -> c_float;
132+
#[link_name="powf"] pure fn pow(n: c_float, e: c_float) -> c_float;
133+
// FIXME enable when rounding modes become available
134+
// #[link_name="rintf"] pure fn rint(n: c_float) -> c_float;
135+
#[link_name="roundf"] pure fn round(n: c_float) -> c_float;
136+
#[link_name="scalbnf"] pure fn ldexp_radix(n: c_float, i: c_int) -> c_float;
137+
#[link_name="sinf"] pure fn sin(n: c_float) -> c_float;
138+
#[link_name="sinhf"] pure fn sinh(n: c_float) -> c_float;
139+
#[link_name="sqrtf"] pure fn sqrt(n: c_float) -> c_float;
140+
#[link_name="tanf"] pure fn tan(n: c_float) -> c_float;
141+
#[link_name="tanhf"] pure fn tanh(n: c_float) -> c_float;
142+
#[link_name="tgammaf"] pure fn tgamma(n: c_float) -> c_float;
143+
#[link_name="truncf"] pure fn trunc(n: c_float) -> c_float;
77144
}
78145

79146
//

0 commit comments

Comments
 (0)