[haiku-commits] r41595 - in haiku/branches/developer/bonefish/signals: headers/posix src/apps/terminal src/bin/debug/profile src/bin/debug/scheduling_recorder src/system/libroot/posix/signal

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 19 May 2011 22:39:12 +0200 (CEST)

Author: bonefish
Date: 2011-05-19 22:39:11 +0200 (Thu, 19 May 2011)
New Revision: 41595
Changeset: https://dev.haiku-os.org/changeset/41595

Modified:
   haiku/branches/developer/bonefish/signals/headers/posix/signal.h
   haiku/branches/developer/bonefish/signals/src/apps/terminal/TermApp.cpp
   haiku/branches/developer/bonefish/signals/src/bin/debug/profile/profile.cpp
   
haiku/branches/developer/bonefish/signals/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp
   
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/set_signal_disposition.cpp
   
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/signal.c
Log:
<signal.h>:
* Style cleanup.
* Grouped function prototypes by functionality.
* Marked extensions.
* Removed BeOS typedef __signal_func_ptr. Added typedef __sighandler_t instead
  and replaced all occurrences of sighandler_t with it. sighandler_t is a GNU
  extension and now only defined when __USE_GNU is defined.


Modified: haiku/branches/developer/bonefish/signals/headers/posix/signal.h
===================================================================
--- haiku/branches/developer/bonefish/signals/headers/posix/signal.h    
2011-05-19 20:38:53 UTC (rev 41594)
+++ haiku/branches/developer/bonefish/signals/headers/posix/signal.h    
2011-05-19 20:39:11 UTC (rev 41595)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2011 Haiku, Inc. All Rights Reserved.
+ * Copyright 2002-2011, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  */
 #ifndef _SIGNAL_H_
@@ -12,22 +12,26 @@
 typedef int    sig_atomic_t;
 typedef __haiku_int32 sigset_t;
 
-typedef void (*sighandler_t)(int);
+
+/* signal handler function type */
+typedef void (*__sighandler_t)(int);
+
+#ifdef __USE_GNU
+typedef __sighandler_t sighandler_t;
        /* GNU-like signal handler typedef */
+#endif
 
-typedef void (*__signal_func_ptr)(int);
-       /* deprecated, for compatibility with BeOS only */
 
-
 /* macros defining the standard signal handling behavior */
-#define SIG_DFL                ((sighandler_t)0)       /* "default" signal 
behaviour */
-#define SIG_IGN                ((sighandler_t)1)       /* ignore signal */
-#define SIG_ERR                ((sighandler_t)-1)      /* an error occurred 
during signal processing */
-#define SIG_HOLD       ((sighandler_t)3)       /* the signal was hold */
+#define SIG_DFL                ((__sighandler_t)0)             /* "default" 
signal behaviour */
+#define SIG_IGN                ((__sighandler_t)1)             /* ignore 
signal */
+#define SIG_ERR                ((__sighandler_t)-1)    /* an error occurred 
during signal
+                                                                               
           processing */
+#define SIG_HOLD       ((__sighandler_t)3)             /* the signal was hold 
*/
 
 union sigval {
        int             sival_int;
-       void    *sival_ptr;
+       void*   sival_ptr;
 };
 
 typedef struct {
@@ -37,26 +41,22 @@
                                                                   this signal 
*/
        pid_t                   si_pid;         /* sending process ID */
        uid_t                   si_uid;         /* real user ID of sending 
process */
-       void                    *si_addr;       /* address of faulting 
instruction */
+       void*                   si_addr;        /* address of faulting 
instruction */
        int                             si_status;      /* exit value or signal 
*/
        long                    si_band;        /* band event for SIGPOLL */
        union sigval    si_value;       /* signal value */
 } siginfo_t;
 
-/*
- * structure used by sigaction()
- *
- * Note: the 'sa_userdata' field is a non-POSIX extension.
- * See the documentation for more info on this.
- */
+/* structure used by sigaction() */
 struct sigaction {
        union {
-               sighandler_t    sa_handler;
-               void                    (*sa_sigaction)(int, siginfo_t *, void 
*);
+               __sighandler_t  sa_handler;
+               void                    (*sa_sigaction)(int, siginfo_t*, void*);
        };
        sigset_t        sa_mask;
        int                     sa_flags;
-       void            *sa_userdata;  /* will be passed to the signal handler 
*/
+       void*           sa_userdata;    /* will be passed to the signal handler,
+                                                                  BeOS 
extension */
 };
 
 /* values for sa_flags */
@@ -78,18 +78,16 @@
 #define MINSIGSTKSZ            4096
 #define SIGSTKSZ               16384
 
-/*
- * for signals using an alternate stack
- */
+/* for signals using an alternate stack */
 typedef struct stack_t {
-       void    *ss_sp;
+       void*   ss_sp;
        size_t  ss_size;
        int             ss_flags;
 } stack_t;
 
 typedef struct sigstack {
        int     ss_onstack;
-       void    *ss_sp;
+       void*   ss_sp;
 } sigstack;
 
 /* for the 'how' arg of sigprocmask() */
@@ -141,8 +139,10 @@
  * releases.  Use them at your own peril (if you do use them, at least
  * be smart and use them backwards from signal 32).
  */
-#define MAX_SIGNO              32      /* the most signals that a single 
thread can reference */
-#define __signal_max   29      /* the largest signal number that is actually 
defined */
+#define MAX_SIGNO              32      /* the most signals that a single 
thread can
+                                                          reference */
+#define __signal_max   29      /* the largest signal number that is actually
+                                                          defined */
 #define NSIG                   (__signal_max+1)
        /* the number of defined signals */
 
@@ -200,54 +200,68 @@
 
 
 /* the global table of text strings containing descriptions for each signal */
-extern const char * const sys_siglist[NSIG];
+extern const char* const sys_siglist[NSIG];
+       /* BSD extension */
 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-sighandler_t signal(int sig, sighandler_t signalHandler);
-sighandler_t sigset(int sig, sighandler_t signalHandler);
-int     raise(int sig);
-int     kill(pid_t pid, int sig);
-int     send_signal(pid_t tid, unsigned int sig);
-int            killpg(pid_t processGroupID, int sig);
+
+/* signal management (actions and block masks) */
+__sighandler_t signal(int signal, __sighandler_t signalHandler);
+int     sigaction(int signal, const struct sigaction* action,
+                       struct sigaction* oldAction);
+__sighandler_t sigset(int signal, __sighandler_t signalHandler);
+int            sigignore(int signal);
+int            sighold(int signal);
+int            sigrelse(int signal);
+int            sigpause(int signal);
+int            siginterrupt(int signal, int flag);
+
+int     sigprocmask(int how, const sigset_t* set, sigset_t* oldSet);
+int            pthread_sigmask(int how, const sigset_t* set, sigset_t* oldSet);
+
+/* sending signals */
+int     raise(int signal);
+int     kill(pid_t pid, int signal);
+int            killpg(pid_t processGroupID, int signal);
 int            sigqueue(pid_t pid, int signal, const union sigval userValue);
+int            pthread_kill(pthread_t thread, int signal);
+int     send_signal(pid_t threadID, unsigned int signal);
+                       /* BeOS extension */
 
-int     sigaction(int sig, const struct sigaction *act, struct sigaction 
*oact);
-int            siginterrupt(int sig, int flag);
-int     sigprocmask(int how, const sigset_t *set, sigset_t *oset);
-int     sigpending(sigset_t *set);
-int     sigsuspend(const sigset_t *mask);
-int    sigwait(const sigset_t *set, int *sig);
-int            sigwaitinfo(const sigset_t *set, siginfo_t *info);
-int            sigtimedwait(const sigset_t *set, siginfo_t *info,
-           const struct timespec *timeout);
+/* querying and waiting for signals */
+int     sigpending(sigset_t* set);
+int     sigsuspend(const sigset_t* mask);
+int    sigwait(const sigset_t* set, int* _signal);
+int            sigwaitinfo(const sigset_t* set, siginfo_t* info);
+int            sigtimedwait(const sigset_t* set, siginfo_t* info,
+           const struct timespec* timeout);
 
-int     sigemptyset(sigset_t *set);
-int     sigfillset(sigset_t *set);
-int    sigaddset(sigset_t *set, int signo);
-int    sigdelset(sigset_t *set, int signo);
-int    sigismember(const sigset_t *set, int signo);
-int            sigignore(int signo);
-int            sighold(int signo);
-int            sigrelse(int signo);
-int            sigpause(int signo);
+/* setting the per-thread signal stack */
+int            sigaltstack(const stack_t* stack, stack_t* oldStack);
+void   set_signal_stack(void* base, size_t size);
+                       /* BeOS extension */
 
-void   set_signal_stack(void *ptr, size_t size);
-int            sigaltstack(const stack_t *ss, stack_t *oss);
+/* signal set (sigset_t) manipulation */
+int     sigemptyset(sigset_t* set);
+int     sigfillset(sigset_t* set);
+int    sigaddset(sigset_t* set, int signal);
+int    sigdelset(sigset_t* set, int signal);
+int    sigismember(const sigset_t* set, int signal);
 
-int            pthread_kill(pthread_t thread, int signal);
-int            pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
+/* printing signal names */
+void   psiginfo(const siginfo_t* info, const char* message);
+void   psignal(int signal, const char* message);
 
-void   psiginfo(const siginfo_t *info, const char *message);
-void   psignal(int signal, const char *message);
 
 #ifdef __cplusplus
 }
 #endif
 
+
 /* TODO: move this into the documentation!
  * ==================================================
  * !!! SPECIAL NOTES CONCERNING NON-POSIX EXTENSIONS:
@@ -269,7 +283,7 @@
  * handling. It also allows an opportunity, via the 'sigaction' struct, to
  * enable additional data to be passed to the handler. For example:
  *    void
- *    my_signal_handler(int sig, char *userData, vregs regs)
+ *    my_signal_handler(int sig, char* userData, vregs regs)
  *    {
  *    . . .
  *    }
@@ -277,7 +291,7 @@
  *    struct sigaction sa;
  *    char data_buffer[32];
  *
- *    sa.sa_handler = (sighandler_t)my_signal_handler;
+ *    sa.sa_handler = (__sighandler_t)my_signal_handler;
  *    sigemptyset(&sa.sa_mask);
  *    sa.sa_userdata = userData;
  *
@@ -287,8 +301,9 @@
  * The two additional arguments available to the signal handler are extensions
  * to the Posix standard. This feature was introduced by the BeOS and retained
  * by Haiku. However, to remain compatible with Posix and ANSI C, the type
- * of the sa_handler field is defined as 'sighandler_t'. This requires the 
handler
- * to be cast when assigned to the sa_handler field, as in the example above.
+ * of the sa_handler field is defined as '__sighandler_t'. This requires the
+ * handler to be cast when assigned to the sa_handler field, as in the example
+ * above.
  *
  * The 3 arguments that Haiku provides to signal handlers are as follows:
  * 1) The first argument is the (usual) signal number.
@@ -310,18 +325,22 @@
  * signal handlers get this as the last argument
  */
 
+
 typedef struct vregs vregs;
+       /* BeOS extension */
 
+
 /* include architecture specific definitions */
 #include __HAIKU_ARCH_HEADER(signal.h)
 
+
 typedef struct vregs mcontext_t;
 
-typedef struct ucontext_t {
-       struct ucontext_t       *uc_link;
-       sigset_t        uc_sigmask;
-       stack_t         uc_stack;
-       mcontext_t      uc_mcontext;
+typedef struct __ucontext_t {
+       struct __ucontext_t*    uc_link;
+       sigset_t                                uc_sigmask;
+       stack_t                                 uc_stack;
+       mcontext_t                              uc_mcontext;
 } ucontext_t;
 
 

Modified: 
haiku/branches/developer/bonefish/signals/src/apps/terminal/TermApp.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/apps/terminal/TermApp.cpp     
2011-05-19 20:38:53 UTC (rev 41594)
+++ haiku/branches/developer/bonefish/signals/src/apps/terminal/TermApp.cpp     
2011-05-19 20:39:11 UTC (rev 41595)
@@ -78,7 +78,7 @@
        // a shell exits.
        struct sigaction action;
 #ifdef __HAIKU__
-       action.sa_handler = (sighandler_t)_SigChildHandler;
+       action.sa_handler = (__sighandler_t)_SigChildHandler;
 #else
        action.sa_handler = (__signal_func_ptr)_SigChildHandler;
 #endif

Modified: 
haiku/branches/developer/bonefish/signals/src/bin/debug/profile/profile.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/bin/debug/profile/profile.cpp 
2011-05-19 20:38:53 UTC (rev 41594)
+++ haiku/branches/developer/bonefish/signals/src/bin/debug/profile/profile.cpp 
2011-05-19 20:39:11 UTC (rev 41595)
@@ -653,7 +653,7 @@
 
        // install signal handlers so we can exit gracefully
     struct sigaction action;
-    action.sa_handler = (sighandler_t)signal_handler;
+    action.sa_handler = (__sighandler_t)signal_handler;
     sigemptyset(&action.sa_mask);
     action.sa_userdata = NULL;
     if (sigaction(SIGHUP, &action, NULL) < 0

Modified: 
haiku/branches/developer/bonefish/signals/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp
 2011-05-19 20:38:53 UTC (rev 41594)
+++ 
haiku/branches/developer/bonefish/signals/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp
 2011-05-19 20:39:11 UTC (rev 41595)
@@ -116,7 +116,7 @@
 
                // install signal handlers so we can exit gracefully
                struct sigaction action;
-               action.sa_handler = (sighandler_t)_SignalHandler;
+               action.sa_handler = (__sighandler_t)_SignalHandler;
                sigemptyset(&action.sa_mask);
                action.sa_userdata = this;
                if (sigaction(SIGHUP, &action, NULL) < 0

Modified: 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/set_signal_disposition.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/set_signal_disposition.cpp
        2011-05-19 20:38:53 UTC (rev 41594)
+++ 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/set_signal_disposition.cpp
        2011-05-19 20:39:11 UTC (rev 41595)
@@ -7,8 +7,8 @@
 #include <signal.h>
 
 
-sighandler_t
-sigset(int signal, sighandler_t signalHandler)
+__sighandler_t
+sigset(int signal, __sighandler_t signalHandler)
 {
        struct sigaction newAction;
        struct sigaction oldAction;
@@ -25,18 +25,18 @@
                        &oldAction) == -1) {
                return SIG_ERR;
        }
-       
+
        sigset_t newSet;
        sigset_t oldSet;
 
        sigemptyset(&newSet);
        sigaddset(&newSet, signal);
-       
+
        if (signalHandler == SIG_HOLD) {
                if (sigprocmask(SIG_BLOCK, &newSet, &oldSet) == -1)
                        return SIG_ERR;
        } else {
-               // Disposition is not equal to SIG_HOLD, so sig will be 
+               // Disposition is not equal to SIG_HOLD, so sig will be
                // removed from the calling process' signal mask.
                if (sigprocmask(SIG_UNBLOCK, &newSet, &oldSet) == -1)
                        return SIG_ERR;

Modified: 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/signal.c
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/signal.c
  2011-05-19 20:38:53 UTC (rev 41594)
+++ 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/signal/signal.c
  2011-05-19 20:39:11 UTC (rev 41595)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2007, Haiku Inc. All rights reserved.
+ * Copyright 2002-2011, Haiku Inc. All rights reserved.
  * Distributed under the terms of the MIT license.
  *
  * Author:
@@ -11,8 +11,8 @@
 #include <stdio.h>
 
 
-sighandler_t
-signal(int sig, sighandler_t signalHandler)
+__sighandler_t
+signal(int sig, __sighandler_t signalHandler)
 {
        struct sigaction newAction, oldAction;
 


Other related posts:

  • » [haiku-commits] r41595 - in haiku/branches/developer/bonefish/signals: headers/posix src/apps/terminal src/bin/debug/profile src/bin/debug/scheduling_recorder src/system/libroot/posix/signal - ingo_weinhold