summaryrefslogtreecommitdiff
path: root/src/sfnt.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2024-05-12 14:26:32 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2024-05-18 10:23:51 -0700
commit21ed391440ec9c227f3d18cc222aab2d3d0f9e14 (patch)
tree12566d127f73c9e55e1fb94b0ed3524971937579 /src/sfnt.c
parent88b0bb4db9aaecff8b01e81726b911fa5d02b2fb (diff)
downloademacs-21ed391440ec9c227f3d18cc222aab2d3d0f9e14.tar.gz
emacs-21ed391440ec9c227f3d18cc222aab2d3d0f9e14.tar.bz2
emacs-21ed391440ec9c227f3d18cc222aab2d3d0f9e14.zip
Simplify 32-bit Android bit fiddling
* 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.
Diffstat (limited to 'src/sfnt.c')
-rw-r--r--src/sfnt.c42
1 files changed, 2 insertions, 40 deletions
diff --git a/src/sfnt.c b/src/sfnt.c
index d909fba7677..1832082e4f9 100644
--- a/src/sfnt.c
+++ b/src/sfnt.c
@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <fcntl.h>
#include <intprops.h>
#include <inttypes.h>
+#include <stdbit.h>
#include <stdckdint.h>
#include <stdint.h>
#include <stdio.h>
@@ -3678,45 +3679,6 @@ sfnt_multiply_divide_1 (unsigned int a, unsigned int b,
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
@@ -3730,7 +3692,7 @@ sfnt_multiply_divide_2 (struct sfnt_large_integer *ab,
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;