diff options
-rw-r--r-- | alloc.c | 25 | ||||
-rw-r--r-- | darwin_stop_world.c | 16 | ||||
-rw-r--r-- | dyn_load.c | 7 | ||||
-rw-r--r-- | include/gc.h | 18 | ||||
-rw-r--r-- | include/private/gc_priv.h | 7 | ||||
-rw-r--r-- | include/private/gcconfig.h | 8 | ||||
-rw-r--r-- | malloc.c | 6 | ||||
-rw-r--r-- | misc.c | 2 | ||||
-rw-r--r-- | os_dep.c | 6 | ||||
-rw-r--r-- | pthread_stop_world.c | 12 | ||||
-rw-r--r-- | pthread_support.c | 2 | ||||
-rw-r--r-- | tests/test.c | 2 | ||||
-rw-r--r-- | win32_threads.c | 2 |
13 files changed, 67 insertions, 46 deletions
@@ -71,14 +71,14 @@ word GC_gc_no = 0; 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. */ @@ -119,24 +119,25 @@ GC_API unsigned GC_CALL GC_get_version(void) 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. */ diff --git a/darwin_stop_world.c b/darwin_stop_world.c index cfe24655..d829f6a6 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -168,13 +168,19 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p, 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 @@ -691,8 +691,13 @@ GC_FirstDLOpenedLinkMap(void) } 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). */ diff --git a/include/gc.h b/include/gc.h index db8de0a9..2041f62f 100644 --- a/include/gc.h +++ b/include/gc.h @@ -59,7 +59,7 @@ typedef void * GC_PTR; /* preserved only for backward compatibility */ /* 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 @@ -1824,14 +1824,14 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void); /* 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) @@ -1839,34 +1839,34 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void); # 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 */ @@ -1884,7 +1884,7 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void); # 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(); \ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 4468984b..8370fc73 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -93,7 +93,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */ #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) @@ -614,7 +614,8 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc; # 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 @@ -2463,7 +2464,7 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, # 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 diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 714e5d15..d45abda8 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -3105,7 +3105,7 @@ # 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 @@ -3139,7 +3139,11 @@ #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) @@ -181,7 +181,11 @@ GC_INNER void * GC_generic_malloc_inner(size_t lb, int k) #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) @@ -873,7 +873,7 @@ GC_API void GC_CALL GC_init(void) } # 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; @@ -1212,7 +1212,7 @@ GC_INNER size_t GC_page_size = 0; 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; @@ -1220,7 +1220,7 @@ GC_INNER size_t GC_page_size = 0; # 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; @@ -2030,7 +2030,7 @@ void GC_register_data_segments(void) #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 diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 407db8fc..6ee4282b 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -136,7 +136,7 @@ STATIC volatile AO_t GC_world_is_stopped = FALSE; #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 @@ -388,15 +388,15 @@ STATIC void GC_restart_handler(int sig) # 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); } diff --git a/pthread_support.c b/pthread_support.c index 1db9af6a..1b6a3022 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1189,7 +1189,7 @@ GC_INNER void GC_thr_init(void) } } 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; diff --git a/tests/test.c b/tests/test.c index 6c9bef41..4e00ea32 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1519,7 +1519,7 @@ void check_heap_stats(void) # 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 diff --git a/win32_threads.c b/win32_threads.c index 1e0d55e8..14ac9d60 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2453,7 +2453,7 @@ GC_INNER void GC_thr_init(void) } 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; |