From: Nicholas Nethercote Date: Tue, 22 Jun 2004 14:18:42 +0000 (+0000) Subject: Convert VG_(exitcode), a global variable, into a local variable. X-Git-Tag: svn/VALGRIND_2_1_2~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17afdbd10728c1b50914a3d1ff1ebf0ce35c6315;p=thirdparty%2Fvalgrind.git Convert VG_(exitcode), a global variable, into a local variable. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2436 --- diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 652506d99b..9043e522ad 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -980,7 +980,7 @@ typedef /* The scheduler. */ -extern VgSchedReturnCode VG_(scheduler) ( void ); +extern VgSchedReturnCode VG_(scheduler) ( Int* exit_code ); extern void VG_(scheduler_init) ( void ); @@ -1474,11 +1474,6 @@ extern UInt VG_(dispatch_ctr); /* This is the ThreadId of the last thread the scheduler ran. */ extern ThreadId VG_(last_run_tid); -/* This is the argument to __NR_exit() supplied by the first thread to - call that syscall. We eventually pass that to __NR_exit() for - real. */ -extern Int VG_(exitcode); - /* If we're doing the default action of a fatal signal */ extern jmp_buf VG_(fatal_signal_jmpbuf); extern Bool VG_(fatal_signal_set); /* jmp_buf is valid */ diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 53b6c31c44..7f75ff26dd 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -179,11 +179,6 @@ ThreadId VG_(last_run_tid) = 0; descriptor or a socket descriptor. */ Bool VG_(logging_to_filedes) = True; -/* This is the argument to __NR_exit() supplied by the first thread to - call that syscall. We eventually pass that to __NR_exit() for - real. */ -Int VG_(exitcode) = 0; - /*====================================================================*/ /*=== Counters, for profiling purposes only ===*/ @@ -2633,6 +2628,7 @@ int main(int argc, char **argv) Addr esp_at_startup; /* client's %esp at the point we gained control. */ UInt * client_auxv; VgSchedReturnCode src; + Int exitcode = 0; vki_rlimit zero = { 0, 0 }; //============================================================ @@ -2976,7 +2972,7 @@ int main(int argc, char **argv) if (__builtin_setjmp(&VG_(fatal_signal_jmpbuf)) == 0) { VG_(fatal_signal_set) = True; - src = VG_(scheduler)(); + src = VG_(scheduler)( &exitcode ); } else src = VgSrc_FatalSig; @@ -3003,7 +2999,7 @@ int main(int argc, char **argv) if (VG_(needs).core_errors || VG_(needs).skin_errors) VG_(show_all_errors)(); - SK_(fini)( VG_(exitcode) ); + SK_(fini)( exitcode ); VG_(do_sanity_checks)( True /*include expensive checks*/ ); @@ -3045,7 +3041,7 @@ int main(int argc, char **argv) /* The thread's %EBX at the time it did __NR_exit() will hold the arg to __NR_exit(), so we just do __NR_exit() with that arg. */ - VG_(exit)( VG_(exitcode) ); + VG_(exit)( exitcode ); /* NOT ALIVE HERE! */ VG_(core_panic)("entered the afterlife in main() -- ExitSyscall"); break; /* what the hell :) */ diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 61a08eba89..5ef5834e6b 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -876,7 +876,7 @@ void idle ( void ) * One thread asks to shutdown Valgrind * The specified number of basic blocks has gone by. */ -VgSchedReturnCode VG_(scheduler) ( void ) +VgSchedReturnCode VG_(scheduler) ( Int* exitcode ) { ThreadId tid, tid_next; UInt trc; @@ -956,7 +956,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) /* All threads have exited - pretend someone called exit() */ if (n_waiting_for_reaper == n_exists) { - VG_(exitcode) = 0; /* ? */ + *exitcode = 0; /* ? */ return VgSrc_ExitSyscall; } @@ -1108,7 +1108,7 @@ VgSchedReturnCode VG_(scheduler) ( void ) ) { /* If __NR_exit, remember the supplied argument. */ - VG_(exitcode) = VG_(threads)[tid].m_ebx; /* syscall arg1 */ + *exitcode = VG_(threads)[tid].m_ebx; /* syscall arg1 */ /* Only run __libc_freeres if the tool says it's ok and it hasn't been overridden with --run-libc-freeres=no