[Mesa-dev] [PATCH 1/3] u_cpu_detect: make arch and little_endian constants, add abi and x86-64

Luca Barbieri luca at luca-barbieri.com
Fri Aug 13 19:19:24 PDT 2010


> There's no merit in duplicating in util_caps what's already provided by
> p_config.h / p_compiler.h

Indeed it's not a great thing.

However, Keith wanted to be able to check those with ifs instead of
#ifdefs, and it does indeed make the code a bit nicer.
But the current definitions in p_config.h don't allow that.

So it's either:
1. Duplicate it like I did in the latest patchset
2. Replace the p_config.h logic with something like in the latest
patchset and change hundreds of places in the codebase
3. Change the p_config.h logic so everything not defined is set to 0 instead
4. Give up and just use the #ifdefs as I did in the earlier patchsets

Thinking about it again, I'd suggest either #3 or #4 instead of the #1
I did there.
I don't think it's worth spending much time on this matter though.


BTW, I'm not sure why the PIPE_ARCH_* defines exist in the first
place, since the compiler already provides __i386__, WORDS_BIGENDIAN
and similar.
If Windows doesn't define them, ad-hoc code can be introduced to
define those, like
#if defined(WIN32) && !defined(__i386__)
#define __i386__
#endif

This should reduce the learning curve to the codebase. Several similar
issues exist like the use of INLINE, FREE, etc. instead of manually
defining the commonly used keywords in places where they are not
available.

But this is another matter, and also not really worth spending much
time on (except perhaps "INLINE" which at least personally I manage to
forget about almost every time).


More information about the mesa-dev mailing list