From owner-freebsd-questions Wed Jun 20 9:52:37 2001 Delivered-To: freebsd-questions@freebsd.org Received: from smtp.bmi.net (smtp.bmi.net [204.57.191.31]) by hub.freebsd.org (Postfix) with ESMTP id 7EAF837B403 for ; Wed, 20 Jun 2001 09:52:34 -0700 (PDT) (envelope-from jmcoopr@webmail.bmi.net) Received: from smtp.bmi.net (dsl-154.bmi.net [207.173.60.230]) by smtp.bmi.net (Pro-8.9.3/Pro-8.9.3) with SMTP id JAA03283; Wed, 20 Jun 2001 09:49:21 -0700 Date: Wed, 20 Jun 2001 09:49:25 -0700 From: John Merryweather Cooper To: j mckitrick Cc: freebsd-questions@FreeBSD.ORG Subject: Re: what does this define do? Message-ID: <20010620094925.A14541@johncoop> References: <20010620173855.A2941@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit In-Reply-To: <20010620173855.A2941@dogma.freebsd-uk.eu.org>; from jcm@FreeBSD-uk.eu.org on Wed, Jun 20, 2001 at 09:38:55 -0700 X-Mailer: Balsa 1.1.4 Lines: 33 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2001.06.20 09:38 j mckitrick wrote: > > at the risk of making a fool of myself (one which i am never hesitant to > take ;-) could someone explain to me how this macro > > #define n(flags) (~(flags) & (flags)) > > is different from this one? > > #define n(flags) 0 > > Potentially, in the code generated . . . This is, of course, highly compiler dependent. Looks like somebody is concerned with the efficiency of a MOV AX, 0 as opposed to an XOR AX, AX. But IMHO, this is a waste of effort in C, since God only knows what the compiler is going to puke out for this define. The first macro might even result in a performance "hit" if the compiler has to make some internal calls on the flags pseudo parameter to do bitwise operations on it. It might be interesting (for the curious) to see how above and the following differ in code output: #define n(flags) ((flags) - (flags)) #define n(flags) ((flags) ^ (flags)) jmc > Jonathon > -- > "It is through will alone I set my mind in motion...." > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message