On 03/04/13 23:15, Jordan Justen wrote:

> Hmm, I was wondering what ~(BIT13|BIT12|BIT11|BIT10) might do, but
> then I saw that BIT31 and lower in Base.h don't use the 'u' suffix.

What about

// inclusive "high", width > high >= low >= 0
#define BITS32I(high, low) BITS32((high) + 1, (low))
#define BITS64I(high, low) BITS62((high) + 1, (low))

// exclusive "high", width >= high > low >= 0
#define BITS32(high, low) ((UINT32)-1 >> 32 - (high) + (low) << (low))
#define BITS64(high, low) ((UINT64)-1 >> 64 - (high) + (low) << (low))

Then it would be (UINT16)~BITS32I(13, 10).

Alas these evaluate "low" twice, but I can't readily see a solution with
single evaluation. For example

#define BITS32(high, low) ((UINT32)-1 << (high) ^ (UINT32)-1 << (low))

is undefined behavior for high==32 (which is valid input for the
exclusive case).

Laszlo

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to