Browse Source

fork.h: replace with register-atfork.h

UNREGISTER_ATFORK is now defined for all ports in register-atfork.h, so most
previous includes of fork.h actually only need register-atfork.h now, and
cxa_finalize.c does not need an ifdef UNREGISTER_ATFORK any more.

The nptl-specific fork generation counters can then go to pthreadP.h, and
fork.h be removed.

Checked on x86_64-linux-gnu and i686-gnu.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
nsz/bug19329-v2
Samuel Thibault 5 years ago
parent
commit
64786a7090
  1. 1
      htl/forward.c
  2. 2
      nptl/libc_pthread_init.c
  3. 1
      nptl/nptl-init.c
  4. 6
      nptl/pthreadP.h
  5. 2
      nptl/pthread_atfork.c
  6. 4
      stdlib/cxa_finalize.c
  7. 27
      sysdeps/generic/fork.h
  8. 20
      sysdeps/htl/fork.h
  9. 1
      sysdeps/htl/pt-atfork.c
  10. 2
      sysdeps/nptl/fork.c
  11. 26
      sysdeps/nptl/fork.h
  12. 8
      sysdeps/nptl/libc-lockP.h

1
htl/forward.c

@ -22,7 +22,6 @@
#include <shlib-compat.h>
#include <pthread-functions.h>
#include <libc-lock.h>
#include <fork.h>
#include <pt-internal.h>
/* Pointers to the libc functions. */

2
nptl/libc_pthread_init.c

@ -18,7 +18,7 @@
#include <unistd.h>
#include <list.h>
#include <fork.h>
#include <register-atfork.h>
#include <dl-sysdep.h>
#include <tls.h>
#include <string.h>

1
nptl/nptl-init.c

@ -29,7 +29,6 @@
#include <ldsodefs.h>
#include <tls.h>
#include <list.h>
#include <fork.h>
#include <version.h>
#include <shlib-compat.h>
#include <lowlevellock.h>

6
nptl/pthreadP.h

@ -355,6 +355,12 @@ extern void __nptl_death_event (void);
hidden_proto (__nptl_create_event)
hidden_proto (__nptl_death_event)
/* The fork generation counter, defined in libpthread. */
extern unsigned long int __fork_generation attribute_hidden;
/* Pointer to the fork generation counter in the thread library. */
extern unsigned long int *__fork_generation_pointer attribute_hidden;
/* Register the generation counter in the libpthread with the libc. */
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
extern void __libc_pthread_init (unsigned long int *ptr,

2
nptl/pthread_atfork.c

@ -34,7 +34,7 @@
<https://www.gnu.org/licenses/>. */
#include "pthreadP.h"
#include <fork.h>
#include <register-atfork.h>
#include <dso_handle.h>

4
stdlib/cxa_finalize.c

@ -18,7 +18,7 @@
#include <assert.h>
#include <stdlib.h>
#include "exit.h"
#include <fork.h>
#include <register-atfork.h>
#include <sysdep.h>
#include <stdint.h>
@ -102,9 +102,7 @@ __cxa_finalize (void *d)
/* Remove the registered fork handlers. We do not have to
unregister anything if the program is going to terminate anyway. */
#ifdef UNREGISTER_ATFORK
if (d != NULL)
UNREGISTER_ATFORK (d);
#endif
__libc_lock_unlock (__exit_funcs_lock);
}

27
sysdeps/generic/fork.h

@ -1,27 +0,0 @@
/* Stub version of header for fork handling. Mainly to handle pthread_atfork
and friends. Outside dependencies:
UNREGISTER_ATFORK
If defined it must expand to a function call which takes one void*
parameter which is the DSO handle for the DSO which gets unloaded.
The function so called has to remove the atfork handlers registered
by this module. */
/* System specific fork definition. Generic version.
Copyright (C) 2002-2021 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
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

20
sysdeps/htl/fork.h

@ -1,20 +0,0 @@
/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <lowlevellock.h>
#include <register-atfork.h>

1
sysdeps/htl/pt-atfork.c

@ -18,7 +18,6 @@
#include <pthread.h>
#include <pt-internal.h>
#include <fork.h>
#include <dso_handle.h>
#include <register-atfork.h>

2
sysdeps/nptl/fork.c

@ -28,7 +28,7 @@
#include <stdio-lock.h>
#include <atomic.h>
#include <nptl/pthreadP.h>
#include <fork.h>
#include <register-atfork.h>
#include <arch-fork.h>
#include <futex-internal.h>
#include <malloc/malloc-internal.h>

26
sysdeps/nptl/fork.h

@ -1,26 +0,0 @@
/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <lowlevellock.h>
#include <register-atfork.h>
/* The fork generation counter, defined in libpthread. */
extern unsigned long int __fork_generation attribute_hidden;
/* Pointer to the fork generation counter in the thread library. */
extern unsigned long int *__fork_generation_pointer attribute_hidden;

8
sysdeps/nptl/libc-lockP.h

@ -308,14 +308,6 @@ __libc_cleanup_routine (struct __pthread_cleanup_frame *f)
__libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
/* Register handlers to execute before and after `fork'. Note that the
last parameter is NULL. The handlers registered by the libc are
never removed so this is OK. */
extern int __register_atfork (void (*__prepare) (void),
void (*__parent) (void),
void (*__child) (void),
void *__dso_handle);
/* Functions that are used by this file and are internal to the GNU C
library. */

Loading…
Cancel
Save