CMS 3D CMS Logo

Signal.h

Go to the documentation of this file.
00001 #ifndef CLASSLIB_SYSAPI_SIGNAL_H
00002 # define CLASSLIB_SYSAPI_SIGNAL_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "classlib/sysapi/system.h"
00007 # include <cstdio>
00008 # include <cstdlib>
00009 # include <cerrno>
00010 
00011 # ifdef _WIN32
00012 #  include <windows.h>
00013 # else
00014 #  include <unistd.h>
00015 #  include <sys/stat.h>
00016 #  include <ucontext.h>
00017 # endif
00018 
00019 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00020 
00021 // Not all systems with POSIX signals necessarily have SA_SIGINFO.
00022 # ifndef SA_SIGINFO
00023 #  define SA_SIGINFO 0
00024 # endif
00025 
00026 // Hacks for fields we might not have in siginfo_t.  Just print zero.
00027 # if !HAVE_SIGINFO_SI_UTIME             // darwin
00028 #  define si_utime si_signo ? 0 : 0
00029 #  define si_stime si_signo ? 0 : 0
00030 # endif
00031 # if !HAVE_SIGINFO_SI_INT
00032 #  if HAVE_SIGINFO_SI_VALUE             // darwin
00033 #   define si_int   si_value.sigval_int
00034 #   define si_ptr   si_value.sigval_ptr
00035 #  else                                 // (none known)
00036 #   define si_int   si_signo ? 0 : 0
00037 #   define si_ptr   si_signo ? (void *) 0 : (void *) 0
00038 #  endif
00039 # endif
00040 
00041 // Windows doesn't have this, so fake a suitable substitute
00042 # ifdef _WIN32
00043 #  define STDERR_HANDLE GetStdHandle (STD_ERROR_HANDLE)
00044 # else
00045 #  define STDERR_HANDLE STDERR_FILENO
00046 # endif
00047 
00048 // Define a suitable wrapper to write to system file descriptors.
00049 // This is needed because on Windows we are using HANDLEs, not the
00050 // compiler's crippled posixy interface.
00051 # ifdef _WIN32
00052 #  define MYWRITE(fd,data,n)    do { DWORD written; WriteFile(fd,data,n,\
00053                                         &written,0); } while (0)
00054 # else
00055 #  define MYWRITE(fd,data,n)    write(fd,data,n)
00056 # endif
00057 
00058 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00059 
00064 static const int SIGNAL_MESSAGE_BUFSIZE = 256;
00065 
00066 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00067 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00068 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00069 
00070 #if HAVE_RAISE && !HAVE_RAISE_DECL
00071 // raise() declaration for systems that have the function but do
00072 // not declare it in their headers.  (FIXME: Are there any?)
00073 extern "C" int raise (int signalnr);
00074 #endif
00075 
00076 #if HAVE_STRSIGNAL && !HAVE_STRSIGNAL_DECL
00077 // strsignal() declaration for systems that have the function but do
00078 // not declare it in their headers.  (FIXME: Are there any?)
00079 extern "C" char *strsignal (int signalnr);
00080 #endif
00081 
00082 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00083 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00084 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00085 
00086 #endif // CLASSLIB_SYSAPI_SIGNAL_H

Generated on Tue Jun 9 17:38:53 2009 for CMSSW by  doxygen 1.5.4