about summary refs log tree commit diff
path: root/sysdeps/posix/sigsetmask.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/sigsetmask.c')
-rw-r--r--sysdeps/posix/sigsetmask.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/sysdeps/posix/sigsetmask.c b/sysdeps/posix/sigsetmask.c
index 7b97a514b0..bb50e4fc10 100644
--- a/sysdeps/posix/sigsetmask.c
+++ b/sysdeps/posix/sigsetmask.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1994,1995,1996,1997,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1994-1997,2001-2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,38 +19,21 @@
 #include <errno.h>
 #include <signal.h>
 
+#include <sigset-cvt-mask.h>
+
 /* Set the mask of blocked signals to MASK, returning the old mask.  */
 int
 __sigsetmask (int mask)
 {
-  register unsigned int sig;
   sigset_t set, oset;
 
-  if (__sigemptyset (&set) < 0)
+  if (sigset_set_old_mask (&set, mask) < 0)
     return -1;
 
-  if (sizeof (mask) == sizeof (set))
-    *(int *) &set = mask;
-  else if (sizeof (unsigned long int) == sizeof (set))
-    *(unsigned long int *) &set = (unsigned int) mask;
-  else
-    for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; ++sig)
-      if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0)
-	return -1;
-
   if (__sigprocmask (SIG_SETMASK, &set, &oset) < 0)
     return -1;
 
-  if (sizeof (mask) == sizeof (oset))
-    mask = *(int *) &oset;
-  else if (sizeof (unsigned long int) == sizeof (oset))
-    mask = *(unsigned long int *) &oset;
-  else
-    for (sig = 1, mask = 0; sig < NSIG && sig <= sizeof (mask) * 8; ++sig)
-      if (__sigismember (&oset, sig))
-	mask |= sigmask (sig);
-
-  return mask;
+  return sigset_get_old_mask (&oset);
 }
 
 weak_alias (__sigsetmask, sigsetmask)