@@ -364,7 +364,7 @@ var LibraryPThread = {
364364 } else if ( cmd === 'alert' ) {
365365 alert ( 'Thread ' + d [ 'threadId' ] + ': ' + d [ 'text' ] ) ;
366366 } 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 ) ;
368368 if ( detached ) {
369369 PThread . returnWorkerToPool ( worker ) ;
370370 }
@@ -538,9 +538,10 @@ var LibraryPThread = {
538538 var tis = pthread . threadInfoStruct >> 2 ;
539539 // spawnThread is always called with a zero-initialized thread struct so
540540 // no need to set any valudes to zero here.
541- Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . detached } } } >> 2 ) , threadParams . detached ) ;
541+ Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . detach_state } } } >> 2 ) , threadParams . detached ) ;
542542 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd } } } >> 2 ) , tlsMemory ) ; // Init thread-local-storage memory array.
543543 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tid } } } >> 2 ) , pthread . threadInfoStruct ) ; // Main thread ID.
544+
544545 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack_size } } } >> 2 ) , threadParams . stackSize ) ;
545546 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack } } } >> 2 ) , stackHigh ) ;
546547 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . attr } } } >> 2 ) , threadParams . stackSize ) ;
@@ -863,7 +864,7 @@ var LibraryPThread = {
863864 return ERRNO_CODES . ESRCH ;
864865 }
865866
866- var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 ) ;
867+ var detached = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 ) ;
867868 if ( detached ) {
868869 err ( 'Attempted to join thread ' + thread + ', which was already detached!' ) ;
869870 return ERRNO_CODES . EINVAL ; // The thread is already detached, can no longer join it!
@@ -880,7 +881,7 @@ var LibraryPThread = {
880881 if ( threadStatus == 1 ) { // Exited?
881882 var threadExitCode = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . threadExitCode } } } ) >> 2 ) ;
882883 if ( status ) { { { makeSetValue ( 'status' , 0 , 'threadExitCode' , 'i32' ) } } } ;
883- Atomics . store ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 , 1 ) ; // Mark the thread as detached.
884+ Atomics . store ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 , 1 ) ; // Mark the thread as detached.
884885
885886 if ( ! ENVIRONMENT_IS_PTHREAD ) cleanupThread ( thread ) ;
886887 else postMessage ( { 'cmd' : 'cleanupThread' , 'thread' : thread } ) ;
@@ -969,7 +970,7 @@ var LibraryPThread = {
969970 // Follow musl convention: detached:0 means not detached, 1 means the thread
970971 // was created as detached, and 2 means that the thread was detached via
971972 // pthread_detach.
972- var wasDetached = Atomics . compareExchange ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detached } } } ) >> 2 , 0 , 2 ) ;
973+ var wasDetached = Atomics . compareExchange ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . detach_state } } } ) >> 2 , 0 , 2 ) ;
973974
974975 return wasDetached ? ERRNO_CODES . EINVAL : 0 ;
975976 } ,
0 commit comments