Date: Wed, 20 Jun 2001 09:49:25 -0700 From: John Merryweather Cooper <jmcoopr@webmail.bmi.net> To: j mckitrick <jcm@FreeBSD-uk.eu.org> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: what does this define do? Message-ID: <20010620094925.A14541@johncoop> 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 References: <20010620173855.A2941@dogma.freebsd-uk.eu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010620094925.A14541>