Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jan 2000 08:27:18 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        Satoshi Asami <asami@cs.berkeley.edu>, current@FreeBSD.ORG
Subject:   Re: sigisempty?
Message-ID:  <Pine.BSF.4.21.0001200800100.1541-100000@alphplex.bde.org>
In-Reply-To: <200001191657.LAA29895@khavrinen.lcs.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 19 Jan 2000, Garrett Wollman wrote:

> <<On Wed, 19 Jan 2000 07:03:04 -0800 (PST), asami@cs.berkeley.edu (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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001200800100.1541-100000>