about summary refs log tree commit diff
path: root/src/libstd/sys/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sys/windows')
-rw-r--r--src/libstd/sys/windows/helper_signal.rs38
-rw-r--r--src/libstd/sys/windows/mod.rs1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/helper_signal.rs b/src/libstd/sys/windows/helper_signal.rs
new file mode 100644
index 00000000000..c547c79e83a
--- /dev/null
+++ b/src/libstd/sys/windows/helper_signal.rs
@@ -0,0 +1,38 @@
+// Copyright 2014 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.
+
+use libc::{mod, BOOL, LPCSTR, HANDLE, LPSECURITY_ATTRIBUTES, CloseHandle};
+use ptr;
+
+pub type signal = HANDLE;
+
+pub fn new() -> (HANDLE, HANDLE) {
+    unsafe {
+        let handle = CreateEventA(ptr::null_mut(), libc::FALSE, libc::FALSE,
+                                  ptr::null());
+        (handle, handle)
+    }
+}
+
+pub fn signal(handle: HANDLE) {
+    assert!(unsafe { SetEvent(handle) != 0 });
+}
+
+pub fn close(handle: HANDLE) {
+    assert!(unsafe { CloseHandle(handle) != 0 });
+}
+
+extern "system" {
+    fn CreateEventA(lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
+                    bManualReset: BOOL,
+                    bInitialState: BOOL,
+                    lpName: LPCSTR) -> HANDLE;
+    fn SetEvent(hEvent: HANDLE) -> BOOL;
+}
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 85fbc6b936c..6f6ca3f2e62 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -39,6 +39,7 @@ pub mod os;
 pub mod tcp;
 pub mod udp;
 pub mod pipe;
+pub mod helper_signal;
 
 pub mod addrinfo {
     pub use sys_common::net::get_host_addresses;