physfs_internal.h
changeset 145 d6385584f6c4
parent 137 66bddb94b6e0
child 150 221f15a7cb08
equal deleted inserted replaced
144:819455c581e5 145:d6385584f6c4
   302 
   302 
   303 
   303 
   304 /* These get used all over for lessening code clutter. */
   304 /* These get used all over for lessening code clutter. */
   305 #define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; }
   305 #define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; }
   306 #define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; }
   306 #define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; }
       
   307 #define BAIL_MACRO_MUTEX(e, m, r) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; }
       
   308 #define BAIL_IF_MACRO_MUTEX(c, e, m, r) if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; }
   307 
   309 
   308 
   310 
   309 
   311 
   310 
   312 
   311 /*--------------------------------------------------------------------------*/
   313 /*--------------------------------------------------------------------------*/
   631  * On error, return zero and set the error message. Return non-zero on success.
   633  * On error, return zero and set the error message. Return non-zero on success.
   632  */
   634  */
   633 int __PHYSFS_platformDelete(const char *path);
   635 int __PHYSFS_platformDelete(const char *path);
   634 
   636 
   635 
   637 
       
   638 /*
       
   639  * Create a platform-specific mutex. This can be whatever datatype your
       
   640  *  platform uses for mutexes, but it is cast to a (void *) for abstractness.
       
   641  *
       
   642  * Return (NULL) if you couldn't create one. Systems without threads can
       
   643  *  return any arbitrary non-NULL value.
       
   644  */
       
   645 void *__PHYSFS_platformCreateMutex(void);
       
   646 
       
   647 /*
       
   648  * Destroy a platform-specific mutex, and clean up any resources associated
       
   649  *  with it. (mutex) is a value previously returned by
       
   650  *  __PHYSFS_platformCreateMutex(). This can be a no-op on single-threaded
       
   651  *  platforms.
       
   652  */
       
   653 void __PHYSFS_platformDestroyMutex(void *mutex);
       
   654 
       
   655 /*
       
   656  * Grab possession of a platform-specific mutex. Mutexes should be recursive;
       
   657  *  that is, the same thread should be able to call this function multiple
       
   658  *  times in a row without causing a deadlock. This function should block 
       
   659  *  until a thread can gain possession of the mutex.
       
   660  *
       
   661  * Return non-zero if the mutex was grabbed, zero if there was an 
       
   662  *  unrecoverable problem grabbing it (this should not be a matter of 
       
   663  *  timing out! We're talking major system errors; block until the mutex 
       
   664  *  is available otherwise.)
       
   665  */
       
   666 int __PHYSFS_platformGrabMutex(void *mutex);
       
   667 
       
   668 /*
       
   669  * Relinquish possession of the mutex when this method has been called 
       
   670  *  once for each time that platformGrabMutex was called. Once possession has
       
   671  *  been released, the next thread in line to grab the mutex (if any) may
       
   672  *  proceed.
       
   673  */
       
   674 void __PHYSFS_platformReleaseMutex(void *mutex);
       
   675 
   636 #ifdef __cplusplus
   676 #ifdef __cplusplus
   637 }
   677 }
   638 #endif
   678 #endif
   639 
   679 
   640 #endif
   680 #endif