From f32ccf22fea51331c9645da025af2dab6153f8af Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Thu, 22 Feb 2018 23:23:48 +0300 Subject: [PATCH] Eliminate C++ warnings about deprecated register keyword (GC source) Issue #206 (bdwgc). * blacklst.c (GC_number_stack_black_listed, total_stack_black_listed): Remove register keyword for local variables. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Likewise. * extra/pcr_interface.c [PCR] (GC_enumerate_block): Likewise. * finalize.c (GC_grow_table): Likewise. * headers.c (alloc_hdr, GC_init_headers, GC_remove_counts, GC_prev_block): Likewise. * include/private/gc_pmark.h (PUSH_OBJ): Likewise. * mach_dep.c [!HAVE_PUSH_REGS && !HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed): Likewise. * mark.c (clear_marks_for_block): Likewise. * mark_rts.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_add_roots_inner): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB] (GC_page_was_dirty): Likewise. * os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages, GC_page_was_ever_dirty): Likewise. * os_dep.c (GC_write_fault_handler): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * os_dep.c [SAVE_CALL_CHAIN && NARGS>0] (GC_save_callers): Likewise. * pthread_stop_world.c [!NACL] (GC_start_world): Likewise. * pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Likewise. * typd_mlc.c (GC_push_complex_descriptor): Likewise. * win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread): Likewise. --- blacklst.c | 4 ++-- dyn_load.c | 2 +- extra/pcr_interface.c | 4 ++-- finalize.c | 4 ++-- headers.c | 15 ++++++++------- include/private/gc_pmark.h | 2 +- mach_dep.c | 4 ++-- mark.c | 2 +- mark_rts.c | 4 ++-- os_dep.c | 18 +++++++++--------- pthread_stop_world.c | 8 ++++---- pthread_support.c | 8 ++++---- typd_mlc.c | 12 ++++++------ win32_threads.c | 8 ++++---- 14 files changed, 48 insertions(+), 47 deletions(-) diff --git a/blacklst.c b/blacklst.c index 356f636e8..452a340d0 100644 --- a/blacklst.c +++ b/blacklst.c @@ -263,7 +263,7 @@ struct hblk * GC_is_black_listed(struct hblk *h, word len) STATIC word GC_number_stack_black_listed(struct hblk *start, struct hblk *endp1) { - register struct hblk * h; + struct hblk * h; word result = 0; for (h = start; (word)h < (word)endp1; h++) { @@ -277,7 +277,7 @@ STATIC word GC_number_stack_black_listed(struct hblk *start, /* Return the total number of (stack) black-listed bytes. */ static word total_stack_black_listed(void) { - register unsigned i; + unsigned i; word total = 0; for (i = 0; i < GC_n_heap_sects; i++) { diff --git a/dyn_load.c b/dyn_load.c index c3cd186bd..330cd86a9 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -875,7 +875,7 @@ GC_INNER void GC_register_dynamic_libraries(void) /* Known irrelevant map entries */ static int n_irr = 0; struct stat buf; - register int j; + int j; for (j = 0; j < n_irr; j++) { if (map_irr[j] == start) goto irrelevant; diff --git a/extra/pcr_interface.c b/extra/pcr_interface.c index 8756cf132..ff4618743 100644 --- a/extra/pcr_interface.c +++ b/extra/pcr_interface.c @@ -65,8 +65,8 @@ typedef struct { void GC_enumerate_block(struct hblk *h, enumerate_data * ed) { - register hdr * hhdr; - register size_t sz; + hdr * hhdr; + size_t sz; ptr_t p; ptr_t lim; word descr; diff --git a/finalize.c b/finalize.c index b16533420..640ee4e70 100644 --- a/finalize.c +++ b/finalize.c @@ -96,8 +96,8 @@ GC_API void GC_CALL GC_push_finalizer_structures(void) STATIC void GC_grow_table(struct hash_chain_entry ***table, signed_word *log_size_ptr) { - register word i; - register struct hash_chain_entry *p; + word i; + struct hash_chain_entry *p; signed_word log_old_size = *log_size_ptr; signed_word log_new_size = log_old_size + 1; word old_size = log_old_size == -1 ? 0 : (word)1 << log_old_size; diff --git a/headers.c b/headers.c index 0c258de79..bdc8311dc 100644 --- a/headers.c +++ b/headers.c @@ -167,9 +167,9 @@ static hdr * hdr_free_list = 0; /* Return an uninitialized header */ static hdr * alloc_hdr(void) { - register hdr * result; + hdr * result; - if (hdr_free_list == 0) { + if (NULL == hdr_free_list) { result = (hdr *)GC_scratch_alloc(sizeof(hdr)); } else { result = hdr_free_list; @@ -192,7 +192,7 @@ GC_INLINE void free_hdr(hdr * hhdr) GC_INNER void GC_init_headers(void) { - register unsigned i; + unsigned i; GC_all_nils = (bottom_index *)GC_scratch_alloc(sizeof(bottom_index)); if (GC_all_nils == NULL) { @@ -302,7 +302,8 @@ GC_INNER void GC_remove_header(struct hblk *h) /* Remove forwarding counts for h */ GC_INNER void GC_remove_counts(struct hblk *h, size_t sz/* bytes */) { - register struct hblk * hbp; + struct hblk * hbp; + for (hbp = h+1; (word)hbp < (word)h + sz; hbp += 1) { SET_HDR(hbp, 0); } @@ -376,12 +377,12 @@ GC_INNER struct hblk * GC_next_used_block(struct hblk *h) /* Unlike the above, this may return a free block. */ GC_INNER struct hblk * GC_prev_block(struct hblk *h) { - register bottom_index * bi; - register signed_word j = ((word)h >> LOG_HBLKSIZE) & (BOTTOM_SZ-1); + bottom_index * bi; + signed_word j = ((word)h >> LOG_HBLKSIZE) & (BOTTOM_SZ-1); GET_BI(h, bi); if (bi == GC_all_nils) { - register word hi = (word)h >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); + word hi = (word)h >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); bi = GC_all_bottom_indices_end; while (bi != 0 && bi -> key > hi) bi = bi -> desc_link; j = BOTTOM_SZ - 1; diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index 41d97b79b..aad245c88 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -126,7 +126,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp); /* the mark stack. */ #define PUSH_OBJ(obj, hhdr, mark_stack_top, mark_stack_limit) \ do { \ - register word _descr = (hhdr) -> hb_descr; \ + word _descr = (hhdr) -> hb_descr; \ GC_ASSERT(!HBLK_IS_FREE(hhdr)); \ if (_descr != 0) { \ mark_stack_top++; \ diff --git a/mach_dep.c b/mach_dep.c index 2c62cc63f..b65e6dbe0 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -298,8 +298,8 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *), /* We're not sure whether he would like */ /* to be acknowledged for it or not. */ jmp_buf regs; - register word * i = (word *) ®s; - register ptr_t lim = (ptr_t)(®s) + (sizeof regs); + word * i = (word *)®s; + ptr_t lim = (ptr_t)(®s) + sizeof(regs); /* Setjmp doesn't always clear all of the buffer. */ /* That tends to preserve garbage. Clear it. */ diff --git a/mark.c b/mark.c index 4c240b923..07a23601c 100644 --- a/mark.c +++ b/mark.c @@ -188,7 +188,7 @@ GC_INNER void GC_set_hdr_marks(hdr *hhdr) */ static void clear_marks_for_block(struct hblk *h, word dummy GC_ATTR_UNUSED) { - register hdr * hhdr = HDR(h); + hdr * hhdr = HDR(h); if (IS_UNCOLLECTABLE(hhdr -> hb_obj_kind)) return; /* Mark bit for these is cleared only once the object is */ diff --git a/mark_rts.c b/mark_rts.c index fe25931a7..3f0b6f16b 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -183,7 +183,7 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp) /* virtually guaranteed to be dominated by the time it */ /* takes to scan the roots. */ { - register int i; + int i; struct roots * old = NULL; /* initialized to prevent warning. */ for (i = 0; i < n_root_sets; i++) { @@ -371,7 +371,7 @@ STATIC void GC_remove_tmp_roots(void) GC_API int GC_CALL GC_is_tmp_root(void *p) { static int last_root_set = MAX_ROOT_SETS; - register int i; + int i; if (last_root_set < n_root_sets && (word)p >= (word)GC_static_roots[last_root_set].r_start diff --git a/os_dep.c b/os_dep.c index cba23c318..f591d7076 100644 --- a/os_dep.c +++ b/os_dep.c @@ -2817,7 +2817,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) /* side of labeling pages as dirty (and this implementation does). */ GC_INNER GC_bool GC_page_was_dirty(struct hblk * h) { - register word index; + word index; if (HDR(h) == 0) return TRUE; @@ -2830,7 +2830,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) /* Add all pages in pht2 to pht1. */ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2) { - register unsigned i; + unsigned i; for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i]; } @@ -2841,7 +2841,8 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h) # endif { - register word index; + word index; + if (HDR(h) == 0) return TRUE; index = PHT_HASH(h); @@ -3293,8 +3294,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) # endif if (SIG_OK && CODE_OK) { - register struct hblk * h = - (struct hblk *)((word)addr & ~(GC_page_size-1)); + struct hblk * h = (struct hblk *)((word)addr & ~(GC_page_size-1)); GC_bool in_allocd_block; size_t i; @@ -3807,14 +3807,14 @@ GC_INNER void GC_read_dirty(GC_bool output_unneeded) limit = vaddr + pagesize * npages; for (; (word)vaddr < (word)limit; vaddr += pagesize) { if ((*bufp++) & PG_MODIFIED) { - register struct hblk * h; + struct hblk * h; ptr_t next_vaddr = vaddr + pagesize; # ifdef DEBUG_DIRTY_BITS GC_log_printf("dirty page at: %p\n", (void *)vaddr); # endif for (h = (struct hblk *)vaddr; (word)h < (word)next_vaddr; h++) { - register word index = PHT_HASH(h); + word index = PHT_HASH(h); set_pht_entry_from_index(GC_grungy_pages, index); } } @@ -4479,7 +4479,7 @@ catch_exception_raise(mach_port_t exception_port GC_ATTR_UNUSED, UNPROTECT(h, GC_page_size); for (i = 0; i < divHBLKSZ(GC_page_size); i++) { - register int index = PHT_HASH(h+i); + int index = PHT_HASH(h+i); async_set_pht_entry_from_index(GC_dirty_pages, index); } } else if (GC_mprotect_state == GC_MP_DISCARDING) { @@ -4680,7 +4680,7 @@ GC_INNER void GC_save_callers(struct callinfo info[NFRAMES]) && nframes < NFRAMES; fp = (struct frame *)((long) fp -> FR_SAVFP + BIAS), nframes++) { # if NARGS > 0 - register int i; + int i; # endif info[nframes].ci_pc = fp->FR_SAVPC; diff --git a/pthread_stop_world.c b/pthread_stop_world.c index a6ca776db..45435aa0d 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -1034,11 +1034,11 @@ GC_INNER void GC_start_world(void) { # ifndef NACL pthread_t self = pthread_self(); - register int i; - register GC_thread p; + int i; + GC_thread p; # ifndef GC_OPENBSD_UTHREADS - register int n_live_threads = 0; - register int result; + int n_live_threads = 0; + int result; # endif # ifdef DEBUG_THREADS diff --git a/pthread_support.c b/pthread_support.c index e6a6a429b..31066e770 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -577,8 +577,8 @@ STATIC GC_thread GC_new_thread(pthread_t id) STATIC void GC_delete_thread(pthread_t id) { int hv = THREAD_TABLE_INDEX(id); - register GC_thread p = GC_threads[hv]; - register GC_thread prev = 0; + GC_thread p = GC_threads[hv]; + GC_thread prev = NULL; # ifdef DEBUG_THREADS GC_log_printf("Deleting thread %p, n_threads = %d\n", @@ -616,8 +616,8 @@ STATIC void GC_delete_gc_thread(GC_thread t) { pthread_t id = t -> id; int hv = THREAD_TABLE_INDEX(id); - register GC_thread p = GC_threads[hv]; - register GC_thread prev = 0; + GC_thread p = GC_threads[hv]; + GC_thread prev = NULL; GC_ASSERT(I_HOLD_LOCK()); while (p != t) { diff --git a/typd_mlc.c b/typd_mlc.c index b5e2c6122..a67671af7 100644 --- a/typd_mlc.c +++ b/typd_mlc.c @@ -427,15 +427,15 @@ STATIC word GC_descr_obj_size(complex_descriptor *d) STATIC mse * GC_push_complex_descriptor(word *addr, complex_descriptor *d, mse *msp, mse *msl) { - register ptr_t current = (ptr_t) addr; - register word nelements; - register word sz; - register word i; + ptr_t current = (ptr_t)addr; + word nelements; + word sz; + word i; switch(d -> TAG) { case LEAF_TAG: { - register GC_descr descr = d -> ld.ld_descriptor; + GC_descr descr = d -> ld.ld_descriptor; nelements = d -> ld.ld_nelements; if (msl - msp <= (ptrdiff_t)nelements) return(0); @@ -450,7 +450,7 @@ STATIC mse * GC_push_complex_descriptor(word *addr, complex_descriptor *d, } case ARRAY_TAG: { - register complex_descriptor *descr = d -> ad.ad_element_descr; + complex_descriptor *descr = d -> ad.ad_element_descr; nelements = d -> ad.ad_nelements; sz = GC_descr_obj_size(descr); diff --git a/win32_threads.c b/win32_threads.c index 71cafa33a..03eb6b5ae 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -670,8 +670,8 @@ STATIC void GC_delete_gc_thread_no_free(GC_vthread t) DWORD id = ((GC_thread)t) -> id; /* Cast away volatile qualifier, since we have lock. */ int hv = THREAD_TABLE_INDEX(id); - register GC_thread p = GC_threads[hv]; - register GC_thread prev = 0; + GC_thread p = GC_threads[hv]; + GC_thread prev = NULL; GC_ASSERT(I_HOLD_LOCK()); while (p != (GC_thread)t) { @@ -704,8 +704,8 @@ STATIC void GC_delete_thread(DWORD id) } } else { int hv = THREAD_TABLE_INDEX(id); - register GC_thread p = GC_threads[hv]; - register GC_thread prev = 0; + GC_thread p = GC_threads[hv]; + GC_thread prev = NULL; GC_ASSERT(I_HOLD_LOCK()); while (p -> id != id) {