summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-05-02 20:30:38 +0930
committerAlan Modra <amodra@gmail.com>2023-05-03 14:47:34 +0930
commitd659ef954399b0b1693d1cd02dbac222100b9aa2 (patch)
treefcf2497da0b88d7a8fba92a9840a770b6dc57e67 /bfd
parentf68912e8310e28ffdfa8a16e0f3db4bcb5b2f620 (diff)
downloadbinutils-gdb-d659ef954399b0b1693d1cd02dbac222100b9aa2.tar.gz
hash.c: replace some unsigned long with unsigned int
* hash.c (higher_prime_number): Use uint32_t param, return value, tables and variables. (bfd_default_hash_table_size): Make it an unsigned int. (bfd_hash_set_default_size): Use unsigned int param and return. * bfd-in.h (bfd_hash_set_default_size): Update prototype. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/bfd-in.h2
-rw-r--r--bfd/bfd-in2.h2
-rw-r--r--bfd/hash.c79
3 files changed, 41 insertions, 42 deletions
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index de7285626cd..0a4da9aa407 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -333,7 +333,7 @@ extern void bfd_hash_traverse
/* Allows the default size of a hash table to be configured. New hash
tables allocated using bfd_hash_table_init will be created with
this size. */
-extern unsigned long bfd_hash_set_default_size (unsigned long);
+extern unsigned int bfd_hash_set_default_size (unsigned int);
/* This structure is used to keep track of stabs in sections
information while linking. */
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index c7bcd5f51fb..f5e1c1380c0 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -340,7 +340,7 @@ extern void bfd_hash_traverse
/* Allows the default size of a hash table to be configured. New hash
tables allocated using bfd_hash_table_init will be created with
this size. */
-extern unsigned long bfd_hash_set_default_size (unsigned long);
+extern unsigned int bfd_hash_set_default_size (unsigned int);
/* This structure is used to keep track of stabs in sections
information while linking. */
diff --git a/bfd/hash.c b/bfd/hash.c
index 6e60bedc05b..add7d10ecb3 100644
--- a/bfd/hash.c
+++ b/bfd/hash.c
@@ -304,50 +304,49 @@ SUBSUBSECTION
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
@@ -360,7 +359,7 @@ higher_prime_number (unsigned long n)
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. */
@@ -660,15 +659,15 @@ bfd_hash_traverse (struct bfd_hash_table *table,
out:
table->frozen = 0;
}
-
-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)