diff options
Diffstat (limited to 'pthread_spin_destroy.c')
| -rw-r--r-- | pthread_spin_destroy.c | 65 | 
1 files changed, 34 insertions, 31 deletions
| diff --git a/pthread_spin_destroy.c b/pthread_spin_destroy.c index bf32e6b..3347597 100644 --- a/pthread_spin_destroy.c +++ b/pthread_spin_destroy.c @@ -39,7 +39,7 @@  int -pthread_spin_destroy(pthread_spinlock_t *lock) +pthread_spin_destroy (pthread_spinlock_t * lock)  {    register pthread_spinlock_t s;    int result = 0; @@ -52,16 +52,19 @@ pthread_spin_destroy(pthread_spinlock_t *lock)    if ((s = *lock) != PTHREAD_SPINLOCK_INITIALIZER)      {        if (s->interlock == PTW32_SPIN_USE_MUTEX) -        { -          result = pthread_mutex_destroy(&(s->u.mutex)); -        } -      else if ( (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != -		ptw32_interlocked_compare_exchange((PTW32_INTERLOCKED_LPLONG) &(s->interlock), -						   (PTW32_INTERLOCKED_LONG) PTW32_OBJECT_INVALID, -						   (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) -        { -          result = EINVAL; -        } +	{ +	  result = pthread_mutex_destroy (&(s->u.mutex)); +	} +      else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != +	       ptw32_interlocked_compare_exchange ((PTW32_INTERLOCKED_LPLONG) +						   & (s->interlock), +						   (PTW32_INTERLOCKED_LONG) +						   PTW32_OBJECT_INVALID, +						   (PTW32_INTERLOCKED_LONG) +						   PTW32_SPIN_UNLOCKED)) +	{ +	  result = EINVAL; +	}        if (0 == result)  	{ @@ -70,7 +73,7 @@ pthread_spin_destroy(pthread_spinlock_t *lock)  	   * have finished with the spinlock before destroying it.  	   */  	  *lock = NULL; -	  (void) free(s); +	  (void) free (s);  	}      }    else @@ -78,32 +81,32 @@ pthread_spin_destroy(pthread_spinlock_t *lock)        /*         * See notes in ptw32_spinlock_check_need_init() above also.         */ -      EnterCriticalSection(&ptw32_spinlock_test_init_lock); +      EnterCriticalSection (&ptw32_spinlock_test_init_lock);        /*         * Check again.         */        if (*lock == PTHREAD_SPINLOCK_INITIALIZER) -        { -          /* -           * This is all we need to do to destroy a statically -           * initialised spinlock that has not yet been used (initialised). -           * If we get to here, another thread -           * waiting to initialise this mutex will get an EINVAL. -           */ -          *lock = NULL; -        } +	{ +	  /* +	   * This is all we need to do to destroy a statically +	   * initialised spinlock that has not yet been used (initialised). +	   * If we get to here, another thread +	   * waiting to initialise this mutex will get an EINVAL. +	   */ +	  *lock = NULL; +	}        else -        { -          /* -           * The spinlock has been initialised while we were waiting -           * so assume it's in use. -           */ -          result = EBUSY; -        } +	{ +	  /* +	   * The spinlock has been initialised while we were waiting +	   * so assume it's in use. +	   */ +	  result = EBUSY; +	} -      LeaveCriticalSection(&ptw32_spinlock_test_init_lock); +      LeaveCriticalSection (&ptw32_spinlock_test_init_lock);      } -  return(result); +  return (result);  } | 
