src/platform_unix.c
changeset 1012 f254870dd7dd
parent 1003 a28d30d275e2
child 1016 957c97389257
equal deleted inserted replaced
1011:6bc1363ad17d 1012:f254870dd7dd
   345 } /* __PHYSFS_platformSetDefaultAllocator */
   345 } /* __PHYSFS_platformSetDefaultAllocator */
   346 
   346 
   347 
   347 
   348 #if (defined PHYSFS_NO_PTHREADS_SUPPORT)
   348 #if (defined PHYSFS_NO_PTHREADS_SUPPORT)
   349 
   349 
   350 PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) { return(0x0001); }
   350 void *__PHYSFS_platformGetThreadID(void) { return((void *) 0x0001); }
   351 void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
   351 void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
   352 void __PHYSFS_platformDestroyMutex(void *mutex) {}
   352 void __PHYSFS_platformDestroyMutex(void *mutex) {}
   353 int __PHYSFS_platformGrabMutex(void *mutex) { return(1); }
   353 int __PHYSFS_platformGrabMutex(void *mutex) { return(1); }
   354 void __PHYSFS_platformReleaseMutex(void *mutex) {}
   354 void __PHYSFS_platformReleaseMutex(void *mutex) {}
   355 
   355 
   360     pthread_mutex_t mutex;
   360     pthread_mutex_t mutex;
   361     pthread_t owner;
   361     pthread_t owner;
   362     PHYSFS_uint32 count;
   362     PHYSFS_uint32 count;
   363 } PthreadMutex;
   363 } PthreadMutex;
   364 
   364 
   365 /* Just in case; this is a panic value. */
   365 
   366 #if ((!defined SIZEOF_INT) || (SIZEOF_INT <= 0))
   366 void *__PHYSFS_platformGetThreadID(void)
   367 #  define SIZEOF_INT 4
   367 {
   368 #endif
   368     return( (void *) ((size_t) pthread_self()) );
   369 
       
   370 #if (SIZEOF_INT == 4)
       
   371 #  define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint32) (thr)) )
       
   372 #elif (SIZEOF_INT == 2)
       
   373 #  define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint16) (thr)) )
       
   374 #elif (SIZEOF_INT == 1)
       
   375 #  define PHTREAD_TO_UI64(thr) ( (PHYSFS_uint64) ((PHYSFS_uint8) (thr)) )
       
   376 #else
       
   377 #  define PHTREAD_TO_UI64(thr) ((PHYSFS_uint64) (thr))
       
   378 #endif
       
   379 
       
   380 PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
       
   381 {
       
   382     return(PHTREAD_TO_UI64(pthread_self()));
       
   383 } /* __PHYSFS_platformGetThreadID */
   369 } /* __PHYSFS_platformGetThreadID */
   384 
   370 
   385 
   371 
   386 void *__PHYSFS_platformCreateMutex(void)
   372 void *__PHYSFS_platformCreateMutex(void)
   387 {
   373 {