1 #include <../../nrnconf.h>
22 "Duke, Yale, and the BlueBrain Project -- Copyright 1984-2022\n\
23 See http://neuron.yale.edu/neuron/credits\n";
25 #if defined(WIN32) || defined(NRNMECH_DLL_STYLE)
31 #undef DLL_DEFAULT_FNAME
32 #define DLL_DEFAULT_FNAME "nrnmech.dll"
35 #if defined(NRNMECH_DLL_STYLE)
38 #ifndef DLL_DEFAULT_FNAME
39 #define DLL_DEFAULT_FNAME "libnrnmech.dylib"
43 void nrn_possible_mismatched_arch(
const char* libname) {
44 if (strncmp(NRNHOSTCPU,
"arm64", 5) == 0) {
47 const char* we_are{
"arm64"};
49 const char* we_are{
"x86_64"};
54 cmd =
new char[strlen(libname) + 100];
55 sprintf(cmd,
"lipo -archs %s 2> /dev/null", libname);
56 char libname_arch[20]{0};
62 fgets(libname_arch, 18,
p);
63 if (strlen(libname_arch) == 0) {
69 fprintf(stderr,
"libnrniv.dylib running as %s\n", we_are);
70 fprintf(stderr,
"but %s can only run as %s\n", libname, libname_arch);
77 #ifndef DLL_DEFAULT_FNAME
78 #define DLL_DEFAULT_FNAME "./libnrnmech.so"
87 if (hoc_lookup(name) != (Symbol*) 0) { \
88 IGNORE(fprintf(stderr, CHKmes, name)); \
92 static char CHKmes[] =
"The user defined name, %s, already exists\n";
109 1e20,
"diam", 1
e-9, 1e9,
"cm",
110 0., 1e9,
"rallbranch", 1., 1e9,
111 "nseg", 1., 1e9,
"celsius", -273.,
112 1e6,
"dt", 1
e-9, 1e15, 0,
116 "uF/cm2",
"celsius",
"degC",
"dt",
"ms",
"t",
"ms",
117 "v",
"mV",
"i_cap",
"mA/cm2", 0, 0};
210 char* abspath =
NULL;
215 #if defined(HAVE_REALPATH)
216 abspath = realpath(relpath,
NULL);
218 #if defined(__MINGW32__)
219 abspath = _fullpath(
NULL, relpath, 0);
221 abspath = strdup(relpath);
225 handle =
dlopen(abspath, flags);
228 nrn_possible_mismatched_arch(abspath);
234 handle =
dlopen(relpath, flags);
237 "realpath failed errno=%d (%s) and dlopen failed with %s\n",
242 nrn_possible_mismatched_arch(abspath);
253 fprintf(stderr,
"loading membrane mechanisms from %s\n", cp1);
357 CHECK(
"i_membrane_");
376 #if !MAC && !defined(WIN32)
381 #if defined(WIN32) || defined(NRNMECH_DLL_STYLE)
384 FILE* ff =
fopen(DLL_DEFAULT_FNAME,
"r");
401 strncat(
buf,
"\\", 100);
408 for (cp2 = cp1; *cp2; ++cp2) {
423 s->
type = OBJECTFUNC;
452 int j,
k, modltype, pindx, modltypemax;
556 if (strcmp(m[0],
"0") == 0) {
557 }
else if (m[0][0] >
'9') {
559 "Mechanism %s needs to be re-translated.\n\
560 It's pre version 6.0 \"c\" code is incompatible with this neuron version.\n",
569 "Mechanism %s needs to be re-translated.\n\
570 It's version %s \"c\" code is incompatible with this neuron version.\n",
585 if (nrnpointerindex == -1) {
590 for (
k = 0,
j = 0, modltype =
nrnocCONST; modltype <= modltypemax; modltype++,
j++) {
592 for (; m2[
j];
j++,
k++) {
609 for (
j = 0,
k = 0, modltype =
nrnocCONST; modltype <= modltypemax; modltype++,
j++) {
610 for (; m2[
j];
j++,
k++) {
617 cp = strchr(
buf,
'[');
625 sscanf(cp + 1,
"%d", &
indx);
646 s2->
u.
rng.index = nrnpointerindex;
648 s2->
u.
rng.index = pindx;
661 nrnpointerindex +=
indx;
685 (*nrnpy_reg_mech_p_)(
type);
690 static int lastion = EXTRACELL + 1;
724 if (strcmp(
name,
"area") == 0) {
726 }
else if (strcmp(
name,
"iontype") == 0) {
728 }
else if (strcmp(
name,
"cvodeieq") == 0) {
730 }
else if (strcmp(
name,
"netsend") == 0) {
732 }
else if (strcmp(
name,
"pointer") == 0) {
734 }
else if (strcmp(
name,
"pntproc") == 0) {
736 }
else if (strcmp(
name,
"bbcorepointer") == 0) {
738 }
else if (strcmp(
name,
"watch") == 0) {
740 }
else if (strcmp(
name,
"diam") == 0) {
742 }
else if (strcmp(
name,
"fornetcon") == 0) {
746 if (
name[0] ==
'#') {
750 if (s && s->
type == MECHANISM) {
754 "mechanism %s : unknown semantics for %s\n",
801 int (*checkpoint)(
void**),
838 double* makevector(
int nrows)
841 v = (
double*)
emalloc((
unsigned)(nrows*
sizeof(double)));
927 printf(
"before-after processing type %d for %s not implemented\n",
949 if (s && s[
i]->extra) {
966 for (
i = 0; tol[
i].
name; ++
i) {
987 pv = (
double**)
ecalloc(2 *
n,
sizeof(
double*));
992 for (
i = 0;
i <
n; ++
i) {
994 if (
pv[
i] >=
p->param &&
pv[
i] < (
p->param +
p->param_size)) {
1013 for (
k = 1;
k < na; ++
k) {
1020 assert(j < msym->s_varn);
1034 }
else if (
cons == 0) {
1036 }
else if (
cons == 2) {
void morph_alloc(Prop *p)
static const char * morph_mech[]
static struct @26 usrprop[]
Symbol * hoc_table_lookup(const char *, Symlist *)
void hoc_symbol_tolerance(Symbol *, double)
void nrn_mk_prop_pools(int)
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
DLFCN_EXPORT void * dlopen(const char *file, int mode)
DLFCN_EXPORT char * dlerror(void)
DLFCN_EXPORT int dlclose(void *handle)
DLFCN_NOINLINE DLFCN_EXPORT void * dlsym(void *handle, const char *name)
double chkarg(int, double low, double high)
void nrn_verify_ion_charge_defined()
static HocParmLimits limits[]
void hoc_execerror(const char *, const char *)
static void destruct(void *v)
static void * cons(Object *o)
void hoc_reg_nmodl_filename(int type, const char *filename)
void hoc_reg_nmodl_text(int type, const char *txt)
double hoc_call_func(Symbol *s, int narg)
Symbol * hoc_install(const char *, int, double, Symlist **)
const char * expand_env_var(const char *s)
void hoc_register_var(DoubScal *scdoub, DoubVec *vdoub, VoidFunc *fn)
void hoc_retpushx(double x)
void hoc_symbol_limits(Symbol *sym, float low, float high)
Symbol * hoc_lookup(const char *)
void state_discontinuity(int i, double *pd, double d)
void * erealloc(void *ptr, size_t n)
void * ecalloc(size_t n, size_t size)
hoc_List * hoc_l_newlist()
Symlist * hoc_built_in_symlist
static int ode_count(int type)
char * hoc_symbol_units(Symbol *, const char *)
FILE * popen(char *s1, char *s2)
void(* nrn_bamech_t)(Node *, double *, Datum *, Datum *, struct NrnThread *)
void(* nrn_ode_map_t)(int, double **, double **, double *, Datum *, double *, int)
int(* nrn_ode_count_t)(int)
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
#define BEFORE_AFTER_SIZE
#define BEFORE_BREAKPOINT
static double map(void *v)
char * emalloc(unsigned n)
Prop * prop_alloc(Prop **, int, Node *)
void SectionRef_reg(void)
void modl_reg(void)
Needed for compilation.
void node_destruct(Node **, int)
void SectionList_reg(void)
int const size_t const size_t n
void(* pnt_receive_t)(Point_process *, double *, double)
void(* pnt_receive_init_t)(Point_process *, double *, double)
void(* NrnWatchAllocateFunc_t)(Datum *)
int nrn_noauto_dlopen_nrnmech
const char ** nrn_nmodl_filename_
double _modl_get_dt_thread(NrnThread *nt)
void hoc_register_limits(int type, HocParmLimits *limits)
void hoc_reg_ba(int mt, nrn_bamech_t f, int type)
void hoc_nrn_load_dll(void)
void nrn_writes_conc(int type, int unused)
short * nrn_is_artificial_
short * nrn_artcell_qindex_
void hoc_register_dparam_semantics(int type, int ix, const char *name)
void add_nrn_artcell(int type, int qi)
static HocParmLimits _hoc_parm_limits[]
void add_nrn_fornetcons(int type, int indx)
void nrnunit_use_legacy()
NrnWatchAllocateFunc_t * nrn_watch_allocate_
void hoc_register_tolerance(int type, HocStateTolerance *tol, Symbol ***stol)
int * nrn_fornetcon_type_
void * nrn_realpath_dlopen(const char *relpath, int flags)
void _cvode_abstol(Symbol **s, double *tol, int i)
void _modl_set_dt_thread(double newdt, NrnThread *nt)
pnt_receive_init_t * pnt_receive_init
void hoc_register_prop_size(int type, int psize, int dpsize)
int nrn_pointing(double *pd)
static HocParmUnits _hoc_parm_units[]
int * nrn_fornetcon_index_
void hoc_register_units(int type, HocParmUnits *units)
void hoc_register_cvode(int i, nrn_ode_count_t cnt, nrn_ode_map_t map, Pvmi spec, Pvmi matsol)
void _nrn_thread_table_reg(int i, void(*f)(double *, Datum *, Datum *, NrnThread *, int))
Point_process ** point_process
void add_nrn_has_net_event(int type)
int mswin_load_dll(const char *cp1)
int nrn_netrec_state_adjust
cTemplate ** nrn_pnt_template_
int nrn_load_dll_recover_error()
static int memb_func_size_
void hoc_reg_bbcore_write(int type, bbcore_write_t f)
int * nrn_prop_param_size_
int state_discon_allowed_
void(*)(double *, int *, int *, int *, double *, Datum *, Datum *, NrnThread *) bbcore_write_t
int nrn_is_artificial(int pnttype)
int point_reg_helper(Symbol *s2)
int nrn_has_net_event_cnt_
void hoc_reg_bbcore_read(int type, bbcore_write_t f)
void nrn_register_mech_common(const char **m, Pvmp alloc, Pvmi cur, Pvmi jacob, Pvmi stat, Pvmi initialize, int nrnpointerindex, int vectorized)
int point_register_mech(const char **m, Pvmp alloc, Pvmi cur, Pvmi jacob, Pvmi stat, Pvmi initialize, int nrnpointerindex, int vectorized, void *(*constructor)(Object *), void(*destructor)(void *), Member_func *fmember)
void nrn_threads_create(int, int)
int * nrn_dparam_ptr_start_
void _modl_set_dt(double newdt)
void nrn_load_name_check(const char *name)
int * nrn_prop_dparam_size_
void hoc_register_synonym(int i, void(*syn)(int, double **, Datum **))
double nrn_call_mech_func(Symbol *s, int narg, Prop *p, int type)
bbcore_write_t * nrn_bbcore_write_
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
double hoc_default_dll_loaded_
void register_destructor(Pvmp d)
Symlist * nrn_load_dll_called_
int * nrn_dparam_ptr_end_
pnt_receive_t * pnt_receive
const char ** nrn_nmodl_text_
Node ** node_construct(int)
void hoc_reg_watch_allocate(int type, NrnWatchAllocateFunc_t waf)
void(* nrnpy_reg_mech_p_)(int)
bbcore_write_t * nrn_bbcore_read_
static char nmodl_version_[]
void register_mech(const char **m, Pvmp alloc, Pvmi cur, Pvmi jacob, Pvmi stat, Pvmi initialize, int nrnpointerindex, int vectorized)
void _nrn_setdata_reg(int i, void(*call)(Prop *))
void _nrn_thread_reg(int i, int cons, void(*f)(Datum *))
static philox4x32_key_t k
void steer_point_process(void *v)
static void pnode(Prop *)
static void * constructor(Object *ho)
static void destructor(void *v)
void(* setdata_)(struct Prop *)
void(* thread_table_check_)(double *, Datum *, Datum *, NrnThread *, int)
void(* _update_ion_pointers)(Datum *)
void(* thread_mem_init_)(Datum *)
void(* thread_cleanup_)(Datum *)
Represent main neuron object computed by single thread.
short cpublic
Note: public is a reserved keyword.
HocStruct Symbol ** ppsym
struct Symbol::@37::@38 rng
HocStruct cTemplate * ctemplate
char * strstr(char *cs, char *ct)