int GC_parallel = FALSE; /* By default, parallel GC is off. */
#endif
-#ifndef GC_FULL_FREQ
-# define GC_FULL_FREQ 19 /* Every 20th collection is a full */
+#if defined(GC_FULL_FREQ) && !defined(CPPCHECK)
+ int GC_full_freq = GC_FULL_FREQ;
+#else
+ int GC_full_freq = 19; /* Every 20th collection is a full */
/* collection, whether we need it */
/* or not. */
#endif
-int GC_full_freq = GC_FULL_FREQ;
-
STATIC GC_bool GC_need_full_gc = FALSE;
/* Need full GC do to heap growth. */
int GC_dont_expand = FALSE;
#endif
-#ifndef GC_FREE_SPACE_DIVISOR
-# define GC_FREE_SPACE_DIVISOR 3 /* must be > 0 */
+#if defined(GC_FREE_SPACE_DIVISOR) && !defined(CPPCHECK)
+ word GC_free_space_divisor = GC_FREE_SPACE_DIVISOR; /* must be > 0 */
+#else
+ word GC_free_space_divisor = 3;
#endif
-word GC_free_space_divisor = GC_FREE_SPACE_DIVISOR;
-
GC_INNER int GC_CALLBACK GC_never_stop_func(void)
{
return(0);
}
-#ifndef GC_TIME_LIMIT
-# define GC_TIME_LIMIT 50 /* We try to keep pause times from exceeding */
+#if defined(GC_TIME_LIMIT) && !defined(CPPCHECK)
+ unsigned long GC_time_limit = GC_TIME_LIMIT;
+ /* We try to keep pause times from exceeding */
/* this by much. In milliseconds. */
+#else
+ unsigned long GC_time_limit = 50;
#endif
-unsigned long GC_time_limit = GC_TIME_LIMIT;
-
#ifndef NO_CLOCK
STATIC CLOCK_TYPE GC_start_time = 0;
/* Time at which we stopped world. */
arm_unified_thread_state_t unified_state;
mach_msg_type_number_t unified_thread_state_count
= ARM_UNIFIED_THREAD_STATE_COUNT;
-
- kern_result = thread_get_state(thread, ARM_UNIFIED_THREAD_STATE,
+# if defined(CPPCHECK)
+# define GC_ARM_UNIFIED_THREAD_STATE 1
+# else
+# define GC_ARM_UNIFIED_THREAD_STATE ARM_UNIFIED_THREAD_STATE
+# endif
+ kern_result = thread_get_state(thread, GC_ARM_UNIFIED_THREAD_STATE,
(natural_t *)&unified_state,
&unified_thread_state_count);
- if (unified_state.ash.flavor != ARM_THREAD_STATE32) {
- ABORT("unified_state flavor should be ARM_THREAD_STATE32");
- }
+# if !defined(CPPCHECK)
+ if (unified_state.ash.flavor != ARM_THREAD_STATE32) {
+ ABORT("unified_state flavor should be ARM_THREAD_STATE32");
+ }
+# endif
state = unified_state.ts_32;
} else
# endif
}
if( cachedResult == 0 ) {
# if defined(NETBSD) && defined(RTLD_DI_LINKMAP)
+# if defined(CPPCHECK)
+# define GC_RTLD_DI_LINKMAP 2
+# else
+# define GC_RTLD_DI_LINKMAP RTLD_DI_LINKMAP
+# endif
struct link_map *lm = NULL;
- if (!dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lm) && lm != NULL) {
+ if (!dlinfo(RTLD_SELF, GC_RTLD_DI_LINKMAP, &lm) && lm != NULL) {
/* Now lm points link_map object of libgc. Since it */
/* might not be the first dynamically linked object, */
/* try to find it (object next to the main object). */
/* better choices. But those had incorrect definitions on some older */
/* systems. Notably "typedef int size_t" is WRONG. */
#ifdef _WIN64
-# ifdef __int64
+# if defined(__int64) && !defined(CPPCHECK)
typedef unsigned __int64 GC_word;
typedef __int64 GC_signed_word;
# else
/* This is for debugging only (useful if environment variables are */
/* unsupported); cannot call GC_disable as goes before GC_init. */
# define GC_INIT_CONF_MAX_RETRIES (void)(GC_dont_gc = 1)
-#elif defined(GC_MAX_RETRIES)
+#elif defined(GC_MAX_RETRIES) && !defined(CPPCHECK)
/* Set GC_max_retries to the desired value at start-up */
# define GC_INIT_CONF_MAX_RETRIES GC_set_max_retries(GC_MAX_RETRIES)
#else
# define GC_INIT_CONF_MAX_RETRIES /* empty */
#endif
-#ifdef GC_FREE_SPACE_DIVISOR
+#if defined(GC_FREE_SPACE_DIVISOR) && !defined(CPPCHECK)
/* Set GC_free_space_divisor to the desired value at start-up */
# define GC_INIT_CONF_FREE_SPACE_DIVISOR \
GC_set_free_space_divisor(GC_FREE_SPACE_DIVISOR)
# define GC_INIT_CONF_FREE_SPACE_DIVISOR /* empty */
#endif
-#ifdef GC_FULL_FREQ
+#if defined(GC_FULL_FREQ) && !defined(CPPCHECK)
/* Set GC_full_freq to the desired value at start-up */
# define GC_INIT_CONF_FULL_FREQ GC_set_full_freq(GC_FULL_FREQ)
#else
# define GC_INIT_CONF_FULL_FREQ /* empty */
#endif
-#ifdef GC_TIME_LIMIT
+#if defined(GC_TIME_LIMIT) && !defined(CPPCHECK)
/* Set GC_time_limit to the desired value at start-up */
# define GC_INIT_CONF_TIME_LIMIT GC_set_time_limit(GC_TIME_LIMIT)
#else
# define GC_INIT_CONF_TIME_LIMIT /* empty */
#endif
-#if defined(GC_SIG_SUSPEND) && defined(GC_THREADS)
+#if defined(GC_SIG_SUSPEND) && defined(GC_THREADS) && !defined(CPPCHECK)
# define GC_INIT_CONF_SUSPEND_SIGNAL GC_set_suspend_signal(GC_SIG_SUSPEND)
#else
# define GC_INIT_CONF_SUSPEND_SIGNAL /* empty */
#endif
-#if defined(GC_SIG_THR_RESTART) && defined(GC_THREADS)
+#if defined(GC_SIG_THR_RESTART) && defined(GC_THREADS) && !defined(CPPCHECK)
# define GC_INIT_CONF_THR_RESTART_SIGNAL \
GC_set_thr_restart_signal(GC_SIG_THR_RESTART)
#else
# define GC_INIT_CONF_THR_RESTART_SIGNAL /* empty */
#endif
-#ifdef GC_MAXIMUM_HEAP_SIZE
+#if defined(GC_MAXIMUM_HEAP_SIZE) && !defined(CPPCHECK)
/* Limit the heap size to the desired value (useful for debugging). */
/* The limit could be overridden either at the program start-up by */
/* the similar environment variable or anytime later by the */
# define GC_INIT_CONF_IGNORE_WARN /* empty */
#endif
-#ifdef GC_INITIAL_HEAP_SIZE
+#if defined(GC_INITIAL_HEAP_SIZE) && !defined(CPPCHECK)
/* Set heap size to the desired value at start-up */
# define GC_INIT_CONF_INITIAL_HEAP_SIZE \
{ size_t heap_size = GC_get_heap_size(); \
#ifndef SIZE_MAX
# include <limits.h>
#endif
-#ifdef SIZE_MAX
+#if defined(SIZE_MAX) && !defined(CPPCHECK)
# define GC_SIZE_MAX SIZE_MAX
#else
# define GC_SIZE_MAX (~(size_t)0)
# define GC_MACH_THREAD_STATE x86_THREAD_STATE64
# define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
# endif
-# elif defined(ARM32) && defined(ARM_UNIFIED_THREAD_STATE)
+# elif defined(ARM32) && defined(ARM_UNIFIED_THREAD_STATE) \
+ && !defined(CPPCHECK)
# define GC_THREAD_STATE_T arm_unified_thread_state_t
# define GC_MACH_THREAD_STATE ARM_UNIFIED_THREAD_STATE
# define GC_MACH_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT
# ifndef GC_OPENBSD_UTHREADS
# define SIG_SUSPEND SIGXFSZ
# endif
-# elif defined(_SIGRTMIN)
+# elif defined(_SIGRTMIN) && !defined(CPPCHECK)
# define SIG_SUSPEND _SIGRTMIN + 6
# else
# define SIG_SUSPEND SIGRTMIN + 6
# endif
#endif
#ifdef SAVE_CALL_CHAIN
-# ifndef SAVE_CALL_COUNT
+# if !defined(SAVE_CALL_COUNT) || defined(CPPCHECK)
# define NFRAMES 6 /* Number of frames to save. Even for */
/* alignment reasons. */
# else
#endif
#if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
-# define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT)
+# if defined(CPPCHECK)
+# define FIXUP_POINTER(p) (p = (p) << 4) /* e.g. */
+# else
+# define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT)
+# endif
#endif
#if defined(FIXUP_POINTER)
#ifdef GC_COLLECT_AT_MALLOC
/* Parameter to force GC at every malloc of size greater or equal to */
/* the given value. This might be handy during debugging. */
- size_t GC_dbg_collect_at_malloc_min_lb = (GC_COLLECT_AT_MALLOC);
+# if defined(CPPCHECK)
+ size_t GC_dbg_collect_at_malloc_min_lb = 16*1024; /* e.g. */
+# else
+ size_t GC_dbg_collect_at_malloc_min_lb = (GC_COLLECT_AT_MALLOC);
+# endif
#endif
GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc(size_t lb, int k)
}
# endif
-# ifdef GC_INITIAL_HEAP_SIZE
+# if defined(GC_INITIAL_HEAP_SIZE) && !defined(CPPCHECK)
initial_heap_sz = GC_INITIAL_HEAP_SIZE;
# else
initial_heap_sz = MINHINCR * HBLKSIZE;
ptr_t sp = GC_approx_sp();
# ifdef STACK_GROWS_DOWN
result = GC_find_limit(sp, TRUE);
-# ifdef HEURISTIC2_LIMIT
+# if defined(HEURISTIC2_LIMIT) && !defined(CPPCHECK)
if ((word)result > (word)HEURISTIC2_LIMIT
&& (word)sp < (word)HEURISTIC2_LIMIT) {
result = HEURISTIC2_LIMIT;
# endif
# else
result = GC_find_limit(sp, FALSE);
-# ifdef HEURISTIC2_LIMIT
+# if defined(HEURISTIC2_LIMIT) && !defined(CPPCHECK)
if ((word)result < (word)HEURISTIC2_LIMIT
&& (word)sp > (word)HEURISTIC2_LIMIT) {
result = HEURISTIC2_LIMIT;
#ifdef USE_MMAP_ANON
# define zero_fd -1
-# if defined(MAP_ANONYMOUS)
+# if defined(MAP_ANONYMOUS) && !defined(CPPCHECK)
# define OPT_MAP_ANON MAP_ANONYMOUS
# else
# define OPT_MAP_ANON MAP_ANON
#ifndef SIG_THR_RESTART
# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) \
|| defined(GC_NETBSD_THREADS) || defined(GC_USESIGRT_SIGNALS)
-# ifdef _SIGRTMIN
+# if defined(_SIGRTMIN) && !defined(CPPCHECK)
# define SIG_THR_RESTART _SIGRTMIN + 5
# else
# define SIG_THR_RESTART SIGRTMIN + 5
# endif /* !USE_TKILL_ON_ANDROID */
# ifdef GC_ENABLE_SUSPEND_THREAD
-# ifndef GC_TIME_LIMIT
-# define GC_TIME_LIMIT 50
-# endif
-
STATIC void GC_brief_async_signal_safe_sleep(void)
{
struct timeval tv;
tv.tv_sec = 0;
- tv.tv_usec = 1000 * GC_TIME_LIMIT / 2;
+# if defined(GC_TIME_LIMIT) && !defined(CPPCHECK)
+ tv.tv_usec = 1000 * GC_TIME_LIMIT / 2;
+# else
+ tv.tv_usec = 1000 * 50 / 2;
+# endif
select(0, 0, 0, 0, &tv);
}
}
} else {
markers = GC_nprocs;
-# ifdef GC_MIN_MARKERS
+# if defined(GC_MIN_MARKERS) && !defined(CPPCHECK)
/* This is primarily for targets without getenv(). */
if (markers < GC_MIN_MARKERS)
markers = GC_MIN_MARKERS;
# ifdef SAVE_CALL_CHAIN
max_heap_sz *= 3;
# ifdef SAVE_CALL_COUNT
- max_heap_sz += max_heap_sz * SAVE_CALL_COUNT/4;
+ max_heap_sz += max_heap_sz * NFRAMES / 4;
# endif
# endif
# endif
}
markers = ncpu;
# endif
-# ifdef GC_MIN_MARKERS
+# if defined(GC_MIN_MARKERS) && !defined(CPPCHECK)
/* This is primarily for testing on systems without getenv(). */
if (markers < GC_MIN_MARKERS)
markers = GC_MIN_MARKERS;