Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
obey sonar and make SwappedContext::stack_ private
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 8 Jan 2019 17:13:55 +0000 (18:13 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 8 Jan 2019 22:17:12 +0000 (23:17 +0100)
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextSwapped.hpp
src/kernel/context/ContextUnix.cpp

index 1e65b48..56208f7 100644 (file)
@@ -33,9 +33,9 @@ BoostContext::BoostContext(std::function<void()> code, void_pfn_smxprocess_t cle
     /* We need to pass the bottom of the stack to make_fcontext,
        depending on the stack direction it may be the lower or higher address: */
 #if PTH_STACKGROWTH == -1
     /* We need to pass the bottom of the stack to make_fcontext,
        depending on the stack direction it may be the lower or higher address: */
 #if PTH_STACKGROWTH == -1
-    void* stack = static_cast<char*>(this->stack_) + smx_context_usable_stack_size;
+    void* stack = static_cast<char*>(get_stack()) + smx_context_usable_stack_size;
 #else
 #else
-    void* stack = this->stack_;
+    void* stack = get_stack();
 #endif
     ASAN_ONLY(this->asan_stack_ = stack);
 #if BOOST_VERSION < 106100
 #endif
     ASAN_ONLY(this->asan_stack_ = stack);
 #if BOOST_VERSION < 106100
index f6eaf31..d8dab5a 100644 (file)
@@ -200,11 +200,11 @@ RawContext::RawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup
 {
    if (has_code()) {
 #if PTH_STACKGROWTH == -1
 {
    if (has_code()) {
 #if PTH_STACKGROWTH == -1
-     ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
+     ASAN_ONLY(this->asan_stack_ = static_cast<char*>(get_stack()) + smx_context_usable_stack_size);
 #else
 #else
-     ASAN_ONLY(this->asan_stack_ = this->stack_);
+     ASAN_ONLY(this->asan_stack_ = get_stack());
 #endif
 #endif
-     this->stack_top_ = raw_makecontext(this->stack_, smx_context_usable_stack_size, RawContext::wrapper, this);
+     this->stack_top_ = raw_makecontext(get_stack(), smx_context_usable_stack_size, RawContext::wrapper, this);
    } else {
      set_maestro(this); // save maestro for run_all()
      if (MC_is_active())
    } else {
      set_maestro(this); // save maestro for run_all()
      if (MC_is_active())
index a270f90..b550205 100644 (file)
@@ -140,6 +140,11 @@ void SwappedContext::set_maestro(SwappedContext* ctx)
     factory_->workers_context_[0] = ctx;
 }
 
     factory_->workers_context_[0] = ctx;
 }
 
+void* SwappedContext::get_stack()
+{
+  return stack_;
+}
+
 void SwappedContext::stop()
 {
   Context::stop();
 void SwappedContext::stop()
 {
   Context::stop();
index da798ed..8ff75d5 100644 (file)
@@ -46,15 +46,14 @@ public:
   virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
 
   void set_maestro(SwappedContext* ctx);
   virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
 
   void set_maestro(SwappedContext* ctx);
+  void* get_stack();
 
   // FIXME: Killme
   static thread_local uintptr_t worker_id_;
 
 
   // FIXME: Killme
   static thread_local uintptr_t worker_id_;
 
-protected:
-  void* stack_ = nullptr; /* the thread stack */
-
 private:
 private:
-  SwappedContextFactory* factory_; // for sequential and parallel run_all()
+  void* stack_ = nullptr;                /* the thread stack */
+  SwappedContextFactory* const factory_; // for sequential and parallel run_all()
 };
 
 } // namespace context
 };
 
 } // namespace context
index 727ffb8..0ad3f4e 100644 (file)
@@ -46,7 +46,7 @@ UContext::UContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_fun
   if (has_code()) {
     getcontext(&this->uc_);
     this->uc_.uc_link = nullptr;
   if (has_code()) {
     getcontext(&this->uc_);
     this->uc_.uc_link = nullptr;
-    this->uc_.uc_stack.ss_sp   = sg_makecontext_stack_addr(this->stack_);
+    this->uc_.uc_stack.ss_sp   = sg_makecontext_stack_addr(get_stack());
     this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size);
 #if PTH_STACKGROWTH == -1
     ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
     this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size);
 #if PTH_STACKGROWTH == -1
     ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);