summaryrefslogtreecommitdiff
path: root/glfw/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'glfw/src/util.rs')
-rw-r--r--glfw/src/util.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/glfw/src/util.rs b/glfw/src/util.rs
new file mode 100644
index 0000000..f77aaf8
--- /dev/null
+++ b/glfw/src/util.rs
@@ -0,0 +1,10 @@
+use libc::{c_long, getpid, syscall, SYS_gettid};
+
+pub fn is_main_thread() -> bool
+{
+ let ttid = unsafe { syscall(SYS_gettid) };
+
+ let pid = c_long::from(unsafe { getpid() });
+
+ ttid == pid
+}