/* Free a mutex */ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp) { if (mutexp) { #ifdef TSRM_WIN32 DeleteCriticalSection(mutexp); free(mutexp); #elif defined(GNUPTH) free(mutexp); #elif defined(PTHREADS) pthread_mutex_destroy(mutexp); free(mutexp); #elif defined(NSAPI) crit_terminate(mutexp); #elif defined(PI3WEB) PISync_delete(mutexp); #elif defined(TSRM_ST) st_mutex_destroy(mutexp); #elif defined(BETHREADS) delete_sem(mutexp->sem); free(mutexp); #endif } #ifdef THR_DEBUG printf("Mutex freed thread: %d\n",mythreadid()); #endif }
/* Allocate a mutex */ TSRM_API MUTEX_T tsrm_mutex_alloc(void) { MUTEX_T mutexp; #ifdef TSRM_WIN32 mutexp = malloc(sizeof(CRITICAL_SECTION)); InitializeCriticalSection(mutexp); #elif defined(GNUPTH) mutexp = (MUTEX_T) malloc(sizeof(*mutexp)); pth_mutex_init(mutexp); #elif defined(PTHREADS) mutexp = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); pthread_mutex_init(mutexp,NULL); #elif defined(NSAPI) mutexp = crit_init(); #elif defined(PI3WEB) mutexp = PIPlatform_allocLocalMutex(); #elif defined(TSRM_ST) mutexp = st_mutex_new(); #elif defined(BETHREADS) mutexp = (beos_ben*)malloc(sizeof(beos_ben)); mutexp->ben = 0; mutexp->sem = create_sem(1, "PHP sempahore"); #endif #ifdef THR_DEBUG printf("Mutex created thread: %d\n",mythreadid()); #endif return( mutexp ); }
/* Free a mutex */ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp) {/*{{{*/ if (mutexp) { #ifdef TSRM_WIN32 DeleteCriticalSection(mutexp); free(mutexp); #elif defined(GNUPTH) free(mutexp); #elif defined(PTHREADS) pthread_mutex_destroy(mutexp); free(mutexp); #elif defined(TSRM_ST) st_mutex_destroy(mutexp); #endif } #ifdef THR_DEBUG printf("Mutex freed thread: %d\n",mythreadid()); #endif }/*}}}*/
/* Allocate a mutex */ TSRM_API MUTEX_T tsrm_mutex_alloc(void) {/*{{{*/ MUTEX_T mutexp; #ifdef TSRM_WIN32 mutexp = malloc(sizeof(CRITICAL_SECTION)); InitializeCriticalSection(mutexp); #elif defined(GNUPTH) mutexp = (MUTEX_T) malloc(sizeof(*mutexp)); pth_mutex_init(mutexp); #elif defined(PTHREADS) mutexp = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); pthread_mutex_init(mutexp,NULL); #elif defined(TSRM_ST) mutexp = st_mutex_new(); #endif #ifdef THR_DEBUG printf("Mutex created thread: %d\n",mythreadid()); #endif return( mutexp ); }/*}}}*/