Re: sigisempty?

2000-01-24 Thread Satoshi - Ports Wraith - Asami

 * From: Bruce Evans [EMAIL PROTECTED]

 * The correct answer seems to be "you can't do that" :-).  Even checking

Err.  Now why am I not surprised that you said that? ;)

Anyway, I have committed the following patch submitted by Alexander
Langer.  It has a nice feature of working for both -current and
-stable without any additional #ifdef's.  I hope it's ok.

Satoshi
===
--- lib/libxview/notify/ntfy.h.orig Tue Jun 29 07:18:14 1993
+++ lib/libxview/notify/ntfy.h  Mon Jan 10 15:50:53 2000
@@ -188,7 +197,12 @@
 #define sigisempty(s)   (!(((s)-__sigbits[0]) | ((s)-__sigbits[1])   \
 | ((s)-__sigbits[2]) | ((s)-__sigbits[3])))
 #else
-#define sigisempty(s)   (!(*(s)))
+static int
+sigisempty (sigset_t *s) {
+   sigset_t n;  
+   bzero(n, sizeof(sigset_t));
+   return (! memcmp(n, s, sizeof(sigset_t)));
+}
 #endif
 
 /*


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: sigisempty?

2000-01-24 Thread Kelly Yancey

On 24 Jan 2000, Satoshi - Ports Wraith - Asami wrote:

 Anyway, I have committed the following patch submitted by Alexander
 Langer.  It has a nice feature of working for both -current and
 -stable without any additional #ifdef's.  I hope it's ok.
 
 Satoshi
 ===
 --- lib/libxview/notify/ntfy.h.orig   Tue Jun 29 07:18:14 1993
 +++ lib/libxview/notify/ntfy.hMon Jan 10 15:50:53 2000
 @@ -188,7 +197,12 @@
  #define sigisempty(s)   (!(((s)-__sigbits[0]) | ((s)-__sigbits[1])   \
  | ((s)-__sigbits[2]) | ((s)-__sigbits[3])))
  #else
 -#define sigisempty(s)   (!(*(s)))
 +static int
 +sigisempty (sigset_t *s) {
 + sigset_t n;  
 + bzero(n, sizeof(sigset_t));
 + return (! memcmp(n, s, sizeof(sigset_t)));
 +}
  #endif
  
  /*
 

  Suggestion: use sigemptyset() rather than bzero().

  Kelly

--
Kelly Yancey  -  [EMAIL PROTECTED]  -  Richmond, VA
Analyst / E-business Development, Bell Industries  http://www.bellind.com/
Maintainer, BSD Driver Database   http://www.posi.net/freebsd/drivers/
Coordinator, Team FreeBSDhttp://www.posi.net/freebsd/Team-FreeBSD/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: sigisempty?

2000-01-24 Thread Alexander Langer

Thus spake Satoshi - Ports Wraith - Asami ([EMAIL PROTECTED]):

 Langer.  It has a nice feature of working for both -current and
 -stable without any additional #ifdef's.  I hope it's ok.

I now saw Garret Wollman's function.
I like the use of the static-vars.

The use of sigemptyset makes it more transparenter for later changes,
that I hope won't occur, but at the moment it doesn't matter since
sigemptyset is 

int
sigemptyset(set)
sigset_t *set;
{
int i;

for (i = 0; i  _SIG_WORDS; i++)
set-__bits[i] = 0;
return (0);
}

I attached a patch against patch-lo anyways (sorry ;-)

Alex
-- 
I doubt, therefore I might be. 


--- /tmp/xview/patches/patch-lo Thu Jan 20 04:38:25 2000
+++ patch-loMon Jan 24 17:14:58 2000
@@ -20,15 +20,17 @@
union   wait status;/* Return value from wait3 */
  #else SVR4
int status; /* Return value from wait3 */
-@@ -188,7 +197,12 @@
+@@ -188,7 +197,14 @@
  #define sigisempty(s)   (!(((s)-__sigbits[0]) | ((s)-__sigbits[1])   \
  | ((s)-__sigbits[2]) | ((s)-__sigbits[3])))
  #else
 -#define sigisempty(s)   (!(*(s)))
 +static int
 +sigisempty (sigset_t *s) {
-+  sigset_t n;  
-+  bzero(n, sizeof(sigset_t));
++  static sigset_t n;  
++  static int emptied = 0;
++  if (!emptied)
++  sigemptyset(n), emptied++;
 +  return (! memcmp(n, s, sizeof(sigset_t)));
 +}
  #endif



Re: sigisempty?

2000-01-19 Thread Bruce Evans

On Wed, 19 Jan 2000, Garrett Wollman wrote:

 On Wed, 19 Jan 2000 07:03:04 -0800 (PST), [EMAIL PROTECTED] (Satoshi Asami) 
said:
 
  How do I test if sigset_t is empty in -current?  The xview sources
  have this macro:
 
 int
 sigisempty(sigset_t *my_sigset)
 {
   static sigset_t empty_ss;
   static int emptied;
 
   if (!emptied) {
   sigemptyset(empty_ss);
   emptied++;
   }
 
   return (memcmp(my_sigset, empty_ss, sizeof empty_ss) == 0);
 }

You should know better than to compare structs for equality.  Even
the implementation can't do this in a machine-independent way.  The
current implementation can do it machine-independently by comparing
each element of the __bits[] struct member with 0.

The correct answer seems to be "you can't do that" :-).  Even checking
all signals from 1 to the maximum signal number is difficult because
the maximum signal number is difficult to determine and it may be
INT_MAX.

rcs has fought with variations of this problem.  It now uses the following
method: keep track of the largest signal number of interest for the
current operation, and check all signals from that signal number down to 1.
See rcs/lib/rcsutil.c.

Bruce



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: sigisempty?

2000-01-19 Thread Anton Berezin

On Wed, Jan 19, 2000 at 07:03:04AM -0800, Satoshi Asami wrote:

 How do I test if sigset_t is empty in -current?  The xview sources
 have this macro:
 
 #define sigisempty(s)   (!(*(s)))
 
 which is ok for the old sigset_t (unsigned int) but obviously won't
 work for the new one since it's a struct.

The very same file nfty.h already has a hack for SVR4:

#ifdef SVR4
#define sigisempty(s)   (!(((s)-__sigbits[0]) | ((s)-__sigbits[1])   \
| ((s)-__sigbits[2]) | ((s)-__sigbits[3])))

When I compiled xview on a -current machine I just did it the very same
hacky way:

#define sigisempty(s)   (!(((s)-__bits[0]) | ((s)-__bits[1])   \
| ((s)-__bits[2]) | ((s)-__bits[3])))

Of course, the #if for FreeBSD and its version is necessary.

Cheers,
-- 
Anton Berezin [EMAIL PROTECTED]
The Protein Laboratory, University of Copenhagen


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message