/* Heap size at which we need a collection to avoid expanding past */
/* limits used by blacklisting. */
-STATIC word GC_collect_at_heapsize = (word)(-1);
+STATIC word GC_collect_at_heapsize = GC_WORD_MAX;
/* Have we allocated enough to amortize a collection? */
GC_INNER GC_bool GC_should_collect(void)
{
word used = GC_composite_in_use + GC_atomic_in_use;
word heap_sz = GC_heapsize - GC_unmapped_bytes;
- return used >= heap_sz ? 0 : used < ((word)-1) / 100 ?
+ return used >= heap_sz ? 0 : used < GC_WORD_MAX / 100 ?
(int)((used * 100) / heap_sz) : (int)(used / (heap_sz / 100));
}
*/
GC_collect_at_heapsize += bytes;
if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
- GC_collect_at_heapsize = (word)(-1);
+ GC_collect_at_heapsize = GC_WORD_MAX;
if ((word)p <= (word)GC_least_plausible_heap_addr
|| GC_least_plausible_heap_addr == 0) {
}
#endif
-void * GC_least_plausible_heap_addr = (void *)ONES;
+void * GC_least_plausible_heap_addr = (void *)GC_WORD_MAX;
void * GC_greatest_plausible_heap_addr = 0;
GC_INLINE word GC_max(word x, word y)
GC_collect_at_heapsize =
GC_heapsize + expansion_slop - 2*MAXHINCR*HBLKSIZE;
if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
- GC_collect_at_heapsize = (word)(-1);
+ GC_collect_at_heapsize = GC_WORD_MAX;
if (GC_on_heap_resize)
(*GC_on_heap_resize)(GC_heapsize);
static word last_fo_entries = 0;
static word last_bytes_finalized = 0;
-#define GC_WORD_MAX (~(word)0)
-
/* Collect or expand heap in an attempt make the indicated number of */
/* free blocks available. Should be called until the blocks are */
/* available (setting retry value to TRUE unless this is the first call */
} else {
ptr_t datastart, dataend;
# ifdef DATASTART_IS_FUNC
- static ptr_t datastart_cached = (ptr_t)(word)-1;
+ static ptr_t datastart_cached = (ptr_t)GC_WORD_MAX;
/* Evaluate DATASTART only once. */
- if (datastart_cached == (ptr_t)(word)-1) {
+ if (datastart_cached == (ptr_t)GC_WORD_MAX) {
datastart_cached = DATASTART;
}
datastart = datastart_cached;
# ifdef KEEP_BACK_PTRS
long i;
/* Stops when GC_gc_no wraps; that's OK. */
- last_back_trace_gc_no = (word)(-1); /* disable others. */
+ last_back_trace_gc_no = GC_WORD_MAX; /* disable others. */
for (i = 0; i < GC_backtraces; ++i) {
/* FIXME: This tolerates concurrent heap mutation, */
/* which may cause occasional mysterious results. */
struct hblk * hbp;
for (hbp = h; (word)hbp < (word)h + sz; hbp += BOTTOM_SZ) {
- if (!get_index((word) hbp)) return(FALSE);
- if ((word)hbp > (~(word)0) - (word)BOTTOM_SZ * HBLKSIZE)
+ if (!get_index((word)hbp))
+ return FALSE;
+ if ((word)hbp > GC_WORD_MAX - (word)BOTTOM_SZ * HBLKSIZE)
break; /* overflow of hbp+=BOTTOM_SZ is expected */
}
- if (!get_index((word)h + sz - 1)) return(FALSE);
+ if (!get_index((word)h + sz - 1))
+ return FALSE;
for (hbp = h + 1; (word)hbp < (word)h + sz; hbp += 1) {
word i = HBLK_PTR_DIFF(hbp, h);
SET_HDR(hbp, (hdr *)(i > MAX_JUMP? MAX_JUMP : i));
}
- return(TRUE);
+ return TRUE;
}
/* Remove the header for block h */
# include "gc_locks.h"
#endif
-#define ONES ((word)(signed_word)(-1))
+#define GC_WORD_MAX (~(word)0)
# ifdef STACK_GROWS_DOWN
# define COOLER_THAN >
# define HOTTER_THAN <
# define MAKE_COOLER(x,y) if ((word)((x) + (y)) > (word)(x)) {(x) += (y);} \
- else (x) = (ptr_t)ONES
+ else (x) = (ptr_t)GC_WORD_MAX
# define MAKE_HOTTER(x,y) (x) -= (y)
# else
# define COOLER_THAN <
/* Note: Preserve *_freelists names for some clients. */
# ifdef GC_GCJ_SUPPORT
void * gcj_freelists[TINY_FREELISTS];
-# define ERROR_FL ((void *)(word)-1)
+# define ERROR_FL ((void *)GC_WORD_MAX)
/* Value used for gcj_freelists[-1]; allocation is */
/* erroneous. */
# endif
}
# else
for (i = 0; i < divWORDSZ(n_marks + WORDSZ); ++i) {
- hhdr -> hb_marks[i] = ONES;
+ hhdr -> hb_marks[i] = GC_WORD_MAX;
}
# endif
# ifdef MARK_BIT_PER_OBJ
ptr_t GC_find_limit(ptr_t p, GC_bool up)
{
- return GC_find_limit_with_bound(p, up, up ? (ptr_t)(word)(-1) : 0);
+ return GC_find_limit_with_bound(p, up, up ? (ptr_t)GC_WORD_MAX : 0);
}
# endif /* NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES */
} msg;
mach_msg_id_t id;
- if ((word)arg == (word)-1) return 0; /* to make compiler happy */
+ if ((word)arg == GC_WORD_MAX) return 0; /* to prevent a compiler warning */
# if defined(CPPCHECK)
reply.data[0] = 0; /* to prevent "field unused" warnings */
msg.data[0] = 0;
word my_mark_no = 0;
IF_CANCEL(int cancel_state;)
- if ((word)id == (word)-1) return 0; /* to make compiler happy */
+ if ((word)id == GC_WORD_MAX) return 0; /* to prevent a compiler warning */
DISABLE_CANCEL(cancel_state);
/* Mark threads are not cancellable; they */
/* should be invisible to client. */
STATIC DWORD GC_main_thread = 0;
-#define ADDR_LIMIT ((ptr_t)(word)-1)
+#define ADDR_LIMIT ((ptr_t)GC_WORD_MAX)
struct GC_Thread_Rep {
union {
{
word my_mark_no = 0;
- if ((word)id == (word)-1) return 0; /* to make compiler happy */
+ if ((word)id == GC_WORD_MAX) return 0; /* to prevent a compiler warning */
marker_sp[(word)id] = GC_approx_sp();
# ifdef IA64
marker_bsp[(word)id] = GC_save_regs_in_stack();