]> xenbits.xensource.com Git - unikraft/libs/libcxx.git/commitdiff
Enable threads support
authorCostin Lupu <costin.lupu@cs.pub.ro>
Tue, 4 Jun 2019 20:54:39 +0000 (23:54 +0300)
committerFelipe Huici <felipe.huici@neclab.eu>
Wed, 5 Jun 2019 11:29:29 +0000 (13:29 +0200)
This patch defines the macros and adds the hashtable template required for
enabling threads support in cxx library.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Config.uk
Makefile.uk
patches/0003-Add-hashtable-template-for-pthreads.patch [new file with mode: 0644]

index 996266975bc651b3fbe577ab8133b79fd0a86c0a..16a11dc018a3fef1be710b1dd00eb82a9b9c29dc 100644 (file)
--- 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
index a455386fafdae38755ea75b8af6b3c0b93d7790c..b673f7252fb3588837d940df78337382e3664517 100644 (file)
@@ -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 (file)
index 0000000..6a99062
--- /dev/null
@@ -0,0 +1,51 @@
+From 215ae6f079c9d3e1ed21fc549e41ef5d6d796d71 Mon Sep 17 00:00:00 2001
+From: Teodora Serbanescu <teo.serbanescu16@gmail.com>
+Date: Thu, 18 Apr 2019 15:15:33 +0300
+Subject: [PATCH] Add hashtable template for pthreads
+
+Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
+---
+ 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 <size_t I>
+ #include <cstdint>
+ #include <__debug>
+
++#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
++#include <pthread.h>
++#endif
++
+ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+ #pragma GCC system_header
+ #endif
+@@ -1473,6 +1478,22 @@ struct _LIBCPP_TEMPLATE_VIS hash<double>
+     }
+ };
++#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
++template <>
++struct _LIBCPP_TEMPLATE_VIS hash<pthread_t>
++    : public __scalar_hash<size_t>
++{
++    _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<size_t>::operator()((size_t) __v.p);
++    }
++};
++#endif
++
+ template <>
+ struct _LIBCPP_TEMPLATE_VIS hash<long double>
+     : public __scalar_hash<long double>
+-- 
+2.11.0
+