* src/sfnt.c: Include stdbit.h.
(sfnt_count_leading_zero_bits) [!INT64_MAX]: Remove this function,
which was confusingly named as it actually returned 31 minus the
number of leading zero bits.
(sfnt_multiply_divide_2) [!INT64_MAX]: Use stdc_leading_zeros instead.
(cherry picked from commit
21ed391440ec9c227f3d18cc222aab2d3d0f9e14)
#include <fcntl.h>
#include <intprops.h>
#include <inttypes.h>
+#include <stdbit.h>
#include <stdckdint.h>
#include <stdint.h>
#include <stdio.h>
value->high = hi;
}
-/* Count the number of most significant zero bits in N. */
-
-static unsigned int
-sfnt_count_leading_zero_bits (unsigned int n)
-{
- int shift;
-
- shift = 0;
-
- if (n & 0xffff0000ul)
- {
- n >>= 16;
- shift += 16;
- }
-
- if (n & 0x0000ff00ul)
- {
- n >>= 8;
- shift += 8;
- }
-
- if (n & 0x000000f0ul)
- {
- n >>= 4;
- shift += 4;
- }
-
- if (n & 0x0000000cul)
- {
- n >>= 2;
- shift += 2;
- }
-
- if (n & 0x00000002ul)
- shift += 1;
-
- return shift;
-}
-
/* Calculate AB / C. Value is a 32 bit unsigned integer. */
static unsigned int
hi = ab->high;
lo = ab->low;
- i = 31 - sfnt_count_leading_zero_bits (hi);
+ i = stdc_leading_zeros (hi);
r = (hi << i) | (lo >> (32 - i));
lo <<= i;
q = r / c;