@@ -366,7 +366,7 @@ var LibraryPThread = {
366
366
} else if ( cmd === 'alert' ) {
367
367
alert ( 'Thread ' + d [ 'threadId' ] + ': ' + d [ 'text' ] ) ;
368
368
} else if ( cmd === 'exit' ) {
369
- var detached = worker . pthread && Atomics . load ( HEAPU32 , ( worker . pthread . threadInfoStruct + { { { C_STRUCTS . pthread . detached } } } ) >> 2 ) ;
369
+ var detached = worker . pthread && Atomics . load ( HEAPU32 , ( worker . pthread . threadInfoStruct + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 ) ;
370
370
if ( detached ) {
371
371
PThread . returnWorkerToPool ( worker ) ;
372
372
}
@@ -554,9 +554,10 @@ var LibraryPThread = {
554
554
var tis = pthread . threadInfoStruct >> 2 ;
555
555
// spawnThread is always called with a zero-initialized thread struct so
556
556
// no need to set any valudes to zero here.
557
- Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . detached } } } >> 2 ) , threadParams . detached ) ;
557
+ Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . detach_state } } } >> 2 ) , threadParams . detached ) ;
558
558
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd } } } >> 2 ) , tlsMemory ) ; // Init thread-local-storage memory array.
559
559
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tid } } } >> 2 ) , pthread . threadInfoStruct ) ; // Main thread ID.
560
+
560
561
Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack_size } } } >> 2 ) , threadParams . stackSize ) ;
561
562
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack } } } >> 2 ) , stackHigh ) ;
562
563
Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . attr } } } >> 2 ) , threadParams . stackSize ) ;
@@ -879,7 +880,7 @@ var LibraryPThread = {
879
880
return ERRNO_CODES . ESRCH ;
880
881
}
881
882
882
- var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 ) ;
883
+ var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 ) ;
883
884
if ( detached ) {
884
885
err ( 'Attempted to join thread ' + thread + ', which was already detached!' ) ;
885
886
return ERRNO_CODES . EINVAL ; // The thread is already detached, can no longer join it!
@@ -896,7 +897,7 @@ var LibraryPThread = {
896
897
if ( threadStatus == 1 ) { // Exited?
897
898
var threadExitCode = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . threadExitCode } } } ) >> 2 ) ;
898
899
if ( status ) { { { makeSetValue ( 'status' , 0 , 'threadExitCode' , 'i32' ) } } } ;
899
- Atomics . store ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 , 1 ) ; // Mark the thread as detached.
900
+ Atomics . store ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 , 1 ) ; // Mark the thread as detached.
900
901
901
902
if ( ! ENVIRONMENT_IS_PTHREAD ) cleanupThread ( thread ) ;
902
903
else postMessage ( { 'cmd' : 'cleanupThread' , 'thread' : thread } ) ;
@@ -985,7 +986,7 @@ var LibraryPThread = {
985
986
// Follow musl convention: detached:0 means not detached, 1 means the thread
986
987
// was created as detached, and 2 means that the thread was detached via
987
988
// pthread_detach.
988
- var wasDetached = Atomics . compareExchange ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 , 0 , 2 ) ;
989
+ var wasDetached = Atomics . compareExchange ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 , 0 , 2 ) ;
989
990
990
991
return wasDetached ? ERRNO_CODES . EINVAL : 0 ;
991
992
} ,
0 commit comments