summaryrefslogtreecommitdiff
path: root/libmudflap/mf-hooks1.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-17 02:29:00 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-17 02:29:00 +0000
commitee3213a30ff759561602be8e94553d06b2fa2e61 (patch)
tree7eb9ea11806846cc5d60256f51b3b0a1033126fe /libmudflap/mf-hooks1.c
parentfbe74ea41cc74eaed95d398bdc4f9237d6fea6d0 (diff)
downloadgcc-ee3213a30ff759561602be8e94553d06b2fa2e61.tar.gz
* gcc.c (MFWRAP_SPEC): Don't wrap pthread_join or pthread_exit.
* acinclude.m4: New file. * configure.ac: Invoke LIBMUDFLAP_CHECK_TLS. * configure, config.h.in, Makefile.in, testsuite/Makefile.in: Rebuild. * mf-hooks1.c (__mf_0fn_malloc): Move body from ... (__mf_0fn_calloc): ... here. * mf-hooks3.c (struct pthread_info): Remove. (__mf_pthread_info, __mf_pthread_info_idx): Remove. (LIBMUDFLAPTH_THREADS_MAX): Set to 1021. (struct mf_thread_data): New. (mf_thread_data, mf_thread_data_lock): New. (__mf_allocate_blank_threadinfo): Remove. (__mf_find_threadinfo): Rewrite and simplify. Only use if TLS is not available. (__mf_state_perthread): Remove. (__mf_get_state, __mf_set_state): New. (__mf_pthread_cleanup): Use &errno, rather than saved pointer. Update mf_thread_data killing procedure. (__mf_pthread_spawner): Similarly. (__mf_0fn_pthread_create): Only use wrapper if necessary. Remove code to allocate thread stack space. (__mf_0fn_pthread_join, pthread_join): Remove. (__mf_0fn_pthread_exit, pthread_exit): Remove. * mf-impl.h (dyn_pthread_join, dyn_pthread_exit): Remove. (__mf_state_1): Rename from __mf_state; use TLS when available. (__mf_get_state, __mf_set_state): New. Update all users. * mf-runtime.c (begin_recursion_protect1): New. (BEGIN_RECURSION_PROTECT): Use it. (__mf_state_1): Rename from __mf_state; use TLS when available. (threads_active_p): Remove. (__mf_usage): Compute it directly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102108 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libmudflap/mf-hooks1.c')
-rw-r--r--libmudflap/mf-hooks1.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/libmudflap/mf-hooks1.c b/libmudflap/mf-hooks1.c
index 6f9d159e461..9460e443498 100644
--- a/libmudflap/mf-hooks1.c
+++ b/libmudflap/mf-hooks1.c
@@ -79,7 +79,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
void *
__mf_0fn_malloc (size_t c)
{
- /* fprintf (stderr, "0fn malloc c=%lu\n", c); */
+ enum foo { BS = 4096, NB=10 };
+ static char bufs[NB][BS];
+ static unsigned bufs_used[NB];
+ unsigned i;
+
+ for (i=0; i<NB; i++)
+ {
+ if (! bufs_used[i] && c < BS)
+ {
+ bufs_used[i] = 1;
+ return & bufs[i][0];
+ }
+ }
return NULL;
}
#endif
@@ -114,21 +126,7 @@ WRAPPER(void *, malloc, size_t c)
void *
__mf_0fn_calloc (size_t c, size_t n)
{
- enum foo { BS = 4096, NB=10 };
- static char bufs[NB][BS];
- static unsigned bufs_used[NB];
- unsigned i;
-
- /* fprintf (stderr, "0fn calloc c=%lu n=%lu\n", c, n); */
- for (i=0; i<NB; i++)
- {
- if (! bufs_used[i] && (c*n) < BS)
- {
- bufs_used[i] = 1;
- return & bufs[i][0];
- }
- }
- return NULL;
+ return __mf_0fn_malloc (c * n);
}
#endif
@@ -194,7 +192,7 @@ WRAPPER(void *, realloc, void *buf, size_t c)
/* Ensure heap wiping doesn't occur during this peculiar
unregister/reregister pair. */
LOCKTH ();
- __mf_state = reentrant;
+ __mf_set_state (reentrant);
saved_wipe_heap = __mf_opts.wipe_heap;
__mf_opts.wipe_heap = 0;
@@ -212,7 +210,7 @@ WRAPPER(void *, realloc, void *buf, size_t c)
/* Restore previous setting. */
__mf_opts.wipe_heap = saved_wipe_heap;
- __mf_state = active;
+ __mf_set_state (active);
UNLOCKTH ();
return result;