mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 11:48:30 +00:00
Further improve ipv4.games server
This commit is contained in:
parent
3b4fcd8575
commit
32321ab1e9
9 changed files with 307 additions and 113 deletions
|
@ -52,6 +52,9 @@ enum PosixThreadStatus {
|
|||
// - kPosixThreadZombie -> _pthread_free() will happen whenever
|
||||
// convenient, e.g. pthread_create() entry or atexit handler.
|
||||
kPosixThreadZombie,
|
||||
|
||||
// special main thread
|
||||
kPosixThreadMain,
|
||||
};
|
||||
|
||||
struct PosixThread {
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
*/
|
||||
wontreturn void pthread_exit(void *rc) {
|
||||
struct PosixThread *pt;
|
||||
if ((pt = (struct PosixThread *)__get_tls()->tib_pthread)) {
|
||||
pt = (struct PosixThread *)pthread_self();
|
||||
if (pt->status != kPosixThreadMain) {
|
||||
pt->rc = rc;
|
||||
_gclongjmp(pt->exiter, 1);
|
||||
} else {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
int pthread_join(pthread_t thread, void **value_ptr) {
|
||||
struct PosixThread *pt;
|
||||
if (thread == __get_tls()->tib_pthread) {
|
||||
if (thread == pthread_self()) {
|
||||
return EDEADLK;
|
||||
}
|
||||
if (!(pt = (struct PosixThread *)thread) || //
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
│ 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"
|
||||
|
||||
|
@ -25,3 +27,10 @@
|
|||
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