[Mesa-dev] [PATCH] mesa: fix situations where ffs or ffsl may not be defined
Alexander von Gluck
kallisti5 at unixzen.com
Tue Jan 10 20:35:19 PST 2012
On 10.01.2012 21:53, Brian Paul wrote:
> On Mon, Jan 9, 2012 at 2:39 PM, Alexander von Gluck
> <kallisti5 at unixzen.com> wrote:
>>
>> ---
>> src/mesa/main/imports.h | 16 ++++++++++++----
>> 1 files changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
>> index b7e8743..522ffeb 100644
>> --- a/src/mesa/main/imports.h
>> +++ b/src/mesa/main/imports.h
>> @@ -568,13 +568,19 @@ _mesa_init_sqrt_table(void);
>>
>> #ifdef __GNUC__
>>
>> -#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(ANDROID) ||
>> defined(__APPLE__)
>> +#if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
>> #define ffs __builtin_ffs
>> #define ffsll __builtin_ffsll
>> +#define _mesa_ffs __builtin_ffs
>> +#define _mesa_ffsll __builtin_ffsll
>> +#else /* older GCC, no builtin */
>> +#include <string.h>
>
> string.h is already included via compiler.h above.
Good catch. Reforming patch.
>> +extern int
>> +_mesa_ffs(int32_t i);
>> +extern int
>> +_mesa_ffsll(int64_t i);
>> #endif
>>
>> -#define _mesa_ffs(i) ffs(i)
>> -#define _mesa_ffsll(i) ffsll(i)
>>
>> #if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
>> #define _mesa_bitcount(i) __builtin_popcount(i)
>> @@ -586,7 +592,9 @@ extern unsigned int
>> _mesa_bitcount_64(uint64_t n);
>> #endif
>>
>> -#else
>> +#else /* non-GNUC */
>> +#include <strings.h>
>
> Why include strings.h here?
__mesa_ffs actually calls ffs if the OS is non-gnuc and not WIN32 or IBMC
This is because I was doing research on non-gnuc + ffs / ffsl and noticed
AIX and MacOS X have ffs / ffsl defined in strings.h vs string.h
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
http://publib.boulder.ibm.com/infocenter/aix/v6r1/topic/com.ibm.aix.basetechref/doc/basetrf1/bcopy.htm
Thanks!
-- Alex
More information about the mesa-dev
mailing list