Path: blob/main/system/lib/pthread/pthread_self_stub.c
6172 views
/*1* Copyright 2021 The Emscripten Authors. All rights reserved.2* Emscripten is available under two separate licenses, the MIT license and the3* University of Illinois/NCSA Open Source License. Both these licenses can be4* found in the LICENSE file.5*/67#include "pthread_impl.h"8#include <unistd.h>9#include <emscripten/stack.h>1011static struct pthread __main_pthread;1213uintptr_t __get_tp(void) {14return (uintptr_t)&__main_pthread;15}1617// In case the stub syscall is not linked it18static int dummy_getpid() {19return 42;20}21weak_alias(dummy_getpid, __syscall_getpid);2223pthread_t emscripten_main_runtime_thread_id() {24return &__main_pthread;25}2627extern int __stack_high;28extern int __stack_low;2930__attribute__((constructor))31static void init_pthread_self(void) {32__main_pthread.locale = &libc.global_locale;33__main_pthread.tid = getpid();34__main_pthread.stack = &__stack_high;35__main_pthread.stack_size = ((size_t)&__stack_high) - ((size_t)&__stack_low);36__main_pthread.guard_size = __default_guardsize;37}383940