| 1 | @[has_globals] |
| 2 | module os |
| 3 | |
| 4 | #flag -lpthread |
| 5 | |
| 6 | fn C.pthread_self() usize |
| 7 | |
| 8 | // g_main_thread_id and is_main_thread can be used to determine if the current thread is the main thread. |
| 9 | // if need to get the tid of the main thread, can use the global variable g_main_thread_id |
| 10 | // instead of using thread_id() every time. |
| 11 | __global g_main_thread_id = u64(C.pthread_self()) |
| 12 | |
| 13 | // is_main_thread returns whether the current thread is the main thread. |
| 14 | pub fn is_main_thread() bool { |
| 15 | return g_main_thread_id == u64(C.pthread_self()) |
| 16 | } |
| 17 | |
| 18 | fn signal_ignore_internal(_ ...Signal) { |
| 19 | // just do nothing by default, since that is most portable ¯\_(ツ)_/¯, |
| 20 | // especially on platforms like OpenBSD etc |
| 21 | } |
| 22 | |