diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-01-18 15:10:02 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-03-12 10:19:22 -0300 |
commit | 2b47727c68b6329cf8890e56fc9dbaa4e7300961 (patch) | |
tree | a6068c64f81fa0221cddd7f96d4a2ed3fbf816a9 /sysdeps/mach | |
parent | cdba937662b16fc3685a8115f21e73f21330a44c (diff) | |
download | glibc-2b47727c68b6329cf8890e56fc9dbaa4e7300961.tar.gz |
posix: Consolidate register-atfork
Both htl and nptl uses a different data structure to implement atfork
handlers. The nptl one was refactored by 27761a1042d to use a dynarray
which simplifies the code.
This patch moves the nptl one to be the generic implementation and
replace Hurd linked one. Different than previous NPTL, Hurd also uses
a global lock, so performance should be similar.
Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for
i686-gnu.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/hurd/fork.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c index 2b39f4e8b5..1c5299e686 100644 --- a/sysdeps/mach/hurd/fork.c +++ b/sysdeps/mach/hurd/fork.c @@ -30,6 +30,7 @@ #include <malloc/malloc-internal.h> #include <nss/nss_database.h> #include <unwind-link.h> +#include <register-atfork.h> #undef __fork @@ -37,12 +38,6 @@ /* Things that want to be locked while forking. */ symbol_set_declare (_hurd_fork_locks) - -/* Application callbacks registered through pthread_atfork. */ -DEFINE_HOOK (_hurd_atfork_prepare_hook, (void)); -DEFINE_HOOK (_hurd_atfork_child_hook, (void)); -DEFINE_HOOK (_hurd_atfork_parent_hook, (void)); - /* Things that want to be called before we fork, to prepare the parent for task_create, when the new child task will inherit our address space. */ DEFINE_HOOK (_hurd_fork_prepare_hook, (void)); @@ -72,7 +67,7 @@ __fork (void) struct hurd_sigstate *volatile ss; struct nss_database_data nss_database_data; - RUN_HOOK (_hurd_atfork_prepare_hook, ()); + __run_fork_handlers (atfork_run_prepare, true); ss = _hurd_self_sigstate (); __spin_lock (&ss->critical_section_lock); @@ -726,10 +721,8 @@ __fork (void) if (!err) { - if (pid != 0) - RUN_HOOK (_hurd_atfork_parent_hook, ()); - else - RUN_HOOK (_hurd_atfork_child_hook, ()); + __run_fork_handlers (pid == 0 ? atfork_run_child : atfork_run_parent, + true); } return err ? __hurd_fail (err) : pid; |