From 9f4d913809d364b29458b03e20e85c05885ab6f9 Mon Sep 17 00:00:00 2001 From: ivmai Date: Sat, 12 Feb 2011 15:02:35 +0000 Subject: [PATCH] 2011-02-10 Ivan Maidanski * NT_MAKEFILE: Define _CRT_SECURE_NO_DEPRECATE for C++ files as well. * NT_STATIC_THREADS_MAKEFILE: Ditto. * doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Refine. * include/gc.h (GC_INIT): Document. * include/private/gc_priv.h (GC_MACH_HEADER, GC_MACH_SECTION, GC_GETSECTBYNAME): Define depending only on the word size (i.e., define these macros also for ARM). * tests/test.c (check_heap_stats): Print main thread stack bottom as well (only if verbose mode is on). --- ChangeLog | 13 +++++++++++++ NT_MAKEFILE | 2 +- NT_STATIC_THREADS_MAKEFILE | 2 +- doc/README.macros | 5 +++-- include/gc.h | 3 +++ include/private/gc_priv.h | 23 +++++++++++------------ tests/test.c | 4 ++++ 7 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42d3ff23..ab522493 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-02-10 Ivan Maidanski + + * NT_MAKEFILE: Define _CRT_SECURE_NO_DEPRECATE for C++ files as + well. + * NT_STATIC_THREADS_MAKEFILE: Ditto. + * doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Refine. + * include/gc.h (GC_INIT): Document. + * include/private/gc_priv.h (GC_MACH_HEADER, GC_MACH_SECTION, + GC_GETSECTBYNAME): Define depending only on the word size (i.e., + define these macros also for ARM). + * tests/test.c (check_heap_stats): Print main thread stack bottom + as well (only if verbose mode is on). + 2011-02-09 Ivan Maidanski (mostly Jean-Claude Beaudoin) * mach_dep.c (GC_with_callee_saves_pushed): Fix and improve code diff --git a/NT_MAKEFILE b/NT_MAKEFILE index e454b0b0..f9077a3d 100644 --- a/NT_MAKEFILE +++ b/NT_MAKEFILE @@ -18,7 +18,7 @@ all: gctest.exe cord\de.exe test_cpp.exe $(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DALL_INTERIOR_POINTERS -DGC_NOT_DLL -D_CRT_SECURE_NO_DEPRECATE $*.c /Fo$*.obj .cpp.obj: - $(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DALL_INTERIOR_POINTERS -DGC_NOT_DLL $*.CPP /Fo$*.obj + $(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DALL_INTERIOR_POINTERS -DGC_NOT_DLL -D_CRT_SECURE_NO_DEPRECATE $*.CPP /Fo$*.obj $(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h include\private\msvc_dbg.h diff --git a/NT_STATIC_THREADS_MAKEFILE b/NT_STATIC_THREADS_MAKEFILE index dfcc7c6a..6892d291 100644 --- a/NT_STATIC_THREADS_MAKEFILE +++ b/NT_STATIC_THREADS_MAKEFILE @@ -25,7 +25,7 @@ all: gctest.exe cord\de.exe test_cpp.exe $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -DGC_NOT_DLL -DGC_THREADS -DTHREAD_LOCAL_ALLOC -DPARALLEL_MARK -D_CRT_SECURE_NO_DEPRECATE $*.c /Fo$*.obj .cpp.obj: - $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -DGC_NOT_DLL $*.CPP -DGC_THREADS -DTHREAD_LOCAL_ALLOC /Fo$*.obj + $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -DGC_NOT_DLL $*.CPP -DGC_THREADS -DTHREAD_LOCAL_ALLOC -D_CRT_SECURE_NO_DEPRECATE $*.cpp /Fo$*.obj $(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h include\private\msvc_dbg.h diff --git a/doc/README.macros b/doc/README.macros index c1d8aea6..6e9ebd8b 100644 --- a/doc/README.macros +++ b/doc/README.macros @@ -529,5 +529,6 @@ PLATFORM_ANDROID Compile for Android NDK platform. SN_TARGET_PS3 Compile for Sony PS/3. USE_GET_STACKBASE_FOR_MAIN (Linux only) Use pthread_attr_getstack() instead -of __libc_stack_end for getting the primordial thread stack base (useful if -the client modifies the program's address space). +of __libc_stack_end (or instead of any hard-coded value) for getting the +primordial thread stack base (useful if the client modifies the program's +address space). diff --git a/include/gc.h b/include/gc.h index 6a3f9ec9..d90ba5c5 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1436,6 +1436,9 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void); # define GC_INIT_CONF_INITIAL_HEAP_SIZE /* empty */ #endif +/* Portable clients should call this at the program start-up. More */ +/* over, some platforms require this call to be done strictly from the */ +/* primordial thread. */ #define GC_INIT() { GC_INIT_CONF_DONT_EXPAND; /* pre-init */ \ GC_INIT_CONF_FORCE_UNMAP_ON_GCOLLECT; \ GC_INIT_CONF_MAX_RETRIES; \ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index a10080aa..556cf60f 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -473,32 +473,20 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc; # define GC_THREAD_STATE_T ppc_thread_state_t # define GC_MACH_THREAD_STATE PPC_THREAD_STATE # define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT -# define GC_MACH_HEADER mach_header -# define GC_MACH_SECTION section -# define GC_GETSECTBYNAME getsectbynamefromheader # else # define GC_THREAD_STATE_T ppc_thread_state64_t # define GC_MACH_THREAD_STATE PPC_THREAD_STATE64 # define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE64_COUNT -# define GC_MACH_HEADER mach_header_64 -# define GC_MACH_SECTION section_64 -# define GC_GETSECTBYNAME getsectbynamefromheader_64 # endif # elif defined(I386) || defined(X86_64) # if CPP_WORDSZ == 32 # define GC_THREAD_STATE_T x86_thread_state32_t # define GC_MACH_THREAD_STATE x86_THREAD_STATE32 # define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE32_COUNT -# define GC_MACH_HEADER mach_header -# define GC_MACH_SECTION section -# define GC_GETSECTBYNAME getsectbynamefromheader # else # define GC_THREAD_STATE_T x86_thread_state64_t # define GC_MACH_THREAD_STATE x86_THREAD_STATE64 # define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT -# define GC_MACH_HEADER mach_header_64 -# define GC_MACH_SECTION section_64 -# define GC_GETSECTBYNAME getsectbynamefromheader_64 # endif # else # if defined(ARM32) @@ -509,6 +497,17 @@ GC_EXTERN GC_warn_proc GC_current_warn_proc; # define GC_MACH_THREAD_STATE MACHINE_THREAD_STATE # define GC_MACH_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT # endif + +# if CPP_WORDSZ == 32 +# define GC_MACH_HEADER mach_header +# define GC_MACH_SECTION section +# define GC_GETSECTBYNAME getsectbynamefromheader +# else +# define GC_MACH_HEADER mach_header_64 +# define GC_MACH_SECTION section_64 +# define GC_GETSECTBYNAME getsectbynamefromheader_64 +# endif + /* Try to work out the right way to access thread state structure */ /* members. The structure has changed its definition in different */ /* Darwin versions. This now defaults to the (older) names */ diff --git a/tests/test.c b/tests/test.c index 11816706..d8cf4f68 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1284,6 +1284,10 @@ void check_heap_stats(void) # endif GC_invoke_finalizers(); } + if (GC_print_stats) { + GC_log_printf("Primordial thread stack bottom: %p\n", + GC_stackbottom); + } (void)GC_printf("Completed %u tests\n", n_tests); (void)GC_printf("Allocated %d collectable objects\n", collectable_count); (void)GC_printf("Allocated %d uncollectable objects\n", -- 2.40.0