- if( !Lock->ReaderWaiting ) {
- Lock->ReaderWaiting = malloc(sizeof(pthread_rwlock_t));
- pthread_rwlock_init( (void*)Lock->ReaderWaiting, 0 );
+ if( !*MutexPtr ) {
+ *MutexPtr = malloc( sizeof(pthread_mutex_t) );
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+ pthread_mutex_init(*MutexPtr, NULL);
+ }
+ if( pthread_mutex_lock(*MutexPtr) ) {
+ fprintf(stderr, "ERROR: Mutex pointer %p double locked\n", MutexPtr);
+ AcessNative_Exit();