2010-07-13 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Tue, 13 Jul 2010 09:44:01 +0000 (09:44 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:54 +0000 (21:06 +0400)
* gc_dlopen.c (disable_gc_for_dlopen): Update the comment.
* gc_dlopen.c (dlopen): Ditto.
* include/gc.h: Update copyright header.
* include/gc.h (GC_enable_incremental): Refine the comment.
* include/gc.h (DECLSPEC_NORETURN): Define macro as empty if
missing (only for Win32).
* include/gc.h (GC_ExitThread): Use DECLSPEC_NORETURN.
* win32_threads.c (GC_ExitThread): Ditto.
* include/gc.h (GC_endthreadex): Add a comment.

ChangeLog
gc_dlopen.c
include/gc.h
win32_threads.c

index 431a6ea..1ba11c8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-07-13  Ivan Maidanski <ivmai@mail.ru>
+
+       * gc_dlopen.c (disable_gc_for_dlopen): Update the comment.
+       * gc_dlopen.c (dlopen): Ditto.
+       * include/gc.h: Update copyright header.
+       * include/gc.h (GC_enable_incremental): Refine the comment.
+       * include/gc.h (DECLSPEC_NORETURN): Define macro as empty if
+       missing (only for Win32).
+       * include/gc.h (GC_ExitThread): Use DECLSPEC_NORETURN.
+       * win32_threads.c (GC_ExitThread): Ditto.
+       * include/gc.h (GC_endthreadex): Add a comment.
+
 2010-05-31  Ivan Maidanski <ivmai@mail.ru> (really Alexander Belchenko)
 
        * include/cord.h: Fix typos.
index 268cd7c..87d14c1 100644 (file)
 # endif
 
   /* Make sure we're not in the middle of a collection, and make        */
-  /* sure we don't start any.   Returns previous value of GC_dont_gc.   */
+  /* sure we don't start any.                                           */
   /* This is invoked prior to a dlopen call to avoid synchronization    */
   /* issues.  We can't just acquire the allocation lock, since startup  */
-  /* code in dlopen may try to allocate.                                */
-  /* This solution risks heap growth in the presence of many dlopen     */
-  /* calls in either a multithreaded environment, or if the library     */
+  /* code in dlopen may try to allocate.  This solution risks heap      */
+  /* growth (or, even, heap overflow) in the presence of many dlopen    */
+  /* calls in either a multi-threaded environment, or if the library    */
   /* initialization code allocates substantial amounts of GC'ed memory. */
-  /* But I don't know of a better solution.                             */
   static void disable_gc_for_dlopen(void)
   {
     DCL_LOCK_STATE;
@@ -79,6 +78,8 @@ GC_API void * WRAP_DLFUNC(dlopen)(const char *path, int mode)
     void * result;
 
 #   ifndef USE_PROC_FOR_LIBRARIES
+      /* Disable collections.  This solution risks heap growth (or,     */
+      /* even, heap overflow) but there seems no better solutions.      */
       disable_gc_for_dlopen();
 #   endif
     result = (void *)REAL_DLFUNC(dlopen)(path, mode);
index 56f8c4d..7041fa8 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright 1996-1999 by Silicon Graphics.  All rights reserved.
  * Copyright 1999 by Hewlett-Packard Company.  All rights reserved.
  * Copyright (C) 2007 Free Software Foundation, Inc
+ * Copyright (c) 2000-2010 by Hewlett-Packard Development Company.
  *
  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
@@ -523,7 +524,7 @@ GC_API void GC_CALL GC_enable(void);
 /* Enable incremental/generational collection.  Not advisable unless    */
 /* dirty bits are available or most heap objects are pointer-free       */
 /* (atomic) or immutable.  Don't use in leak finding mode.  Ignored if  */
-/* GC_dont_gc is true.  Only the generational piece of this is          */
+/* GC_dont_gc is non-zero.  Only the generational piece of this is      */
 /* functional if GC_parallel is TRUE or if GC_time_limit is             */
 /* GC_TIME_UNLIMITED.  Causes thread-local variant of GC_gcj_malloc()   */
 /* to revert to locked allocation.  Must be called before any such      */
@@ -1253,7 +1254,13 @@ GC_API void GC_CALL GC_register_has_static_roots_callback(
                 LPVOID /* lpParameter */, DWORD /* dwCreationFlags */,
                 LPDWORD /* lpThreadId */);
 
-    GC_API void WINAPI GC_ExitThread(DWORD /* dwExitCode */);
+#   ifndef DECLSPEC_NORETURN
+      /* Typically defined in winnt.h. */
+#     define DECLSPEC_NORETURN /* empty */
+#   endif
+
+    GC_API DECLSPEC_NORETURN void WINAPI GC_ExitThread(
+                                                DWORD /* dwExitCode */);
 
 #   if !defined(_WIN32_WCE) && !defined(__CEGCC__)
 #     if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) \
@@ -1269,6 +1276,8 @@ GC_API void GC_CALL GC_register_has_static_roots_callback(
                         void * /* arglist */, unsigned /* initflag */,
                         unsigned * /* thrdaddr */);
 
+      /* Note: _endthreadex() is not currently marked as no-return in   */
+      /* VC++ and MinGW headers, so we don't mark it neither.           */
       GC_API void GC_CALL GC_endthreadex(unsigned /* retval */);
 #   endif /* !_WIN32_WCE */
 
index 7ad84db..f3a4830 100644 (file)
@@ -2052,7 +2052,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
     }
   }
 
-  GC_API void WINAPI GC_ExitThread(DWORD dwExitCode)
+  GC_API DECLSPEC_NORETURN void WINAPI GC_ExitThread(DWORD dwExitCode)
   {
     GC_unregister_my_thread();
     ExitThread(dwExitCode);