0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::ctx::posix: Wrap pthread_timedjoin_np().

This commit is contained in:
Jason Volk 2020-05-05 20:33:20 -07:00
parent 6a9dbf310a
commit 72ae3073d3
2 changed files with 38 additions and 2 deletions

View file

@ -22,6 +22,7 @@ AM_LDFLAGS = \
-Wl,--unresolved-symbols=ignore-in-shared-libs \
-Wl,--wrap=pthread_create \
-Wl,--wrap=pthread_join \
-Wl,--wrap=pthread_timedjoin_np \
-Wl,--wrap=pthread_self \
-Wl,--wrap=pthread_setname_np \
-Wl,-z,nodelete \

View file

@ -91,6 +91,40 @@ pthread_join(pthread_t __th,
void **__thread_return)
__attribute__((weak, alias("__wrap_pthread_join")));
//
// hook pthread_timedjoin_np
//
extern "C" int
__real_pthread_timedjoin_np(pthread_t __th,
void **__thread_return,
const struct timespec *__abstime);
extern "C" int
__wrap_pthread_timedjoin_np(pthread_t __th,
void **__thread_return,
const struct timespec *__abstime)
{
const auto it
{
std::find_if(begin(ircd::ctx::posix::ctxs), end(ircd::ctx::posix::ctxs), [&]
(const auto &context)
{
return ircd::ctx::id(context) == __th;
})
};
return it != end(ircd::ctx::posix::ctxs)?
ircd_pthread_timedjoin_np(__th, __thread_return, __abstime):
__real_pthread_timedjoin_np(__th, __thread_return, __abstime);
}
extern "C" int
pthread_timedjoin_np(pthread_t __th,
void **__thread_return,
const struct timespec *__abstime)
__attribute__((weak, alias("__wrap_pthread_timedjoin_np")));
//
// hook pthread_self
//
@ -222,8 +256,9 @@ ircd_pthread_timedjoin_np(pthread_t __th,
void **__thread_return,
const struct timespec *__abstime)
{
always_assert(false);
return EINVAL;
//TODO: XXX ctx timed join
ircd_pthread_join(__th, __thread_return);
return 0;
}
void