greater than N, and near a power of two. Copied from libiberty.
Returns zero for ridiculously large N to signify an error. */
-static unsigned long
-higher_prime_number (unsigned long n)
+static uint32_t
+higher_prime_number (uint32_t n)
{
/* These are primes that are near, but slightly smaller than, a
power of two. */
- static const unsigned long primes[] =
+ static const uint32_t primes[] =
{
- (unsigned long) 31,
- (unsigned long) 61,
- (unsigned long) 127,
- (unsigned long) 251,
- (unsigned long) 509,
- (unsigned long) 1021,
- (unsigned long) 2039,
- (unsigned long) 4093,
- (unsigned long) 8191,
- (unsigned long) 16381,
- (unsigned long) 32749,
- (unsigned long) 65521,
- (unsigned long) 131071,
- (unsigned long) 262139,
- (unsigned long) 524287,
- (unsigned long) 1048573,
- (unsigned long) 2097143,
- (unsigned long) 4194301,
- (unsigned long) 8388593,
- (unsigned long) 16777213,
- (unsigned long) 33554393,
- (unsigned long) 67108859,
- (unsigned long) 134217689,
- (unsigned long) 268435399,
- (unsigned long) 536870909,
- (unsigned long) 1073741789,
- (unsigned long) 2147483647,
- /* 4294967291L */
- ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
+ UINT32_C (31),
+ UINT32_C (61),
+ UINT32_C (127),
+ UINT32_C (251),
+ UINT32_C (509),
+ UINT32_C (1021),
+ UINT32_C (2039),
+ UINT32_C (4093),
+ UINT32_C (8191),
+ UINT32_C (16381),
+ UINT32_C (32749),
+ UINT32_C (65521),
+ UINT32_C (131071),
+ UINT32_C (262139),
+ UINT32_C (524287),
+ UINT32_C (1048573),
+ UINT32_C (2097143),
+ UINT32_C (4194301),
+ UINT32_C (8388593),
+ UINT32_C (16777213),
+ UINT32_C (33554393),
+ UINT32_C (67108859),
+ UINT32_C (134217689),
+ UINT32_C (268435399),
+ UINT32_C (536870909),
+ UINT32_C (1073741789),
+ UINT32_C (2147483647),
+ UINT32_C (4294967291)
};
- const unsigned long *low = &primes[0];
- const unsigned long *high = &primes[sizeof (primes) / sizeof (primes[0])];
+ const uint32_t *low = &primes[0];
+ const uint32_t *high = &primes[sizeof (primes) / sizeof (primes[0])];
while (low != high)
{
- const unsigned long *mid = low + (high - low) / 2;
+ const uint32_t *mid = low + (high - low) / 2;
if (n >= *mid)
low = mid + 1;
else
return *low;
}
-static unsigned long bfd_default_hash_table_size = DEFAULT_SIZE;
+static unsigned int bfd_default_hash_table_size = DEFAULT_SIZE;
/* Create a new hash table, given a number of entries. */
out:
table->frozen = 0;
}
-\f
-unsigned long
-bfd_hash_set_default_size (unsigned long hash_size)
+
+unsigned int
+bfd_hash_set_default_size (unsigned int hash_size)
{
/* These silly_size values result in around 1G and 32M of memory
being allocated for the table of pointers. Note that the number
of elements allocated will be almost twice the size of any power
of two chosen here. */
- unsigned long silly_size = sizeof (size_t) > 4 ? 0x4000000 : 0x400000;
+ unsigned int silly_size = sizeof (size_t) > 4 ? 0x4000000 : 0x400000;
if (hash_size > silly_size)
hash_size = silly_size;
else if (hash_size != 0)