platform/unix.c
changeset 145 d6385584f6c4
parent 137 66bddb94b6e0
child 171 0d92d6358410
equal deleted inserted replaced
144:819455c581e5 145:d6385584f6c4
   658     errno = 0;
   658     errno = 0;
   659     BAIL_IF_MACRO(remove(path) == -1, strerror(errno), 0);
   659     BAIL_IF_MACRO(remove(path) == -1, strerror(errno), 0);
   660     return(1);
   660     return(1);
   661 } /* __PHYSFS_platformDelete */
   661 } /* __PHYSFS_platformDelete */
   662 
   662 
       
   663 
       
   664 void *__PHYSFS_platformCreateMutex(void)
       
   665 {
       
   666     int rc;
       
   667     pthread_mutex_t *m = (pthread_mutex_t *) malloc(sizeof (pthread_mutex_t));
       
   668     BAIL_IF_MACRO(m == NULL, ERR_OUT_OF_MEMORY, NULL);
       
   669     rc = pthread_mutex_init(m, NULL);
       
   670     if (rc != 0)
       
   671     {
       
   672         free(m);
       
   673         BAIL_MACRO(strerror(rc), NULL);
       
   674     } /* if */
       
   675 
       
   676     return((void *) m);
       
   677 } /* __PHYSFS_platformCreateMutex */
       
   678 
       
   679 
       
   680 void __PHYSFS_platformDestroyMutex(void *mutex)
       
   681 {
       
   682     pthread_mutex_destroy((pthread_mutex_t *) mutex);
       
   683     free(mutex);
       
   684 } /* __PHYSFS_platformDestroyMutex */
       
   685 
       
   686 
       
   687 int __PHYSFS_platformGrabMutex(void *mutex)
       
   688 {
       
   689     return(pthread_mutex_lock((pthread_mutex_t *) mutex) == 0);    
       
   690 } /* __PHYSFS_platformGrabMutex */
       
   691 
       
   692 
       
   693 void __PHYSFS_platformReleaseMutex(void *mutex)
       
   694 {
       
   695     pthread_mutex_unlock((pthread_mutex_t *) mutex);
       
   696 } /* __PHYSFS_platformReleaseMutex */
       
   697 
   663 /* end of unix.c ... */
   698 /* end of unix.c ... */
   664 
   699