2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2011-11-09 17:27:11 -06:00
|
|
|
// GetLastError doesn't seem to work with stack switching
|
|
|
|
// xfail-test
|
|
|
|
|
2011-07-18 15:14:33 -05:00
|
|
|
#[cfg(target_os = "win32")]
|
2012-07-03 18:11:00 -05:00
|
|
|
extern "stdcall" mod kernel32 {
|
2011-07-27 07:19:39 -05:00
|
|
|
fn SetLastError(err: uint);
|
|
|
|
fn GetLastError() -> uint;
|
2011-07-18 16:59:44 -05:00
|
|
|
}
|
2011-07-18 15:14:33 -05:00
|
|
|
|
2011-11-09 17:27:11 -06:00
|
|
|
|
2011-07-18 16:59:44 -05:00
|
|
|
#[cfg(target_os = "win32")]
|
|
|
|
fn main() {
|
2013-01-25 17:18:45 -06:00
|
|
|
unsafe {
|
|
|
|
let expected = 1234u;
|
|
|
|
kernel32::SetLastError(expected);
|
|
|
|
let actual = kernel32::GetLastError();
|
|
|
|
log(error, actual);
|
|
|
|
assert (expected == actual);
|
|
|
|
}
|
2011-07-18 15:14:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
#[cfg(target_os = "linux")]
|
2011-12-30 02:18:55 -06:00
|
|
|
#[cfg(target_os = "freebsd")]
|
2011-08-19 17:16:48 -05:00
|
|
|
fn main() { }
|