From: Costin Lupu Date: Tue, 4 Jun 2019 20:54:39 +0000 (+0300) Subject: Enable threads support X-Git-Tag: RELEASE-0.4~7 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=853ae3d80e9faffb648e2b9df2d3c9822ee87a57;p=unikraft%2Flibs%2Flibcxx.git Enable threads support This patch defines the macros and adds the hashtable template required for enabling threads support in cxx library. Signed-off-by: Vlad-Andrei Badoiu Signed-off-by: Teodora Serbanescu Signed-off-by: Costin Lupu Reviewed-by: Felipe Huici --- diff --git a/Config.uk b/Config.uk index 9962669..16a11dc 100644 --- a/Config.uk +++ b/Config.uk @@ -4,3 +4,9 @@ menuconfig LIBCXX select LIBCXXABI select LIBUNWIND default n + +if LIBCXX +config CXX_THREADS + bool "Enable CXX threads support" + default n +endif diff --git a/Makefile.uk b/Makefile.uk index a455386..b673f72 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -96,6 +96,11 @@ CONFIG_FLAGS += -D LIBCXX_BUILDING_LIBCXXABI \ -D _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE -D __DYNAMIC_REENT__ \ +ifdef CONFIG_CXX_THREADS +CONFIG_FLAGS += -D__linux__ -D_LIBCPP_HAS_THREAD_API_PTHREAD +else +CONFIG_FLAGS += -D_LIBCPP_HAS_NO_THREADS +endif LIBCXX_CFLAGS-y += $(CONFIG_FLAGS) LIBCXX_CXXFLAGS-y += $(CONFIG_FLAGS) diff --git a/patches/0003-Add-hashtable-template-for-pthreads.patch b/patches/0003-Add-hashtable-template-for-pthreads.patch new file mode 100644 index 0000000..6a99062 --- /dev/null +++ b/patches/0003-Add-hashtable-template-for-pthreads.patch @@ -0,0 +1,51 @@ +From 215ae6f079c9d3e1ed21fc549e41ef5d6d796d71 Mon Sep 17 00:00:00 2001 +From: Teodora Serbanescu +Date: Thu, 18 Apr 2019 15:15:33 +0300 +Subject: [PATCH] Add hashtable template for pthreads + +Signed-off-by: Teodora Serbanescu +--- + include/utility | 20 +++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/include/utility b/include/utility +index ed9bf03..c5b74fd 100644 +--- a/include/utility ++++ b/include/utility +@@ -205,6 +205,10 @@ template + #include + #include <__debug> + ++#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) ++#include ++#endif ++ + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + #pragma GCC system_header + #endif +@@ -1473,6 +1478,22 @@ struct _LIBCPP_TEMPLATE_VIS hash + } + }; + ++#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) ++template <> ++struct _LIBCPP_TEMPLATE_VIS hash ++ : public __scalar_hash ++{ ++ _LIBCPP_INLINE_VISIBILITY ++ size_t operator()(pthread_t __v) const _NOEXCEPT ++ { ++ // -0.0 and 0.0 should return same hash ++ if (__v == 0) ++ return 0; ++ return __scalar_hash::operator()((size_t) __v.p); ++ } ++}; ++#endif ++ + template <> + struct _LIBCPP_TEMPLATE_VIS hash + : public __scalar_hash +-- +2.11.0 +