[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/LIBCXX PATCH v2] Enable threads support


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Tue, 4 Jun 2019 23:54:39 +0300
  • Cc: felipe.huici@xxxxxxxxx, Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>, Teodora Serbanescu <teo.serbanescu16@xxxxxxxxx>
  • Delivery-date: Tue, 04 Jun 2019 20:54:54 +0000
  • Ironport-phdr: 9a23:O8aOoB2h4y6V1HaMsmDT+DRfVm0co7zxezQtwd8ZsesWKvnxwZ3uMQTl6Ol3ixeRBMOHsqsC0raO+Pm8EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCegbb9oMRm7ohndusYLjYZtN6081gbHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhTwZPDAl7m7Yls1wjLpaoB2/oRx/35XUa5yROPZnY6/RYc8WSW9HU81MVSJOH5m8YpMPAeQfIOhWoYrzqVwVoBeiGQWhHv/jxyVUinPq26AxzuQvERvB3AwlB98DrnPUrM7pNKcTV+C+0a/GzSjbb/NLxDzw75THchc6ofGQXLJwd9DdyU0yFwPdk1WdspDqPyiP2uQVrmiU9PBsVfioi2M+rQx6vzuhxt80h4XUiY8Z10rI+CZ5zYovO9G0Vkx2bcSqHZdIqi2XOJZ6TtkhTmxooio21LMLtJChcCQXx5kr2RjSYOGdfYeS+BLsTuORLC99hHJiZb2wmQ6/8VOlyu3gTsm010tKrjZdntnMqH8N0xvT59CZSvt45Eih2DKP2xrP5eFfO0w0jbfbJIU7zr4qkZofqUXDHinol0XqlKKaa0op9vWy5+nkYrjqvIGQO5F2hw3kPKkigsm/Dv45MggKUWib4+O81Lj78ELlR7VKleE2kqjfsJzAIcQbu7a5AxJO34k/8BazFS+m0MkDknUdNlJFfwqLj5L1NFHWPPD4EfC/jkywkDh1wPDKJKbhDYvXLnfYirjhe6hy61VAxwou0NxS5olZCr4EIP3pW0/xsMbUAQM+Mwyx2+znEsly1psCWWKTBa+UKKbSsV6O5uIuJOmMf5YZtyvjJPg7+fHuiWQ0mVscfamywZsXc2q0H/t4LEWfe3bshc0BEWgStAokUOPqkEGCUSJUZ3uqUaIz+DU7CIO+DYjdXIytgKGB3CanEZ1XfW1GDE6DHmvsd4qeQPgAcjydItJ5mDweSbehU5Mh1Q2ptALi1bpnKvDb9TAAup350th6+vfTmg8z9TBuFMuSyXyCT2Z1nmMVXDI2x7x/oVFgxVuZy6d3n+dYGcZO5/NRSQg2L4Tcz+spQ+z1DwfAeNaOUxOqT8urBRk1T8kt2JkebkA7HM+t3T7Z2C//KLgOi72NTLgp6r+Ui3P2PNp8zTDCybE8p1I9BNNSPyu8gfgspEDoG4fVnhDBxO6RfqMG0XuIrT/bwA==
  • Ironport-sdr: 7YTimL5hQ6daBwKHickdJQqfVjjBn8dyw3JwwGtiR1kEmndocgmB7D2UWPG2UuBC3B22mxIuJU 8nsUX+yVpxuA==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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@xxxxxxxxxxxxxxx>
Signed-off-by: Teodora Serbanescu <teo.serbanescu16@xxxxxxxxx>
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 Config.uk                                     |  6 +++
 Makefile.uk                                   |  5 ++
 ...-Add-hashtable-template-for-pthreads.patch | 51 +++++++++++++++++++
 3 files changed, 62 insertions(+)
 create mode 100644 patches/0003-Add-hashtable-template-for-pthreads.patch

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 <teo.serbanescu16@xxxxxxxxx>
+Date: Thu, 18 Apr 2019 15:15:33 +0300
+Subject: [PATCH] Add hashtable template for pthreads
+
+Signed-off-by: Teodora Serbanescu <teo.serbanescu16@xxxxxxxxx>
+---
+ 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
+
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.