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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [sigset.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* sigset.c - signal set manipulation functions */
2
 
3
/* Copyright 2002, Red Hat Inc. */
4
 
5
/* Note: these are currently grouped together in one file so that
6
         it will override the default version in the libc/unix
7
         directory which has grouped all functions in one file. */
8
 
9
/* sigaddset function */
10
 
11
#include <signal.h>
12
#include <bits/sigset.h>
13
#include <errno.h>
14
#include <string.h>
15
#include <machine/weakalias.h>
16
 
17
int
18
sigaddset (sigset_t *set, const int signo)
19
{
20
  int index, mask;
21
  __sigset_t *st = (__sigset_t *)set;
22
 
23
  if (signo > NSIG)
24
    {
25
      errno = EINVAL;
26
      return -1;
27
    }
28
 
29
  index = (signo - 1) / (8 * sizeof(long));
30
  mask = 1 << ((signo - 1) % (8 * sizeof(long)));
31
 
32
  st->__val[index] |= mask;
33
  return 0;
34
}
35
 
36
/* sigdelset function */
37
 
38
int
39
sigdelset (sigset_t *set, const int signo)
40
{
41
  int index, mask;
42
  __sigset_t *st = (__sigset_t *)set;
43
 
44
  if (signo > NSIG)
45
    {
46
      errno = EINVAL;
47
      return -1;
48
    }
49
 
50
  index = (signo - 1) / (8 * sizeof(long));
51
  mask = 1 << ((signo - 1) % (8 * sizeof(long)));
52
 
53
  st->__val[index] &= ~mask;
54
  return 0;
55
}
56
 
57
/* sigemptyset function */
58
 
59
int
60
sigemptyset (sigset_t *set)
61
{
62
  int size = NSIG / 8;
63
  __sigset_t *st = (__sigset_t *)set;
64
  memset (st->__val, 0, size);
65
  return 0;
66
}
67
 
68
/* sigfillset function */
69
 
70
int
71
sigfillset (sigset_t *set)
72
{
73
  int size = NSIG / 8;
74
  __sigset_t *st = (__sigset_t *)set;
75
  memset (st->__val, 0xff, size);
76
  return 0;
77
}
78
 
79
/* sigismember function */
80
 
81
int
82
sigismember (const sigset_t *set, int signo)
83
{
84
  int index, mask;
85
  __sigset_t *st = (__sigset_t *)set;
86
 
87
  if (signo > NSIG)
88
    {
89
      errno = EINVAL;
90
      return -1;
91
    }
92
 
93
  index = (signo - 1) / (8 * sizeof(long));
94
  mask = 1 << ((signo - 1) % (8 * sizeof(long)));
95
 
96
  return (st->__val[index] & mask) != 0;
97
}
98
 

powered by: WebSVN 2.1.0

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