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.

139 lines
4.3 KiB

  1. /* $OpenBSD: signal.h,v 1.25 2016/05/09 23:55:52 guenther 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. Neither the name of the University nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * @(#)signal.h 8.3 (Berkeley) 3/30/94
  32. */
  33. #ifndef _USER_SIGNAL_H
  34. #define _USER_SIGNAL_H
  35. #include <sys/signal.h>
  36. #if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
  37. #include <sys/types.h>
  38. #endif
  39. __BEGIN_DECLS
  40. #if __BSD_VISIBLE
  41. extern const char *const sys_signame[_NSIG];
  42. extern const char *const sys_siglist[_NSIG];
  43. #endif
  44. int raise(int);
  45. #if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
  46. #if __BSD_VISIBLE || (__XPG_VISIBLE >= 500 && __XPG_VISIBLE < 700)
  47. void (*bsd_signal(int, void (*)(int)))(int);
  48. #endif
  49. int kill(pid_t, int);
  50. int sigaction(int, const struct sigaction *__restrict,
  51. struct sigaction *__restrict);
  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 *__restrict, sigset_t *__restrict);
  59. #if __POSIX_VISIBLE >= 199506
  60. int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
  61. #endif
  62. int sigsuspend(const sigset_t *);
  63. #if !defined(_ANSI_LIBRARY)
  64. extern int *__errno(void);
  65. __only_inline int sigaddset(sigset_t *__set, int __signo)
  66. {
  67. if (__signo <= 0 || __signo >= _NSIG) {
  68. *__errno() = 22; /* EINVAL */
  69. return -1;
  70. }
  71. *__set |= (1U << ((__signo)-1)); /* sigmask(__signo) */
  72. return (0);
  73. }
  74. __only_inline int sigdelset(sigset_t *__set, int __signo)
  75. {
  76. if (__signo <= 0 || __signo >= _NSIG) {
  77. *__errno() = 22; /* EINVAL */
  78. return -1;
  79. }
  80. *__set &= ~(1U << ((__signo)-1)); /* sigmask(__signo) */
  81. return (0);
  82. }
  83. __only_inline int sigismember(const sigset_t *__set, int __signo)
  84. {
  85. if (__signo <= 0 || __signo >= _NSIG) {
  86. *__errno() = 22; /* EINVAL */
  87. return -1;
  88. }
  89. return ((*__set & (1U << ((__signo)-1))) != 0);
  90. }
  91. __only_inline int sigemptyset(sigset_t *__set)
  92. {
  93. *__set = 0;
  94. return (0);
  95. }
  96. __only_inline int sigfillset(sigset_t *__set)
  97. {
  98. *__set = ~(sigset_t)0;
  99. return (0);
  100. }
  101. #endif /* !_ANSI_LIBRARY */
  102. #if __BSD_VISIBLE || __XPG_VISIBLE >= 420
  103. int killpg(pid_t, int);
  104. int siginterrupt(int, int);
  105. int sigpause(int);
  106. int sigaltstack(const struct sigaltstack *__restrict,
  107. struct sigaltstack *__restrict);
  108. #if __BSD_VISIBLE
  109. int sigblock(int);
  110. int sigsetmask(int);
  111. int sigvec(int, struct sigvec *, struct sigvec *);
  112. int thrkill(pid_t _tid, int _signum, void *_tcb);
  113. #endif
  114. #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
  115. #if __BSD_VISIBLE || __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE >= 500
  116. int sigwait(const sigset_t *__restrict, int *__restrict);
  117. #endif
  118. #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
  119. void psignal(unsigned int, const char *);
  120. #endif
  121. #endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
  122. __END_DECLS
  123. #endif /* !_USER_SIGNAL_H */