summaryrefslogtreecommitdiff
path: root/thread_local_alloc.c
diff options
context:
space:
mode:
authorivmai <ivmai>2009-09-26 23:10:54 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:48 +0200
commit7225f60941c19b023a87b44e950463555de55ef1 (patch)
tree1d8717f7afb180bdf5d37b804b61e1debd4e62e6 /thread_local_alloc.c
parentcbdc6415cc8a2eb3de850771a45afaeddd283233 (diff)
2009-09-26 Ivan Maidanski <ivmai@mail.ru>
* Makefile.direct: Document EMPTY_GETENV_RESULTS. * gcj_mlc.c (GC_clear_stack): Remove declaration. * malloc.c (GC_clear_stack): Ditto. * mallocx.c (GC_clear_stack): Ditto. * typd_mlc.c (GC_clear_stack): Ditto. * gcj_mlc.c (GENERAL_MALLOC, GENERAL_MALLOC_IOP): Rename to GENERAL_MALLOC_INNER and GENERAL_MALLOC_INNER_IOP, respectively; remove "lb" unnecessary cast to word. * include/private/gc_priv.h (GC_clear_stack): Add declaration. * include/private/gc_priv.h (GENERAL_MALLOC, GENERAL_MALLOC_IOP): Move common declaration from typd_mlc.c and malloc.c; remove unnecessary result and "lb" parameter casts. * include/private/thread_local_alloc.h: Guard against duplicate header file inclusion. * os_dep.c (USE_MUNMAP): Replace "-->" with an error directive for the case when USE_MMAP is not defined. * pthread_support.c (GC_is_thread_tsd_valid): New internal function (only if GC_ASSERTIONS and THREAD_LOCAL_ALLOC); move the code from thread-local GC_malloc(); add FIXME for the condition. * win32_threads.c (GC_is_thread_tsd_valid): Ditto. * thread_local_alloc.c (GC_gcjobjfreelist): Change the type (to match that of its definition). * thread_local_alloc.c (GC_destroy_thread_local): Add a cast for GC_gcjobjfreelist. * thread_local_alloc.c (GC_lookup_thread, GC_lookup_thread_inner): Remove unused declaration; don't include pthread.h. * thread_local_alloc.c (GC_is_thread_tsd_valid): New declaration (only if GC_ASSERTIONS). * thread_local_alloc.c (GC_malloc): Use GC_is_thread_tsd_valid() instead of GC_lookup_thread(). * win32_threads.c (GC_lookup_thread_inner): Define as STATIC. * win32_threads.c (UNPROTECT): Rename to UNPROTECT_THREAD (to have id different from that in os_dep.c).
Diffstat (limited to 'thread_local_alloc.c')
-rw-r--r--thread_local_alloc.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/thread_local_alloc.c b/thread_local_alloc.c
index f45b08d..0045e1e 100644
--- a/thread_local_alloc.c
+++ b/thread_local_alloc.c
@@ -111,7 +111,7 @@ void GC_init_thread_local(GC_tlfs p)
}
#ifdef GC_GCJ_SUPPORT
- extern void ** GC_gcjobjfreelist;
+ extern ptr_t * GC_gcjobjfreelist;
#endif
/* We hold the allocator lock. */
@@ -125,18 +125,13 @@ void GC_destroy_thread_local(GC_tlfs p)
return_freelists(p -> ptrfree_freelists, GC_aobjfreelist);
return_freelists(p -> normal_freelists, GC_objfreelist);
# ifdef GC_GCJ_SUPPORT
- return_freelists(p -> gcj_freelists, GC_gcjobjfreelist);
+ return_freelists(p -> gcj_freelists, (void **)GC_gcjobjfreelist);
# endif
}
-#if defined(GC_ASSERTIONS) && defined(GC_PTHREADS) && !defined(CYGWIN32) \
- && !defined(GC_WIN32_PTHREADS)
-# include <pthread.h>
- extern char * GC_lookup_thread(pthread_t id);
-#endif
-
-#if defined(GC_ASSERTIONS) && defined(GC_WIN32_THREADS)
- void * /*GC_thread*/ GC_lookup_thread_inner(unsigned /*DWORD*/ thread_id);
+#ifdef GC_ASSERTIONS
+ /* Defined in pthread_support.c or win32_threads.c. */
+ GC_bool GC_is_thread_tsd_valid(void *tsd);
#endif
GC_API void * GC_CALL GC_malloc(size_t bytes)
@@ -163,20 +158,9 @@ GC_API void * GC_CALL GC_malloc(size_t bytes)
}
# endif
GC_ASSERT(GC_is_initialized);
-# ifdef GC_ASSERTIONS
- /* We can't check tsd correctly, since we don't have access to */
- /* the right declarations. But we can check that it's close. */
- LOCK();
- {
-# if defined(GC_WIN32_THREADS)
- char * me = (char *)GC_lookup_thread_inner(GetCurrentThreadId());
-# else
- char * me = GC_lookup_thread(pthread_self());
-# endif
- GC_ASSERT((char *)tsd > me && (char *)tsd < me + 1000);
- }
- UNLOCK();
-# endif
+
+ GC_ASSERT(GC_is_thread_tsd_valid(tsd));
+
tiny_fl = ((GC_tlfs)tsd) -> normal_freelists;
GC_FAST_MALLOC_GRANS(result, granules, tiny_fl, DIRECT_GRANULES,
NORMAL, GC_core_malloc(bytes), obj_link(result)=0);