@@ -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 }
@@ -536,10 +536,11 @@ var LibraryPThread = {
536536 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . threadStatus } } } >> 2 ) , 0 ) ; // threadStatus <- 0, meaning not yet exited.
537537 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . threadExitCode } } } >> 2 ) , 0 ) ; // threadExitCode <- 0.
538538 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 ) ;
540540 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd } } } >> 2 ) , tlsMemory ) ; // Init thread-local-storage memory array.
541541 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd_used } } } >> 2 ) , 0 ) ; // Mark initial status to unused.
542542 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tid } } } >> 2 ) , pthread . threadInfoStruct ) ; // Main thread ID.
543+
543544 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack_size } } } >> 2 ) , threadParams . stackSize ) ;
544545 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack } } } >> 2 ) , stackHigh ) ;
545546 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . attr } } } >> 2 ) , threadParams . stackSize ) ;
@@ -862,7 +863,7 @@ var LibraryPThread = {
862863 return ERRNO_CODES . ESRCH ;
863864 }
864865
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 ) ;
866867 if ( detached ) {
867868 err ( 'Attempted to join thread ' + thread + ', which was already detached!' ) ;
868869 return ERRNO_CODES . EINVAL ; // The thread is already detached, can no longer join it!
@@ -879,7 +880,7 @@ var LibraryPThread = {
879880 if ( threadStatus == 1 ) { // Exited?
880881 var threadExitCode = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . threadExitCode } } } ) >> 2 ) ;
881882 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.
883884
884885 if ( ! ENVIRONMENT_IS_PTHREAD ) cleanupThread ( thread ) ;
885886 else postMessage ( { 'cmd' : 'cleanupThread' , 'thread' : thread } ) ;
@@ -968,7 +969,7 @@ var LibraryPThread = {
968969 // Follow musl convention: detached:0 means not detached, 1 means the thread
969970 // was created as detached, and 2 means that the thread was detached via
970971 // 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 ) ;
972973
973974 return wasDetached ? ERRNO_CODES . EINVAL : 0 ;
974975 } ,
0 commit comments