From: ivmai Date: Fri, 22 Apr 2011 21:40:15 +0000 (+0000) Subject: 2011-04-22 Ivan Maidanski X-Git-Tag: gc7_2alpha6~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1afd6d5538d21c7ff854563bcedab00d2c0b8ee;p=gc 2011-04-22 Ivan Maidanski * os_dep.c (GC_get_maps): Always close the file. * pthread_support.c (GC_get_nprocs): Ditto. * os_dep.c (READ): Define similarly across the file (without parameters). * pthread_support.c (GC_get_nprocs): Use signed int type for "i" and "len" local variables (since read() may return -1). * include/private/gc_pmark.h (LONG_MULT): Add prefix/suffix double underscore; add "volatile" for asm. * include/private/gc_pmark.h (LONG_MULT): Add missing parentheses. * include/private/gc_priv.h (OR_WORD): Ditto. * include/private/gc_priv.h (OR_WORD): Remove unnecessary brackets and ';' symbol. --- diff --git a/ChangeLog b/ChangeLog index b57c19e6..a61a85ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-04-22 Ivan Maidanski + + * os_dep.c (GC_get_maps): Always close the file. + * pthread_support.c (GC_get_nprocs): Ditto. + * os_dep.c (READ): Define similarly across the file (without + parameters). + * pthread_support.c (GC_get_nprocs): Use signed int type for "i" + and "len" local variables (since read() may return -1). + * include/private/gc_pmark.h (LONG_MULT): Add prefix/suffix + double underscore; add "volatile" for asm. + * include/private/gc_pmark.h (LONG_MULT): Add missing + parentheses. + * include/private/gc_priv.h (OR_WORD): Ditto. + * include/private/gc_priv.h (OR_WORD): Remove unnecessary brackets + and ';' symbol. + 2011-04-22 Ivan Maidanski * os_dep.c (GC_get_stack_base): Implement for Android (same as diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index a24dda83..05b082b4 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -189,20 +189,20 @@ exit_label: ; \ # define SET_MARK_BIT_EXIT_IF_SET(hhdr,bit_no,exit_label) \ { \ word * mark_word_addr = hhdr -> hb_marks + divWORDSZ(bit_no); \ - \ OR_WORD_EXIT_IF_SET(mark_word_addr, (word)1 << modWORDSZ(bit_no), \ exit_label); \ } -#endif +#endif /* USE_MARK_BITS */ #if defined(I386) && defined(__GNUC__) # define LONG_MULT(hprod, lprod, x, y) { \ - asm("mull %2" : "=a"(lprod), "=d"(hprod) : "g"(y), "0"(x)); \ + __asm__ __volatile__("mull %2" : "=a"(lprod), "=d"(hprod) \ + : "g"(y), "0"(x)); \ } #else /* No in-line X86 assembly code */ # define LONG_MULT(hprod, lprod, x, y) { \ - unsigned long long prod = (unsigned long long)x \ - * (unsigned long long)y; \ + unsigned long long prod = (unsigned long long)(x) \ + * (unsigned long long)(y); \ hprod = prod >> 32; \ lprod = (unsigned32)prod; \ } @@ -216,7 +216,6 @@ exit_label: ; \ { \ char * mark_byte_addr = (char *)hhdr -> hb_marks + (bit_no); \ char mark_byte = *mark_byte_addr; \ - \ if (mark_byte) goto exit_label; \ *mark_byte_addr = 1; \ } diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 9d97e327..7168c147 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -787,7 +787,7 @@ typedef word page_hash_table[PHT_SIZE]; # if defined(THREADS) && defined(MPROTECT_VDB) # include "atomic_ops.h" # endif -#endif +#endif /* !PARALLEL_MARK */ /* We maintain layout maps for heap blocks containing objects of a given */ /* size. Each entry in this map describes a byte offset and has the */ @@ -1338,10 +1338,9 @@ struct GC_traced_stack_sect_s { /* Set mark bit correctly, even if mark bits may be concurrently */ /* accessed. */ #ifdef PARALLEL_MARK -# define OR_WORD(addr, bits) \ - { AO_or((volatile AO_t *)(addr), (AO_t)bits); } +# define OR_WORD(addr, bits) AO_or((volatile AO_t *)(addr), (AO_t)(bits)) #else -# define OR_WORD(addr, bits) *(addr) |= (bits) +# define OR_WORD(addr, bits) (void)(*(addr) |= (bits)) #endif /* Mark bit operations */ @@ -1355,16 +1354,15 @@ struct GC_traced_stack_sect_s { #ifdef USE_MARK_BYTES # define mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[n]) -# define set_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[n]) = 1 -# define clear_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[n]) = 0 -#else /* !USE_MARK_BYTES */ -# define mark_bit_from_hdr(hhdr,n) (((hhdr)->hb_marks[divWORDSZ(n)] \ - >> (modWORDSZ(n))) & (word)1) +# define set_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[n] = 1) +# define clear_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[n] = 0) +#else +# define mark_bit_from_hdr(hhdr,n) \ + (((hhdr)->hb_marks[divWORDSZ(n)] >> modWORDSZ(n)) & (word)1) # define set_mark_bit_from_hdr(hhdr,n) \ - OR_WORD((hhdr)->hb_marks+divWORDSZ(n), \ - (word)1 << modWORDSZ(n)) -# define clear_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \ - &= ~((word)1 << modWORDSZ(n)) + OR_WORD((hhdr)->hb_marks+divWORDSZ(n), (word)1 << modWORDSZ(n)) +# define clear_mark_bit_from_hdr(hhdr,n) \ + ((hhdr)->hb_marks[divWORDSZ(n)] &= ~((word)1 << modWORDSZ(n))) #endif /* !USE_MARK_BYTES */ #ifdef MARK_BIT_PER_OBJ @@ -1381,8 +1379,8 @@ struct GC_traced_stack_sect_s { # define MARK_BIT_OFFSET(sz) BYTES_TO_GRANULES(sz) # define IF_PER_OBJ(x) # define FINAL_MARK_BIT(sz) \ - ((sz) > MAXOBJBYTES? MARK_BITS_PER_HBLK \ - : BYTES_TO_GRANULES((sz) * HBLK_OBJS(sz))) + ((sz) > MAXOBJBYTES ? MARK_BITS_PER_HBLK \ + : BYTES_TO_GRANULES((sz) * HBLK_OBJS(sz))) #endif /* Important internal collector routines */ @@ -1628,7 +1626,7 @@ GC_INNER void GC_freehblk(struct hblk * p); /* Misc GC: */ GC_INNER GC_bool GC_expand_hp_inner(word n); -GC_INNER void GC_start_reclaim(int abort_if_found); +GC_INNER void GC_start_reclaim(GC_bool abort_if_found); /* Restore unmarked objects to free */ /* lists, or (if abort_if_found is */ /* TRUE) report them. */ diff --git a/os_dep.c b/os_dep.c index a562b79c..db3fd2b3 100644 --- a/os_dep.c +++ b/os_dep.c @@ -264,10 +264,13 @@ GC_INNER char * GC_get_maps(void) maps_size = 0; do { result = GC_repeat_read(f, maps_buf, maps_buf_sz-1); - if (result <= 0) return 0; + if (result <= 0) + break; maps_size += result; } while (result == maps_buf_sz-1); close(f); + if (result <= 0) + return 0; # ifdef THREADS if (maps_size > old_maps_size) { if (GC_print_stats) @@ -3662,7 +3665,7 @@ GC_INNER void GC_dirty_init(void) GC_INNER void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree) {} -# define READ(fd,buf,nbytes) read(fd, buf, nbytes) +#define READ read GC_INNER void GC_read_dirty(void) { diff --git a/pthread_support.c b/pthread_support.c index 16d0dc9a..d9c3792c 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -727,13 +727,14 @@ STATIC void GC_remove_all_threads_but_me(void) /* Some old kernels only have a single "cpu nnnn ..." */ /* entry in /proc/stat. We identify those as */ /* uniprocessors. */ - size_t i, len = 0; + int i, len; f = open("/proc/stat", O_RDONLY); - if (f < 0 || (len = STAT_READ(f, stat_buf, STAT_BUF_SIZE)) < 100) { + if (f < 0) { WARN("Couldn't read /proc/stat\n", 0); return 1; /* assume an uniprocessor */ } + len = STAT_READ(f, stat_buf, STAT_BUF_SIZE); close(f); for (i = 0; i < len - 100; ++i) {