Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
<https://www.gnu.org/licenses/>. */
#include <gmp.h>
+#include <stdbit.h>
#include "gmp-impl.h"
#include "longlong.h"
if (UDIV_TIME > (2 * UMUL_TIME + 6)
&& (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME)
{
- int normalization_steps;
-
- count_leading_zeros (normalization_steps, divisor_limb);
+ int normalization_steps = stdc_leading_zeros (divisor_limb);
if (normalization_steps != 0)
{
mp_limb_t divisor_limb_inverted;
{
if (UDIV_NEEDS_NORMALIZATION)
{
- int normalization_steps;
-
- count_leading_zeros (normalization_steps, divisor_limb);
+ int normalization_steps = stdc_leading_zeros (divisor_limb);
if (normalization_steps != 0)
{
divisor_limb <<= normalization_steps;
<https://www.gnu.org/licenses/>. */
#include <gmp.h>
+#include <stdbit.h>
#include "gmp-impl.h"
#include "longlong.h"
if (UDIV_TIME > (2 * UMUL_TIME + 6)
&& (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME)
{
- int normalization_steps;
-
- count_leading_zeros (normalization_steps, divisor_limb);
+ int normalization_steps = stdc_leading_zeros (divisor_limb);
if (normalization_steps != 0)
{
mp_limb_t divisor_limb_inverted;
{
if (UDIV_NEEDS_NORMALIZATION)
{
- int normalization_steps;
-
- count_leading_zeros (normalization_steps, divisor_limb);
+ int normalization_steps = stdc_leading_zeros (divisor_limb);
if (normalization_steps != 0)
{
divisor_limb <<= normalization_steps;
#include <stdint.h>
#include <rounding-mode.h>
#include <tininess.h>
+#include <stdbit.h>
/* The gmp headers need some configuration frobs. */
#define HAVE_ALLOCA 1
}
/* Determine how many bits of the result we already have. */
- count_leading_zeros (bits, num[numsize - 1]);
+ bits = stdc_leading_zeros (num[numsize - 1]);
bits = numsize * BITS_PER_MP_LIMB - bits;
/* Now we know the exponent of the number in base two.
|--- n ---|
*/
- count_leading_zeros (cnt, den[densize - 1]);
+ cnt = stdc_leading_zeros (den[densize - 1]);
+
if (cnt > 0)
{
#define got_limb \
if (bits == 0) \
{ \
- int cnt; \
- if (quot == 0) \
- cnt = BITS_PER_MP_LIMB; \
- else \
- count_leading_zeros (cnt, quot); \
+ int cnt = stdc_leading_zeros (quot); \
exponent -= cnt; \
if (BITS_PER_MP_LIMB - cnt > MANT_DIG) \
{ \
#include <ieee754.h>
#include <float.h>
#include <stdlib.h>
+#include <stdbit.h>
/* Convert a `double' in IEEE754 standard double-precision format to a
multi-precision integer representing the significand scaled up by its
if (res_ptr[N - 1] != 0)
{
- count_leading_zeros (cnt, res_ptr[N - 1]);
+ cnt = stdc_leading_zeros (res_ptr[N - 1]);
cnt -= NUM_LEADING_ZEROS;
#if N == 2
res_ptr[N - 1] = res_ptr[1] << cnt
}
else
{
- count_leading_zeros (cnt, res_ptr[0]);
+ cnt = stdc_leading_zeros (res_ptr[0]);
if (cnt >= NUM_LEADING_ZEROS)
{
res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
#include <math.h>
#include <math_private.h>
#include <stdlib.h>
+#include <stdbit.h>
/* Convert a `long double' in IEEE854 quad-precision format to a
multi-precision integer representing the significand scaled up by its
#if N == 2
if (res_ptr[N - 1] != 0)
{
- count_leading_zeros (cnt, res_ptr[N - 1]);
+ cnt = stdc_leading_zeros (res_ptr[N - 1]);
cnt -= NUM_LEADING_ZEROS;
res_ptr[N - 1] = res_ptr[N - 1] << cnt
| (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
}
else
{
- count_leading_zeros (cnt, res_ptr[0]);
+ cnt = stdc_leading_zeros (res_ptr[0]);
if (cnt >= NUM_LEADING_ZEROS)
{
res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
if (res_ptr[j] != 0)
break;
- count_leading_zeros (cnt, res_ptr[j]);
+ cnt = stdc_leading_zeros (res_ptr[j]);
cnt -= NUM_LEADING_ZEROS;
l = N - 1 - j;
if (cnt < 0)
#include <float.h>
#include <math.h>
#include <stdlib.h>
+#include <stdbit.h>
/* Convert a `long double' in IBM extended format to a multi-precision
integer representing the significand scaled up by its number of
#if N == 2
if (res_ptr[N - 1] != 0)
{
- count_leading_zeros (cnt, res_ptr[N - 1]);
+ cnt = stdc_leading_zeros (res_ptr[N - 1]);
cnt -= NUM_LEADING_ZEROS;
res_ptr[N - 1] = res_ptr[N - 1] << cnt
| (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
}
else
{
- count_leading_zeros (cnt, res_ptr[0]);
+ cnt = stdc_leading_zeros (res_ptr[0]);
if (cnt >= NUM_LEADING_ZEROS)
{
res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
if (res_ptr[j] != 0)
break;
- count_leading_zeros (cnt, res_ptr[j]);
+ cnt = stdc_leading_zeros (res_ptr[j]);
cnt -= NUM_LEADING_ZEROS;
l = N - 1 - j;
if (cnt < 0)
#include <float.h>
#include <math.h>
#include <stdlib.h>
+#include <stdbit.h>
/* Convert a `long double' in IEEE854 standard double-precision format to a
multi-precision integer representing the significand scaled up by its
if (res_ptr[N - 1] != 0)
{
- count_leading_zeros (cnt, res_ptr[N - 1]);
+ cnt = stdc_leading_zeros (res_ptr[N - 1]);
if (cnt != 0)
{
#if N == 2
}
else
{
- count_leading_zeros (cnt, res_ptr[0]);
+ cnt = stdc_leading_zeros (res_ptr[0]);
res_ptr[N - 1] = res_ptr[0] << cnt;
res_ptr[0] = 0;
*expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt;
#include <endian.h>
#include <stdlib.h>
#include <bits/wordsize.h>
+#include <stdbit.h>
#if __WORDSIZE != 32
#error This is for 32-bit targets only
{
/* 0q = nn / 0D */
- count_leading_zeros (bm, d0);
+ bm = stdc_leading_zeros (d0);
if (bm != 0)
{
if (d0 == 0)
d0 = 1 / d0; /* Divide intentionally by zero. */
- count_leading_zeros (bm, d0);
+ bm = stdc_leading_zeros (d0);
if (bm == 0)
{
{
/* 0q = NN / dd */
- count_leading_zeros (bm, d1);
+ bm = stdc_leading_zeros (d1);
if (bm == 0)
{
/* From (n1 >= d1) /\ (the most significant bit of d1 is set),
#include <ieee754.h>
#include <float.h>
#include <stdlib.h>
+#include <stdbit.h>
/* Convert a `long double' in IEEE854 standard double-precision format to a
multi-precision integer representing the significand scaled up by its
if (res_ptr[N - 1] != 0)
{
- count_leading_zeros (cnt, res_ptr[N - 1]);
+ cnt = stdc_leading_zeros (res_ptr[N - 1]);
if (cnt != 0)
{
#if N == 2
}
else if (res_ptr[0] != 0)
{
- count_leading_zeros (cnt, res_ptr[0]);
+ cnt = stdc_leading_zeros (res_ptr[0]);
res_ptr[N - 1] = res_ptr[0] << cnt;
res_ptr[0] = 0;
*expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt;