You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/15 13:36:06 UTC
svn commit: r815278 - in /commons/sandbox/runtime/trunk/src/main/native:
include/arch/windows/acr_arch.h os/win32/signals.c
Author: mturk
Date: Tue Sep 15 11:36:06 2009
New Revision: 815278
URL: http://svn.apache.org/viewvc?rev=815278&view=rev
Log:
Extend Win32 posix signals
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=815278&r1=815277&r2=815278&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Tue Sep 15 11:36:06 2009
@@ -471,11 +471,63 @@
#define SIG_SGE (SIG_PF)4 /* signal gets error */
#define SIG_ACK (SIG_PF)5 /* acknowledge */
-#define sigmask(S) (1 << ((S) - 1))
+#define sigmask(S) (1 << ((S) - 1) & 31)
#define SIG_BLOCK 1
#define SIG_UNBLOCK 2
#define SIG_SETMASK 3
+typedef LONG sigset_t;
+
+typedef union sigval {
+ /* Members as suggested by Annex C of POSIX 1003.1b. */
+ int sival_int;
+ void *sival_ptr;
+} sigval_t;
+
+typedef struct siginfo {
+ int si_signo; /* Signal number */
+ int si_errno; /* An errno value */
+ DWORD si_pid; /* Sending process ID */
+ DWORD si_uid; /* Real user ID of sending process */
+ int si_status; /* Exit value or signal */
+ sigval_t si_value; /* Signal value */
+} siginfo_t;
+
+struct sigaction {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
+};
+
+ACR_INLINE int sigaddset(sigset_t *set, int signo)
+{
+
+ if (signo <= 0 || signo >= _NSIG) {
+ return ACR_EINVAL;
+ }
+ *set |= (1 << ((signo)-1));
+ return 0;
+}
+
+ACR_INLINE int sigdelset(sigset_t *set, int signo) {
+
+ if (signo <= 0 || signo >= _NSIG) {
+ return ACR_EINVAL;
+ }
+ *set &= ~(1 << ((signo)-1));
+ return 0;
+}
+
+ACR_INLINE int sigismember(const sigset_t *set, int signo)
+{
+
+ if (signo <= 0 || signo >= _NSIG) {
+ return ACR_EINVAL;
+ }
+ return (*set & (1 << ((signo)-1))) != 0;
+}
/*
* ---------------------------------------------------------------------
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c?rev=815278&r1=815277&r2=815278&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c Tue Sep 15 11:36:06 2009
@@ -50,10 +50,10 @@
#define PIPE_TIMEOUT 1000
static CRITICAL_SECTION signal_lock;
-int dll_daemon_mode = 0;
-volatile LONG current_signal_mask;
-volatile LONG current_signal_queue;
-volatile LONG current_signal_listeners;
+int dll_daemon_mode = 0;
+volatile sigset_t current_signal_mask;
+volatile sigset_t current_signal_queue;
+volatile LONG current_signal_listeners;
static SIG_PF signal_handlers[ACR_NUMSIG];
static volatile int signal_handlers_running;
@@ -196,7 +196,7 @@
if (posix_signal) {
/* Sync with signal callback handler */
EnterCriticalSection(&signal_lock);
- current_signal_queue |= sigmask(posix_signal);
+ sigaddset(current_signal_queue, posix_signal);
/* Fire the signal events.
* The first locked listener will handle
* the signal.
@@ -238,7 +238,7 @@
}
/* Sync with signal handler */
EnterCriticalSection(&signal_lock);
- current_signal_queue |= sigmask(pd->msg.signal);
+ sigaddset(current_signal_queue, pd->msg.signal);
/* Notify the signal monitor thread.
* Signal monitor thread will interrupt all waiters
* and dispatch the signals if there are no waiters pending.
@@ -536,7 +536,7 @@
}
/* Remove the signal from the queue
*/
- current_signal_queue &= ~sigmask(i);
+ sigdelset(current_signal_queue, i);
if (sig != SIG_IGN && sig != SIG_ERR) {
LeaveCriticalSection(&signal_lock);
(*sig)(i);