mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Make more improvements to threading support
- fix rare thread exit race condition on openbsd - pthread_getattr_np() now supplies detached status - child threads may now pthread_join() the main thread - introduce sigandset(), sigorset(), and sigisemptyset() - introduce pthread_cleanup_push() and pthread_cleanup_pop()
This commit is contained in:
parent
38df0a4186
commit
4a6fd3d910
52 changed files with 586 additions and 241 deletions
|
@ -16,21 +16,14 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/thread/posixthread.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
STATIC_YOINK("_pthread_main");
|
||||
|
||||
/**
|
||||
* Returns current POSIX thread.
|
||||
*/
|
||||
pthread_t pthread_self(void) {
|
||||
return __get_tls()->tib_pthread;
|
||||
}
|
||||
|
||||
static struct PosixThread pthread_main;
|
||||
__attribute__((__constructor__)) static void pthread_self_init(void) {
|
||||
pthread_main.tid = gettid();
|
||||
pthread_main.status = kPosixThreadMain;
|
||||
__get_tls()->tib_pthread = (pthread_t)&pthread_main;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue