Changeset 8fe1cdb in mainline
- Timestamp:
- 2006-04-01T15:20:20Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0319a8f6
- Parents:
- c4c5de5
- Location:
- libc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/include/futex.h
rc4c5de5 r8fe1cdb 33 33 #include <types.h> 34 34 35 #define FUTEX_INITIALIZER {1} 36 35 37 extern void futex_initialize(atomic_t *futex, int value); 36 38 extern int futex_down(atomic_t *futex); -
libc/malloc/malloc.c
rc4c5de5 r8fe1cdb 462 462 #define ABORT_ON_ASSERT_FAILURE 1 463 463 #define PROCEED_ON_ERROR 0 464 #define USE_LOCKS 0464 #define USE_LOCKS 1 465 465 #define INSECURE 0 466 466 #define HAVE_MMAP 0 … … 764 764 */ 765 765 766 #ifndef WIN32767 766 /* By default use posix locks */ 768 #include <pthread.h> 769 #define MLOCK_T pthread_mutex_t 770 #define INITIAL_LOCK(l) pthread_mutex_init(l, NULL) 771 #define ACQUIRE_LOCK(l) pthread_mutex_lock(l) 772 #define RELEASE_LOCK(l) pthread_mutex_unlock(l) 767 #include <futex.h> 768 #define MLOCK_T atomic_t 769 #define INITIAL_LOCK(l) futex_initialize(l, 1) 770 /* futex_down cannot fail, but can return different 771 * retvals for OK 772 */ 773 #define ACQUIRE_LOCK(l) ({futex_down(l);0;}) 774 #define RELEASE_LOCK(l) futex_up(l) 773 775 774 776 #if HAVE_MORECORE 775 static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER;777 static MLOCK_T morecore_mutex = FUTEX_INITIALIZER; 776 778 #endif /* HAVE_MORECORE */ 777 779 778 static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; 779 780 #else /* WIN32 */ 781 /* 782 Because lock-protected regions have bounded times, and there 783 are no recursive lock calls, we can use simple spinlocks. 784 */ 785 786 #define MLOCK_T long 787 static int win32_acquire_lock (MLOCK_T *sl) { 788 for (;;) { 789 #ifdef InterlockedCompareExchangePointer 790 if (!InterlockedCompareExchange(sl, 1, 0)) 791 return 0; 792 #else /* Use older void* version */ 793 if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0)) 794 return 0; 795 #endif /* InterlockedCompareExchangePointer */ 796 Sleep (0); 797 } 798 } 799 800 static void win32_release_lock (MLOCK_T *sl) { 801 InterlockedExchange (sl, 0); 802 } 803 804 #define INITIAL_LOCK(l) *(l)=0 805 #define ACQUIRE_LOCK(l) win32_acquire_lock(l) 806 #define RELEASE_LOCK(l) win32_release_lock(l) 807 #if HAVE_MORECORE 808 static MLOCK_T morecore_mutex; 809 #endif /* HAVE_MORECORE */ 810 static MLOCK_T magic_init_mutex; 811 #endif /* WIN32 */ 780 static MLOCK_T magic_init_mutex = FUTEX_INITIALIZER; 781 812 782 813 783 #define USE_LOCK_BIT (2U)
Note:
See TracChangeset
for help on using the changeset viewer.