Skip to content

Commit e82af14

Browse files
committed
---
yaml --- r: 135896 b: refs/heads/try c: bdeb1d7 h: refs/heads/master v: v3
1 parent 3def2a8 commit e82af14

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 8794107f74682607f368776cc8b78820629778e6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ae81c89f34f1ac2cdb596cf216612e94822a8466
5-
refs/heads/try: 2acd6b77413817d89a067603fe54fdc9baa66df0
5+
refs/heads/try: bdeb1d738676d671b92a7057e3ba1791fa012351
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1+
// Copyright 2014 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+
111
extern crate libc;
2-
use libc::{c_void, LPVOID, DWORD};
3-
use libc::types::os::arch::extra::LPWSTR;
412

5-
extern "system" {
6-
fn FormatMessageW(flags: DWORD,
7-
lpSrc: LPVOID,
8-
msgId: DWORD,
9-
langId: DWORD,
10-
buf: LPWSTR,
11-
nsize: DWORD,
12-
args: *const c_void)
13-
-> DWORD;
13+
#[cfg(windows)]
14+
mod imp {
15+
use libc::{c_void, LPVOID, DWORD};
16+
use libc::types::os::arch::extra::LPWSTR;
17+
18+
extern "system" {
19+
fn FormatMessageW(flags: DWORD,
20+
lpSrc: LPVOID,
21+
msgId: DWORD,
22+
langId: DWORD,
23+
buf: LPWSTR,
24+
nsize: DWORD,
25+
args: *const c_void)
26+
-> DWORD;
27+
}
28+
29+
pub fn test() {
30+
let mut buf: [u16, ..50] = [0, ..50];
31+
let ret = unsafe {
32+
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
33+
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
34+
};
35+
// On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
36+
// stacks taking control of pvArbitrary
37+
assert!(ret != 0);
38+
}
1439
}
1540

16-
fn test() {
17-
let mut buf: [u16, ..50] = [0, ..50];
18-
let ret = unsafe {
19-
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
20-
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
21-
};
22-
// On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
23-
// stacks taking control of pvArbitrary
24-
assert!(ret != 0);
41+
#[cfg(not(windows))]
42+
mod imp {
43+
pub fn test() { }
2544
}
45+
2646
fn main() {
27-
test()
28-
}
47+
imp::test()
48+
}

0 commit comments

Comments
 (0)