--- radeon_cs_gem.c.orig 2014-11-28 13:44:09.000000000 -0500 +++ radeon_cs_gem.c 2014-11-29 20:38:14.000000000 -0500 @@ -78,14 +78,30 @@ static pthread_mutex_t id_mutex = PTHREAD_MUTEX_INITIALIZER; static uint32_t cs_id_source = 0; +#if __GNUC__*100000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__ >= 304060 /** * result is undefined if called with ~0 */ +/* __builtin_ctz returns number of trailing zeros, only gcc >= 3.4.6 */ static uint32_t get_first_zero(const uint32_t n) { - /* __builtin_ctz returns number of trailing zeros. */ return 1 << __builtin_ctz(~n); } +#else +/* in: ~1110,0001,trailing0==0,1<<0 out: 0001 */ +#include +static uint32_t get_first_zero(const uint32_t n) +{ + uint32_t nn, i; + nn=n; + for(i=0;i<=sizeof(n)*CHAR_BIT-1;++i) + { + if(!(nn & 1)) return (uint32_t) 1<>1; + } + return (uint32_t) 0; +} +#endif /** * Returns a free id for cs.