ちなみに今は

f(x) {
 int i=1,y=0;
 for (;i != 0x80000000;i*=2,y++) {
  if (i==x)
   return y;
 }
 return -1; // 一致しない
}

という関数でやってます。
これより良い方法があればご教授下さい。