src/thread/pthread/SDL_syssem.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/thread/pthread/SDL_syssem.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/thread/pthread/SDL_syssem.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -41,102 +41,102 @@
     1.4  
     1.5  /* Create a semaphore, initialized with value */
     1.6  SDL_sem *
     1.7 -SDL_CreateSemaphore (Uint32 initial_value)
     1.8 +SDL_CreateSemaphore(Uint32 initial_value)
     1.9  {
    1.10 -    SDL_sem *sem = (SDL_sem *) SDL_malloc (sizeof (SDL_sem));
    1.11 +    SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
    1.12      if (sem) {
    1.13 -        if (sem_init (&sem->sem, 0, initial_value) < 0) {
    1.14 -            SDL_SetError ("sem_init() failed");
    1.15 -            SDL_free (sem);
    1.16 +        if (sem_init(&sem->sem, 0, initial_value) < 0) {
    1.17 +            SDL_SetError("sem_init() failed");
    1.18 +            SDL_free(sem);
    1.19              sem = NULL;
    1.20          }
    1.21      } else {
    1.22 -        SDL_OutOfMemory ();
    1.23 +        SDL_OutOfMemory();
    1.24      }
    1.25      return sem;
    1.26  }
    1.27  
    1.28  void
    1.29 -SDL_DestroySemaphore (SDL_sem * sem)
    1.30 +SDL_DestroySemaphore(SDL_sem * sem)
    1.31  {
    1.32      if (sem) {
    1.33 -        sem_destroy (&sem->sem);
    1.34 -        SDL_free (sem);
    1.35 +        sem_destroy(&sem->sem);
    1.36 +        SDL_free(sem);
    1.37      }
    1.38  }
    1.39  
    1.40  int
    1.41 -SDL_SemTryWait (SDL_sem * sem)
    1.42 +SDL_SemTryWait(SDL_sem * sem)
    1.43  {
    1.44      int retval;
    1.45  
    1.46      if (!sem) {
    1.47 -        SDL_SetError ("Passed a NULL semaphore");
    1.48 +        SDL_SetError("Passed a NULL semaphore");
    1.49          return -1;
    1.50      }
    1.51      retval = SDL_MUTEX_TIMEDOUT;
    1.52 -    if (sem_trywait (&sem->sem) == 0) {
    1.53 +    if (sem_trywait(&sem->sem) == 0) {
    1.54          retval = 0;
    1.55      }
    1.56      return retval;
    1.57  }
    1.58  
    1.59  int
    1.60 -SDL_SemWait (SDL_sem * sem)
    1.61 +SDL_SemWait(SDL_sem * sem)
    1.62  {
    1.63      int retval;
    1.64  
    1.65      if (!sem) {
    1.66 -        SDL_SetError ("Passed a NULL semaphore");
    1.67 +        SDL_SetError("Passed a NULL semaphore");
    1.68          return -1;
    1.69      }
    1.70  
    1.71 -    retval = sem_wait (&sem->sem);
    1.72 +    retval = sem_wait(&sem->sem);
    1.73      if (retval < 0) {
    1.74 -        SDL_SetError ("sem_wait() failed");
    1.75 +        SDL_SetError("sem_wait() failed");
    1.76      }
    1.77      return retval;
    1.78  }
    1.79  
    1.80  int
    1.81 -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout)
    1.82 +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
    1.83  {
    1.84      int retval;
    1.85  
    1.86      if (!sem) {
    1.87 -        SDL_SetError ("Passed a NULL semaphore");
    1.88 +        SDL_SetError("Passed a NULL semaphore");
    1.89          return -1;
    1.90      }
    1.91  
    1.92      /* Try the easy cases first */
    1.93      if (timeout == 0) {
    1.94 -        return SDL_SemTryWait (sem);
    1.95 +        return SDL_SemTryWait(sem);
    1.96      }
    1.97      if (timeout == SDL_MUTEX_MAXWAIT) {
    1.98 -        return SDL_SemWait (sem);
    1.99 +        return SDL_SemWait(sem);
   1.100      }
   1.101  
   1.102      /* Ack!  We have to busy wait... */
   1.103      /* FIXME: Use sem_timedwait()? */
   1.104 -    timeout += SDL_GetTicks ();
   1.105 +    timeout += SDL_GetTicks();
   1.106      do {
   1.107 -        retval = SDL_SemTryWait (sem);
   1.108 +        retval = SDL_SemTryWait(sem);
   1.109          if (retval == 0) {
   1.110              break;
   1.111          }
   1.112 -        SDL_Delay (1);
   1.113 +        SDL_Delay(1);
   1.114      }
   1.115 -    while (SDL_GetTicks () < timeout);
   1.116 +    while (SDL_GetTicks() < timeout);
   1.117  
   1.118      return retval;
   1.119  }
   1.120  
   1.121  Uint32
   1.122 -SDL_SemValue (SDL_sem * sem)
   1.123 +SDL_SemValue(SDL_sem * sem)
   1.124  {
   1.125      int ret = 0;
   1.126      if (sem) {
   1.127 -        sem_getvalue (&sem->sem, &ret);
   1.128 +        sem_getvalue(&sem->sem, &ret);
   1.129          if (ret < 0) {
   1.130              ret = 0;
   1.131          }
   1.132 @@ -145,18 +145,18 @@
   1.133  }
   1.134  
   1.135  int
   1.136 -SDL_SemPost (SDL_sem * sem)
   1.137 +SDL_SemPost(SDL_sem * sem)
   1.138  {
   1.139      int retval;
   1.140  
   1.141      if (!sem) {
   1.142 -        SDL_SetError ("Passed a NULL semaphore");
   1.143 +        SDL_SetError("Passed a NULL semaphore");
   1.144          return -1;
   1.145      }
   1.146  
   1.147 -    retval = sem_post (&sem->sem);
   1.148 +    retval = sem_post(&sem->sem);
   1.149      if (retval < 0) {
   1.150 -        SDL_SetError ("sem_post() failed");
   1.151 +        SDL_SetError("sem_post() failed");
   1.152      }
   1.153      return retval;
   1.154  }