--- radeon_cs_gem.c.orig 2014-11-28 13:44:09.000000000 -0500 +++ radeon_cs_gem.c 2014-11-28 14:57:59.000000000 -0500 @@ -81,11 +81,30 @@ /** * result is undefined if called with ~0 */ + /* __builtin_ctz returns number of trailing zeros. */ +/* static uint32_t get_first_zero(const uint32_t n) { - /* __builtin_ctz returns number of trailing zeros. */ return 1 << __builtin_ctz(~n); } +*/ + +#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; +} +/* + * oops on first patch rel, code wants a mask for first zero not count + * entry: ~1110,0001,trailing0==0,1<<0 is 0001. sorry was hurrying + */ /** * Returns a free id for cs.