2012-12-10 17:32:48 -08: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 15:27:11 -08:00
|
|
|
// GetLastError doesn't seem to work with stack switching
|
|
|
|
// xfail-test
|
|
|
|
|
2011-07-18 13:14:33 -07:00
|
|
|
#[cfg(target_os = "win32")]
|
2012-07-03 16:11:00 -07:00
|
|
|
extern "stdcall" mod kernel32 {
|
2011-07-27 14:19:39 +02:00
|
|
|
fn SetLastError(err: uint);
|
|
|
|
fn GetLastError() -> uint;
|
2011-07-18 14:59:44 -07:00
|
|
|
}
|
2011-07-18 13:14:33 -07:00
|
|
|
|
2011-11-09 15:27:11 -08:00
|
|
|
|
2011-07-18 14:59:44 -07:00
|
|
|
#[cfg(target_os = "win32")]
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2013-01-25 15:18:45 -08:00
|
|
|
unsafe {
|
|
|
|
let expected = 1234u;
|
|
|
|
kernel32::SetLastError(expected);
|
|
|
|
let actual = kernel32::GetLastError();
|
|
|
|
log(error, actual);
|
|
|
|
assert (expected == actual);
|
|
|
|
}
|
2011-07-18 13:14:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
#[cfg(target_os = "linux")]
|
2011-12-30 16:18:55 +08:00
|
|
|
#[cfg(target_os = "freebsd")]
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() { }
|