From: Zoltan Varga Date: Thu, 3 Mar 2005 21:09:34 +0000 (+0000) Subject: 2005-03-03 Zoltan Varga X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b40e5dd6f5d78b8b5ba7b6563141032a6ebc2e2;p=gc 2005-03-03 Zoltan Varga * include/gc.h pthread_support.c win32_threads.: Add GC_thread_is_registered API function. svn path=/trunk/mono/; revision=41410 --- diff --git a/ChangeLog b/ChangeLog index 4b6d7ef4..9f0c7bdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-03-03 Zoltan Varga + + * include/gc.h pthread_support.c win32_threads.: Add + GC_thread_is_registered API function. + 2005-02-17 Raja R Harinath * acinclude.m4: Don't include distributed libtool.m4. diff --git a/include/gc.h b/include/gc.h index a60a6560..970c5b5b 100644 --- a/include/gc.h +++ b/include/gc.h @@ -827,6 +827,9 @@ GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p)); /* Always returns its argument. */ GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p)); +/* Returns 1 if the calling thread is registered with the GC, 0 otherwise */ +GC_API int GC_thread_is_registered GC_PROTO((void)); + /* Safer, but slow, pointer addition. Probably useful mainly with */ /* a preprocessor. Useful only for heap pointers. */ #ifdef GC_DEBUG diff --git a/pthread_support.c b/pthread_support.c index 5bb157f8..a1130ab2 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -400,6 +400,17 @@ GC_PTR GC_local_gcj_malloc(size_t bytes, # endif /* !THREAD_LOCAL_ALLOC */ +int GC_thread_is_registered (void) +{ + void *ptr; + + LOCK(); + ptr = (void *)GC_lookup_thread(pthread_self()); + UNLOCK(); + + return ptr ? 1 : 0; +} + #if 0 /* To make sure that we're using LinuxThreads and not some other thread diff --git a/win32_threads.c b/win32_threads.c index d2e97dee..681e1c2b 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -72,6 +72,11 @@ volatile LONG GC_max_thread_index = 0; /* Largest index in thread_table */ extern LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info); +int GC_thread_is_registered (void) +{ + return 1; +} + /* * This may be called from DllMain, and hence operates under unusual * constraints.