summaryrefslogtreecommitdiffstats
path: root/libiberty
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-05-10 16:00:53 +0200
committerMartin Liska <mliska@suse.cz>2022-05-10 16:04:30 +0200
commit50b009c5daef92bc60fc26fcc4c495e117667387 (patch)
treebb5537637562b9fa5e5b35be905f7b8faac0c94c /libiberty
parentRISC-V: Provide `fmin'/`fmax' RTL patterns (diff)
downloadgcc-50b009c5daef92bc60fc26fcc4c495e117667387.tar.gz
gcc-50b009c5daef92bc60fc26fcc4c495e117667387.tar.bz2
gcc-50b009c5daef92bc60fc26fcc4c495e117667387.tar.xz
libiberty: stop using PTR macro
include/ChangeLog: * hashtab.h (HTAB_EMPTY_ENTRY): Use void * instead PTR. (HTAB_DELETED_ENTRY): Likewise. libiberty/ChangeLog: * alloca.c (C_alloca): Use void * instead PTR. * calloc.c (malloc): Likewise. (bzero): Likewise. (calloc): Likewise. * hashtab.c (find_empty_slot_for_expand): Likewise. (eq_pointer): Likewise. (htab_create_alloc_ex): Likewise. (htab_create_typed_alloc): Likewise. (htab_set_functions_ex): Likewise. (htab_delete): Likewise. (htab_empty): Likewise. (htab_expand): Likewise. (htab_find_with_hash): Likewise. (htab_find): Likewise. (htab_find_slot_with_hash): Likewise. (htab_find_slot): Likewise. (htab_remove_elt): Likewise. (htab_remove_elt_with_hash): Likewise. (htab_clear_slot): Likewise. (htab_traverse_noresize): Likewise. (htab_traverse): Likewise. (htab_hash_string): Likewise. (iterative_hash): Likewise. (hash_pointer): Likewise. * memchr.c (memchr): Likewise. * memcmp.c (memcmp): Likewise. * memcpy.c (memcpy): Likewise. * memmove.c (memmove): Likewise. * mempcpy.c (memcpy): Likewise. (mempcpy): Likewise. * memset.c (memset): Likewise. * objalloc.c (malloc): Likewise. (free): Likewise. (objalloc_create): Likewise. (_objalloc_alloc): Likewise. (objalloc_free_block): Likewise. * random.c (PTR): Likewise. (void): Likewise. (initstate): Likewise. (setstate): Likewise. * regex.c: Likewise. * spaces.c (malloc): Likewise. (free): Likewise. * stpcpy.c (memcpy): Likewise. * strdup.c (malloc): Likewise. (memcpy): Likewise. * strerror.c (malloc): Likewise. (memset): Likewise. * strndup.c (malloc): Likewise. (memcpy): Likewise. * strsignal.c (malloc): Likewise. (memset): Likewise. * vasprintf.c (malloc): Likewise. * vprintf-support.c: Likewise. * xatexit.c (malloc): Likewise. * xmalloc.c (xmalloc): Likewise. (xcalloc): Likewise. (xrealloc): Likewise. * xmemdup.c (xmemdup): Likewise.
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/alloca.c6
-rw-r--r--libiberty/calloc.c8
-rw-r--r--libiberty/hashtab.c94
-rw-r--r--libiberty/memchr.c6
-rw-r--r--libiberty/memcmp.c2
-rw-r--r--libiberty/memcpy.c4
-rw-r--r--libiberty/memmove.c4
-rw-r--r--libiberty/mempcpy.c6
-rw-r--r--libiberty/memset.c4
-rw-r--r--libiberty/objalloc.c22
-rw-r--r--libiberty/random.c16
-rw-r--r--libiberty/regex.c8
-rw-r--r--libiberty/spaces.c4
-rw-r--r--libiberty/stpcpy.c2
-rw-r--r--libiberty/strdup.c4
-rw-r--r--libiberty/strerror.c4
-rw-r--r--libiberty/strndup.c4
-rw-r--r--libiberty/strsignal.c4
-rw-r--r--libiberty/vasprintf.c2
-rw-r--r--libiberty/vprintf-support.c2
-rw-r--r--libiberty/xatexit.c2
-rw-r--r--libiberty/xmalloc.c14
-rw-r--r--libiberty/xmemdup.c8
23 files changed, 115 insertions, 115 deletions
diff --git a/libiberty/alloca.c b/libiberty/alloca.c
index 9b2e9cb12b6..b75f7560f94 100644
--- a/libiberty/alloca.c
+++ b/libiberty/alloca.c
@@ -158,7 +158,7 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */
158 158
159/* @undocumented C_alloca */ 159/* @undocumented C_alloca */
160 160
161PTR 161void *
162C_alloca (size_t size) 162C_alloca (size_t size)
163{ 163{
164 auto char probe; /* Probes stack depth: */ 164 auto char probe; /* Probes stack depth: */
@@ -181,7 +181,7 @@ C_alloca (size_t size)
181 { 181 {
182 register header *np = hp->h.next; 182 register header *np = hp->h.next;
183 183
184 free ((PTR) hp); /* Collect garbage. */ 184 free ((void *) hp); /* Collect garbage. */
185 185
186 hp = np; /* -> next header. */ 186 hp = np; /* -> next header. */
187 } 187 }
@@ -210,7 +210,7 @@ C_alloca (size_t size)
210 210
211 /* User storage begins just after header. */ 211 /* User storage begins just after header. */
212 212
213 return (PTR) ((char *) new_storage + sizeof (header)); 213 return (void *) ((char *) new_storage + sizeof (header));
214 } 214 }
215} 215}
216 216
diff --git a/libiberty/calloc.c b/libiberty/calloc.c
index f4bd27b1cd2..c7d97a6e362 100644
--- a/libiberty/calloc.c
+++ b/libiberty/calloc.c
@@ -16,13 +16,13 @@ Uses @code{malloc} to allocate storage for @var{nelem} objects of
16#include <stddef.h> 16#include <stddef.h>
17 17
18/* For systems with larger pointers than ints, this must be declared. */ 18/* For systems with larger pointers than ints, this must be declared. */
19PTR malloc (size_t); 19void *malloc (size_t);
20void bzero (PTR, size_t); 20void bzero (void *, size_t);
21 21
22PTR 22void *
23calloc (size_t nelem, size_t elsize) 23calloc (size_t nelem, size_t elsize)
24{ 24{
25 register PTR ptr; 25 register void *ptr;
26 26
27 if (nelem == 0 || elsize == 0) 27 if (nelem == 0 || elsize == 0)
28 nelem = elsize = 1; 28 nelem = elsize = 1;
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index d3cc86b75d6..f7621cd47e5 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -73,7 +73,7 @@ static hashval_t htab_mod_m2 (hashval_t, htab_t);
73static hashval_t hash_pointer (const void *); 73static hashval_t hash_pointer (const void *);
74static int eq_pointer (const void *, const void *); 74static int eq_pointer (const void *, const void *);
75static int htab_expand (htab_t); 75static int htab_expand (htab_t);
76static PTR *find_empty_slot_for_expand (htab_t, hashval_t); 76static void **find_empty_slot_for_expand (htab_t, hashval_t);
77 77
78/* At some point, we could make these be NULL, and modify the 78/* At some point, we could make these be NULL, and modify the
79 hash-table routines to handle NULL specially; that would avoid 79 hash-table routines to handle NULL specially; that would avoid
@@ -196,7 +196,7 @@ higher_prime_index (unsigned long n)
196/* Returns non-zero if P1 and P2 are equal. */ 196/* Returns non-zero if P1 and P2 are equal. */
197 197
198static int 198static int
199eq_pointer (const PTR p1, const PTR p2) 199eq_pointer (const void *p1, const void *p2)
200{ 200{
201 return p1 == p2; 201 return p1 == p2;
202} 202}
@@ -304,7 +304,7 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
304 result = (htab_t) (*alloc_f) (alloc_arg, 1, sizeof (struct htab)); 304 result = (htab_t) (*alloc_f) (alloc_arg, 1, sizeof (struct htab));
305 if (result == NULL) 305 if (result == NULL)
306 return NULL; 306 return NULL;
307 result->entries = (PTR *) (*alloc_f) (alloc_arg, size, sizeof (PTR)); 307 result->entries = (void **) (*alloc_f) (alloc_arg, size, sizeof (void *));
308 if (result->entries == NULL) 308 if (result->entries == NULL)
309 { 309 {
310 if (free_f != NULL) 310 if (free_f != NULL)
@@ -357,7 +357,7 @@ htab_create_typed_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
357 result = (htab_t) (*alloc_tab_f) (1, sizeof (struct htab)); 357 result = (htab_t) (*alloc_tab_f) (1, sizeof (struct htab));
358 if (result == NULL) 358 if (result == NULL)
359 return NULL; 359 return NULL;
360 result->entries = (PTR *) (*alloc_f) (size, sizeof (PTR)); 360 result->entries = (void **) (*alloc_f) (size, sizeof (void *));
361 if (result->entries == NULL) 361 if (result->entries == NULL)
362 { 362 {
363 if (free_f != NULL) 363 if (free_f != NULL)
@@ -379,7 +379,7 @@ htab_create_typed_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
379 379
380void 380void
381htab_set_functions_ex (htab_t htab, htab_hash hash_f, htab_eq eq_f, 381htab_set_functions_ex (htab_t htab, htab_hash hash_f, htab_eq eq_f,
382 htab_del del_f, PTR alloc_arg, 382 htab_del del_f, void *alloc_arg,
383 htab_alloc_with_arg alloc_f, htab_free_with_arg free_f) 383 htab_alloc_with_arg alloc_f, htab_free_with_arg free_f)
384{ 384{
385 htab->hash_f = hash_f; 385 htab->hash_f = hash_f;
@@ -412,7 +412,7 @@ void
412htab_delete (htab_t htab) 412htab_delete (htab_t htab)
413{ 413{
414 size_t size = htab_size (htab); 414 size_t size = htab_size (htab);
415 PTR *entries = htab->entries; 415 void **entries = htab->entries;
416 int i; 416 int i;
417 417
418 if (htab->del_f) 418 if (htab->del_f)
@@ -438,7 +438,7 @@ void
438htab_empty (htab_t htab) 438htab_empty (htab_t htab)
439{ 439{
440 size_t size = htab_size (htab); 440 size_t size = htab_size (htab);
441 PTR *entries = htab->entries; 441 void **entries = htab->entries;
442 int i; 442 int i;
443 443
444 if (htab->del_f) 444 if (htab->del_f)
@@ -447,9 +447,9 @@ htab_empty (htab_t htab)
447 (*htab->del_f) (entries[i]); 447 (*htab->del_f) (entries[i]);
448 448
449 /* Instead of clearing megabyte, downsize the table. */ 449 /* Instead of clearing megabyte, downsize the table. */
450 if (size > 1024*1024 / sizeof (PTR)) 450 if (size > 1024*1024 / sizeof (void *))
451 { 451 {
452 int nindex = higher_prime_index (1024 / sizeof (PTR)); 452 int nindex = higher_prime_index (1024 / sizeof (void *));
453 int nsize = prime_tab[nindex].prime; 453 int nsize = prime_tab[nindex].prime;
454 454
455 if (htab->free_f != NULL) 455 if (htab->free_f != NULL)
@@ -457,15 +457,15 @@ htab_empty (htab_t htab)
457 else if (htab->free_with_arg_f != NULL) 457 else if (htab->free_with_arg_f != NULL)
458 (*htab->free_with_arg_f) (htab->alloc_arg, htab->entries); 458 (*htab->free_with_arg_f) (htab->alloc_arg, htab->entries);
459 if (htab->alloc_with_arg_f != NULL) 459 if (htab->alloc_with_arg_f != NULL)
460 htab->entries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize, 460 htab->entries = (void **) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,
461 sizeof (PTR *)); 461 sizeof (void **));
462 else 462 else
463 htab->entries = (PTR *) (*htab->alloc_f) (nsize, sizeof (PTR *)); 463 htab->entries = (void **) (*htab->alloc_f) (nsize, sizeof (void **));
464 htab->size = nsize; 464 htab->size = nsize;
465 htab->size_prime_index = nindex; 465 htab->size_prime_index = nindex;
466 } 466 }
467 else 467 else
468 memset (entries, 0, size * sizeof (PTR)); 468 memset (entries, 0, size * sizeof (void *));
469 htab->n_deleted = 0; 469 htab->n_deleted = 0;
470 htab->n_elements = 0; 470 htab->n_elements = 0;
471} 471}
@@ -477,12 +477,12 @@ htab_empty (htab_t htab)
477 This function also assumes there are no deleted entries in the table. 477 This function also assumes there are no deleted entries in the table.
478 HASH is the hash value for the element to be inserted. */ 478 HASH is the hash value for the element to be inserted. */
479 479
480static PTR * 480static void **
481find_empty_slot_for_expand (htab_t htab, hashval_t hash) 481find_empty_slot_for_expand (htab_t htab, hashval_t hash)
482{ 482{
483 hashval_t index = htab_mod (hash, htab); 483 hashval_t index = htab_mod (hash, htab);
484 size_t size = htab_size (htab); 484 size_t size = htab_size (htab);
485 PTR *slot = htab->entries + index; 485 void **slot = htab->entries + index;
486 hashval_t hash2; 486 hashval_t hash2;
487 487
488 if (*slot == HTAB_EMPTY_ENTRY) 488 if (*slot == HTAB_EMPTY_ENTRY)
@@ -516,10 +516,10 @@ find_empty_slot_for_expand (htab_t htab, hashval_t hash)
516static int 516static int
517htab_expand (htab_t htab) 517htab_expand (htab_t htab)
518{ 518{
519 PTR *oentries; 519 void **oentries;
520 PTR *olimit; 520 void **olimit;
521 PTR *p; 521 void **p;
522 PTR *nentries; 522 void **nentries;
523 size_t nsize, osize, elts; 523 size_t nsize, osize, elts;
524 unsigned int oindex, nindex; 524 unsigned int oindex, nindex;
525 525
@@ -543,10 +543,10 @@ htab_expand (htab_t htab)
543 } 543 }
544 544
545 if (htab->alloc_with_arg_f != NULL) 545 if (htab->alloc_with_arg_f != NULL)
546 nentries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize, 546 nentries = (void **) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,
547 sizeof (PTR *)); 547 sizeof (void **));
548 else 548 else
549 nentries = (PTR *) (*htab->alloc_f) (nsize, sizeof (PTR *)); 549 nentries = (void **) (*htab->alloc_f) (nsize, sizeof (void **));
550 if (nentries == NULL) 550 if (nentries == NULL)
551 return 0; 551 return 0;
552 htab->entries = nentries; 552 htab->entries = nentries;
@@ -558,11 +558,11 @@ htab_expand (htab_t htab)
558 p = oentries; 558 p = oentries;
559 do 559 do
560 { 560 {
561 PTR x = *p; 561 void *x = *p;
562 562
563 if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY) 563 if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
564 { 564 {
565 PTR *q = find_empty_slot_for_expand (htab, (*htab->hash_f) (x)); 565 void **q = find_empty_slot_for_expand (htab, (*htab->hash_f) (x));
566 566
567 *q = x; 567 *q = x;
568 } 568 }
@@ -581,12 +581,12 @@ htab_expand (htab_t htab)
581/* This function searches for a hash table entry equal to the given 581/* This function searches for a hash table entry equal to the given
582 element. It cannot be used to insert or delete an element. */ 582 element. It cannot be used to insert or delete an element. */
583 583
584PTR 584void *
585htab_find_with_hash (htab_t htab, const PTR element, hashval_t hash) 585htab_find_with_hash (htab_t htab, const void *element, hashval_t hash)
586{ 586{
587 hashval_t index, hash2; 587 hashval_t index, hash2;
588 size_t size; 588 size_t size;
589 PTR entry; 589 void *entry;
590 590
591 htab->searches++; 591 htab->searches++;
592 size = htab_size (htab); 592 size = htab_size (htab);
@@ -615,8 +615,8 @@ htab_find_with_hash (htab_t htab, const PTR element, hashval_t hash)
615/* Like htab_find_slot_with_hash, but compute the hash value from the 615/* Like htab_find_slot_with_hash, but compute the hash value from the
616 element. */ 616 element. */
617 617
618PTR 618void *
619htab_find (htab_t htab, const PTR element) 619htab_find (htab_t htab, const void *element)
620{ 620{
621 return htab_find_with_hash (htab, element, (*htab->hash_f) (element)); 621 return htab_find_with_hash (htab, element, (*htab->hash_f) (element));
622} 622}
@@ -629,14 +629,14 @@ htab_find (htab_t htab, const PTR element)
629 slot. When inserting an entry, NULL may be returned if memory 629 slot. When inserting an entry, NULL may be returned if memory
630 allocation fails. */ 630 allocation fails. */
631 631
632PTR * 632void **
633htab_find_slot_with_hash (htab_t htab, const PTR element, 633htab_find_slot_with_hash (htab_t htab, const void *element,
634 hashval_t hash, enum insert_option insert) 634 hashval_t hash, enum insert_option insert)
635{ 635{
636 PTR *first_deleted_slot; 636 void **first_deleted_slot;
637 hashval_t index, hash2; 637 hashval_t index, hash2;
638 size_t size; 638 size_t size;
639 PTR entry; 639 void *entry;
640 640
641 size = htab_size (htab); 641 size = htab_size (htab);
642 if (insert == INSERT && size * 3 <= htab->n_elements * 4) 642 if (insert == INSERT && size * 3 <= htab->n_elements * 4)
@@ -697,8 +697,8 @@ htab_find_slot_with_hash (htab_t htab, const PTR element,
697/* Like htab_find_slot_with_hash, but compute the hash value from the 697/* Like htab_find_slot_with_hash, but compute the hash value from the
698 element. */ 698 element. */
699 699
700PTR * 700void **
701htab_find_slot (htab_t htab, const PTR element, enum insert_option insert) 701htab_find_slot (htab_t htab, const void *element, enum insert_option insert)
702{ 702{
703 return htab_find_slot_with_hash (htab, element, (*htab->hash_f) (element), 703 return htab_find_slot_with_hash (htab, element, (*htab->hash_f) (element),
704 insert); 704 insert);
@@ -709,7 +709,7 @@ htab_find_slot (htab_t htab, const PTR element, enum insert_option insert)
709 element in the hash table, this function does nothing. */ 709 element in the hash table, this function does nothing. */
710 710
711void 711void
712htab_remove_elt (htab_t htab, const PTR element) 712htab_remove_elt (htab_t htab, const void *element)
713{ 713{
714 htab_remove_elt_with_hash (htab, element, (*htab->hash_f) (element)); 714 htab_remove_elt_with_hash (htab, element, (*htab->hash_f) (element));
715} 715}
@@ -720,9 +720,9 @@ htab_remove_elt (htab_t htab, const PTR element)
720 function does nothing. */ 720 function does nothing. */
721 721
722void 722void
723htab_remove_elt_with_hash (htab_t htab, const PTR element, hashval_t hash) 723htab_remove_elt_with_hash (htab_t htab, const void *element, hashval_t hash)
724{ 724{
725 PTR *slot; 725 void **slot;
726 726
727 slot = htab_find_slot_with_hash (htab, element, hash, NO_INSERT); 727 slot = htab_find_slot_with_hash (htab, element, hash, NO_INSERT);
728 if (slot == NULL) 728 if (slot == NULL)
@@ -740,7 +740,7 @@ htab_remove_elt_with_hash (htab_t htab, const PTR element, hashval_t hash)
740 again. */ 740 again. */
741 741
742void 742void
743htab_clear_slot (htab_t htab, PTR *slot) 743htab_clear_slot (htab_t htab, void **slot)
744{ 744{
745 if (slot < htab->entries || slot >= htab->entries + htab_size (htab) 745 if (slot < htab->entries || slot >= htab->entries + htab_size (htab)
746 || *slot == HTAB_EMPTY_ENTRY || *slot == HTAB_DELETED_ENTRY) 746 || *slot == HTAB_EMPTY_ENTRY || *slot == HTAB_DELETED_ENTRY)
@@ -759,17 +759,17 @@ htab_clear_slot (htab_t htab, PTR *slot)
759 argument. */ 759 argument. */
760 760
761void 761void
762htab_traverse_noresize (htab_t htab, htab_trav callback, PTR info) 762htab_traverse_noresize (htab_t htab, htab_trav callback, void *info)
763{ 763{
764 PTR *slot; 764 void **slot;
765 PTR *limit; 765 void **limit;
766 766
767 slot = htab->entries; 767 slot = htab->entries;
768 limit = slot + htab_size (htab); 768 limit = slot + htab_size (htab);
769 769
770 do 770 do
771 { 771 {
772 PTR x = *slot; 772 void *x = *slot;
773 773
774 if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY) 774 if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
775 if (!(*callback) (slot, info)) 775 if (!(*callback) (slot, info))
@@ -782,7 +782,7 @@ htab_traverse_noresize (htab_t htab, htab_trav callback, PTR info)
782 too empty to improve effectivity of subsequent calls. */ 782 too empty to improve effectivity of subsequent calls. */
783 783
784void 784void
785htab_traverse (htab_t htab, htab_trav callback, PTR info) 785htab_traverse (htab_t htab, htab_trav callback, void *info)
786{ 786{
787 size_t size = htab_size (htab); 787 size_t size = htab_size (htab);
788 if (htab_elements (htab) * 8 < size && size > 32) 788 if (htab_elements (htab) * 8 < size && size > 32)
@@ -829,7 +829,7 @@ htab_collisions (htab_t htab)
829 function they just started using for Perl's hashes. */ 829 function they just started using for Perl's hashes. */
830 830
831hashval_t 831hashval_t
832htab_hash_string (const PTR p) 832htab_hash_string (const void *p)
833{ 833{
834 const unsigned char *str = (const unsigned char *) p; 834 const unsigned char *str = (const unsigned char *) p;
835 hashval_t r = 0; 835 hashval_t r = 0;
@@ -926,7 +926,7 @@ acceptable. Do NOT use for cryptographic purposes.
926*/ 926*/
927 927
928hashval_t 928hashval_t
929iterative_hash (const PTR k_in /* the key */, 929iterative_hash (const void *k_in /* the key */,
930 register size_t length /* the length of the key */, 930 register size_t length /* the length of the key */,
931 register hashval_t initval /* the previous hash, or 931 register hashval_t initval /* the previous hash, or
932 an arbitrary value */) 932 an arbitrary value */)
@@ -990,7 +990,7 @@ iterative_hash (const PTR k_in /* the key */,
990/* Returns a hash code for pointer P. Simplified version of evahash */ 990/* Returns a hash code for pointer P. Simplified version of evahash */
991 991
992static hashval_t 992static hashval_t
993hash_pointer (const PTR p) 993hash_pointer (const void *p)
994{ 994{
995 intptr_t v = (intptr_t) p; 995 intptr_t v = (intptr_t) p;
996 unsigned a, b, c; 996 unsigned a, b, c;
diff --git a/libiberty/memchr.c b/libiberty/memchr.c
index 7448ab9e71c..7551b140b59 100644
--- a/libiberty/memchr.c
+++ b/libiberty/memchr.c
@@ -18,15 +18,15 @@ returned.
18#include <ansidecl.h> 18#include <ansidecl.h>
19#include <stddef.h> 19#include <stddef.h>
20 20
21PTR 21void *
22memchr (register const PTR src_void, int c, size_t length) 22memchr (register const void *src_void, int c, size_t length)
23{ 23{
24 const unsigned char *src = (const unsigned char *)src_void; 24 const unsigned char *src = (const unsigned char *)src_void;
25 25
26 while (length-- > 0) 26 while (length-- > 0)
27 { 27 {
28 if (*src == c) 28 if (*src == c)
29 return (PTR)src; 29 return (void *)src;
30 src++; 30 src++;
31 } 31 }
32 return NULL; 32 return NULL;
diff --git a/libiberty/memcmp.c b/libiberty/memcmp.c
index 37db60f3826..5b1af020e6c 100644
--- a/libiberty/memcmp.c
+++ b/libiberty/memcmp.c
@@ -20,7 +20,7 @@ as if comparing unsigned char arrays.
20#include <stddef.h> 20#include <stddef.h>
21 21
22int 22int
23memcmp (const PTR str1, const PTR str2, size_t count) 23memcmp (const void *str1, const void *str2, size_t count)
24{ 24{
25 register const unsigned char *s1 = (const unsigned char*)str1; 25 register const unsigned char *s1 = (const unsigned char*)str1;
26 register const unsigned char *s2 = (const unsigned char*)str2; 26 register const unsigned char *s2 = (const unsigned char*)str2;
diff --git a/libiberty/memcpy.c b/libiberty/memcpy.c
index 7f67d0bd1f2..c627fa4ee9e 100644
--- a/libiberty/memcpy.c
+++ b/libiberty/memcpy.c
@@ -18,8 +18,8 @@ Copies @var{length} bytes from memory region @var{in} to region
18 18
19void bcopy (const void*, void*, size_t); 19void bcopy (const void*, void*, size_t);
20 20
21PTR 21void *
22memcpy (PTR out, const PTR in, size_t length) 22memcpy (void *out, const void *in, size_t length)
23{ 23{
24 bcopy(in, out, length); 24 bcopy(in, out, length);
25 return out; 25 return out;
diff --git a/libiberty/memmove.c b/libiberty/memmove.c
index ebda7cbb41c..8c92d6b9c21 100644
--- a/libiberty/memmove.c
+++ b/libiberty/memmove.c
@@ -18,8 +18,8 @@ Copies @var{count} bytes from memory area @var{from} to memory area
18 18
19void bcopy (const void*, void*, size_t); 19void bcopy (const void*, void*, size_t);
20 20
21PTR 21void *
22memmove (PTR s1, const PTR s2, size_t n) 22memmove (void *s1, const void *s2, size_t n)
23{ 23{
24 bcopy (s2, s1, n); 24 bcopy (s2, s1, n);
25 return s1; 25 return s1;
diff --git a/libiberty/mempcpy.c b/libiberty/mempcpy.c
index 34d9b2f4297..94f0872d8d0 100644
--- a/libiberty/mempcpy.c
+++ b/libiberty/mempcpy.c
@@ -33,10 +33,10 @@ Copies @var{length} bytes from memory region @var{in} to region
33#include <ansidecl.h> 33#include <ansidecl.h>
34#include <stddef.h> 34#include <stddef.h>
35 35
36extern PTR memcpy (PTR, const PTR, size_t); 36extern void *memcpy (void *, const void *, size_t);
37 37
38PTR 38void *
39mempcpy (PTR dst, const PTR src, size_t len) 39mempcpy (void *dst, const void *src, size_t len)
40{ 40{
41 return (char *) memcpy (dst, src, len) + len; 41 return (char *) memcpy (dst, src, len) + len;
42} 42}
diff --git a/libiberty/memset.c b/libiberty/memset.c
index 47666896127..084e5dc0158 100644
--- a/libiberty/memset.c
+++ b/libiberty/memset.c
@@ -16,8 +16,8 @@ Sets the first @var{count} bytes of @var{s} to the constant byte
16#include <ansidecl.h> 16#include <ansidecl.h>
17#include <stddef.h> 17#include <stddef.h>
18 18
19PTR 19void *
20memset (PTR dest, register int val, register size_t len) 20memset (void *dest, register int val, register size_t len)
21{ 21{
22 register unsigned char *ptr = (unsigned char*)dest; 22 register unsigned char *ptr = (unsigned char*)dest;
23 while (len-- > 0) 23 while (len-- > 0)
diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c
index cf5de1fcb2d..3f8c5f7ab27 100644
--- a/libiberty/objalloc.c
+++ b/libiberty/objalloc.c
@@ -37,8 +37,8 @@ Boston, MA 02110-1301, USA. */
37#include <stdlib.h> 37#include <stdlib.h>
38#else 38#else
39/* For systems with larger pointers than ints, this must be declared. */ 39/* For systems with larger pointers than ints, this must be declared. */
40extern PTR malloc (size_t); 40extern void *malloc (size_t);
41extern void free (PTR); 41extern void free (void *);
42#endif 42#endif
43 43
44#endif 44#endif
@@ -92,7 +92,7 @@ objalloc_create (void)
92 if (ret == NULL) 92 if (ret == NULL)
93 return NULL; 93 return NULL;
94 94
95 ret->chunks = (PTR) malloc (CHUNK_SIZE); 95 ret->chunks = (void *) malloc (CHUNK_SIZE);
96 if (ret->chunks == NULL) 96 if (ret->chunks == NULL)
97 { 97 {
98 free (ret); 98 free (ret);
@@ -111,7 +111,7 @@ objalloc_create (void)
111 111
112/* Allocate space from an objalloc structure. */ 112/* Allocate space from an objalloc structure. */
113 113
114PTR 114void *
115_objalloc_alloc (struct objalloc *o, unsigned long original_len) 115_objalloc_alloc (struct objalloc *o, unsigned long original_len)
116{ 116{
117 unsigned long len = original_len; 117 unsigned long len = original_len;
@@ -132,7 +132,7 @@ _objalloc_alloc (struct objalloc *o, unsigned long original_len)
132 { 132 {
133 o->current_ptr += len; 133 o->current_ptr += len;
134 o->current_space -= len; 134 o->current_space -= len;
135 return (PTR) (o->current_ptr - len); 135 return (void *) (o->current_ptr - len);
136 } 136 }
137 137
138 if (len >= BIG_REQUEST) 138 if (len >= BIG_REQUEST)
@@ -148,9 +148,9 @@ _objalloc_alloc (struct objalloc *o, unsigned long original_len)
148 chunk->next = (struct objalloc_chunk *) o->chunks; 148 chunk->next = (struct objalloc_chunk *) o->chunks;
149 chunk->current_ptr = o->current_ptr; 149 chunk->current_ptr = o->current_ptr;
150 150
151 o->chunks = (PTR) chunk; 151 o->chunks = (void *) chunk;
152 152
153 return (PTR) (ret + CHUNK_HEADER_SIZE); 153 return (void *) (ret + CHUNK_HEADER_SIZE);
154 } 154 }
155 else 155 else
156 { 156 {
@@ -165,7 +165,7 @@ _objalloc_alloc (struct objalloc *o, unsigned long original_len)
165 o->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE; 165 o->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE;
166 o->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE; 166 o->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE;
167 167
168 o->chunks = (PTR) chunk; 168 o->chunks = (void *) chunk;
169 169
170 return objalloc_alloc (o, len); 170 return objalloc_alloc (o, len);
171 } 171 }
@@ -195,7 +195,7 @@ objalloc_free (struct objalloc *o)
195 recently allocated blocks. */ 195 recently allocated blocks. */
196 196
197void 197void
198objalloc_free_block (struct objalloc *o, PTR block) 198objalloc_free_block (struct objalloc *o, void *block)
199{ 199{
200 struct objalloc_chunk *p, *small; 200 struct objalloc_chunk *p, *small;
201 char *b = (char *) block; 201 char *b = (char *) block;
@@ -257,7 +257,7 @@ objalloc_free_block (struct objalloc *o, PTR block)
257 257
258 if (first == NULL) 258 if (first == NULL)
259 first = p; 259 first = p;
260 o->chunks = (PTR) first; 260 o->chunks = (void *) first;
261 261
262 /* Now start allocating from this small block again. */ 262 /* Now start allocating from this small block again. */
263 o->current_ptr = b; 263 o->current_ptr = b;
@@ -287,7 +287,7 @@ objalloc_free_block (struct objalloc *o, PTR block)
287 q = next; 287 q = next;
288 } 288 }
289 289
290 o->chunks = (PTR) p; 290 o->chunks = (void *) p;
291 291
292 while (p->current_ptr != NULL) 292 while (p->current_ptr != NULL)
293 p = p->next; 293 p = p->next;
diff --git a/libiberty/random.c b/libiberty/random.c
index b1d3c6c6ae4..be8819dd6b8 100644
--- a/libiberty/random.c
+++ b/libiberty/random.c
@@ -68,12 +68,12 @@ control over the state of the random number generator.
68#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits*/ 68#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits*/
69 69
70#ifdef __STDC__ 70#ifdef __STDC__
71# define PTR void * 71# define void *void *
72# ifndef NULL 72# ifndef NULL
73# define NULL (void *) 0 73# define NULL (void *) 0
74# endif 74# endif
75#else 75#else
76# define PTR char * 76# define void *char *
77# ifndef NULL 77# ifndef NULL
78# define NULL (void *) 0 78# define NULL (void *) 0
79# endif 79# endif
@@ -254,10 +254,10 @@ srandom (unsigned int x)
254 Note: The first thing we do is save the current state, if any, just like 254 Note: The first thing we do is save the current state, if any, just like
255 setstate so that it doesn't matter when initstate is called. 255 setstate so that it doesn't matter when initstate is called.
256 Returns a pointer to the old state. */ 256 Returns a pointer to the old state. */
257PTR 257void *
258initstate (unsigned int seed, PTR arg_state, unsigned long n) 258initstate (unsigned int seed, void *arg_state, unsigned long n)
259{ 259{
260 PTR ostate = (PTR) &state[-1]; 260 void *ostate = (void *) &state[-1];
261 261
262 if (rand_type == TYPE_0) 262 if (rand_type == TYPE_0)
263 state[-1] = rand_type; 263 state[-1] = rand_type;
@@ -320,13 +320,13 @@ initstate (unsigned int seed, PTR arg_state, unsigned long n)
320 same state as the current state 320 same state as the current state
321 Returns a pointer to the old state information. */ 321 Returns a pointer to the old state information. */
322 322
323PTR 323void *
324setstate (PTR arg_state) 324setstate (void *arg_state)
325{ 325{
326 register long int *new_state = (long int *) arg_state; 326 register long int *new_state = (long int *) arg_state;
327 register int type = new_state[0] % MAX_TYPES; 327 register int type = new_state[0] % MAX_TYPES;
328 register int rear = new_state[0] / MAX_TYPES; 328 register int rear = new_state[0] / MAX_TYPES;
329 PTR ostate = (PTR) &state[-1]; 329 void *ostate = (void *) &state[-1];
330 330
331 if (rand_type == TYPE_0) 331 if (rand_type == TYPE_0)
332 state[-1] = rand_type; 332 state[-1] = rand_type;
diff --git a/libiberty/regex.c b/libiberty/regex.c
index 84af5276ae8..c1738c989ab 100644
--- a/libiberty/regex.c
+++ b/libiberty/regex.c
@@ -384,8 +384,8 @@ typedef unsigned long int uintptr_t;
384# endif /* not using relocating allocator */ 384# endif /* not using relocating allocator */
385 385
386 386
387/* True if `size1' is non-NULL and PTR is pointing anywhere inside 387/* True if `size1' is non-NULL and void *is pointing anywhere inside
388 `string1' or just past its end. This works if PTR is NULL, which is 388 `string1' or just past its end. This works if void *is NULL, which is
389 a good thing. */ 389 a good thing. */
390# define FIRST_STRING_P(ptr) \ 390# define FIRST_STRING_P(ptr) \
391 (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) 391 (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
@@ -5256,7 +5256,7 @@ PREFIX(re_search_2) (struct re_pattern_buffer *bufp, const char *string1,
5256} 5256}
5257 5257
5258#ifdef WCHAR 5258#ifdef WCHAR
5259/* This converts PTR, a pointer into one of the search wchar_t strings 5259/* This converts void *, a pointer into one of the search wchar_t strings
5260 `string1' and `string2' into an multibyte string offset from the 5260 `string1' and `string2' into an multibyte string offset from the
5261 beginning of that string. We use mbs_offset to optimize. 5261 beginning of that string. We use mbs_offset to optimize.
5262 See convert_mbs_to_wcs. */ 5262 See convert_mbs_to_wcs. */
@@ -5266,7 +5266,7 @@ PREFIX(re_search_2) (struct re_pattern_buffer *bufp, const char *string1,
5266 : ((regoff_t)((mbs_offset2 != NULL? mbs_offset2[(ptr)-string2] : 0) \ 5266 : ((regoff_t)((mbs_offset2 != NULL? mbs_offset2[(ptr)-string2] : 0) \
5267 + csize1))) 5267 + csize1)))
5268#else /* BYTE */ 5268#else /* BYTE */
5269/* This converts PTR, a pointer into one of the search strings `string1' 5269/* This converts void *, a pointer into one of the search strings `string1'
5270 and `string2' into an offset from the beginning of that string. */ 5270 and `string2' into an offset from the beginning of that string. */
5271# define POINTER_TO_OFFSET(ptr) \ 5271# define POINTER_TO_OFFSET(ptr) \
5272 (FIRST_STRING_P (ptr) \ 5272 (FIRST_STRING_P (ptr) \
diff --git a/libiberty/spaces.c b/libiberty/spaces.c
index 50d15882ee6..2b6971c4b93 100644
--- a/libiberty/spaces.c
+++ b/libiberty/spaces.c
@@ -40,8 +40,8 @@ valid until at least the next call.
40#include <unixlib.h> 40#include <unixlib.h>
41#else 41#else
42/* For systems with larger pointers than ints, these must be declared. */ 42/* For systems with larger pointers than ints, these must be declared. */
43extern PTR malloc (size_t); 43extern void *malloc (size_t);
44extern void free (PTR); 44extern void free (void *);
45#endif 45#endif
46 46
47const char * 47const char *
diff --git a/libiberty/stpcpy.c b/libiberty/stpcpy.c
index 880e4fca7c7..2d3eb4c71cd 100644
--- a/libiberty/stpcpy.c
+++ b/libiberty/stpcpy.c
@@ -33,7 +33,7 @@ Copies the string @var{src} into @var{dst}. Returns a pointer to
33#include <stddef.h> 33#include <stddef.h>
34 34
35extern size_t strlen (const char *); 35extern size_t strlen (const char *);
36extern PTR memcpy (PTR, const PTR, size_t); 36extern void *memcpy (void *, const void *, size_t);
37 37
38char * 38char *
39stpcpy (char *dst, const char *src) 39stpcpy (char *dst, const char *src)
diff --git a/libiberty/strdup.c b/libiberty/strdup.c
index 78c2093b61a..8a4188eadfb 100644
--- a/libiberty/strdup.c
+++ b/libiberty/strdup.c
@@ -13,8 +13,8 @@ Returns a pointer to a copy of @var{s} in memory obtained from
13#include <stddef.h> 13#include <stddef.h>
14 14
15extern size_t strlen (const char*); 15extern size_t strlen (const char*);
16extern PTR malloc (size_t); 16extern void *malloc (size_t);
17extern PTR memcpy (PTR, const PTR, size_t); 17extern void *memcpy (void *, const void *, size_t);
18 18
19char * 19char *
20strdup(const char *s) 20strdup(const char *s)
diff --git a/libiberty/strerror.c b/libiberty/strerror.c
index cc7692c1d69..07db71698d9 100644
--- a/libiberty/strerror.c
+++ b/libiberty/strerror.c
@@ -30,13 +30,13 @@
30#ifdef HAVE_STDLIB_H 30#ifdef HAVE_STDLIB_H
31#include <stdlib.h> 31#include <stdlib.h>
32#else 32#else
33extern PTR malloc (); 33extern void *malloc ();
34#endif 34#endif
35 35
36#ifdef HAVE_STRING_H 36#ifdef HAVE_STRING_H
37#include <string.h> 37#include <string.h>
38#else 38#else
39extern PTR memset (); 39extern void *memset ();
40#endif 40#endif
41 41
42#ifndef MAX 42#ifndef MAX
diff --git a/libiberty/strndup.c b/libiberty/strndup.c
index 5992ee9cfa1..cfbb381ad0d 100644
--- a/libiberty/strndup.c
+++ b/libiberty/strndup.c
@@ -34,8 +34,8 @@ memory was available. The result is always NUL terminated.
34#include <stddef.h> 34#include <stddef.h>
35 35
36extern size_t strnlen (const char *s, size_t maxlen); 36extern size_t strnlen (const char *s, size_t maxlen);
37extern PTR malloc (size_t); 37extern void *malloc (size_t);
38extern PTR memcpy (PTR, const PTR, size_t); 38extern void *memcpy (void *, const void *, size_t);
39 39
40char * 40char *
41strndup (const char *s, size_t n) 41strndup (const char *s, size_t n)
diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c
index 666b1b4f15e..36b41f17e12 100644
--- a/libiberty/strsignal.c
+++ b/libiberty/strsignal.c
@@ -26,13 +26,13 @@
26#ifdef HAVE_STDLIB_H 26#ifdef HAVE_STDLIB_H
27#include <stdlib.h> 27#include <stdlib.h>
28#else 28#else
29extern PTR malloc (); 29extern void *malloc ();
30#endif 30#endif
31 31
32#ifdef HAVE_STRING_H 32#ifdef HAVE_STRING_H
33#include <string.h> 33#include <string.h>
34#else 34#else
35extern PTR memset (); 35extern void *memset ();
36#endif 36#endif
37 37
38/* Undefine the macro we used to hide the definition of sys_siglist 38/* Undefine the macro we used to hide the definition of sys_siglist
diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c
index e2717d83f37..c8c0152865b 100644
--- a/libiberty/vasprintf.c
+++ b/libiberty/vasprintf.c
@@ -33,7 +33,7 @@ Floor, Boston, MA 02110-1301, USA. */
33#ifdef HAVE_STDLIB_H 33#ifdef HAVE_STDLIB_H
34#include <stdlib.h> 34#include <stdlib.h>
35#else 35#else
36extern PTR malloc (); 36extern void *malloc ();
37#endif 37#endif
38#include "libiberty.h" 38#include "libiberty.h"
39#include "vprintf-support.h" 39#include "vprintf-support.h"
diff --git a/libiberty/vprintf-support.c b/libiberty/vprintf-support.c
index 231e584bbc1..92aedce1edd 100644
--- a/libiberty/vprintf-support.c
+++ b/libiberty/vprintf-support.c
@@ -49,7 +49,7 @@ libiberty_vprintf_buffer_size (const char *format, va_list args)
49#ifdef va_copy 49#ifdef va_copy
50 va_copy (ap, args); 50 va_copy (ap, args);
51#else 51#else
52 memcpy ((PTR) &ap, (PTR) &args, sizeof (va_list)); 52 memcpy ((void *) &ap, (void *) &args, sizeof (va_list));
53#endif 53#endif
54 54
55 while (*p != '\0') 55 while (*p != '\0')
diff --git a/libiberty/xatexit.c b/libiberty/xatexit.c
index 6fdad9ed806..8a985cab4bc 100644
--- a/libiberty/xatexit.c
+++ b/libiberty/xatexit.c
@@ -37,7 +37,7 @@ failure. If you use @code{xatexit} to register functions, you must use
37#include <unixlib.h> 37#include <unixlib.h>
38#else 38#else
39/* For systems with larger pointers than ints, this must be declared. */ 39/* For systems with larger pointers than ints, this must be declared. */
40PTR malloc (size_t); 40void *malloc (size_t);
41#endif 41#endif
42 42
43static void xatexit_cleanup (void); 43static void xatexit_cleanup (void);
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index e7d52683d35..3cc4cea37c3 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -139,10 +139,10 @@ xmalloc_failed (size_t size)
139 xexit (1); 139 xexit (1);
140} 140}
141 141
142PTR 142void *
143xmalloc (size_t size) 143xmalloc (size_t size)
144{ 144{
145 PTR newmem; 145 void *newmem;
146 146
147 if (size == 0) 147 if (size == 0)
148 size = 1; 148 size = 1;
@@ -153,10 +153,10 @@ xmalloc (size_t size)
153 return (newmem); 153 return (newmem);
154} 154}
155 155
156PTR 156void *
157xcalloc (size_t nelem, size_t elsize) 157xcalloc (size_t nelem, size_t elsize)
158{ 158{
159 PTR newmem; 159 void *newmem;
160 160
161 if (nelem == 0 || elsize == 0) 161 if (nelem == 0 || elsize == 0)
162 nelem = elsize = 1; 162 nelem = elsize = 1;
@@ -168,10 +168,10 @@ xcalloc (size_t nelem, size_t elsize)
168 return (newmem); 168 return (newmem);
169} 169}
170 170
171PTR 171void *
172xrealloc (PTR oldmem, size_t size) 172xrealloc (void *oldmem, size_t size)
173{ 173{
174 PTR newmem; 174 void *newmem;
175 175
176 if (size == 0) 176 if (size == 0)
177 size = 1; 177 size = 1;
diff --git a/libiberty/xmemdup.c b/libiberty/xmemdup.c
index 4602afd7d9f..f2ed41f9b4d 100644
--- a/libiberty/xmemdup.c
+++ b/libiberty/xmemdup.c
@@ -31,11 +31,11 @@ allocated, the remaining memory is zeroed.
31# endif 31# endif
32#endif 32#endif
33 33
34PTR 34void *
35xmemdup (const PTR input, size_t copy_size, size_t alloc_size) 35xmemdup (const void *input, size_t copy_size, size_t alloc_size)
36{ 36{
37 PTR output = xmalloc (alloc_size); 37 void *output = xmalloc (alloc_size);
38 if (alloc_size > copy_size) 38 if (alloc_size > copy_size)
39 memset ((char *) output + copy_size, 0, alloc_size - copy_size); 39 memset ((char *) output + copy_size, 0, alloc_size - copy_size);
40 return (PTR) memcpy (output, input, copy_size); 40 return (void *) memcpy (output, input, copy_size);
41} 41}