OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [signal/] [sigaction.c] - Blame information for rev 1766

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
 
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Library General Public License as
6
   published by the Free Software Foundation; either version 2 of the
7
   License, or (at your option) any later version.
8
 
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
 
14
   You should have received a copy of the GNU Library General Public
15
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
16
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
   Boston, MA 02111-1307, USA.  */
18
 
19
#include <errno.h>
20
#include <signal.h>
21
#include <string.h>
22
#include <sys/syscall.h>
23
#include <bits/kernel_sigaction.h>
24
 
25
 
26
#if defined __NR_rt_sigaction
27
 
28
/* If ACT is not NULL, change the action for SIG to *ACT.
29
   If OACT is not NULL, put the old action for SIG in *OACT.  */
30
int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
31
{
32
    int result;
33
    struct kernel_sigaction kact, koact;
34
 
35
#ifdef SIGCANCEL
36
    if (sig == SIGCANCEL) {
37
        __set_errno (EINVAL);
38
        return -1;
39
    }
40
#endif
41
    if (act) {
42
        kact.k_sa_handler = act->sa_handler;
43
        memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
44
        kact.sa_flags = act->sa_flags;
45
# ifdef HAVE_SA_RESTORER
46
        kact.sa_restorer = act->sa_restorer;
47
# endif
48
    }
49
 
50
    /* XXX The size argument hopefully will have to be changed to the
51
       real size of the user-level sigset_t.  */
52
    result = __syscall_rt_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
53
            oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
54
 
55
    if (oact && result >= 0) {
56
        oact->sa_handler = koact.k_sa_handler;
57
        memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask));
58
        oact->sa_flags = koact.sa_flags;
59
# ifdef HAVE_SA_RESTORER
60
        oact->sa_restorer = koact.sa_restorer;
61
# endif
62
    }
63
    return result;
64
}
65
 
66
 
67
#else
68
 
69
/* If ACT is not NULL, change the action for SIG to *ACT.
70
   If OACT is not NULL, put the old action for SIG in *OACT.  */
71
int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
72
{
73
    int result;
74
    struct old_kernel_sigaction kact, koact;
75
 
76
#ifdef SIGCANCEL
77
    if (sig == SIGCANCEL) {
78
        __set_errno (EINVAL);
79
        return -1;
80
    }
81
#endif
82
    if (act) {
83
        kact.k_sa_handler = act->sa_handler;
84
        kact.sa_mask = act->sa_mask.__val[0];
85
        kact.sa_flags = act->sa_flags;
86
# ifdef HAVE_SA_RESTORER
87
        kact.sa_restorer = act->sa_restorer;
88
# endif
89
    }
90
    result = __syscall_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
91
            oact ? __ptrvalue (&koact) : NULL);
92
 
93
    if (oact && result >= 0) {
94
        oact->sa_handler = koact.k_sa_handler;
95
        oact->sa_mask.__val[0] = koact.sa_mask;
96
        oact->sa_flags = koact.sa_flags;
97
# ifdef HAVE_SA_RESTORER
98
        oact->sa_restorer = koact.sa_restorer;
99
# endif
100
    }
101
    return result;
102
}
103
 
104
#endif
105
 
106
weak_alias(__libc_sigaction, sigaction)
107
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.