Commit 958e1e9f authored by chan's avatar chan
Browse files

Replaced by PTHREAD_MUTEX_INITIALIZER by pthread_mutex_init(...,NULL) because...

Replaced by PTHREAD_MUTEX_INITIALIZER by pthread_mutex_init(...,NULL) because strict C compiler like Sun's cc failed to compile PTHREAD_MUTEX_INITIALIZER on 32-bit linux because PTHREAD_MUTEX_INITIALIZER is implemented with C++ feature on 32bit linux.
parent 09a1222a
...@@ -19,7 +19,15 @@ ...@@ -19,7 +19,15 @@
#define MPE_ThreadID_t int #define MPE_ThreadID_t int
/* MPE coarse-grained lock support mechanism */ /* MPE coarse-grained lock support mechanism */
pthread_mutex_t MPE_Thread_mutex = PTHREAD_MUTEX_INITIALIZER; /*
pthread_mutex_t MPE_Thread_mutex = PTHREAD_MUTEX_INITIALIZER;
Replaced PTHREAD_MUTEX_INITIALIZER by pthread_mutex_init() as
Sun's cc for linux failed to compile PTHREAD_MUTEX_INITIALIZER because
Sun's cc is a strict C compiler and PTHREAD_MUTEX_INITIALIZER
implementation on 32bit linux uses C++ feature.
*/
pthread_mutex_t MPE_Thread_mutex;
pthread_key_t MPE_ThreadStm_key; pthread_key_t MPE_ThreadStm_key;
MPE_ThreadID_t MPE_Thread_count = 0; MPE_ThreadID_t MPE_Thread_count = 0;
...@@ -37,6 +45,11 @@ void MPE_Log_thread_init( void ) ...@@ -37,6 +45,11 @@ void MPE_Log_thread_init( void )
{ {
int thd_fn_rc; int thd_fn_rc;
MPE_Thread_count = 0; MPE_Thread_count = 0;
thd_fn_rc = pthread_mutex_init( &MPE_Thread_mutex, NULL );
if ( thd_fn_rc != 0 ) {
perror( "pthread_mutex_init() fails!" );
pthread_exit( NULL );
}
thd_fn_rc = pthread_key_create( &MPE_ThreadStm_key, MPE_ThreadStm_free ); thd_fn_rc = pthread_key_create( &MPE_ThreadStm_key, MPE_ThreadStm_free );
if ( thd_fn_rc != 0 ) { if ( thd_fn_rc != 0 ) {
perror( "pthread_key_create() fails!" ); perror( "pthread_key_create() fails!" );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment