Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.0 KiB

  1. /* $OpenBSD: signal.h,v 1.6 2002/02/19 19:39:36 millert Exp $ */
  2. /* $NetBSD: signal.h,v 1.8 1996/02/29 00:04:57 jtc Exp $ */
  3. /*-
  4. * Copyright (c) 1991, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. All advertising materials mentioning features or use of this software
  16. * must display the following acknowledgement:
  17. * This product includes software developed by the University of
  18. * California, Berkeley and its contributors.
  19. * 4. Neither the name of the University nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * @(#)signal.h 8.3 (Berkeley) 3/30/94
  36. */
  37. #ifndef _USER_SIGNAL_H
  38. #define _USER_SIGNAL_H
  39. #include <sys/signal.h>
  40. #if !defined(_ANSI_SOURCE)
  41. #include <sys/types.h>
  42. #endif
  43. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  44. extern __const char *__const sys_signame[_NSIG];
  45. extern __const char *__const sys_siglist[_NSIG];
  46. #endif
  47. __BEGIN_DECLS
  48. int raise(int);
  49. #ifndef _ANSI_SOURCE
  50. int kill(pid_t, int);
  51. int sigaction(int, const struct sigaction *, struct sigaction *);
  52. int sigaddset(sigset_t *, int);
  53. int sigdelset(sigset_t *, int);
  54. int sigemptyset(sigset_t *);
  55. int sigfillset(sigset_t *);
  56. int sigismember(const sigset_t *, int);
  57. int sigpending(sigset_t *);
  58. int sigprocmask(int, const sigset_t *, sigset_t *);
  59. int sigsuspend(const sigset_t *);
  60. #if defined(__GNUC__)
  61. extern __inline int sigaddset(sigset_t *set, int signo) {
  62. extern int errno;
  63. if (signo <= 0 || signo >= _NSIG) {
  64. errno = 22; /* EINVAL */
  65. return -1;
  66. }
  67. *set |= (1 << ((signo)-1)); /* sigmask(signo) */
  68. return (0);
  69. }
  70. extern __inline int sigdelset(sigset_t *set, int signo) {
  71. extern int errno;
  72. if (signo <= 0 || signo >= _NSIG) {
  73. errno = 22; /* EINVAL */
  74. return -1;
  75. }
  76. *set &= ~(1 << ((signo)-1)); /* sigmask(signo) */
  77. return (0);
  78. }
  79. extern __inline int sigismember(const sigset_t *set, int signo) {
  80. extern int errno;
  81. if (signo <= 0 || signo >= _NSIG) {
  82. errno = 22; /* EINVAL */
  83. return -1;
  84. }
  85. return ((*set & (1 << ((signo)-1))) != 0);
  86. }
  87. #endif
  88. /* List definitions after function declarations, or Reiser cpp gets upset. */
  89. #define sigemptyset(set) (*(set) = 0, 0)
  90. #define sigfillset(set) (*(set) = ~(sigset_t)0, 0)
  91. #ifndef _POSIX_SOURCE
  92. int killpg(pid_t, int);
  93. int sigblock(int);
  94. int siginterrupt(int, int);
  95. int sigpause(int);
  96. int sigreturn(struct sigcontext *);
  97. int sigsetmask(int);
  98. int sigstack(const struct sigstack *, struct sigstack *);
  99. int sigaltstack(const struct sigaltstack *, struct sigaltstack *);
  100. int sigvec(int, struct sigvec *, struct sigvec *);
  101. void psignal(unsigned int, const char *);
  102. int sigwait(const sigset_t *, int *);
  103. #endif /* !_POSIX_SOURCE */
  104. #endif /* !_ANSI_SOURCE */
  105. __END_DECLS
  106. #endif /* !_USER_SIGNAL_H */