@@ -364,7 +364,7 @@ var LibraryPThread = {
364
364
} else if ( cmd === 'alert' ) {
365
365
alert ( 'Thread ' + d [ 'threadId' ] + ': ' + d [ 'text' ] ) ;
366
366
} else if ( cmd === 'exit' ) {
367
- var detached = worker . pthread && Atomics . load ( HEAPU32 , ( worker . pthread . threadInfoStruct + { { { C_STRUCTS . pthread . detached } } } ) >> 2 ) ;
367
+ var detached = worker . pthread && Atomics . load ( HEAPU32 , ( worker . pthread . threadInfoStruct + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 ) ;
368
368
if ( detached ) {
369
369
PThread . returnWorkerToPool ( worker ) ;
370
370
}
@@ -536,10 +536,11 @@ var LibraryPThread = {
536
536
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . threadStatus } } } >> 2 ) , 0 ) ; // threadStatus <- 0, meaning not yet exited.
537
537
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . threadExitCode } } } >> 2 ) , 0 ) ; // threadExitCode <- 0.
538
538
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . profilerBlock } } } >> 2 ) , 0 ) ; // profilerBlock <- 0.
539
- Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . detached } } } >> 2 ) , threadParams . detached ) ;
539
+ Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . detach_state } } } >> 2 ) , threadParams . detached ) ;
540
540
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd } } } >> 2 ) , tlsMemory ) ; // Init thread-local-storage memory array.
541
541
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd_used } } } >> 2 ) , 0 ) ; // Mark initial status to unused.
542
542
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tid } } } >> 2 ) , pthread . threadInfoStruct ) ; // Main thread ID.
543
+
543
544
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack_size } } } >> 2 ) , threadParams . stackSize ) ;
544
545
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack } } } >> 2 ) , stackHigh ) ;
545
546
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . attr } } } >> 2 ) , threadParams . stackSize ) ;
@@ -862,7 +863,7 @@ var LibraryPThread = {
862
863
return ERRNO_CODES . ESRCH ;
863
864
}
864
865
865
- var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 ) ;
866
+ var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 ) ;
866
867
if ( detached ) {
867
868
err ( 'Attempted to join thread ' + thread + ', which was already detached!' ) ;
868
869
return ERRNO_CODES . EINVAL ; // The thread is already detached, can no longer join it!
@@ -879,7 +880,7 @@ var LibraryPThread = {
879
880
if ( threadStatus == 1 ) { // Exited?
880
881
var threadExitCode = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . threadExitCode } } } ) >> 2 ) ;
881
882
if ( status ) { { { makeSetValue ( 'status' , 0 , 'threadExitCode' , 'i32' ) } } } ;
882
- Atomics . store ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 , 1 ) ; // Mark the thread as detached.
883
+ Atomics . store ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 , 1 ) ; // Mark the thread as detached.
883
884
884
885
if ( ! ENVIRONMENT_IS_PTHREAD ) cleanupThread ( thread ) ;
885
886
else postMessage ( { 'cmd' : 'cleanupThread' , 'thread' : thread } ) ;
@@ -968,7 +969,7 @@ var LibraryPThread = {
968
969
// Follow musl convention: detached:0 means not detached, 1 means the thread
969
970
// was created as detached, and 2 means that the thread was detached via
970
971
// pthread_detach.
971
- var wasDetached = Atomics . compareExchange ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 , 0 , 2 ) ;
972
+ var wasDetached = Atomics . compareExchange ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 , 0 , 2 ) ;
972
973
973
974
return wasDetached ? ERRNO_CODES . EINVAL : 0 ;
974
975
} ,
0 commit comments