@@ -366,7 +366,7 @@ var LibraryPThread = {
366366 } else if ( cmd === 'alert' ) {
367367 alert ( 'Thread ' + d [ 'threadId' ] + ': ' + d [ 'text' ] ) ;
368368 } 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 ) ;
370370 if ( detached ) {
371371 PThread . returnWorkerToPool ( worker ) ;
372372 }
@@ -554,9 +554,10 @@ var LibraryPThread = {
554554 var tis = pthread . threadInfoStruct >> 2 ;
555555 // spawnThread is always called with a zero-initialized thread struct so
556556 // 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 ) ;
558558 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tsd } } } >> 2 ) , tlsMemory ) ; // Init thread-local-storage memory array.
559559 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . tid } } } >> 2 ) , pthread . threadInfoStruct ) ; // Main thread ID.
560+
560561 Atomics. store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack_size } } } >> 2 ) , threadParams . stackSize ) ;
561562 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . stack } } } >> 2 ) , stackHigh ) ;
562563 Atomics . store ( HEAPU32 , tis + ( { { { C_STRUCTS . pthread . attr } } } >> 2 ) , threadParams . stackSize ) ;
@@ -879,7 +880,7 @@ var LibraryPThread = {
879880 return ERRNO_CODES . ESRCH ;
880881 }
881882
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 ) ;
883884 if ( detached ) {
884885 err ( 'Attempted to join thread ' + thread + ', which was already detached!' ) ;
885886 return ERRNO_CODES . EINVAL ; // The thread is already detached, can no longer join it!
@@ -896,7 +897,7 @@ var LibraryPThread = {
896897 if ( threadStatus == 1 ) { // Exited?
897898 var threadExitCode = Atomics . load ( HEAPU32 , ( thread + { { { C_STRUCTS . pthread . threadExitCode } } } ) >> 2 ) ;
898899 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.
900901
901902 if ( ! ENVIRONMENT_IS_PTHREAD ) cleanupThread ( thread ) ;
902903 else postMessage ( { 'cmd' : 'cleanupThread' , 'thread' : thread } ) ;
@@ -985,7 +986,7 @@ var LibraryPThread = {
985986 // Follow musl convention: detached:0 means not detached, 1 means the thread
986987 // was created as detached, and 2 means that the thread was detached via
987988 // 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 ) ;
989990
990991 return wasDetached ? ERRNO_CODES . EINVAL : 0 ;
991992 } ,
0 commit comments