Back to index

glibc  2.9
Defines | Functions | Variables
sigtramp.c File Reference
#include "/usr/include/sys/signal.h"
#include <signal.h>
#include <stddef.h>
#include <errno.h>

Go to the source code of this file.

Defines

#define KERNEL
#define sigvec   sun_sigvec
#define sigstack   sun_sigstack
#define sigcontext   sun_sigcontext
#define mytramp   1

Functions

int __raw_sigvec (int sig, const struct sigvec *vec, struct sigvec *ovec)
static void trampoline (int sig, int code, struct sigcontext *context, void *addr)
int __sigvec (int sig, const struct sigvec *vec, struct sigvec *ovec)

Variables

static __sighandler_t handlers [NSIG]

Define Documentation

#define KERNEL

Definition at line 24 of file sigtramp.c.

#define mytramp   1

Definition at line 57 of file sigtramp.c.

#define sigcontext   sun_sigcontext

Definition at line 27 of file sigtramp.c.

#define sigstack   sun_sigstack

Definition at line 26 of file sigtramp.c.

#define sigvec   sun_sigvec

Definition at line 25 of file sigtramp.c.


Function Documentation

int __raw_sigvec ( int  sig,
const struct sigvec vec,
struct sigvec ovec 
)

Here is the caller graph for this function:

int __sigvec ( int  sig,
const struct sigvec vec,
struct sigvec ovec 
)

Definition at line 99 of file sigtramp.c.

{
#ifndef       mytramp
  extern void _sigtramp (int);
#define       trampoline    _sigtramp
#endif
  struct sigvec myvec;
  int mask;
  __sighandler_t ohandler;

  if (sig <= 0 || sig >= NSIG)
    {
      __set_errno (EINVAL);
      return -1;
    }

  mask = __sigblock(sigmask(sig));

  ohandler = handlers[sig];

  if (vec != NULL &&
      vec->sv_handler != SIG_IGN && vec->sv_handler != SIG_DFL)
    {
      handlers[sig] = vec->sv_handler;
      myvec = *vec;
      myvec.sv_handler = trampoline;
      vec = &myvec;
    }

  if (__raw_sigvec(sig, vec, ovec) < 0)
    {
      int save = errno;
      (void) __sigsetmask(mask);
      errno = save;
      return -1;
    }

  if (ovec != NULL && ovec->sv_handler == trampoline)
    ovec->sv_handler = ohandler;

  (void) __sigsetmask(mask);

  return 0;
}

Here is the call graph for this function:

static void trampoline ( int  sig,
int  code,
struct sigcontext context,
void *  addr 
) [static]

Definition at line 71 of file sigtramp.c.

{
  int save[4];

  /* Save the call-clobbered registers.  */
  asm volatile ("movem%.l d0-d1/a0-a1, %0" : : "m" (save[0]));

  /* XXX should save/restore FP regs */

  /* Call the user's handler.  */
  (*((void (*) (int sig, int code, struct sigcontext *context,
              PTR addr)) handlers[sig]))
    (sig, code, context, addr);

  /* Restore the call-clobbered registers.  */
  asm volatile ("movem%.l %0, d0-d1/a0-a1" : : "g" (save[0]) :
              "d0", "d1", "a0", "a1");

  __sigreturn (context);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

__sighandler_t handlers[NSIG] [static]

Definition at line 59 of file sigtramp.c.