Skip to content

Commit be9824b

Browse files
committed
---
yaml --- r: 97245 b: refs/heads/dist-snap c: 705f472 h: refs/heads/master i: 97243: bb9cb91 v: v3
1 parent 323511b commit be9824b

File tree

7 files changed

+156
-75
lines changed

7 files changed

+156
-75
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: a1d3cc53860b1e2377e489333e1f41dec6132b10
9+
refs/heads/dist-snap: 705f472c5509ec3a8fe3448541282eca1386344a
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/num/rational.rs

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use std::cmp;
1515
use std::from_str::FromStr;
1616
use std::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
17-
use super::bigint::{BigInt, BigUint, Sign, Plus, Minus};
17+
use super::bigint::BigInt;
1818

1919
/// Represents the ratio between 2 numbers.
2020
#[deriving(Clone)]
@@ -107,27 +107,6 @@ impl<T: Clone + Integer + Ord>
107107
}
108108
}
109109

110-
impl Ratio<BigInt> {
111-
/// Converts a float into a rational number
112-
pub fn from_float<T: Float>(f: T) -> Option<BigRational> {
113-
if !f.is_finite() {
114-
return None;
115-
}
116-
let (mantissa, exponent, sign) = f.integer_decode();
117-
let bigint_sign: Sign = if sign == 1 { Plus } else { Minus };
118-
if exponent < 0 {
119-
let one: BigInt = One::one();
120-
let denom: BigInt = one << ((-exponent) as uint);
121-
let numer: BigUint = FromPrimitive::from_u64(mantissa).unwrap();
122-
Some(Ratio::new(BigInt::from_biguint(bigint_sign, numer), denom))
123-
} else {
124-
let mut numer: BigUint = FromPrimitive::from_u64(mantissa).unwrap();
125-
numer = numer << (exponent as uint);
126-
Some(Ratio::from_integer(BigInt::from_biguint(bigint_sign, numer)))
127-
}
128-
}
129-
}
130-
131110
/* Comparisons */
132111

133112
// comparing a/b and c/d is the same as comparing a*d and b*c, so we
@@ -642,42 +621,4 @@ mod test {
642621
test(s);
643622
}
644623
}
645-
646-
#[test]
647-
fn test_from_float() {
648-
fn test<T: Float>(given: T, (numer, denom): (&str, &str)) {
649-
let ratio: BigRational = Ratio::from_float(given).unwrap();
650-
assert_eq!(ratio, Ratio::new(
651-
FromStr::from_str(numer).unwrap(),
652-
FromStr::from_str(denom).unwrap()));
653-
}
654-
655-
// f32
656-
test(3.14159265359f32, ("13176795", "4194304"));
657-
test(2f32.pow(&100.), ("1267650600228229401496703205376", "1"));
658-
test(-2f32.pow(&100.), ("-1267650600228229401496703205376", "1"));
659-
test(1.0 / 2f32.pow(&100.), ("1", "1267650600228229401496703205376"));
660-
test(684729.48391f32, ("1369459", "2"));
661-
test(-8573.5918555f32, ("-4389679", "512"));
662-
663-
// f64
664-
test(3.14159265359f64, ("3537118876014453", "1125899906842624"));
665-
test(2f64.pow(&100.), ("1267650600228229401496703205376", "1"));
666-
test(-2f64.pow(&100.), ("-1267650600228229401496703205376", "1"));
667-
test(684729.48391f64, ("367611342500051", "536870912"));
668-
test(-8573.5918555, ("-4713381968463931", "549755813888"));
669-
test(1.0 / 2f64.pow(&100.), ("1", "1267650600228229401496703205376"));
670-
}
671-
672-
#[test]
673-
fn test_from_float_fail() {
674-
use std::{f32, f64};
675-
676-
assert_eq!(Ratio::from_float(f32::NAN), None);
677-
assert_eq!(Ratio::from_float(f32::INFINITY), None);
678-
assert_eq!(Ratio::from_float(f32::NEG_INFINITY), None);
679-
assert_eq!(Ratio::from_float(f64::NAN), None);
680-
assert_eq!(Ratio::from_float(f64::INFINITY), None);
681-
assert_eq!(Ratio::from_float(f64::NEG_INFINITY), None);
682-
}
683624
}

branches/dist-snap/src/librustc/back/link.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use back::archive::{Archive, METADATA_FILENAME};
1313
use back::rpath;
14+
use back::manifest;
1415
use driver::driver::CrateTranslation;
1516
use driver::session::Session;
1617
use driver::session;
@@ -827,6 +828,12 @@ fn link_binary_output(sess: Session,
827828
}
828829
session::OutputExecutable => {
829830
link_natively(sess, false, obj_filename, &out_filename);
831+
// Windows linker will add an ".exe" extension if there was none
832+
let out_filename = match out_filename.extension() {
833+
Some(_) => out_filename.clone(),
834+
None => out_filename.with_extension(win32::EXE_EXTENSION)
835+
};
836+
manifest::postprocess_executable(sess, &out_filename);
830837
}
831838
session::OutputDylib => {
832839
link_natively(sess, true, obj_filename, &out_filename);
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
12+
// To avoid problems with Windows UAC installer detection heuristics,
13+
// Rust-produced executables need an application manifest.
14+
// For details, see issue #10512.
15+
16+
// No-op on other platforms.
17+
18+
use driver::session::Session;
19+
use std::path::Path;
20+
21+
#[cfg(not(windows))]
22+
pub fn postprocess_executable(_sess: Session, _filename: &Path) {}
23+
24+
#[cfg(windows)]
25+
pub fn postprocess_executable(sess: Session, filename: &Path) {
26+
27+
let default_manifest = concat!(
28+
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>",
29+
"<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>",
30+
" <trustInfo xmlns='urn:schemas-microsoft-com:asm.v3'>",
31+
" <security>",
32+
" <requestedPrivileges>",
33+
" <requestedExecutionLevel level='asInvoker' uiAccess='false' />",
34+
" </requestedPrivileges>",
35+
" </security>",
36+
" </trustInfo>",
37+
"</assembly>");
38+
39+
match windows::embed_manifest(filename, default_manifest) {
40+
Ok(_) => (),
41+
Err(msg) => sess.err(format!("Could not embed application manifest: {}", msg))
42+
}
43+
}
44+
45+
#[cfg(windows)]
46+
mod windows {
47+
use std::libc::types::os::arch::extra::{BOOL,WORD,DWORD,HANDLE,LPCWSTR,LPCVOID};
48+
use std::libc::consts::os::extra::FALSE;
49+
use std::cast::transmute;
50+
use std::os;
51+
52+
// FIXME #9053: should import as_utf16_p from std rather than re-defining here
53+
//use std::os::win32::as_utf16_p;
54+
fn as_utf16_p<T>(s: &str, f: |*u16| -> T) -> T {
55+
let mut t = s.to_utf16();
56+
// Null terminate before passing on.
57+
t.push(0u16);
58+
f(t.as_ptr())
59+
}
60+
61+
#[link_name = "kernel32"]
62+
extern "system" {
63+
pub fn BeginUpdateResourceW(pFileName: LPCWSTR,
64+
bDeleteExistingResources: BOOL) -> HANDLE;
65+
pub fn UpdateResourceW(hUpdate: HANDLE,
66+
lpType: LPCWSTR,
67+
lpName: LPCWSTR,
68+
wLanguage: WORD,
69+
lpData: LPCVOID,
70+
cbData: DWORD) -> BOOL;
71+
pub fn EndUpdateResourceW(hUpdate: HANDLE,
72+
fDiscard: BOOL) -> BOOL;
73+
}
74+
75+
fn MAKEINTRESOURCEW(id: int) -> LPCWSTR {
76+
unsafe{ transmute(id) }
77+
}
78+
79+
pub fn embed_manifest(filename: &Path,
80+
manifest: &str) -> Result<(),~str> {
81+
unsafe {
82+
let hUpdate = as_utf16_p(filename.as_str().unwrap(), |path| {
83+
BeginUpdateResourceW(path, FALSE)
84+
});
85+
if hUpdate.is_null() {
86+
return Err(format!("failure in BeginUpdateResourceW: {}", os::last_os_error()));
87+
}
88+
89+
let ok = UpdateResourceW(hUpdate,
90+
MAKEINTRESOURCEW(24), // RT_MANIFEST
91+
MAKEINTRESOURCEW(1), // CREATEPROCESS_MANIFEST_RESOURCE_ID
92+
0, // LANG_NEUTRAL, SUBLANG_NEUTRAL
93+
manifest.as_ptr() as LPCVOID,
94+
manifest.len() as u32);
95+
if ok == FALSE {
96+
return Err(format!("failure in UpdateResourceW: {}", os::last_os_error()));
97+
}
98+
99+
let ok = EndUpdateResourceW(hUpdate, FALSE);
100+
if ok == FALSE {
101+
return Err(format!("failure in EndUpdateResourceW: {}", os::last_os_error()));
102+
}
103+
Ok(())
104+
}
105+
}
106+
}

branches/dist-snap/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub mod front {
8888
pub mod back {
8989
pub mod archive;
9090
pub mod link;
91+
pub mod manifest;
9192
pub mod abi;
9293
pub mod arm;
9394
pub mod mips;

branches/dist-snap/src/libstd/rt/unwind.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,29 @@ impl Unwinder {
180180
self.unwinding = true;
181181
self.cause = Some(cause);
182182

183-
unsafe {
184-
let exception = ~uw::_Unwind_Exception {
185-
exception_class: rust_exception_class(),
186-
exception_cleanup: exception_cleanup,
187-
private_1: 0,
188-
private_2: 0
189-
};
190-
let error = uw::_Unwind_RaiseException(cast::transmute(exception));
191-
rtabort!("Could not unwind stack, error = {}", error as int)
192-
}
183+
rust_fail();
193184

194-
extern "C" fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
195-
exception: *uw::_Unwind_Exception) {
196-
rtdebug!("exception_cleanup()");
185+
// An uninlined, unmangled function upon which to slap yer breakpoints
186+
#[inline(never)]
187+
#[no_mangle]
188+
fn rust_fail() -> ! {
197189
unsafe {
198-
let _: ~uw::_Unwind_Exception = cast::transmute(exception);
190+
let exception = ~uw::_Unwind_Exception {
191+
exception_class: rust_exception_class(),
192+
exception_cleanup: exception_cleanup,
193+
private_1: 0,
194+
private_2: 0
195+
};
196+
let error = uw::_Unwind_RaiseException(cast::transmute(exception));
197+
rtabort!("Could not unwind stack, error = {}", error as int)
198+
}
199+
200+
extern "C" fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
201+
exception: *uw::_Unwind_Exception) {
202+
rtdebug!("exception_cleanup()");
203+
unsafe {
204+
let _: ~uw::_Unwind_Exception = cast::transmute(exception);
205+
}
199206
}
200207
}
201208
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// On Windows this test checks that Rust binaries have an embedded
12+
// application manifest and don't trip UAC installer detection
13+
// heuristics ("setup" is one of the "installer" keywords).
14+
// For details, see issue #10512.
15+
16+
// On other platforms this is a no-op.
17+
18+
pub fn main() {
19+
}

0 commit comments

Comments
 (0)