123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #include <stdlib.h>
- #include "pthread.h"
- #include "implement.h"
- int
- pthread_spin_destroy (pthread_spinlock_t * lock)
- {
- register pthread_spinlock_t s;
- int result = 0;
- if (lock == NULL || *lock == NULL)
- {
- return EINVAL;
- }
- if ((s = *lock) != PTHREAD_SPINLOCK_INITIALIZER)
- {
- if (s->interlock == PTE_SPIN_USE_MUTEX)
- {
- result = pthread_mutex_destroy (&(s->u.mutex));
- }
- else if (PTE_SPIN_UNLOCKED !=
- PTE_ATOMIC_COMPARE_EXCHANGE (
- & (s->interlock),
- (int) PTE_OBJECT_INVALID,
- PTE_SPIN_UNLOCKED))
- {
- result = EINVAL;
- }
- if (0 == result)
- {
-
- *lock = NULL;
- (void) free (s);
- }
- }
- else
- {
-
- pte_osMutexLock (pte_spinlock_test_init_lock);
-
- if (*lock == PTHREAD_SPINLOCK_INITIALIZER)
- {
-
- *lock = NULL;
- }
- else
- {
-
- result = EBUSY;
- }
- pte_osMutexUnlock(pte_spinlock_test_init_lock);
- }
- return (result);
- }
|