]> granicus.if.org Git - pdns/commitdiff
Switch from std::function to boost::function
authorAndrew Nelless <andrew@nelless.net>
Wed, 24 Feb 2016 15:10:22 +0000 (15:10 +0000)
committerAndrew Nelless <andrew@nelless.net>
Wed, 24 Feb 2016 15:10:22 +0000 (15:10 +0000)
GNUs implementation of std::function can't eat 3 pointers without allocating,
(24 bytes) whereas both LLVM libc++ and boost::function can. boost::function
has been move enabled since 1.52 (Nov 2012).

pdns/mtasker.hh
pdns/mtasker_context.hh
pdns/mtasker_fcontext.cc
pdns/mtasker_ucontext.cc

index 4fa965af2fe9d2b8b295e23f176518e8464179fb..6261e0afaa6a1bc04ee037967cd0335d719b45f0 100644 (file)
@@ -33,6 +33,7 @@
 #include "misc.hh"
 #include "mtasker_context.hh"
 #include <memory>
+#include <boost/function.hpp>
 using namespace ::boost::multi_index;
 
 // #define MTASKERTIMING 1
@@ -56,7 +57,7 @@ private:
   struct ThreadInfo
   {
        std::shared_ptr<pdns_ucontext_t> context;
-       std::function<void(void)> start;
+       boost::function<void(void)> start;
        char* startOfStack;
        char* highestStackSeen;
 #ifdef MTASKERTIMING
index 82112892e9cb7da794e220f01ce0563cdb2c6890..45a73784ecb4318067617e77bddb1b44eed539a2 100644 (file)
@@ -2,7 +2,7 @@
 #define MTASKER_CONTEXT_HH
 
 #include "lazy_allocator.hh"
-#include <functional>
+#include <boost/function.hpp>
 #include <vector>
 #include <exception>
 
@@ -24,6 +24,6 @@ pdns_swapcontext
 
 void
 pdns_makecontext
-(pdns_ucontext_t& ctx, std::function<void(void)>& start);
+(pdns_ucontext_t& ctx, boost::function<void(void)>& start);
 
 #endif // MTASKER_CONTEXT_HH
index 77f473cf1d961f2d18f426a2f0e4900212c2d7f8..a6a9d177c4f7638ae3f304d33529265464c544a6 100644 (file)
@@ -34,7 +34,7 @@ static_assert (std::is_pointer<fcontext_t>::value,
 struct args_t {
     fcontext_t prev_ctx = nullptr;
     pdns_ucontext_t* self = nullptr;
-    std::function<void(void)>* work = nullptr;
+    boost::function<void(void)>* work = nullptr;
 };
 
 extern "C" {
@@ -84,7 +84,7 @@ pdns_swapcontext
 
 void
 pdns_makecontext
-(pdns_ucontext_t& ctx, std::function<void(void)>& start) {
+(pdns_ucontext_t& ctx, boost::function<void(void)>& start) {
     assert (ctx.uc_link);
     assert (ctx.uc_stack.size() >= 8192);
     assert (!ctx.uc_mcontext);
index a10dbe17e05725cc9a798321b5bb180c0d524c1a..aba7955e808b2690b45d362e3570b64a0cc04b09 100644 (file)
@@ -47,7 +47,7 @@ void
 threadWrapper (int const ctx0, int const ctx1, int const fun0, int const fun1) {
     auto ctx = joinPtr<pdns_ucontext_t>(ctx0, ctx1);
     try {
-        auto start = std::move(*joinPtr<std::function<void()>>(fun0, fun1));
+        auto start = std::move(*joinPtr<boost::function<void()>>(fun0, fun1));
         start();
     } catch (...) {
         ctx->exception = std::current_exception();
@@ -78,7 +78,7 @@ pdns_swapcontext
 
 void
 pdns_makecontext
-(pdns_ucontext_t& ctx, std::function<void(void)>& start) {
+(pdns_ucontext_t& ctx, boost::function<void(void)>& start) {
     assert (ctx.uc_link);
     assert (ctx.uc_stack.size());