#include <machine/asm.h>
#include <asm/unistd.h>
-// void _exit_with_stack_teardown(void* stackBase, int stackSize, int retCode)
+// void _exit_with_stack_teardown(void* stackBase, int stackSize, int status)
ENTRY(_exit_with_stack_teardown)
mov lr, r2
ldr r7, =__NR_munmap
.text
-/* void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode) */
+// void _exit_with_stack_teardown(void * stackBase, int stackSize, int status)
.type _exit_with_stack_teardown, @function
.global _exit_with_stack_teardown
.align 4
.ent _exit_with_stack_teardown
_exit_with_stack_teardown:
- move $s0,$a2 /* preserve retCode for exit() call */
+ move $s0,$a2 /* preserve status for exit() call */
li $v0,__NR_munmap
syscall /* the stack is destroyed by this call */
#include <asm/unistd.h>
#include <machine/asm.h>
-// void _exit_with_stack_teardown(void* stackBase, int stackSize, int retCode)
+// void _exit_with_stack_teardown(void* stackBase, int stackSize, int status)
ENTRY(_exit_with_stack_teardown)
// We can trash %ebx here since this call should never return.
// We can also take advantage of the fact that the linux syscall trap
// handler saves all the registers, so we don't need a stack to keep
- // the retCode argument for exit while doing the munmap */
+ // the status argument for exit while doing the munmap */
mov 4(%esp), %ebx // stackBase
mov 8(%esp), %ecx // stackSize
mov $__NR_munmap, %eax
// If munmap failed, we ignore the failure and exit anyway.
- mov %edx, %ebx // retCode
+ mov %edx, %ebx // status
movl $__NR_exit, %eax
int $0x80
#include <asm/unistd.h>
#include <machine/asm.h>
-// void _exit_with_stack_teardown(void* stackBase, int stackSize, int retCode)
+// void _exit_with_stack_teardown(void* stackBase, int stackSize, int status)
ENTRY(_exit_with_stack_teardown)
// We take advantage of the fact that the linux syscall trap
// handler saves all the registers, so we don't need to save
- // the retCode argument for exit(2) while doing the munmap(2).
+ // the status argument for exit(2) while doing the munmap(2).
mov $__NR_munmap, %eax
syscall
// If munmap failed, ignore the failure and exit anyway.
- mov %rdx, %rdi // retCode
+ mov %rdx, %rdi // status
mov $__NR_exit, %eax
syscall
int (*fn)(void *),
void *arg);
-extern void _exit_thread(int retCode);
+extern void _exit_thread(int status);
/* this function is called from the __bionic_clone
* assembly fragment to call the thread function
* then exit. */
-extern void
-__bionic_clone_entry( int (*fn)(void *), void *arg )
-{
- int ret = (*fn)(arg);
- _exit_thread(ret);
+extern void __bionic_clone_entry(int (*fn)(void*), void* arg) {
+ int status = (*fn)(arg);
+ _exit_thread(status);
}
-int
-clone(int (*fn)(void *), void *child_stack, int flags, void* arg, ...)
-{
+int clone(int (*fn)(void*), void* child_stack, int flags, void* arg, ...) {
va_list args;
int *parent_tidptr = NULL;
void *new_tls = NULL;
extern void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex);
extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex);
-extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode);
-extern void _exit_thread(int retCode);
+extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int status);
+extern void _exit_thread(int status);
int __futex_wake_ex(volatile void *ftx, int pshared, int val)
{
sigfillset(&mask);
sigdelset(&mask, SIGSEGV);
- (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
- // destroy the thread stack
if (user_stack) {
- _exit_thread((int)retval);
+ // Cleaning up this thread's stack is the creator's responsibility, not ours.
+ _exit_thread(0);
} else {
// We need to munmap the stack we're running on before calling exit.
// That's not something we can do in C.
- _exit_with_stack_teardown(stack_base, stack_size, (int)retval);
+ _exit_with_stack_teardown(stack_base, stack_size, 0);
}
}