2003-04-19 Ulrich Drepper <drepper@redhat.com>
+ * stdlib/cxa_finalize.c (__cxa_finalize): Don't call
+ UNREGISTER_ATFORK if d == NULL.
+
* catgets/nl_types.h: Remove __THROW marker from cancellation points.
* dirent/dirent.h: Likewise.
* dlfcn/dlfcn.h: Likewise.
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Remove named semaphore NAME. */
extern int sem_unlink (__const char *__name) __THROW;
-/* Wait for SEM being posted. */
-extern int sem_wait (sem_t *__sem) __THROW;
+/* Wait for SEM being posted.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int sem_wait (sem_t *__sem);
#ifdef __USE_XOPEN2K
-/* Similar to `sem_wait' but wait only until ABSTIME. */
+/* Similar to `sem_wait' but wait only until ABSTIME.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
extern int sem_timedwait (sem_t *__restrict __sem,
- __const struct timespec *__restrict __abstime)
- __THROW;
+ __const struct timespec *__restrict __abstime);
#endif
/* Test whether SEM is posted. */
/* Make calling thread wait for termination of the thread TH. The
exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
- is not NULL. */
-extern int pthread_join (pthread_t __th, void **__thread_return) __THROW;
+ is not NULL.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int pthread_join (pthread_t __th, void **__thread_return);
#ifdef __USE_GNU
/* Check whether thread TH has terminated. If yes return the status of
/* Make calling thread wait for termination of the thread TH, but only
until TIMEOUT. The exit status of the thread is stored in
- *THREAD_RETURN, if THREAD_RETURN is not NULL. */
+ *THREAD_RETURN, if THREAD_RETURN is not NULL.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
- __const struct timespec *__abstime) __THROW;
+ __const struct timespec *__abstime);
#endif
/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
/* Wait for condition variable COND to be signaled or broadcast.
- MUTEX is assumed to be locked before. */
+ MUTEX is assumed to be locked before.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
- pthread_mutex_t *__restrict __mutex) __THROW;
+ pthread_mutex_t *__restrict __mutex);
/* Wait for condition variable COND to be signaled or broadcast until
ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
absolute time specification; zero is the beginning of the epoch
- (00:00:00 GMT, January 1, 1970). */
+ (00:00:00 GMT, January 1, 1970).
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
__const struct timespec *__restrict
- __abstime) __THROW;
+ __abstime);
/* Functions for handling condition variable attributes. */
#include "fork.h"
+/* Defined in libc_pthread_init.c. */
+extern struct fork_handler __pthread_child_handler attribute_hidden;
+/* Three static memory blocks used when registering malloc. */
+static struct fork_handler malloc_prepare;
+static struct fork_handler malloc_parent;
+static struct fork_handler malloc_child;
+
+
void
__unregister_atfork (dso_handle)
void *dso_handle;
{
list_del (runp);
- free (list_entry (runp, struct fork_handler, list));
+ struct fork_handler *p = list_entry (runp, struct fork_handler, list);
+ if (p != &malloc_prepare)
+ free (p);
}
list_for_each_prev_safe (runp, prevp, &__fork_parent_list)
{
list_del (runp);
- free (list_entry (runp, struct fork_handler, list));
+ struct fork_handler *p = list_entry (runp, struct fork_handler, list);
+ if (p != &malloc_parent)
+ free (p);
}
list_for_each_prev_safe (runp, prevp, &__fork_child_list)
{
list_del (runp);
- free (list_entry (runp, struct fork_handler, list));
+ struct fork_handler *p = list_entry (runp, struct fork_handler, list);
+ if (p != &__pthread_child_handler && p != &malloc_child)
+ free (p);
}
/* Release the lock. */
#include <fork.h>
/* If D is non-NULL, call all functions registered with `__cxa_atexit'
- with the same dso handle. Otherwise, if D is NULL, do nothing. */
+ with the same dso handle. Otherwise, if D is NULL, call all of the
+ registered handlers. */
void
__cxa_finalize (void *d)
{
(*f->func.cxa.fn) (f->func.cxa.arg, 0);
}
- /* Remove the registered fork handlers. */
+ /* Remove the registered fork handlers. We do not have to
+ unregister anything if the program is going to terminate anyway. */
#ifdef UNREGISTER_ATFORK
- UNREGISTER_ATFORK (d);
+ if (d != NULL)
+ UNREGISTER_ATFORK (d);
#endif
}