# 2.11BSD#431 - /usr/src/lib/libc/pdp/sys/sigaction.s

##### Functions

    _sigaction        X

       1: /*
       2:  * Copyright (c) 1987 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifdef SYSLIBC_SCCS
       8: _sccsid: <@(#)sigaction.s	1.0 (2.11BSD) 1997/8/23\0>
       9:         .even
      10: #endif SYSLIBC_SCCS
      11:
      12: /*
      13:  * error = sigaction(sig, vec, ovec)
      14:  *	int		error, sig;
      15:  *	struct sigaction *vec, *ovec;
      16:  *
      17:  * Sigaction, or more apropriately, sigaction's helper function sigtramp below,
      18:  * must be loaded in the base segment of overlaid objects.
      19:  *
      20:  * We pass one additional parameter to the sigaction sys call: the address of
      21:  * the "Trampoline Code", sigtramp - the code that handles saving and restoring
      22:  * register context and so on for signals.  On the VAX-11 under BSD4.3 it isn't
      23:  * necessary to pass this address since the trampoline code is stored in the
      24:  * user structure in u.u_pcb.pcb_sigc at a known address in user space.  It
      25:  * really doesn't introduce much extra overhead, so our method for doing it on
      26:  * a PDP-11 is alright too.
      27:  */
      28: #include "SYS.h"
      29:
      30: ENTRY(sigaction)
      31:         mov     (sp),-(sp)      / push return address down one place
      32:         mov     $sigtramp,2(sp) /   to leave a space for the address of
      33:         SYS(sigaction)          /   sigtramp
          /
          /   trap 31 -> [kernel] -> syscall() -> via sysent[] -> handler: sigaction
          /
      34:         mov     (sp)+,(sp)      / (clean up stack)
      35:         bcc     1f
      36:         jmp     x_error
      37: 1:
      38:         rts     pc
      39:
      40: /*
      41:  * sigtramp - Signal "Trampoline Code"
      42:  *
      43:  * This code is transfered to by the kernel when a signal is delivered to a
      44:  * process.  In general, the idea is that sigtramp saves the process' register
      45:  * context and then vectors on to the real signal action routine.  Upon return
      46:  * from the signal action routine sigtramp restores the process' register
      47:  * context and performs a sigreturn.
      48:  *
      49:  * In the case of the PDP-11, the kernel will have already saved r0 and r1 for
      50:  * sigtramp in a sigcontext structure it passes to us.  Sigtramp vectors onto
      51:  * the signal action routine whose address has been left in r0 by the kernel
      52:  * (sigtramp assumes the signal action routine will save any other registers
      53:  * it uses (as all C routines will)).  Upon return from the signal action
      54:  * routine, sigtramp will execute a sigreturn with the sigcontext structure
      55:  * given to us by the kernel.
      56:  *
      57:  * When the kernel transfers control to sigtramp the stack looks like:
      58:  *
      59:  *	-------------------------
      60:  *	| sigcontext structure	| SIG_SC = sp + 6.
      61:  *	|-----------------------|
      62:  *	| pointer to sigcontext	|
      63:  *	|-----------------------|
      64:  *	| code			|
      65:  *	|-----------------------|
      66:  *sp ->	| signal number		|
      67:  *	-------------------------
      68:  *
      69:  * The important features of this as far as sigtramp is concerned are:
      70:  * 1.	The fact that the signal number, signal code, and signal context
      71:  *	pointer are already set up as parameters to the signal action
      72:  *	routine.
      73:  * 2.   There's no need to save r0 & r1 because the kernel's already saved
      74:  *      them for us in the sigcontext structure (C routines save all
      75:  *      registers except r0 & r1 automatically).
      76:  *
      77:  * Note that the stack offset SIG_SC will NOT have to be recomputed if the
      78:  * sigcontext structure changes.
      79:  */
      80: SIG_SC  = 6.                            / stack offset of sigcontext structure
      81:
      82: iot     = 4
      83:
      84: .globl  _sigreturn                      / sigreturn sys call
      85: sigtramp:
      86:         jsr     pc,(r0)                 / transfer to signal action routine
      87:         mov     sp,r0                   / compute address of sigcontext
      88:         add     $SIG_SC,r0              /   (can't use "mov sp,-(sp)")
      89:         mov     r0,-(sp)
      90:         jsr     pc,_sigreturn           /   and perform a sigreturn
      91:         iot                             / die if the sigreturn fails ...

#### Defined functions

SIG_SC defined in line 80; used 1 times

- in line 88

_sccsid defined in line 8; never used
_sigaction defined in line 30; used 14 times

- in /usr/src/bin/tcsh/tc.sig.h line 60
- in /usr/src/lib/libc/compat-43/sigcompat.c line 49
- in /usr/src/lib/libc/gen/siginterrupt.c line 51, 60
- in /usr/src/lib/libc/gen/signal.c line 57
- in /usr/src/libexec/acctd/acctd.c line 97, 105, 113
- in /usr/src/usr.sbin/syslogd/syslogd.c line 201-216(6)

sigtramp defined in line 85; used 1 times

- in line 32

Last modified: 1997-08-28 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 718 |