Index: libc/malloc/malloc.c
===================================================================
--- libc/malloc/malloc.c	(revision 29a9f628c8583835e581747cfad7877e27f6d810)
+++ libc/malloc/malloc.c	(revision 6a347b1e3ccafd6fcaaca3d1b6a51b0df77b2d70)
@@ -462,5 +462,5 @@
 #define ABORT_ON_ASSERT_FAILURE 1
 #define PROCEED_ON_ERROR 0
-#define USE_LOCKS 0
+#define USE_LOCKS 1
 #define INSECURE 0
 #define HAVE_MMAP 0
@@ -764,50 +764,20 @@
 */
 
-#ifndef WIN32
 /* By default use posix locks */
-#include <pthread.h>
-#define MLOCK_T pthread_mutex_t
-#define INITIAL_LOCK(l)      pthread_mutex_init(l, NULL)
-#define ACQUIRE_LOCK(l)      pthread_mutex_lock(l)
-#define RELEASE_LOCK(l)      pthread_mutex_unlock(l)
+#include <futex.h>
+#define MLOCK_T atomic_t
+#define INITIAL_LOCK(l)      futex_initialize(l, 1)
+/* futex_down cannot fail, but can return different
+ * retvals for OK
+ */
+#define ACQUIRE_LOCK(l)      ({futex_down(l);0;})
+#define RELEASE_LOCK(l)      futex_up(l)
 
 #if HAVE_MORECORE
-static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER;
+static MLOCK_T morecore_mutex = FUTEX_INITIALIZER;
 #endif /* HAVE_MORECORE */
 
-static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-#else /* WIN32 */
-/*
-   Because lock-protected regions have bounded times, and there
-   are no recursive lock calls, we can use simple spinlocks.
-*/
-
-#define MLOCK_T long
-static int win32_acquire_lock (MLOCK_T *sl) {
-  for (;;) {
-#ifdef InterlockedCompareExchangePointer
-    if (!InterlockedCompareExchange(sl, 1, 0))
-      return 0;
-#else  /* Use older void* version */
-    if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0))
-      return 0;
-#endif /* InterlockedCompareExchangePointer */
-    Sleep (0);
-  }
-}
-
-static void win32_release_lock (MLOCK_T *sl) {
-  InterlockedExchange (sl, 0);
-}
-
-#define INITIAL_LOCK(l)      *(l)=0
-#define ACQUIRE_LOCK(l)      win32_acquire_lock(l)
-#define RELEASE_LOCK(l)      win32_release_lock(l)
-#if HAVE_MORECORE
-static MLOCK_T morecore_mutex;
-#endif /* HAVE_MORECORE */
-static MLOCK_T magic_init_mutex;
-#endif /* WIN32 */
+static MLOCK_T magic_init_mutex = FUTEX_INITIALIZER;
+
 
 #define USE_LOCK_BIT               (2U)
