signal.mh

来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 245 行

MH
245
字号
/***************************************************************************
 * FILE: signal.h/csignal (Signal definitions)
 *
:include crwatqnx.sp
 *
 * Description: This header is part of the C/C++ standard library. It
 *              declares facilities for handling signals in programs.
 ***************************************************************************/
:segment CNAME
#ifndef _CSIGNAL_INCLUDED
#define _CSIGNAL_INCLUDED

#ifndef __cplusplus
#error The header csignal requires C++
#endif
:elsesegment
#ifndef _SIGNAL_H_INCLUDED
#define _SIGNAL_H_INCLUDED
:endsegment

:include readonly.sp
::
:: The following segment only appears in signal.h.
:segment !CNAME
#ifdef __cplusplus
#include <csignal>

// C99 types in signal.h.
using std::sig_atomic_t;

// C99 functions in signal.h.
using std::signal;
using std::raise;

#else /* __cplusplus not defined */
:: End of segment that is only in signal.h
:endsegment

:: Only need extern "C" in csignal
:segment CNAME
:include cpluspro.sp
:endsegment

#ifndef _COMDEF_H_INCLUDED
 #include <_comdef.h>
#endif
:segment QNX | LINUX
#ifndef __TYPES_H_INCLUDED
 #include <sys/types.h>
#endif
:endsegment

:segment CNAME
namespace std {
  typedef int sig_atomic_t;
}
:elsesegment
typedef int sig_atomic_t;
:endsegment

typedef void (*__sig_func)( int );
:segment LINUX
typedef __sig_func __sighandler_t;

:include incdir.sp
#include _ARCH_INCLUDE(signal.h)

#if defined(_POSIX_SOURCE) || !defined(NO_EXT_KEYS)
:include pshpackl.sp
#include _ARCH_INCLUDE(sigposix.h)
:include poppack.sp
#endif  /* _POSIX_SOURCE || _QNX_SOURCE || !NO_EXT_KEYS */

:elsesegment QNX

#define __SIG_FAR _WCI86FAR

#if defined(_POSIX_SOURCE) || defined(_QNX_SOURCE) || !defined(NO_EXT_KEYS)
:include pshpackl.sp
#ifdef __NEUTRINO__
typedef struct {
    long    nrt;
    long   rt;
    } sigset_t;
#else
typedef long    sigset_t;       /* Used for signal sets             */
#endif
struct sigaction {
    void        (__SIG_FAR *sa_handler)(int);
    sigset_t    sa_mask;
    int         sa_flags;
};
struct _sigaction {
    void        (__SIG_FAR *sa_handler)(int);
    sigset_t sa_mask;
    short int sa_flags;
};

union sigval {
    int         sigval_int;
    void       *sigval_ptr;
};

#ifdef __386__
typedef struct stack_t stack_t;
struct stack_t {
        void         *ss_sp;
        size_t        ss_size;
        int           ss_flags;
        ushort_t      ss_seg;   /* should always be zero; but incase */
};

#define SS_ONSTACK        (1<<0)
#define SS_DISABLE        (1<<1)

#define _SS_SETSEG         (1<<8)

extern int sigaltstack(const stack_t *ss, stack_t *oss);

#endif

#ifndef __NEUTRINO__
struct sigevent {
    int          sigev_signo;
    union sigval sigev_value;
};
struct msigevent {
    long         sigev_signo;
    union sigval sigev_value;
};
#endif
:include poppack.sp
#endif  /* _POSIX_SOURCE || _QNX_SOURCE || !NO_EXT_KEYS */

typedef void (__SIG_FAR *__far_sig_func)( int );

#define __FAR_SIG_ERR       ((__far_sig_func)(unsigned)-1)
#define __FAR_SIG_DFL       ((__far_sig_func)(unsigned)0)
#define __FAR_SIG_IGN       ((__far_sig_func)(unsigned)1)
#define __FAR_SIG_HOLD      ((__far_sig_func)(unsigned)2)

#define SIG_ERR             ((__sig_func)__FAR_SIG_ERR)
#define SIG_DFL             ((__sig_func)__FAR_SIG_DFL)
#define SIG_IGN             ((__sig_func)__FAR_SIG_IGN)
#define SIG_HOLD            ((__sig_func)__FAR_SIG_HOLD)

#define SIGHUP      1   /* hangup */
#define SIGINT      2   /* interrupt */
#define SIGQUIT     3   /* quit */
#define SIGILL      4   /* illegal instruction (not reset when caught) */
#define SIGTRAP     5   /* trace trap (not reset when caught) */
#define SIGIOT      6   /* IOT instruction */
#define SIGABRT     6   /* used by abort */
#define SIGEMT      7   /* EMT instruction */
#define SIGFPE      8   /* floating point exception */
#define SIGKILL     9   /* kill (cannot be caught or ignored) */
#define SIGBUS      10  /* bus error */
#define SIGSEGV     11  /* segmentation violation */
#define SIGSYS      12  /* bad argument to system call */
#define SIGPIPE     13  /* write on pipe with no reader */
#define SIGALRM     14  /* real-time alarm clock */
#define SIGTERM     15  /* software termination signal from kill */
#define SIGUSR1     16  /* user defined signal 1 */
#define SIGUSR2     17  /* user defined signal 2 */
#define SIGCHLD     18  /* death of child */
#define SIGPWR      19  /* power-fail restart */
#define SIGWINCH    20  /* window change */
#define SIGURG      21  /* urgent condition on I/O channel */
#define SIGPOLL     22  /* System V name for SIGIO */
#define SIGIO       22  /* Asynchronus I/O */
#define SIGSTOP     23  /* sendable stop signal not from tty */
#define SIGTSTP     24  /* stop signal from tty */
#define SIGCONT     25  /* continue a stopped process */
#define SIGTTIN     26  /* attempted background tty read */
#define SIGTTOU     27  /* attempted background tty write */
#define SIGDEV      28  /* Dev event */

#define _SIGMAX     32
:elsesegment

#define SIG_IGN         ((__sig_func) 1)
#define SIG_DFL         ((__sig_func) 2)
#define SIG_ERR         ((__sig_func) 3)

#define SIGABRT 1
#define SIGFPE  2
#define SIGILL  3
#define SIGINT  4
#define SIGSEGV 5
#define SIGTERM 6
#define SIGBREAK 7
/* following are OS/2 1.x process flag A,B and C */
#define SIGUSR1 8
#define SIGUSR2 9
#define SIGUSR3 10
/* following are for OS/2 2.x only */
#define SIGIDIVZ 11
#define SIGIOVFL 12

#define _SIGMAX     12
:endsegment
#define _SIGMIN     1

:segment QNX
/* sigprocmask() flags */
#define SIG_BLOCK   0
#define SIG_UNBLOCK 1
#define SIG_SETMASK 2

#define SA_NOCLDSTOP 0x00000001
:endsegment

:segment CNAME
namespace std {
:endsegment
_WCRTLINK extern int  raise( int __sig );
_WCRTLINK extern void (*signal( int __sig, void (*__func)(int) ) )(int);
:segment CNAME
}
:endsegment

:segment QNX | LINUX
#if defined(_POSIX_SOURCE) || defined(_QNX_SOURCE) || !defined(NO_EXT_KEYS)
_WCRTLINK extern int  kill( pid_t __pid, int __signum );
_WCRTLINK extern int  sigaction( int __signo, const struct sigaction *__act, struct sigaction *__oact );
_WCRTLINK extern int  sigaddset( sigset_t *__set, int __signo );
_WCRTLINK extern int  sigdelset( sigset_t *__set, int __signo );
_WCRTLINK extern int  sigemptyset( sigset_t *__set );
_WCRTLINK extern int  sigfillset( sigset_t *__set );
_WCRTLINK extern int  sigismember( const sigset_t *__set, int __signo );
_WCRTLINK extern int  sigpending( sigset_t *__set );
_WCRTLINK extern int  sigprocmask( int __how, const sigset_t *__set, sigset_t *__oset );
_WCRTLINK extern int  sigsuspend( const sigset_t *sigmask );
#endif  /* _POSIX_SOURCE || _QNX_SOURCE || !NO_EXT_KEYS */
:endsegment

:segment CNAME
:include cplusepi.sp
:endsegment

:segment !CNAME
#endif /* __cplusplus */
:endsegment
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?