* 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 <ivmai@mail.ru>
+ * 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 <ivmai@mail.ru>
+
* os_dep.c (GC_get_stack_base): Implement for Android (same as
for Linux).
* pthread_support.c (GC_get_nprocs): Return 1 (instead of -1) if
# 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; \
}
{ \
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; \
}
# 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 */
/* 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 */
#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
# 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 */
/* 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. */
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)
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)
{
/* 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) {