Merge "Had include/arm/fenv.h, but missed include/mips/fenv.h."
diff --git a/libc/arch-arm/bionic/clone.S b/libc/arch-arm/bionic/clone.S
index a95d2d6..7ff3d0d 100644
--- a/libc/arch-arm/bionic/clone.S
+++ b/libc/arch-arm/bionic/clone.S
@@ -30,8 +30,7 @@
 
 ENTRY(__pthread_clone)
     @ insert the args onto the new stack
-    str     r0, [r1, #-4]
-    str     r3, [r1, #-8]
+    stmdb r1!, {r0, r3}
 
     @ do the system call
     @ get flags
@@ -60,8 +59,7 @@
     @ to the C __thread_entry function which does some setup and then
     @ calls the thread's start function
 
-    ldr     r0, [sp, #-4]
-    ldr     r1, [sp, #-8]
+    pop     {r0, r1}
     mov     r2, sp			@ __thread_entry needs the TLS pointer
     b       __thread_entry
 
diff --git a/libc/kernel/arch-mips/asm/mman.h b/libc/kernel/arch-mips/asm/mman.h
index 9e51c67..c5b93a4 100644
--- a/libc/kernel/arch-mips/asm/mman.h
+++ b/libc/kernel/arch-mips/asm/mman.h
@@ -47,22 +47,34 @@
 #define MAP_POPULATE 0x10000  
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAP_NONBLOCK 0x20000  
+#define MAP_STACK 0x40000  
+#define MAP_HUGETLB 0x80000  
 #define MS_ASYNC 0x0001  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_INVALIDATE 0x0002  
 #define MS_SYNC 0x0004  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MCL_CURRENT 1  
 #define MCL_FUTURE 2  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_NORMAL 0  
 #define MADV_RANDOM 1  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_SEQUENTIAL 2  
 #define MADV_WILLNEED 3  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_DONTNEED 4  
 #define MADV_REMOVE 9  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_DONTFORK 10  
 #define MADV_DOFORK 11  
-#define MAP_FILE 0
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_MERGEABLE 12  
+#define MADV_UNMERGEABLE 13  
+#define MADV_HWPOISON 100  
+#define MADV_HUGEPAGE 14  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_NOHUGEPAGE 15  
+#define MADV_DONTDUMP 16  
+#define MADV_DODUMP 17  
+#define MAP_FILE 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index f4bcab9..55b7132 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -131,6 +131,7 @@
 	if (__atexit_invalid)
 		return;
 
+	_ATEXIT_LOCK();
 	call_depth++;
 
 	for (p = __atexit; p != NULL; p = p->next) {
@@ -149,6 +150,7 @@
 				p->fns[n].fn_ptr.cxa_func = NULL;
 				mprotect(p, pgsize, PROT_READ);
 			}
+			_ATEXIT_UNLOCK();
 #if ANDROID
                         /* it looks like we should always call the function
                          * with an argument, even if dso is not NULL. Otherwise
@@ -162,6 +164,7 @@
 			else
 				(*fn.fn_ptr.std_func)();
 #endif /* !ANDROID */
+			_ATEXIT_LOCK();
 		}
 	}
 
@@ -178,6 +181,7 @@
 		}
 		__atexit = NULL;
 	}
+	_ATEXIT_UNLOCK();
 }
 
 /*