32 Commits

Author SHA1 Message Date
Ivan Maidanski 466976e79a Do not include windows.h when compiling gc_cpp.cc
(code refactoring)

* gc_cpp.cc (GC_DONT_INCL_WINDOWS_H): Define macro before include gc.h.
* tests/test_cpp.cc (GC_DONT_INCL_WINDOWS_H): Likewise.
* include/gc.h [GC_WIN32_THREADS && (!GC_PTHREADS || GC_BUILD
|| GC_WINDOWS_H_INCLUDED) && (!GC_NO_THREAD_DECLS || GC_BUILD)]:
If GC_DONT_INCL_WINDOWS_H then do not include process.h, windows.h,
and do not declare GC_CreateThread, GC_ExitThread, GC_DllMain,
GC_beginthreadex, GC_endthreadex.
2018-06-20 10:36:25 +03:00
Ivan Maidanski 2ce94e20e8 Do not include 'new' standard header from gc_cpp.h by default
(fix of commit cb1194d17)

* gc_cpp.cc: Include gc.h (before "new") and "new" standard header
(before gc_cpp.h).
* gc_cpp.cc (GC_ALLOCATOR_THROW_OR_ABORT): New macro (the same
definition as in gc_allocator.h).
* gc_cpp.cc (GC_throw_bad_alloc): New API function definition.
* gc_cpp.cc [!GC_NEW_DELETE_THROW_NOT_NEEDED]
(GC_NEW_DELETE_NEED_THROW): Do not define if _MSC_VER or __DMC__.
* gc_cpp.cc [!_MSC_VER && !__DMC__] (new, new[]): Replace
GC_OP_NEW_OOM_CHECK(obj) to if(!obj)GC_ALLOCATOR_THROW_OR_ABORT().
* gc_cpp.h: Include "new" standard header only if GC_INCLUDE_NEW
and !GC_NEW_ABORTS_ON_OOM and !_LIBCPP_NO_EXCEPTIONS.
* gc_cpp.h [!GC_NEW_ABORTS_ON_OOM && !_LIBCPP_NO_EXCEPTIONS
&& !GC_INCLUDE_NEW] (GC_throw_bad_alloc): Declare API function.
* gc_cpp.h [!GC_NEW_ABORTS_ON_OOM && !_LIBCPP_NO_EXCEPTIONS
&& !GC_INCLUDE_NEW] (GC_OP_NEW_OOM_CHECK): Call GC_throw_bad_alloc()
instead of throw std::bad_alloc; do not use do-while(0) (to eliminate
VC++ warning that the expression is always false).
2018-06-19 10:38:55 +03:00
Ivan Maidanski 4399253c2e Do not specify throw(bad_alloc) in gc_cpp.h
(fix of commit cb1194d17)

* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW, GC_DECL_NEW_THROW): Move from
gc_cpp.h.
* include/gc_cpp.h (gc::new, new): Remove GC_DECL_NEW_THROW specifier.
* include/gc_cpp.h [GC_OPERATOR_NEW_ARRAY] (gc::new[], new[]):
Likewise.
2018-06-15 11:20:42 +03:00
Ivan Maidanski 81b15cc40f Use noexcept specifier in gc_cpp if C++11
* gc_cpp.cc [!_MSC_VER && !__DMC__] (delete, delete[]): Rename
GC_DECL_DELETE_THROW to GC_NOEXCEPT.
* include/gc_cpp.h: Always include "new" header.
* include/gc_cpp.h [!GC_NEW_DELETE_THROW_NOT_NEEDED]
(GC_NEW_DELETE_NEED_THROW): Do not define if __BORLANDC__ or _MSC_VER,
or __WATCOMC__, or if __cplusplus>=201103L and !__clang__.
* include/gc_cpp.h (GC_DECL_DELETE_THROW): Remove.
* include/gc_cpp.h [!GC_NOEXCEPT] (GC_NOEXCEPT): Define internal macro
to except or throw(), or nothing (same as that in gc_allocator.h).
* include/gc_cpp.h [!GC_NEW_ABORTS_ON_OOM] (GC_NEW_ABORTS_ON_OOM):
Define if GC_NOEXCEPT is defined to nothing.
* include/gc_cpp.h (new(size_t,void*), new[](size_t,void*), delete):
Add GC_NOEXCEPT.
2018-06-08 11:50:36 +03:00
Ivan Maidanski 4afeb2fd76 Fix new and delete operators definition for DigitalMars compiler
* gc_cpp.cc (new, delete, new[], delete[]): Do not define if __DMC__.
* include/gc_cpp.h (new[], delete[], new, delete): Define also if
__DMC__.
* include/gc_cpp.h [_MSC_VER] (new[], delete[]): Replace _MSC_VER>1020
to defined(GC_OPERATOR_NEW_ARRAY).
2018-06-04 10:04:09 +03:00
Ivan Maidanski cb1194d17e Never return null pointer by C++ operator new (gc_cpp)
Now, in case of the allocation failure, new and new[] operators throw
bad_alloc (or abort the application if an ancient compiler is used).

* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Remove.
* gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): Move macro
definition to gc_cpp.h.
* gc_cpp.cc [GC_NEW_DELETE_NEED_THROW]: Do not include "new" header.
* gc_cpp.cc [!_MSC_VER] (operator new): Call GC_OP_NEW_OOM_CHECK() for
the allocation result.
* gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY && !CPPCHECK]
(operator new[]): Likewise.
* include/gc.h (GC_abort_on_oom): Declare new API function.
* include/gc_cpp.h [!GC_NEW_DELETE_THROW_NOT_NEEDED
&& (GC_GNUC_PREREQ(4,2) || __BORLANDC__>=0x0550 || _MSC_VER>1020
|| __WATCOMC__>=1050)] (GC_NEW_DELETE_NEED_THROW):
Define macro.
* include/gc_cpp.h [GC_NEW_DELETE_NEED_THROW]: Include "new" header.
* include/gc_cpp.h (GC_OP_NEW_OOM_CHECK): New internal macro (throws
bad_alloc or cals GC_abort_on_oom).
* include/gc_cpp.h (gc::new(size_t), gc::new(size_t,GCPlacement), new):
Add GC_DECL_NEW_THROW; call GC_OP_NEW_OOM_CHECK() for the allocation
result.
* include/gc_cpp.h [GC_OPERATOR_NEW_ARRAY] (gc::new[](size_t),
gc::new[](size_t,GCPlacement, new[]): Likewise.
* misc.c (GC_abort_on_oom): Implement function.
* tests/test.c [CPPCHECK] (main): Call UNTESTED(GC_abort_on_oom).
2018-06-01 11:40:54 +03:00
Ivan Maidanski 3150107d3e Fix global operator delete definition for C++14 in gc_cpp
Issue #195 (bdwgc).

Sized variants of global operator delete should be defined along with
the non-sized ones.  Otherwise compiler might invoke the one from the
standard library (as observed in e.g. Cygwin) leading to a crash.

* gc_cpp.cc [!_MSC_VER && __cplusplus>201103L] (operator delete):
Define sized variant (the size argument is ignored for now).
* gc_cpp.cc [!_MSC_VER && __cplusplus>201103L && GC_OPERATOR_NEW_ARRAY
&& !CPPCHECK] (operator delete[]): Likewise.
2018-01-15 08:20:02 +03:00
Ivan Maidanski 4f98587ff5 Define CLANG/GNUC_PREREQ macros to check gcc/clang minimum version
(code refactoring)

* cord/cordxtra.c (CORD_ATTR_UNUSED): Use GC_GNUC_PREREQ() instead of
direct use of __GNUC[_MINOR]__.
* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Likewise.
* include/gc_config_macros.h (GC_API, GC_ATTR_MALLOC, GC_ATTR_ALLOC_SIZE,
GC_ATTR_NONNULL, GC_ATTR_DEPRECATED, GC_RETURN_ADDR,
GC_RETURN_ADDR_PARENT, GC_PTHREAD_EXIT_ATTRIBUTE): Likewise.
* include/gc_cpp.h (GC_NO_OPERATOR_NEW_ARRAY): Likewise.
* include/gc_inline.h (GC_EXPECT, GC_PREFETCH_FOR_WRITE): Likewise.
* include/new_gc_alloc.h: Likewise.
* include/private/gc_priv.h (GC_INNER, GC_ATTR_UNUSED, EXPECT, GC_INLINE,
GC_ATTR_NOINLINE, GC_API_OSCALL, GC_ATTR_FORMAT_PRINTF,
NONNULL_ARG_NOT_NULL): Likewise.
* include/private/gc_priv.h [CANCEL_SAFE] (GC_cancel_disable_count):
Likewise.
* include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT, PREFETCH,
GC_PREFETCH_FOR_WRITE): Likewise.
* include/private/gcconfig.h [I386 && LINUX && __ELF__]
(GC_NO_SIGSETJMP): Likewise.
* include/private/gcconfig.h [X86_64 && MSWIN32] (MPROTECT_VDB):
Likewise.
* include/private/thread_local_alloc.h [CYGWIN32] (USE_PTHREAD_SPECIFIC):
Likewise.
* include/private/thread_local_alloc.h [LINUX && !ARM32 && !AVR32
|| PLATFORM_ANDROID && !__clang__] (USE_COMPILER_TLS): Likewise.
* mark.c [MSWIN32 || MSWINCE] (GC_mark_some): Likewise.
* mark_rts.c (GC_approx_sp): Likewise.
* tests/test_cpp.cc (ATTR_UNUSED): Likewise.
* tools/setjmp_t.c (nested_sp): Likewise.
* include/gc_config_macros.h (GC_GNUC_PREREQ): New macro (not for
public use).
* include/private/gc_priv.h (GC_CLANG_PREREQ): New private macro.
* include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT): Refine comment.
* include/private/thread_local_alloc.h [LINUX && !ARM32 && !AVR32
|| PLATFORM_ANDROID && !__clang__] (USE_COMPILER_TLS): Use
GC_CLANG_PREREQ() instead of direct use of __clang_major__ and
__clang_minor__.
* mark.c [MSWIN32 || MSWINCE] (GC_mark_some): Likewise.
2017-03-07 18:19:29 +03:00
Ivan Maidanski 791e75754a Workaround 'operator delete[]/new[] never used' cppcheck false warning
* gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[],
operator delete[]): Do not define if CPPCHECK.
2016-11-17 10:02:15 +03:00
Ivan Maidanski db7266bde3 Fix 'replacement operator delete cannot be inline' GCC warning (Cygwin)
(fix commits 83e0a2c, 3379238)

This commit also eliminates
"operator delete is missing exception specification throw()" compiler
warning.

* gc_cpp.cc (operator delete): Define unconditionally (i.e. for Cygwin
too).
* include/gc_cpp.h [__CYGWIN__]: Do not include "new" header.
* include/gc_cpp.h [__CYGWIN__] (operator delete): Remove (as
replacement function 'operator delete' cannot be declared 'inline').
2016-10-29 17:31:41 +03:00
Ivan Maidanski 3b6f4e9353 Reformat code of gc_cpp.cc/h
* include/gc_cpp.h: Reformat code (and comments).
* gc_cpp.cc: Likewise.
* include/gc_cpp.h (operator new): Replace if-then-else with switch.

Conflicts:

    include/gc_cpp.h
2015-05-11 19:11:11 +03:00
Ivan Maidanski 3379238e44 Restore definition of new/delete operators in gc_cpp.cc (for non-VC)
(revert part of commit 3d784ed)

* gc_cpp.cc (new, delete, new[], delete[]): Add definition (unless
_MSC_VER defined).

Conflicts:

    gc_cpp.cc
2015-05-11 19:10:55 +03:00
Ivan Maidanski 28272d58b8 Remove commented out code in gc_cpp.cc/h
(code refactoring)

* gc_cpp.cc: Remove commented out code.
* include/gc_cpp.h: Likewise.

Conflicts:

    gc_cpp.cc
    include/gc_cpp.h
2015-05-11 19:00:15 +03:00
Johannes Totz 3d784edf71 put all the cpp stuff in header
otherwise vc9 will mix up new and delete operators (due to arbitrary ordering during linking)

Conflicts:

	gc_cpp.cc
	include/gc_cpp.h
2015-05-11 19:00:05 +03:00
Ivan Maidanski 6da20ac5b4 Fix more typos in comments and documentation
* alloc.c: Fix typo ("overflow").
* configure.ac: Fix typo ("optimization").
* doc/README.amiga: Fix typos ("also", "specific", "unnecessary").
* doc/README.cords: Fix typos ("descendants", "highlighted").
* ChangeLog: Fix typos ("[un]collectible").
* README.md: Likewise.
* dbg_mlc.c: Likewise.
* doc/README.hp: Likewise.
* doc/README.linux: Likewise.
* doc/gcdescr.html: Likewise.
* doc/gcinterface.html: Likewise.
* include/gc_mark.h: Likewise.
* include/gc_pthread_redirects.h: Likewise.
* include/new_gc_alloc.h: Likewise.
* include/private/dbg_mlc.h: Likewise.
* include/private/gc_pmark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* new_hblk.c: Likewise.
* ChangeLog: Fix typo ("multi-threaded").
* cord/cordxtra.c: Likewise.
* doc/debugging.html: Likewise.
* doc/gcinterface.html: Likewise.
* doc/leak.html: Likewise.
* doc/overview.html: Likewise.
* doc/simple_example.html: Likewise.
* include/gc_mark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* os_dep.c: Likewise.
* ptr_chck.c: Likewise.
* README.md: Fix typo ("pointer-free").
* allchblk.c: Likewise.
* doc/debugging.html: Likewise.
* doc/gcdescr.html: Likewise.
2013-07-11 12:44:35 +04:00
Ivan Maidanski 0ac46cc66e Eliminate 'missing exception specification' warning in gc_cpp.cc (Clang)
* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Define new macro (if not defined
yet) for GCC v4.2+ (or clang).
* gc_cpp.cc: Include new (for std::bad_alloc) if
GC_NEW_DELETE_NEED_THROW.
* gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): New macros
(used to eliminate compiler "missing exception specification" warning
for 'new' and 'delete' operators).
* gc_cpp.cc (new, delete, new[], delete[]): Use
GC_DECL_NEW/DELETE_THROW to define 'throw' clause properly.
2012-08-30 18:01:57 +04:00
Ivan Maidanski b7717690fe Include "config.h" instead of "private/config.h" on HAVE_CONFIG_H
(Change the behavior of HAVE_CONFIG_H macro to the standard one
which assumes that no folder is specified in #include "config.h".)

* configure.ac (AM_CONFIG_HEADER): Replace include/private/config.h to
include/config.h.
* cord/cordbscs.c: Include "config.h" (instead of "private/config.h")
if HAVE_CONFIG_H defined.
* cord/cordprnt.c: Likewise.
* cord/cordxtra.c: Likewise.
* gc_cpp.cc: Likewise.
* include/private/gc_pmark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* real_malloc.c: Likewise.
* tests/disclaim_test.c: Likewise.
* tests/initsecondarythread.c: Likewise.
* tests/subthread_create.c: Likewise.
* tests/test.c: Likewise.
* tests/test_cpp.cc: Likewise.
* tests/thread_leak_test.c: Likewise.
* tests/threadkey_test.c: Likewise.
2012-08-30 15:35:26 +04:00
Ivan Maidanski 2ea2a650ec Reformat code of gc_cpp.cc/h
* gc_cpp.cc (new, new[], delete[]): Reformat code.
* include/gc_cpp.h (GCPlacement, gc, gc_cleanup, new, new[], delete,
cleanup): Likewise.
2011-12-26 10:22:29 +04:00
Ivan Maidanski f6bbc2a7e3 HOTFIX: Fix gc_cpp.cc for Cygwin (remove duplicate function definition).
* gc_cpp.cc (operator delete): Do not define for Cygwin since already
defined in include/gc_cpp.h file.
2011-09-13 14:42:15 +04:00
Ivan Maidanski 6451756248 Remove information about the authors from the source files.
(This information could be observed via "git log" or by looking into
the original version of a file.)

* Makefile.am: Remove original-author and modified-by information
(as well as a time-stamp) from the file header.
* configure.ac: Ditto.
* cord/cordbscs.c: Ditto.
* cord/cordprnt.c: Ditto.
* cord/cordxtra.c: Ditto.
* cord/de.c: Ditto.
* cord/de_cmds.h: Ditto.
* cord/de_win.h: Ditto.
* doc/README.arm.cross: Ditto.
* doc/doc.am: Ditto.
* dyn_load.c: Ditto.
* gc_cpp.cc: Ditto.
* gc_dlopen.c: Ditto.
* include/cord.h: Ditto.
* include/include.am: Ditto.
* include/private/cord_pos.h: Ditto.
* include/private/gc_hdrs.h: Ditto.
* include/weakpointer.h: Ditto.
* m4/gc_set_version.m4: Ditto.
* tests/test_cpp.cc: Ditto.
* cord/cordprnt.c: Fix a typo in a comment.
* AUTHORS: Add authors.
* cord/cordprnt.c: Expand all tabs to spaces; remove trailing spaces
at EOLn.
* cord/de.c: Ditto.
* cord/de_cmds.h: Ditto.
* cord/de_win.c: Ditto.
* cord/de_win.h: Ditto.
* doc/README.arm.cross: Ditto.
* include/private/cord_pos.h: Ditto.
* include/weakpointer.h: Ditto.
* m4/gc_set_version.m4: Ditto.
2011-08-25 00:16:06 +04:00
ivmai 2b8606bf1e 2009-10-19 Ivan Maidanski <ivmai@mail.ru>
* gc_cpp.cc: Include "gc_cpp.h" instead of <gc_cpp.h>.
2011-07-26 21:06:51 +04:00
ivmai db2565100a 2009-09-16 Ivan Maidanski <ivmai@mail.ru>
* ChangeLog: Remove trailing spaces at EOLn; insert blank lines
	where missed.
	* doc/README: Expand all tabs to spaces; remove trailing spaces at
	EOLn; remove multiple trailing blank lines.
	* doc/README.autoconf: Ditto.
	* doc/README.DGUX386: Ditto.
	* doc/README.environment: Ditto.
	* doc/README.macros: Ditto.
	* doc/README.win32: Ditto.
	* tests/test.c: Ditto.
	* tests/test_cpp.cc: Ditto.
	* backgraph.c: Ditto.
	* blacklst.c: Ditto.
	* checksums.c: Ditto.
	* darwin_stop_world.c: Ditto.
	* dbg_mlc.c: Ditto.
	* dyn_load.c: Ditto.
	* finalize.c: Ditto.
	* gc_dlopen.c: Ditto.
	* gcj_mlc.c: Ditto.
	* headers.c: Ditto.
	* mach_dep.c: Ditto.
	* malloc.c: Ditto.
	* mallocx.c: Ditto.
	* new_hblk.c: Ditto.
	* obj_map.c: Ditto.
	* ptr_chck.c: Ditto.
	* real_malloc.c: Ditto.
	* reclaim.c: Ditto.
	* stubborn.c: Ditto.
	* thread_local_alloc.c: Ditto.
	* typd_mlc.c: Ditto.
	* gc_cpp.cc: Ditto.
	* include/gc_allocator.h: Ditto.
	* include/gc_backptr.h: Ditto.
	* include/gc_config_macros.h: Ditto.
	* include/gc_cpp.h: Ditto.
	* include/gc_gcj.h: Ditto.
	* include/gc_inline.h: Ditto.
	* include/gc_mark.h: Ditto.
	* include/gc_pthread_redirects.h: Ditto.
	* include/gc_typed.h: Ditto.
	* include/gc_version.h: Ditto.
	* include/javaxfc.h: Ditto.
	* include/new_gc_alloc.h: Ditto.
	* include/private/darwin_semaphore.h: Ditto.
	* include/private/dbg_mlc.h: Ditto.
	* include/private/gc_hdrs.h: Ditto.
	* include/private/gc_locks.h: Ditto.
	* include/private/gc_pmark.h: Ditto.
	* include/private/gcconfig.h: Ditto.
	* include/private/pthread_support.h: Ditto.
	* include/private/thread_local_alloc.h: Ditto.
	* darwin_stop_world.c: Add copyright header.
	* include/gc_backptr.h: Ditto.
	* include/gc_config_macros.h: Ditto.
	* include/gc_pthread_redirects.h: Ditto.
	* include/gc_version.h: Ditto.
	* include/javaxfc.h: Ditto.
	* include/private/darwin_semaphore.h: Ditto.
	* include/private/pthread_support.h: Ditto.
	* gc_cpp.cc: Make copyright header uniform across the package.
	* include/gc_cpp.h: Ditto.
2011-07-26 21:06:46 +04:00
ivmai d70b0280af 2009-09-16 Ivan Maidanski <ivmai@mail.ru> (really Petter Urkedal)
(gc_config_h_6a.patch with a minor correction)

	* include/private/gc_priv.h: Change include of config.h to
	private/config.h.
	* include/private/gc_pmark.h: Ditto.
	* gc_cpp.cc: Ditto.
	* tests/test.c: Ditto.
	* tests/test_cpp.cc: Include private/config.h (if HAVE_CONFIG_H);
	undefine GC_BUILD.
2011-07-26 21:06:46 +04:00
ivmai f9aaf5b9e7 2009-09-10 Ivan Maidanski <ivmai@mail.ru>
(diff116a, diff116b, diff116c)

	* Makefile.direct (GC_DLL): Add the comment for.
	* doc/README.macros: Fix a typo.
	* doc/README.macros (_DLL, GC_DLL, GC_NOT_DLL): Update info.
	* doc/README.macros (__STDC__): Remove info.
	* dbg_mlc.c (GC_get_back_ptr_info, GC_generate_random_heap_address,
	GC_generate_random_valid_address, GC_print_backtrace,
	GC_generate_random_backtrace, GC_register_describe_type_fn): Add
	GC_API and GC_CALL to function definition.
	* malloc.c (GC_generic_malloc): Ditto.
	* mallocx.c (GC_incr_bytes_allocd, GC_incr_bytes_freed): Ditto.
	* mark.c (GC_mark_and_push): Ditto.
	* misc.c (GC_new_free_list_inner, GC_new_free_list,
	GC_new_kind_inner, GC_new_kind, GC_new_proc_inner, GC_new_proc):
	Ditto.
	* include/gc_backptr.h (GC_get_back_ptr_info,
	GC_generate_random_heap_address, GC_generate_random_valid_address,
	GC_generate_random_backtrace, GC_print_backtrace): Add GC_API and
	GC_CALL to function prototype.
	* include/gc_mark.h (GC_mark_and_push, GC_new_free_list,
	GC_new_free_list_inner, GC_new_kind, GC_new_kind_inner,
	GC_new_proc, GC_new_proc_inner, GC_generic_malloc,
	GC_register_describe_type_fn): Ditto.
	* include/new_gc_alloc.h (GC_incr_bytes_allocd, GC_incr_mem_freed,
	GC_generic_malloc_words_small): Ditto.
	* gc_cpp.cc: Include "config.h" (if HAVE_CONFIG_H defined).
	* include/private/gc_pmark.h: Ditto.
	* include/private/gc_priv.h: Ditto.
	* tests/test.c: Ditto.
	* gc_cpp.cc: Define GC_BUILD.
	* include/private/gc_pmark.h: Ditto.
	* include/private/gc_priv.h: Ditto.
	* gc_dlopen.c (WRAP_FUNC, REAL_FUNC): New macro.
	* gc_dlopen.c (dlopen): Add GC_API to the wrapper function
	definition.
	* pthread_support.c (GC_pthread_create, GC_pthread_sigmask,
	GC_pthread_join, GC_pthread_detach, pthread_sigmask, pthread_join,
	pthread_detach, pthread_create): Ditto.
	* win32_threads.c (GC_pthread_join, GC_pthread_create,
	GC_pthread_sigmask, GC_pthread_detach): Ditto.
	* gc_dlopen.c (dlopen): Use WRAP_FUNC and REAL_FUNC macros.
	* include/gc_backptr.h: Include "gc.h".
	* include/gc_backptr.h: Use extern "C" for the exported functions.
	* include/gc_mark.h: Ditto.
	* include/gc_config_macros.h (GC_THREADS): Define the macro if any
	GC_XXX_THREADS is defined.
	* include/gc_config_macros.h (_PTHREADS, _POSIX4A_DRAFT10_SOURCE):
	Move the definitions below the place where GC_NETBSD_THREADS and
	GC_DGUX386_THREADS are defined.
	* include/gc_config_macros.h (GC_DLL): Don't define (even if _DLL
	is defined) for GCC.
	* include/gc_config_macros.h (GC_API): Define for Cygwin (in the
	same way as for VC++); define for GCC v4+ (other than already
	recognized MinGW/Cygwin) as a "default" visibility attribute if
	GC_DLL is defined.
	* include/gc_config_macros.h (GC_ATTR_MALLOC, GC_ATTR_ALLOC_SIZE):
	New macro.
	* include/gc.h (GC_malloc, GC_malloc_atomic, GC_strdup,
	GC_malloc_uncollectable, GC_malloc_stubborn, GC_memalign,
	GC_malloc_atomic_uncollectable, GC_malloc_ignore_off_page,
	GC_malloc_atomic_ignore_off_page, GC_debug_malloc,
	GC_debug_malloc_atomic,	GC_debug_strdup,
	GC_debug_malloc_uncollectable, GC_debug_malloc_stubborn,
	GC_debug_malloc_ignore_off_page,
	GC_debug_malloc_atomic_ignore_off_page,
	GC_debug_malloc_replacement): Add GC_ATTR_MALLOC attribute.
	* include/gc_gcj.h (GC_gcj_malloc, GC_debug_gcj_malloc,
	GC_gcj_malloc_ignore_off_page): Ditto.
	* include/gc.h (GC_malloc, GC_malloc_atomic,
	GC_malloc_uncollectable, GC_malloc_stubborn,
	GC_malloc_atomic_uncollectable, GC_malloc_ignore_off_page,
	GC_malloc_atomic_ignore_off_page, GC_debug_malloc,
	GC_debug_malloc_atomic, GC_debug_malloc_uncollectable,
	GC_debug_malloc_stubborn, GC_debug_malloc_ignore_off_page,
	GC_debug_malloc_atomic_ignore_off_page,
	GC_debug_malloc_replacement: Add GC_ATTR_ALLOC_SIZE attribute
	(for the first argument).
	* include/gc_gcj.h (GC_gcj_malloc, GC_debug_gcj_malloc,
	GC_gcj_malloc_ignore_off_page): Ditto.
	* include/gc.h (GC_memalign, GC_realloc, GC_debug_realloc,
	GC_debug_realloc_replacement): Add GC_ATTR_ALLOC_SIZE attribute
	(for the second argument).
	* include/gc.h (GC_malloc, GC_malloc_atomic, GC_strdup,
	GC_malloc_uncollectable, GC_malloc_stubborn, GC_memalign,
	GC_malloc_atomic_uncollectable, GC_free, GC_base, GC_size,
	GC_realloc, GC_expand_hp, GC_set_max_heap_size,
	GC_exclude_static_roots, GC_add_roots, GC_remove_roots,
	GC_register_displacement, GC_debug_register_displacement,
	GC_try_to_collect, GC_malloc_ignore_off_page,
	GC_malloc_atomic_ignore_off_page, GC_debug_malloc,
	GC_debug_malloc_atomic, GC_debug_strdup,
	GC_debug_malloc_uncollectable, GC_debug_malloc_stubborn,
	GC_debug_malloc_ignore_off_page,
	GC_debug_malloc_atomic_ignore_off_page, GC_debug_free,
	GC_debug_realloc, GC_debug_malloc_replacement,
	GC_debug_realloc_replacement, GC_finalization_proc,
	GC_register_finalizer, GC_debug_register_finalizer,
	GC_register_finalizer_ignore_self,
	GC_debug_register_finalizer_ignore_self,
	GC_register_finalizer_no_order,
	GC_debug_register_finalizer_no_order,
	GC_register_finalizer_unreachable,
	GC_debug_register_finalizer_unreachable,
	GC_register_disappearing_link,
	GC_general_register_disappearing_link,
	GC_unregister_disappearing_link, GC_noop1, GC_warn_proc,
	GC_set_warn_proc, GC_ignore_warn_proc, GC_fn_type,
	GC_call_with_alloc_lock, GC_stack_base_func,
	GC_call_with_stack_base, GC_same_obj, GC_pre_incr, GC_post_incr,
	GC_is_visible, GC_is_valid_displacement, GC_same_obj_print_proc,
	GC_is_valid_displacement_print_proc, GC_is_visible_print_proc,
	GC_malloc_many, GC_CreateThread, GC_beginthreadex,
	GC_endthreadex): Comment out (or remove if single and meaningless)
	function argument names (to avoid identifiers out of the name
	space).
	* include/gc_gcj.h (GC_init_gcj_malloc, GC_gcj_malloc,
	GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Ditto.
	* include/gc.h (GC_try_to_collect): Update the comment.
	* include/gc.h (GC_size, GC_register_my_thread): Add const
	qualifier for the argument referent.
	* misc.c (GC_size): Ditto.
	* pthread_support.c (GC_register_my_thread_inner,
	GC_register_my_thread): Ditto.
	* win32_threads.c (GC_register_my_thread_inner,
	GC_register_my_thread): Ditto.
	* include/gc.h (GC_INIT_CONF_ROOTS): New macro for internal use
	(define instead of GC_INIT() for Cygwin and AIX).
	* include/gc.h (GC_DONT_EXPAND, GC_MAX_RETRIES,
	GC_FREE_SPACE_DIVISOR, GC_FULL_FREQ, GC_TIME_LIMIT, GC_IGNORE_WARN,
	GC_INITIAL_HEAP_SIZE): Recognize new macro.
	* include/gc.h (GC_INIT_CONF_DONT_EXPAND, GC_INIT_CONF_MAX_RETRIES,
	GC_INIT_CONF_FREE_SPACE_DIVISOR, GC_INIT_CONF_FULL_FREQ,
	GC_INIT_CONF_TIME_LIMIT, GC_INIT_CONF_IGNORE_WARN,
	GC_INIT_CONF_INITIAL_HEAP_SIZE): New macro for internal use.
	* include/gc.h (GC_INIT): Use GC_INIT_CONF_XXX macros.
	* include/gc_mark.h: Prefix GC_H with '_'.
	* include/gc_mark.h (GC_least_plausible_heap_addr,
	GC_greatest_plausible_heap_addr, GC_debug_header_size): Use GC_API
	for the public variable declaration.
	* include/new_gc_alloc.h (GC_objfreelist_ptr, GC_aobjfreelist_ptr,
	GC_uobjfreelist_ptr, GC_auobjfreelist_ptr): Ditto.
	* include/gc_pthread_redirects.h (GC_pthread_create,
	GC_pthread_sigmask, GC_dlopen, GC_pthread_join, GC_pthread_detach):
	Use GC_API for the wrapper prototype.
	* include/gc_pthread_redirects.h (pthread_create, pthread_join,
	pthread_detach, pthread_sigmask, dlopen): Undefine unconditionally
	before redirecting.
	* include/new_gc_alloc.h: Replace GC_incr_mem_freed() with
	GC_incr_bytes_freed(); remove FIXME.
	* include/private/gc_priv.h (GC_make_closure,
	GC_debug_invoke_finalizer, GC_noop): Remove GC_API for the private
	function.
	* tests/test.c (GC_print_stats): Handle GC_DLL case regardless of
	the target.
2011-07-26 21:06:46 +04:00
hboehm 68b9f2740e 2008-07-25 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Ivan Maidanski)
Ivan's description of the patch follows. Note that a few pieces like
	the GC_malloc(0) patch, were not applied since an alternate had been
	previously applied.  A few differed stylistically from the rest of
	the code (mostly casts to void * instead of target type),
	or were classified as too minor to bother.  Note that
	all of Ivan's static declarations which did not correct outright
	naming bugs (as a few did), where replaced by STATIC, which is
	ignored by default.

        - minor bug fixing (for FreeBSD, for THREAD_LOCAL_ALLOC and for
	  GC_malloc(0));
        - addition of missing getter/setter functions for public variables
	  (may be useful if compiled as Win32 DLL);
        - addition of missing GC_API for some exported functions;
        - addition of missing "static" declarator for internal functions
	   and variables (where possible);
        - replacement of all remaining K&R-style definitions with ANSI
	  C ones (__STDC__ macro is not used anymore);
        - addition of some Win32 macro definitions (that may be missing in
	  the standard headers supplied with a compiler) for GWW_VDB mode;
        - elimination of most compiler warnings (except for
	  "uninitialized data" warning);
        - several typos correction;
        - missing parenthesis addition in macros in some header files of
	  "libatomic_ops" module.

	My highlights based on reading the patch:

	* allchblk.c: Remove GC_freehblk_ptr decl.
	Make free_list_index_of() static.
	* include/gc.h: Use __int64 on win64, define GC_oom_func,
	GC_finalizer_notifier_proc, GC_finalizer_notifier_proc,
	add getter and setters: GC_get_gc_no, GC_get_parallel,
	GC_set_oom_fn, GC_set_finalize_on_demand,
	GC_set_java_finalization, GC_set_dont_expand,
	GC_set_no_dls, GC_set_max_retries, GC_set_dont_precollect,
	GC_set_finalizer_notifier.  Always define GC_win32_free_heap.
	gc_config_macros.h: Define _REENTRANT after processing
	GC_THREADS.
	* include/gc_cpp.h: Improve GC_PLACEMENT_DELETE test,
	handling of operator new[] for old Windows compilers.
	* include/gc_inline.h (GC_MALLOC_FAST_GRANS): Add parentheses
	around arguments.
	* dbg_mlc.c, malloc.c, misc.c: Add many GC_API specs.
	* mark.c (GC_mark_and_push_stack): Fix source argument for
	blacklist printing.
	* misc.c: Fix log file naming based on environment variable
	for Windows.  Make GC_set_warn_proc and GC_set_free_space_divisor
	just return current value with 0 argument.  Add DONT_USER_USER32_DLL.
	Add various getters and setters as in gc.h.
	* os_dep.c: Remove no longer used GC_disable/enable_signals
	implementations.  (GC_get_stack_base): Add pthread_attr_destroy
	call.  No longer set GC_old_bus_handler in DARWIN workaround.
	* pthread_support.c: GC_register_my_thread must also
	call GC_init_thread_local.
2011-07-26 21:06:43 +04:00