From 2d108b6850213d4c429f80349e95c2bd8431f1a8 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Tue, 12 Nov 2024 14:40:42 +0100 Subject: [PATCH] Support PROTECT via `_NMODLMUTEX{,UN}LOCK`. --- src/codegen/codegen_neuron_cpp_visitor.cpp | 9 +++++++++ src/codegen/codegen_neuron_cpp_visitor.hpp | 1 + 2 files changed, 10 insertions(+) diff --git a/src/codegen/codegen_neuron_cpp_visitor.cpp b/src/codegen/codegen_neuron_cpp_visitor.cpp index 7e8420cce..ebcf222c5 100644 --- a/src/codegen/codegen_neuron_cpp_visitor.cpp +++ b/src/codegen/codegen_neuron_cpp_visitor.cpp @@ -1103,6 +1103,7 @@ void CodegenNeuronCppVisitor::print_neuron_includes() { printer->add_multi_line(R"CODE( #include "mech_api.h" #include "neuron/cache/mechanism_range.hpp" + #include "nmodlmutex.h" #include "nrniv_mf.h" #include "section_fwd.hpp" )CODE"); @@ -3063,6 +3064,14 @@ void CodegenNeuronCppVisitor::visit_for_netcon(const ast::ForNetcon& node) { printer->pop_block(); } +void CodegenNeuronCppVisitor::visit_protect_statement(const ast::ProtectStatement& node) { + printer->add_line("_NMODLMUTEXLOCK"); + printer->add_indent(); + node.get_expression()->accept(*this); + printer->add_text(";"); + printer->add_line("_NMODLMUTEXUNLOCK"); +} + } // namespace codegen } // namespace nmodl diff --git a/src/codegen/codegen_neuron_cpp_visitor.hpp b/src/codegen/codegen_neuron_cpp_visitor.hpp index 9b36b1c22..4e0ebb106 100644 --- a/src/codegen/codegen_neuron_cpp_visitor.hpp +++ b/src/codegen/codegen_neuron_cpp_visitor.hpp @@ -839,6 +839,7 @@ class CodegenNeuronCppVisitor: public CodegenCppVisitor { void visit_for_netcon(const ast::ForNetcon& node) override; void visit_longitudinal_diffusion_block(const ast::LongitudinalDiffusionBlock& node) override; void visit_lon_diffuse(const ast::LonDiffuse& node) override; + void visit_protect_statement(const ast::ProtectStatement& node) override; public: /****************************************************************************************/