From 8987035885f4ebcb1b34b94aff819084b460cf4b Mon Sep 17 00:00:00 2001 From: Kavinli <0x4f4f4f4f@gmail.com> Date: Sun, 30 Oct 2022 20:49:27 +0800 Subject: [PATCH] fix: __sigval_t causes compile error (#21) Signed-off-by: Super-long <0x4f4f4f4f@gmail.com> --- util/dns_resolve.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/dns_resolve.cc b/util/dns_resolve.cc index 63c937e9..5688aaae 100644 --- a/util/dns_resolve.cc +++ b/util/dns_resolve.cc @@ -25,7 +25,17 @@ struct NotifyStruct { fibers_ext::EventCount evc; }; -static void DnsResolveNotify(__sigval_t val) { +// To ensure compatibility between different versions of Glibc, +// we use sigval_t instead of __sigval_t. However, some older +// versions may still require __sigval_t, such as when __USE_POSIX199309 +// is defined. The following text is derived from the comments in Glibc 2.31: +// To avoid sigval_t (not a standard type name) having C++ name +// mangling depending on whether the selected standard includes union +// sigval, it should not be defined at all when using a standard for +// which the sigval name is not reserved; in that case, headers should +// not include and should use only the +// internal __sigval_t name. +static void DnsResolveNotify(sigval_t val) { NotifyStruct* ns = (NotifyStruct*)val.sival_ptr; ns->gate.store(true, memory_order_relaxed); ns->evc.notify();