]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Convert VG_(exitcode), a global variable, into a local variable.
authorNicholas Nethercote <n.nethercote@gmail.com>
Tue, 22 Jun 2004 14:18:42 +0000 (14:18 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Tue, 22 Jun 2004 14:18:42 +0000 (14:18 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2436

coregrind/vg_include.h
coregrind/vg_main.c
coregrind/vg_scheduler.c

index 652506d99b6503b585ce35212b315a988b1592b2..9043e522ad61afd711566286b12fae246f8d675c 100644 (file)
@@ -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 */
index 53b6c31c442d49a6a79329d55027401b61071c7e..7f75ff26dd5c52d2bd033c238e87607c28d374fc 100644 (file)
@@ -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 :) */
index 61a08eba896600951824bbeea2ec3a57dff9f5c7..5ef5834e6bdfa961dc136b237cc64951c2053ba7 100644 (file)
@@ -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