[PATCH 50/59] fixup! libctf, dedup: add deduplicator
Nick Alcock
nick.alcock@oracle.com
Wed Jul 22 09:34:54 GMT 2020
Fixes for systems on which sizeof (void *) > sizeof (long).
This is all quite ugly: perhaps some new wrappers aroud
ctf_dynhash_lookup and ctf_dynhash_*insert() are called for.
---
libctf/ctf-dedup.c | 19 ++++++++++---------
libctf/ctf-hash.c | 2 +-
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c
index 670d14f77fb..77b34f4539d 100644
--- a/libctf/ctf-dedup.c
+++ b/libctf/ctf-dedup.c
@@ -1269,10 +1269,10 @@ ctf_dedup_populate_mappings (ctf_file_t *fp, ctf_file_t *input _libctf_unused_,
}
/* This will, conveniently, return NULL (i.e. 0) for a new entry. */
- count = (long int) ctf_dynhash_lookup (name_counts, hval);
+ count = (long int) (uintptr_t) ctf_dynhash_lookup (name_counts, hval);
if (ctf_dynhash_cinsert (name_counts, hval,
- (const void *) (count + 1)) < 0)
+ (const void *) (uintptr_t) (count + 1)) < 0)
return ctf_set_errno (fp, errno);
return 0;
@@ -1503,9 +1503,9 @@ ctf_dedup_detect_name_ambiguity (ctf_file_t *fp, ctf_file_t **inputs)
while ((err = ctf_dynhash_cnext (name_counts, &j, &key, &count)) == 0)
{
hval = (const char *) key;
- if ((long int) count > max_hcount)
+ if ((long int) (uintptr_t) count > max_hcount)
{
- max_hcount = (long int) count;
+ max_hcount = (long int) (uintptr_t) count;
max_hval = hval;
}
}
@@ -1866,7 +1866,7 @@ ctf_dedup (ctf_file_t *output, ctf_file_t **inputs, uint32_t ninputs,
ctf_next_t *it = NULL;
for (i = 0; i < ninputs; i++)
- ctf_dprintf ("Input %zi: %s\n", i, ctf_link_input_name (inputs[i]));
+ ctf_dprintf ("Input %i: %s\n", (int) i, ctf_link_input_name (inputs[i]));
if (ctf_dedup_init (output) < 0)
return -1; /* errno is set for us. */
@@ -2396,7 +2396,8 @@ ctf_dedup_maybe_synthesize_forward (ctf_file_t *output, ctf_file_t *target,
}
if (ctf_dynhash_cinsert (td->cd_output_emission_conflicted_forwards,
- decorated, (void *) emitted_forward) < 0)
+ decorated, (void *) (uintptr_t)
+ emitted_forward) < 0)
{
ctf_set_errno (output, ENOMEM);
return CTF_ERR;
@@ -2527,7 +2528,7 @@ ctf_dedup_id_to_target (ctf_file_t *output, ctf_file_t *target,
}
if (!ctf_assert (output, target_id))
return -1;
- return (ctf_id_t) target_id;
+ return (ctf_id_t) (uintptr_t) target_id;
}
/* Emit a single deduplicated TYPE with the given HVAL, located in a given
@@ -2857,7 +2858,7 @@ ctf_dedup_emit_type (const char *hval, ctf_file_t *output, ctf_file_t **inputs,
if (!emission_hashed
&& new_type != 0
&& ctf_dynhash_cinsert (target->ctf_dedup.cd_output_emission_hashes,
- hval, (void *) new_type) < 0)
+ hval, (void *) (uintptr_t) new_type) < 0)
{
ctf_err_warn (output, 0, "out of memory tracking deduplicated "
"global type IDs");
@@ -3016,7 +3017,7 @@ ctf_dedup_populate_type_mapping (ctf_file_t *shared, ctf_file_t *fp,
&i, &k, &v)) == 0)
{
const char *hval = (const char *) k;
- ctf_id_t id_out = (ctf_id_t) v;
+ ctf_id_t id_out = (ctf_id_t) (uintptr_t) v;
ctf_next_t *j = NULL;
ctf_dynset_t *type_ids;
const void *id;
diff --git a/libctf/ctf-hash.c b/libctf/ctf-hash.c
index 76572ff96e4..fd5d61ed7b8 100644
--- a/libctf/ctf-hash.c
+++ b/libctf/ctf-hash.c
@@ -124,7 +124,7 @@ ctf_hash_type_id_key (const void *ptr)
ctf_type_id_key_t *k = (ctf_type_id_key_t *) hep->key;
return htab_hash_pointer ((void *) (uintptr_t) k->ctii_input_num)
- + 59 * htab_hash_pointer ((void *) k->ctii_type);
+ + 59 * htab_hash_pointer ((void *) (uintptr_t) k->ctii_type);
}
int
--
2.27.0.247.g3dff7de930
More information about the Binutils
mailing list