2022-05-23 15:06:11 -07:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_
|
2022-09-10 11:55:39 -07:00
|
|
|
#include "libc/intrin/nopl.internal.h"
|
2022-09-10 02:56:25 -07:00
|
|
|
#include "libc/thread/thread.h"
|
|
|
|
#include "libc/thread/tls.h"
|
2022-05-23 15:06:11 -07:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
2022-11-08 11:39:50 -08:00
|
|
|
_Hide extern int __vforked;
|
|
|
|
_Hide extern bool __time_critical;
|
|
|
|
_Hide extern unsigned __sighandrvas[NSIG];
|
|
|
|
_Hide extern unsigned __sighandflags[NSIG];
|
|
|
|
_Hide extern pthread_mutex_t __fds_lock_obj;
|
|
|
|
_Hide extern pthread_mutex_t __sig_lock_obj;
|
|
|
|
_Hide extern const struct NtSecurityAttributes kNtIsInheritable;
|
2022-05-23 15:06:11 -07:00
|
|
|
|
2022-06-12 11:47:20 -07:00
|
|
|
void __fds_lock(void);
|
|
|
|
void __fds_unlock(void);
|
2022-10-16 12:05:08 -07:00
|
|
|
void __fds_funlock(void);
|
2022-06-12 11:47:20 -07:00
|
|
|
void __sig_lock(void);
|
|
|
|
void __sig_unlock(void);
|
2022-10-16 12:05:08 -07:00
|
|
|
void __sig_funlock(void);
|
2022-06-12 11:47:20 -07:00
|
|
|
|
2022-06-26 02:58:36 -07:00
|
|
|
#ifdef _NOPL0
|
2022-06-12 19:33:42 -07:00
|
|
|
#define __fds_lock() _NOPL0("__threadcalls", __fds_lock)
|
|
|
|
#define __fds_unlock() _NOPL0("__threadcalls", __fds_unlock)
|
|
|
|
#else
|
2022-06-12 11:47:20 -07:00
|
|
|
#define __fds_lock() (__threaded ? __fds_lock() : 0)
|
|
|
|
#define __fds_unlock() (__threaded ? __fds_unlock() : 0)
|
2022-06-12 19:33:42 -07:00
|
|
|
#endif
|
|
|
|
|
2022-06-26 02:58:36 -07:00
|
|
|
#ifdef _NOPL0
|
2022-06-12 19:33:42 -07:00
|
|
|
#define __sig_lock() _NOPL0("__threadcalls", __sig_lock)
|
|
|
|
#define __sig_unlock() _NOPL0("__threadcalls", __sig_unlock)
|
|
|
|
#else
|
2022-06-12 11:47:20 -07:00
|
|
|
#define __sig_lock() (__threaded ? __sig_lock() : 0)
|
|
|
|
#define __sig_unlock() (__threaded ? __sig_unlock() : 0)
|
2022-06-12 19:33:42 -07:00
|
|
|
#endif
|
2022-06-08 20:01:28 -07:00
|
|
|
|
2022-10-16 12:05:08 -07:00
|
|
|
#define __vforked (__tls_enabled && (__get_tls()->tib_flags & TIB_FLAG_VFORKED))
|
|
|
|
|
2022-05-23 15:06:11 -07:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_ */
|