From 6ced0985aaa3ec81be59edb34c1753a9c9b9751a Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 16 Jan 2019 11:29:12 +0100 Subject: [PATCH 1/1] Remove useless wrapper around pthread_atfork(). --- include/xbt/xbt_os_thread.h | 4 ---- src/xbt/mmalloc/mm_module.c | 4 ++-- src/xbt/mmalloc/mmprivate.h | 1 - src/xbt/xbt_os_thread.c | 13 ------------- 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/include/xbt/xbt_os_thread.h b/include/xbt/xbt_os_thread.h index 95a3377adb..a1c4de9697 100644 --- a/include/xbt/xbt_os_thread.h +++ b/include/xbt/xbt_os_thread.h @@ -11,8 +11,6 @@ #include #include -#include - SG_BEGIN_DECL() /** @addtogroup XBT_thread @@ -24,8 +22,6 @@ SG_BEGIN_DECL() * @{ */ -XBT_PUBLIC int xbt_os_thread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); - /** @brief Thread mutex data type (opaque structure) */ typedef struct xbt_os_mutex_ *xbt_os_mutex_t; XBT_PUBLIC xbt_os_mutex_t xbt_os_mutex_init(void); diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index a2bfb2be0d..1782059e4a 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -327,9 +327,9 @@ void *mmalloc_preinit(void) /* Fixme? only the default mdp in protected against forks */ // This is mandated to protect the mmalloced areas through forks. Think of tesh. // Nah, removing the mutex isn't a good idea either for tesh - int res = xbt_os_thread_atfork(mmalloc_fork_prepare, mmalloc_fork_parent, mmalloc_fork_child); + int res = pthread_atfork(mmalloc_fork_prepare, mmalloc_fork_parent, mmalloc_fork_child); if (res != 0) - THROWF(system_error,0,"xbt_os_thread_atfork() failed: return value %d",res); + THROWF(system_error, 0, "pthread_atfork() failed: return value %d", res); } xbt_assert(__mmalloc_default_mdp != NULL); diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index c05e9e356b..97841313e8 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -18,7 +18,6 @@ #include "swag.h" #include "src/internal_config.h" -#include "xbt/xbt_os_thread.h" #include "xbt/mmalloc.h" #include "xbt/ex.h" #include "xbt/dynar.h" diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c index 270af96cf2..dc723291cd 100644 --- a/src/xbt/xbt_os_thread.c +++ b/src/xbt/xbt_os_thread.c @@ -44,19 +44,6 @@ typedef struct xbt_os_thread_ { pvoid_f_pvoid_t start_routine; } s_xbt_os_thread_t; -/** Calls pthread_atfork() if present, and raise an exception otherwise. - * - * The only known user of this wrapper is mmalloc_preinit(), but it is absolutely mandatory there: - * when used with tesh, mmalloc *must* be mutex protected and resistant to forks. - * This functionality is the only way to get it working (by ensuring that the mutex is consistently released on forks) - */ - -/* this function is critical to tesh+mmalloc, don't mess with it */ -int xbt_os_thread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) -{ - return pthread_atfork(prepare, parent, child); -} - /****** mutex related functions ******/ typedef struct xbt_os_mutex_ { pthread_mutex_t m; -- 2.20.1