]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Moved various pieces of linux/core_os.c to the modules that use them.
authorNicholas Nethercote <njn@valgrind.org>
Fri, 10 Jun 2005 22:59:56 +0000 (22:59 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Fri, 10 Jun 2005 22:59:56 +0000 (22:59 +0000)
Managed to kill linux/core_os.h, hooray.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3872

coregrind/core.h
coregrind/linux/Makefile.am
coregrind/linux/core_os.c
coregrind/linux/core_os.h
coregrind/m_main.c
coregrind/m_scheduler/scheduler.c
coregrind/pub_core_scheduler.h

index bd0b4cd431feeaa536d791b9104362edfe79a783..eb4f6b4e51837e54e585baefd1579dcca8ca6bba 100644 (file)
@@ -35,8 +35,6 @@
 #include "tool.h"          // tool stuff
 #include "core_arch.h"     // arch-specific stuff,  eg. x86/core_arch.h
 
-#include "core_os.h"       // OS-specific stuff,    eg. linux/core_os.h
-
 #include <setjmp.h>        // for jmp_buf
 
 #include "pub_core_mallocfree.h"  // for type 'ArenaId'
@@ -177,18 +175,9 @@ extern void
                                  Addr esp_at_startup,
                                  /*MOD*/ ThreadArchState* arch );
 
-// OS/Platform-specific thread clear (after thread exit)
-extern void VGO_(os_state_clear)(ThreadState *);
-
-// OS/Platform-specific thread init (at scheduler init time)
-extern void VGO_(os_state_init)(ThreadState *);
-
 // Run a thread from beginning to end. 
 extern VgSchedReturnCode VGO_(thread_wrapper)(Word /*ThreadId*/ tid);
 
-// Call here to exit the entire Valgrind system.
-extern void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src);
-
 // Allocates a stack for the first thread, then runs it,
 // as if the thread had been set up by clone()
 extern void VGP_(main_thread_wrapper_NORETURN)(ThreadId tid);
index efc2331562c3e2cc4f66dc891ed910874b5e23d6..4e7ee0854cd8b2e8cd198c0cdbeff0433d85f688 100644 (file)
@@ -1,9 +1,6 @@
 include $(top_srcdir)/Makefile.all.am
 include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
 
-noinst_HEADERS = \
-       core_os.h
-
 noinst_LIBRARIES = libos.a
 
 libos_a_SOURCES = \
index 517f51e3b93bc623c93ce834ff47dca906c074fd..d32455e1da4a159fa9b0f55f39b4e24adbf55fc6 100644 (file)
 #include "pub_core_signals.h"
 #include "pub_core_tooliface.h"
 
-void VGO_(os_state_clear)(ThreadState *tst)
-{
-   tst->os_state.lwpid = 0;
-   tst->os_state.threadgroup = 0;
-}
-
-void VGO_(os_state_init)(ThreadState *tst)
-{
-   tst->os_state.valgrind_stack_base = 0;
-   tst->os_state.valgrind_stack_szB  = 0;
-
-   VGO_(os_state_clear)(tst);
-}
-
 static Bool i_am_the_only_thread ( void )
 {
    Int c = VG_(count_living_threads)();
@@ -59,37 +45,6 @@ static Bool i_am_the_only_thread ( void )
    return c == 1;
 }
 
-
-void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src)
-{
-   VG_(debugLog)(1, "core_os", 
-                    "VGO_(terminate_NORETURN)(tid=%lld)\n", (ULong)tid);
-
-   vg_assert(VG_(count_living_threads)() == 0);
-
-   //--------------------------------------------------------------
-   // Exit, according to the scheduler's return code
-   //--------------------------------------------------------------
-   switch (src) {
-   case VgSrc_ExitSyscall: /* the normal way out */
-      VG_(exit)( VG_(threads)[tid].os_state.exitcode );
-      /* NOT ALIVE HERE! */
-      VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
-      break; /* what the hell :) */
-
-   case VgSrc_FatalSig:
-      /* We were killed by a fatal signal, so replicate the effect */
-      vg_assert(VG_(threads)[tid].os_state.fatalsig != 0);
-      VG_(kill_self)(VG_(threads)[tid].os_state.fatalsig);
-      VG_(core_panic)("main(): signal was supposed to be fatal");
-      break;
-
-   default:
-      VG_(core_panic)("main(): unexpected scheduler return code");
-   }
-}
-
-
 /* Run a thread from beginning to end and return the thread's
    scheduler-return-code. */
 
index f59fce93a5d2eb33d80ab2e8999916fe60497573..ae275e93c3150c91811d637cba1cb980904eeec1 100644 (file)
 #ifndef __LINUX_CORE_OS_H
 #define __LINUX_CORE_OS_H
 
-/* OS-specific thread state */
-typedef struct {
-   /* who we are */
-   Int lwpid;                  /* PID of kernel task */
-   Int threadgroup;            /* thread group id */
-
-   ThreadId parent;            /* parent tid (if any) */
-
-   /* runtime details */
-   Addr  valgrind_stack_base;  /* Valgrind's stack base */
-   SizeT valgrind_stack_szB;   /* stack size in bytes */
-
-   /* exit details */
-   Int  exitcode;              /* in the case of exitgroup, set by someone else */
-   Int  fatalsig;              /* fatal signal */
-} os_thread_t;
-
 #endif   // __LINUX_CORE_OS_H
 
 /*--------------------------------------------------------------------*/
index 5d58a979ceb05248cb73149a64433c1cac58f050..42152359db1c3d71219b8dd95c0617ed244fbe23 100644 (file)
@@ -2877,11 +2877,32 @@ void VG_(shutdown_actions_NORETURN) ( ThreadId tid,
    if (0)
        LibVEX_ShowAllocStats();
 
-   /* Ok, finally exit in the os-specific way.  In short, if the
-      (last) thread exited by calling sys_exit, do likewise; if the
-      (last) thread stopped due to a fatal signal, terminate the
-      entire system with that same fatal signal. */
-   VGO_(terminate_NORETURN)( tid, tids_schedretcode );
+   /* Ok, finally exit in the os-specific way, according to the scheduler's
+      return code.  In short, if the (last) thread exited by calling
+      sys_exit, do likewise; if the (last) thread stopped due to a fatal
+      signal, terminate the entire system with that same fatal signal. */
+   VG_(debugLog)(1, "core_os", 
+                    "VGO_(terminate_NORETURN)(tid=%lld)\n", (ULong)tid);
+
+   vg_assert(VG_(count_living_threads)() == 0);
+
+   switch (tids_schedretcode) {
+   case VgSrc_ExitSyscall: /* the normal way out */
+      VG_(exit)( VG_(threads)[tid].os_state.exitcode );
+      /* NOT ALIVE HERE! */
+      VG_(core_panic)("entered the afterlife in main() -- ExitSyscall");
+      break; /* what the hell :) */
+
+   case VgSrc_FatalSig:
+      /* We were killed by a fatal signal, so replicate the effect */
+      vg_assert(VG_(threads)[tid].os_state.fatalsig != 0);
+      VG_(kill_self)(VG_(threads)[tid].os_state.fatalsig);
+      VG_(core_panic)("main(): signal was supposed to be fatal");
+      break;
+
+   default:
+      VG_(core_panic)("main(): unexpected scheduler return code");
+   }
 }
 
 /*--------------------------------------------------------------------*/
index 43a4af226de6e12400efd1d1ea53cee42340ee15..722acfccd933448f3072c29caf8bc68138bcf3b7 100644 (file)
@@ -553,6 +553,20 @@ UInt run_thread_for_a_while ( ThreadId tid )
 }
 
 
+static void os_state_clear(ThreadState *tst)
+{
+   tst->os_state.lwpid = 0;
+   tst->os_state.threadgroup = 0;
+}
+
+static void os_state_init(ThreadState *tst)
+{
+   tst->os_state.valgrind_stack_base = 0;
+   tst->os_state.valgrind_stack_szB  = 0;
+
+   os_state_clear(tst);
+}
+
 static 
 void mostly_clear_thread_record ( ThreadId tid )
 {
@@ -569,7 +583,7 @@ void mostly_clear_thread_record ( ThreadId tid )
    VG_(sigemptyset)(&VG_(threads)[tid].sig_mask);
    VG_(sigemptyset)(&VG_(threads)[tid].tmp_sig_mask);
 
-   VGO_(os_state_clear)(&VG_(threads)[tid]);
+   os_state_clear(&VG_(threads)[tid]);
 
    /* start with no altstack */
    VG_(threads)[tid].altstack.ss_sp = (void *)0xdeadbeef;
@@ -641,7 +655,7 @@ void VG_(scheduler_init) ( void )
 
       VG_(threads)[i].sig_queue = NULL;
 
-      VGO_(os_state_init)(&VG_(threads)[i]);
+      os_state_init(&VG_(threads)[i]);
       mostly_clear_thread_record(i);
 
       VG_(threads)[i].status                    = VgTs_Empty;
index ddc785ff252ee541823ef3922a1ee3c18082ba48..33e9e6b29295915dbb5dbf5266add52707762201 100644 (file)
@@ -95,6 +95,23 @@ typedef
    } 
    ThreadArchState;
 
+/* OS-specific thread state */
+typedef struct {
+   /* who we are */
+   Int lwpid;                  // PID of kernel task
+   Int threadgroup;            // thread group id
+
+   ThreadId parent;            // parent tid (if any)
+
+   /* runtime details */
+   Addr  valgrind_stack_base;  // Valgrind's stack base
+   SizeT valgrind_stack_szB;   // stack size in bytes
+
+   /* exit details */
+   Int  exitcode;              // in the case of exitgroup, set by someone else
+   Int  fatalsig;              // fatal signal
+} os_thread_t;
+
 
 typedef struct {
    /* ThreadId == 0 (and hence vg_threads[0]) is NEVER USED.