]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Remove identical copies of convert_sigset_to_rt, PRE(sys_sigaction)
authorJulian Seward <jseward@acm.org>
Mon, 11 Jul 2011 17:48:24 +0000 (17:48 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 11 Jul 2011 17:48:24 +0000 (17:48 +0000)
and POST(sys_sigaction) in syswrap-x86-linux.c and
syswrap-ppc32-linux.c, and replace them with a single version in
syswrap-linux.c instead.  Derived from patch in bug 266035 comment 10
(Jeff Brown, jeffbrown@google.com).

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

coregrind/m_syswrap/priv_syswrap-linux.h
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-ppc32-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c

index b1e0bdd7ac0d8690e57fe229063a02b941199108..bbc6e36dc9cddc49359ab527b6acc19ad973f163 100644 (file)
@@ -240,6 +240,7 @@ DECL_TEMPLATE(linux, sys_lseek);
 // Darwin (and probably other OSes) don't have the old_sigset_t type.
 DECL_TEMPLATE(linux, sys_sigpending);
 DECL_TEMPLATE(linux, sys_sigprocmask);
+DECL_TEMPLATE(linux, sys_sigaction);
 
 // I think these are Linux-specific?
 DECL_TEMPLATE(linux, sys_rt_sigaction);
index d1f396c0ae5f350cef04d43a2407c1b05994f854..00e4cc6d198d879c5e449d2ec66ed879ae8fdc81 100644 (file)
@@ -2783,6 +2783,68 @@ POST(sys_sigprocmask)
    if (RES == 0 && ARG3 != 0)
       POST_MEM_WRITE( ARG3, sizeof(vki_old_sigset_t));
 }
+
+/* Convert from non-RT to RT sigset_t's */
+static 
+void convert_sigset_to_rt(const vki_old_sigset_t *oldset, vki_sigset_t *set)
+{
+   VG_(sigemptyset)(set);
+   set->sig[0] = *oldset;
+}
+PRE(sys_sigaction)
+{
+   vki_sigaction_toK_t   new, *newp;
+   vki_sigaction_fromK_t old, *oldp;
+
+   PRINT("sys_sigaction ( %ld, %#lx, %#lx )", ARG1,ARG2,ARG3);
+   PRE_REG_READ3(int, "sigaction",
+                 int, signum, const struct old_sigaction *, act,
+                 struct old_sigaction *, oldact);
+
+   newp = oldp = NULL;
+
+   if (ARG2 != 0) {
+      struct vki_old_sigaction *sa = (struct vki_old_sigaction *)ARG2;
+      PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr)&sa->ksa_handler, sizeof(sa->ksa_handler));
+      PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr)&sa->sa_mask, sizeof(sa->sa_mask));
+      PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr)&sa->sa_flags, sizeof(sa->sa_flags));
+      if (ML_(safe_to_deref)(sa,sizeof(sa)) 
+          && (sa->sa_flags & VKI_SA_RESTORER))
+         PRE_MEM_READ( "sigaction(act->sa_restorer)", (Addr)&sa->sa_restorer, sizeof(sa->sa_restorer));
+   }
+
+   if (ARG3 != 0) {
+      PRE_MEM_WRITE( "sigaction(oldact)", ARG3, sizeof(struct vki_old_sigaction));
+      oldp = &old;
+   }
+
+   if (ARG2 != 0) {
+      struct vki_old_sigaction *oldnew = (struct vki_old_sigaction *)ARG2;
+
+      new.ksa_handler = oldnew->ksa_handler;
+      new.sa_flags = oldnew->sa_flags;
+      new.sa_restorer = oldnew->sa_restorer;
+      convert_sigset_to_rt(&oldnew->sa_mask, &new.sa_mask);
+      newp = &new;
+   }
+
+   SET_STATUS_from_SysRes( VG_(do_sys_sigaction)(ARG1, newp, oldp) );
+
+   if (ARG3 != 0 && SUCCESS && RES == 0) {
+      struct vki_old_sigaction *oldold = (struct vki_old_sigaction *)ARG3;
+
+      oldold->ksa_handler = oldp->ksa_handler;
+      oldold->sa_flags = oldp->sa_flags;
+      oldold->sa_restorer = oldp->sa_restorer;
+      oldold->sa_mask = oldp->sa_mask.sig[0];
+   }
+}
+POST(sys_sigaction)
+{
+   vg_assert(SUCCESS);
+   if (RES == 0 && ARG3 != 0)
+      POST_MEM_WRITE( ARG3, sizeof(struct vki_old_sigaction));
+}
 #endif
 
 PRE(sys_signalfd)
index 997acf3a3db784c562961a0b6d821754fb480659..edcd1512c0024ebe0c04d08a3cc7f3e16d7423b9 100644 (file)
@@ -419,7 +419,6 @@ DECL_TEMPLATE(ppc32_linux, sys_ipc);
 DECL_TEMPLATE(ppc32_linux, sys_clone);
 DECL_TEMPLATE(ppc32_linux, sys_sigreturn);
 DECL_TEMPLATE(ppc32_linux, sys_rt_sigreturn);
-DECL_TEMPLATE(ppc32_linux, sys_sigaction);
 DECL_TEMPLATE(ppc32_linux, sys_sigsuspend);
 DECL_TEMPLATE(ppc32_linux, sys_spu_create);
 DECL_TEMPLATE(ppc32_linux, sys_spu_run);
@@ -1392,74 +1391,6 @@ PRE(sys_rt_sigreturn)
 //..    }
 //.. }
 
-
-/* Convert from non-RT to RT sigset_t's */
-static 
-void convert_sigset_to_rt(const vki_old_sigset_t *oldset, vki_sigset_t *set)
-{
-   VG_(sigemptyset)(set);
-   set->sig[0] = *oldset;
-}
-PRE(sys_sigaction)
-{
-   vki_sigaction_toK_t   new, *newp;
-   vki_sigaction_fromK_t old, *oldp;
-
-   PRINT("sys_sigaction ( %ld, %#lx, %#lx )", ARG1,ARG2,ARG3);
-   PRE_REG_READ3(int, "sigaction",
-                 int, signum, const struct old_sigaction *, act,
-                 struct old_sigaction *, oldact);
-
-   newp = oldp = NULL;
-
-   if (ARG2 != 0) {
-      struct vki_old_sigaction *sa = (struct vki_old_sigaction *)ARG2;
-      PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr)&sa->ksa_handler, sizeof(sa->ksa_handler));
-      PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr)&sa->sa_mask, sizeof(sa->sa_mask));
-      PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr)&sa->sa_flags, sizeof(sa->sa_flags));
-      if (ML_(safe_to_deref)(sa,sizeof(sa)) 
-          && (sa->sa_flags & VKI_SA_RESTORER))
-         PRE_MEM_READ( "sigaction(act->sa_restorer)", (Addr)&sa->sa_restorer, sizeof(sa->sa_restorer));
-   }
-
-   if (ARG3 != 0) {
-      PRE_MEM_WRITE( "sigaction(oldact)", ARG3, sizeof(struct vki_old_sigaction));
-      oldp = &old;
-   }
-
-   //jrs 20050207: what?!  how can this make any sense?
-   //if (VG_(is_kerror)(SYSRES))
-   //   return;
-
-   if (ARG2 != 0) {
-      struct vki_old_sigaction *oldnew = (struct vki_old_sigaction *)ARG2;
-
-      new.ksa_handler = oldnew->ksa_handler;
-      new.sa_flags = oldnew->sa_flags;
-      new.sa_restorer = oldnew->sa_restorer;
-      convert_sigset_to_rt(&oldnew->sa_mask, &new.sa_mask);
-      newp = &new;
-   }
-
-   SET_STATUS_from_SysRes( VG_(do_sys_sigaction)(ARG1, newp, oldp) );
-
-   if (ARG3 != 0 && SUCCESS && RES == 0) {
-      struct vki_old_sigaction *oldold = (struct vki_old_sigaction *)ARG3;
-
-      oldold->ksa_handler = oldp->ksa_handler;
-      oldold->sa_flags = oldp->sa_flags;
-      oldold->sa_restorer = oldp->sa_restorer;
-      oldold->sa_mask = oldp->sa_mask.sig[0];
-   }
-}
-
-POST(sys_sigaction)
-{
-   vg_assert(SUCCESS);
-   if (RES == 0 && ARG3 != 0)
-      POST_MEM_WRITE( ARG3, sizeof(struct vki_old_sigaction));
-}
-
 PRE(sys_sigsuspend)
 {
    /* The C library interface to sigsuspend just takes a pointer to
@@ -1596,7 +1527,7 @@ static SyscallTableEntry syscall_table[] = {
 
    GENX_(__NR_getpgrp,           sys_getpgrp),           // 65
    GENX_(__NR_setsid,            sys_setsid),            // 66
-   PLAXY(__NR_sigaction,         sys_sigaction),         // 67
+   LINXY(__NR_sigaction,         sys_sigaction),         // 67
 //..    //   (__NR_sgetmask,          sys_sgetmask),          // 68 */* (ANSI C)
 //..    //   (__NR_ssetmask,          sys_ssetmask),          // 69 */* (ANSI C)
 //.. 
index 6aca6a8f75135b01f7d02724eff3f34203882ed3..c4acdf51504a03b688b53572008d2aff4d51a8dc 100644 (file)
@@ -804,7 +804,6 @@ DECL_TEMPLATE(x86_linux, sys_modify_ldt);
 DECL_TEMPLATE(x86_linux, sys_set_thread_area);
 DECL_TEMPLATE(x86_linux, sys_get_thread_area);
 DECL_TEMPLATE(x86_linux, sys_ptrace);
-DECL_TEMPLATE(x86_linux, sys_sigaction);
 DECL_TEMPLATE(x86_linux, sys_sigsuspend);
 DECL_TEMPLATE(x86_linux, old_select);
 DECL_TEMPLATE(x86_linux, sys_vm86old);
@@ -1708,71 +1707,6 @@ POST(sys_socketcall)
 #  undef ARG2_5
 }
 
-/* Convert from non-RT to RT sigset_t's */
-static 
-void convert_sigset_to_rt(const vki_old_sigset_t *oldset, vki_sigset_t *set)
-{
-   VG_(sigemptyset)(set);
-   set->sig[0] = *oldset;
-}
-PRE(sys_sigaction)
-{
-   vki_sigaction_toK_t   new, *newp;
-   vki_sigaction_fromK_t old, *oldp;
-
-   PRINT("sys_sigaction ( %ld, %#lx, %#lx )", ARG1,ARG2,ARG3);
-   PRE_REG_READ3(int, "sigaction",
-                 int, signum, const struct old_sigaction *, act,
-                 struct old_sigaction *, oldact);
-
-   newp = oldp = NULL;
-
-   if (ARG2 != 0) {
-      struct vki_old_sigaction *sa = (struct vki_old_sigaction *)ARG2;
-      PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr)&sa->ksa_handler, sizeof(sa->ksa_handler));
-      PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr)&sa->sa_mask, sizeof(sa->sa_mask));
-      PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr)&sa->sa_flags, sizeof(sa->sa_flags));
-      if (ML_(safe_to_deref)(sa,sizeof(sa)) 
-          && (sa->sa_flags & VKI_SA_RESTORER))
-         PRE_MEM_READ( "sigaction(act->sa_restorer)", (Addr)&sa->sa_restorer, sizeof(sa->sa_restorer));
-   }
-
-   if (ARG3 != 0) {
-      PRE_MEM_WRITE( "sigaction(oldact)", ARG3, sizeof(struct vki_old_sigaction));
-      oldp = &old;
-   }
-
-   //jrs 20050207: what?!  how can this make any sense?
-   //if (VG_(is_kerror)(SYSRES))
-   //   return;
-
-   if (ARG2 != 0) {
-      struct vki_old_sigaction *oldnew = (struct vki_old_sigaction *)ARG2;
-      new.ksa_handler = oldnew->ksa_handler;
-      new.sa_flags    = oldnew->sa_flags;
-      new.sa_restorer = oldnew->sa_restorer;
-      convert_sigset_to_rt(&oldnew->sa_mask, &new.sa_mask);
-      newp = &new;
-   }
-
-   SET_STATUS_from_SysRes( VG_(do_sys_sigaction)(ARG1, newp, oldp) );
-
-   if (ARG3 != 0 && SUCCESS && RES == 0) {
-      struct vki_old_sigaction *oldold = (struct vki_old_sigaction *)ARG3;
-      oldold->ksa_handler = oldp->ksa_handler;
-      oldold->sa_flags    = oldp->sa_flags;
-      oldold->sa_restorer = oldp->sa_restorer;
-      oldold->sa_mask = oldp->sa_mask.sig[0];
-   }
-}
-
-POST(sys_sigaction)
-{
-   vg_assert(SUCCESS);
-   if (RES == 0 && ARG3 != 0)
-      POST_MEM_WRITE( ARG3, sizeof(struct vki_old_sigaction));
-}
-
 PRE(sys_sigsuspend)
 {
    /* The C library interface to sigsuspend just takes a pointer to
@@ -1954,7 +1888,7 @@ static SyscallTableEntry syscall_table[] = {
 
    GENX_(__NR_getpgrp,           sys_getpgrp),        // 65
    GENX_(__NR_setsid,            sys_setsid),         // 66
-   PLAXY(__NR_sigaction,         sys_sigaction),      // 67
+   LINXY(__NR_sigaction,         sys_sigaction),      // 67
 //zz    //   (__NR_sgetmask,          sys_sgetmask),       // 68 */* (ANSI C)
 //zz    //   (__NR_ssetmask,          sys_ssetmask),       // 69 */* (ANSI C)
 //zz