Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 34043 invoked from network); 15 Sep 2009 11:37:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Sep 2009 11:37:03 -0000 Received: (qmail 94743 invoked by uid 500); 15 Sep 2009 11:37:01 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 94665 invoked by uid 500); 15 Sep 2009 11:37:01 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 94656 invoked by uid 99); 15 Sep 2009 11:37:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Sep 2009 11:37:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Sep 2009 11:36:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D6BD02388978; Tue, 15 Sep 2009 11:36:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r815278 - in /commons/sandbox/runtime/trunk/src/main/native: include/arch/windows/acr_arch.h os/win32/signals.c Date: Tue, 15 Sep 2009 11:36:06 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090915113606.D6BD02388978@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);