From owner-freebsd-current Wed Jan 19 13:27:29 2000 Delivered-To: freebsd-current@freebsd.org Received: from gidora.zeta.org.au (gidora.zeta.org.au [203.26.10.25]) by hub.freebsd.org (Postfix) with SMTP id EAD9E152D3 for ; Wed, 19 Jan 2000 13:27:24 -0800 (PST) (envelope-from bde@zeta.org.au) Received: (qmail 1672 invoked from network); 19 Jan 2000 21:27:20 -0000 Received: from bde.zeta.org.au (203.2.228.102) by gidora.zeta.org.au with SMTP; 19 Jan 2000 21:27:20 -0000 Date: Thu, 20 Jan 2000 08:27:18 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Garrett Wollman Cc: Satoshi Asami , current@FreeBSD.ORG Subject: Re: sigisempty? In-Reply-To: <200001191657.LAA29895@khavrinen.lcs.mit.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 19 Jan 2000, Garrett Wollman wrote: > < > > 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