about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-11-13 23:17:18 -0800
committerAlex Crichton <alex@alexcrichton.com>2013-11-18 20:06:39 -0800
commit24eb1b445dd878c12ca6503a9fa040179b94e614 (patch)
tree838edbe46508aea427ce043f0d0d7e5ef341d26a /src/rt/rust_builtin.cpp
parentab7fe9dd06e93986f6b11512031c891059474653 (diff)
downloadrust-24eb1b445dd878c12ca6503a9fa040179b94e614.tar.gz
rust-24eb1b445dd878c12ca6503a9fa040179b94e614.zip
Implement a native mutex type
This mutex is built on top of pthreads for unix and the related windows apis on
windows. This is a straight port of the lock_and_signal type from C++ to rust.
Almost all operations on the type are unsafe, and it's definitely not
recommended for general use.

Closes #9105
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 7d75d557bf7..28dd4b51a13 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -671,6 +671,27 @@ rust_win32_rand_release() {
 }
 
 #endif
+
+#if defined(__WIN32__)
+
+extern "C" CDECL int
+rust_crit_section_size() { return sizeof(CRITICAL_SECTION); }
+extern "C" CDECL int
+rust_pthread_mutex_t_size() { return 0; }
+extern "C" CDECL int
+rust_pthread_cond_t_size() { return 0; }
+
+#else
+
+extern "C" CDECL int
+rust_crit_section_size() { return 0; }
+extern "C" CDECL int
+rust_pthread_mutex_t_size() { return sizeof(pthread_mutex_t); }
+extern "C" CDECL int
+rust_pthread_cond_t_size() { return sizeof(pthread_cond_t); }
+
+#endif
+
 //
 // Local Variables:
 // mode: C++