delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/22/08:55:38

Date: Sun, 22 Mar 1998 16:54:11 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: sigpending and sigprocmask
Message-ID: <Pine.SUN.3.91.980322165313.12643F-100000@is>
MIME-Version: 1.0

Somebody complained about `sigpending' being on the same object module
as `sigprocmask'; allegedly, this makes problems for some threading
package.

I don't really understand how come `sigpending' is not thread-safe
while `sigprocmask' is, but since I'm responsible for that unholy
marriage, here's the divorce:

*** src/libc/posix/signal/sigprocm.c~0	Sun Aug 31 17:07:16 1997
--- src/libc/posix/signal/sigprocm.c	Fri Mar 20 19:38:56 1998
***************
*** 1,3 ****
--- 1,4 ----
+ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
*************** static int sigprocmask_count = -1;
*** 12,18 ****
  static sigset_t current_mask;
  
  /* Which signals are pending (initially none).  */
! static sigset_t pending_signals;
  
  /* Previous handlers to restore when the blocked signals are unblocked.  */
  typedef void (*sighandler_t)(int);
--- 13,19 ----
  static sigset_t current_mask;
  
  /* Which signals are pending (initially none).  */
! sigset_t __sigprocmask_pending_signals;
  
  /* Previous handlers to restore when the blocked signals are unblocked.  */
  typedef void (*sighandler_t)(int);
*************** static sighandler_t prev_handlers[SIGMAX
*** 23,29 ****
  static void
  sig_suspender (int signo)
  {
!   sigaddset (&pending_signals, signo);
  }
  
  int
--- 24,30 ----
  static void
  sig_suspender (int signo)
  {
!   sigaddset (&__sigprocmask_pending_signals, signo);
  }
  
  int
*************** sigprocmask (int how, const sigset_t *ne
*** 36,42 ****
    if (sigprocmask_count != __bss_count)
      {
        sigprocmask_count = __bss_count;
!       sigemptyset (&pending_signals);
        sigemptyset (&current_mask);
        for (signo = 0; signo < SIGMAX; signo++)
  	prev_handlers[signo] = SIG_ERR;
--- 37,43 ----
    if (sigprocmask_count != __bss_count)
      {
        sigprocmask_count = __bss_count;
!       sigemptyset (&__sigprocmask_pending_signals);
        sigemptyset (&current_mask);
        for (signo = 0; signo < SIGMAX; signo++)
  	prev_handlers[signo] = SIG_ERR;
*************** sigprocmask (int how, const sigset_t *ne
*** 81,107 ****
  	      signal (signo, prev_handlers[signo]);
  	      prev_handlers[signo] = SIG_ERR;
  	    }
! 	  if (sigismember (&pending_signals, signo))
  	    {
! 	      sigdelset (&pending_signals, signo);
  	      raise (signo);
  	    }
  	}
      }
    current_mask = new_mask;
-   return 0;
- }
- 
- int
- sigpending(sigset_t *set)
- {
-   if (set == (sigset_t *)0)
-     {
-       errno = EFAULT;
-       return -1;
-     }
- 
-   *set = pending_signals;
    return 0;
  }
  
--- 82,95 ----
  	      signal (signo, prev_handlers[signo]);
  	      prev_handlers[signo] = SIG_ERR;
  	    }
! 	  if (sigismember (&__sigprocmask_pending_signals, signo))
  	    {
! 	      sigdelset (&__sigprocmask_pending_signals, signo);
  	      raise (signo);
  	    }
  	}
      }
    current_mask = new_mask;
    return 0;
  }
  
*** /dev/null	Fri Mar 20 19:43:48 1998
--- src/libc/posix/signal/sigpendi.c	Fri Mar 20 19:39:00 1998
***************
*** 0 ****
--- 1,19 ----
+ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
+ #include <libc/stubs.h>
+ #include <signal.h>
+ #include <errno.h>
+ 
+ extern sigset_t __sigprocmask_pending_signals;
+ 
+ int
+ sigpending(sigset_t *set)
+ {
+   if (set == (sigset_t *)0)
+     {
+       errno = EFAULT;
+       return -1;
+     }
+ 
+   *set = __sigprocmask_pending_signals;
+   return 0;
+ }
*** src/libc/posix/signal/makefile.~0	Sun Aug 31 21:20:34 1997
--- src/libc/posix/signal/makefile	Fri Mar 20 19:41:54 1998
*************** SRC += sigempty.c
*** 10,15 ****
--- 10,16 ----
  SRC += sigfills.c
  SRC += sigismem.c
  SRC += sigprocm.c
+ SRC += sigpendi.c
  SRC += sigsuspe.c
  
  include $(TOP)/../makefile.inc

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019