]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | ||
9346a6ac | 11 | #![feature(libc, std_misc)] |
c34b1796 | 12 | |
1a4d82fc JJ |
13 | extern crate libc; |
14 | ||
15 | #[cfg(windows)] | |
16 | mod imp { | |
92a42be0 SL |
17 | type LPVOID = *mut u8; |
18 | type DWORD = u32; | |
19 | type LPWSTR = *mut u16; | |
1a4d82fc JJ |
20 | |
21 | extern "system" { | |
22 | fn FormatMessageW(flags: DWORD, | |
23 | lpSrc: LPVOID, | |
24 | msgId: DWORD, | |
25 | langId: DWORD, | |
26 | buf: LPWSTR, | |
27 | nsize: DWORD, | |
92a42be0 | 28 | args: *const u8) |
1a4d82fc JJ |
29 | -> DWORD; |
30 | } | |
31 | ||
32 | pub fn test() { | |
33 | let mut buf: [u16; 50] = [0; 50]; | |
34 | let ret = unsafe { | |
92a42be0 SL |
35 | FormatMessageW(0x1000, 0 as *mut _, 1, 0x400, |
36 | buf.as_mut_ptr(), buf.len() as u32, 0 as *const _) | |
1a4d82fc JJ |
37 | }; |
38 | // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented | |
39 | // stacks taking control of pvArbitrary | |
40 | assert!(ret != 0); | |
41 | } | |
42 | } | |
43 | ||
44 | #[cfg(not(windows))] | |
45 | mod imp { | |
46 | pub fn test() { } | |
47 | } | |
48 | ||
49 | fn main() { | |
50 | imp::test() | |
51 | } |