UbixOS V2
2.0
signal.c
Go to the documentation of this file.
1
/*-
2
* Copyright (c) 2002-2018 The UbixOS Project.
3
* All rights reserved.
4
*
5
* This was developed by Christopher W. Olsen for the UbixOS Project.
6
*
7
* Redistribution and use in source and binary forms, with or without modification, are permitted
8
* provided that the following conditions are met:
9
*
10
* 1) Redistributions of source code must retain the above copyright notice, this list of
11
* conditions, the following disclaimer and the list of authors.
12
* 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13
* conditions, the following disclaimer and the list of authors in the documentation and/or
14
* other materials provided with the distribution.
15
* 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16
* endorse or promote products derived from this software without specific prior written
17
* permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#include <
sys/signal.h
>
30
#include <
sys/sysproto_posix.h
>
31
#include <
sys/thread.h
>
32
#include <
lib/kprintf.h
>
33
#include <
assert.h
>
34
35
int
sys_sigprocmask
(
struct
thread
*td,
struct
sys_sigprocmask_args
*args) {
36
td->
td_retval
[0] = -1;
37
38
if
(args->
oset
!= 0x0) {
39
memcpy
(args->
oset
, &td->
sigmask
,
sizeof
(
sigset_t
));
40
td->
td_retval
[0] = 0x0;
41
}
42
43
if
(args->
set
!= 0x0) {
44
if
(args->
how
==
SIG_SETMASK
) {
45
if
(args->
set
!= 0x0) {
46
memcpy
(&td->
sigmask
, args->
set
,
sizeof
(
sigset_t
));
47
td->
td_retval
[0] = 0;
48
}
else
{
49
td->
td_retval
[0] = -1;
50
}
51
}
else
if
(args->
how
==
SIG_BLOCK
) {
52
if
(args->
set
!= 0x0) {
53
td->
sigmask
.
__bits
[0] &= args->
set
->
__bits
[0];
54
td->
sigmask
.
__bits
[1] &= args->
set
->
__bits
[1];
55
td->
sigmask
.
__bits
[2] &= args->
set
->
__bits
[2];
56
td->
sigmask
.
__bits
[3] &= args->
set
->
__bits
[3];
57
td->
td_retval
[0] = 0;
58
}
else
{
59
td->
td_retval
[0] = -1;
60
}
61
}
else
if
(args->
how
==
SIG_UNBLOCK
) {
62
if
(args->
set
!= 0x0) {
63
td->
sigmask
.
__bits
[0] |= args->
set
->
__bits
[0];
64
td->
sigmask
.
__bits
[1] |= args->
set
->
__bits
[1];
65
td->
sigmask
.
__bits
[2] |= args->
set
->
__bits
[2];
66
td->
sigmask
.
__bits
[3] |= args->
set
->
__bits
[3];
67
td->
td_retval
[0] = 0;
68
}
else
{
69
td->
td_retval
[0] = -1;
70
}
71
}
else
{
72
kprintf
(
"SPM: 0x%X"
, args->
how
);
73
td->
td_retval
[0] = -1;
74
}
75
}
76
77
return
(0);
78
}
79
80
int
sys_sigaction
(
struct
thread
*td,
struct
sys_sigaction_args
*args) {
81
td->
td_retval
[0] = -1;
82
83
if
(args->
oact
!= 0x0) {
84
memcpy
(args->
oact
, &td->
sigact
[args->
sig
],
sizeof
(
struct
sigaction
));
85
td->
td_retval
[0] = 0;
86
}
87
88
if
(args->
act
!= 0x0) {
89
//kprintf("SA: %i", args->sig);
90
memcpy
(&td->
sigact
[args->
sig
], args->
act
,
sizeof
(
struct
sigaction
));
91
td->
td_retval
[0] = 0;
92
}
93
return
(0);
94
}
sys_sigprocmask_args::oset
sigset_t * oset
Definition:
sysproto_posix.h:559
sigaction
Definition:
signal.h:93
sys_sigaction_args
Definition:
sysproto_posix.h:563
sysproto_posix.h
SIG_SETMASK
#define SIG_SETMASK
Definition:
signal.h:44
thread
Definition:
thread.h:40
SIG_BLOCK
#define SIG_BLOCK
Definition:
signal.h:42
assert.h
thread::sigmask
sigset_t sigmask
Definition:
thread.h:49
thread::sigact
struct sigaction sigact[128]
Definition:
thread.h:50
__sigset::__bits
__uint32_t __bits[4]
Definition:
_sigset.h:43
memcpy
void * memcpy(const void *dst, const void *src, size_t length)
__sigset
Definition:
_sigset.h:42
SIG_UNBLOCK
#define SIG_UNBLOCK
Definition:
signal.h:43
sys_sigprocmask_args
Definition:
sysproto_posix.h:551
thread::td_retval
int td_retval[2]
Definition:
thread.h:41
sys_sigaction_args::sig
int sig
Definition:
sysproto_posix.h:565
kprintf.h
sys_sigprocmask_args::how
int how
Definition:
sysproto_posix.h:553
sys_sigprocmask
int sys_sigprocmask(struct thread *td, struct sys_sigprocmask_args *args)
Definition:
signal.c:35
sys_sigaction_args::oact
struct sigaction * oact
Definition:
sysproto_posix.h:571
sys_sigaction_args::act
const struct sigaction * act
Definition:
sysproto_posix.h:568
sys_sigprocmask_args::set
const sigset_t * set
Definition:
sysproto_posix.h:556
sys_sigaction
int sys_sigaction(struct thread *td, struct sys_sigaction_args *args)
Definition:
signal.c:80
signal.h
kprintf
int kprintf(const char *,...)
Definition:
kprintf.c:259
thread.h
C:
Dev
git
UbixOS
sys
kernel
signal.c
Generated by
1.8.16