1 #include <../../nrnconf.h>
5 #if HAVE_POSIX_MEMALIGN
6 #define HAVE_MEMALIGN 1
13 #define _XOPEN_SOURCE 600
33 #include "nrnmpiuse.h"
35 #if defined(__APPLE__) && defined(__MACH__)
36 #include <mach/mach.h>
57 Printf(
"%s %p\n", sp->name, sp);
65 if (strcmp(sp->name, s) == 0) {
98 sp->
name = (
char*)
emalloc((
unsigned) (strlen(s) + 1));
109 (*list)->first = (*list)->last =
nullptr;
132 sp->
u.
pnum =
nullptr;
149 if (list->
first == s) {
151 if (list->
last == s) {
152 list->
last =
nullptr;
156 for (sp = list->
first; sp !=
nullptr; sp = sp->
next) {
163 if (list->
last == s) {
209 void*
p = calloc(
n, size);
225 static int memalign_is_working = 1;
226 if (memalign_is_working) {
227 if (posix_memalign(memptr, 64, size) != 0) {
228 fprintf(stderr,
"posix_memalign not working, falling back to using malloc\n");
229 memalign_is_working = 0;
243 memset(*memptr, 0, nmemb * size);
255 void*
p = realloc(ptr, size);
263 extern "C" void*
erealloc(
void* ptr,
size_t size) {
279 free((
char*) (s1->
u.
pnum));
305 hoc_warning(
"didn't free all objects created with the old template:", s1->
name);
321 free((
char *)
OPOBJ(s1));
331 "In free_symspace may not free all of %s of type=%d\n",
364 Symbol* s1 = (*list)->first;
374 free((
char*) (*list));
408 #if defined(__APPLE__) && defined(__MACH__)
413 struct mach_task_basic_info
info;
414 mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
415 if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t) &
info, &infoCount) !=
418 return (
size_t)
info.resident_size;
419 #elif HAVE_MALLINFO || HAVE_MALLINFO2
424 auto const m = mallinfo2();
426 auto const m = mallinfo();
430 }
else if (item == 2) {
432 }
else if (item == 3) {
434 }
else if (item == 4) {
436 }
else if (item == 5) {
438 }
else if (item == 6) {
439 r = m.hblkhd + m.arena;
441 r = m.hblkhd + m.uordblks;
double chkarg(int, double low, double high)
void hoc_unlink_symbol(Symbol *s, Symlist *list)
void sym_extra_alloc(Symbol *sym)
void hoc_free_val_array(double *p, size_t size)
void * hoc_Emalloc(size_t n)
void * hoc_Ecalloc(size_t n, size_t size)
void hoc_free_string(char *p)
size_t nrn_mallinfo(int item)
void * nrn_cacheline_calloc(void **memptr, size_t nmemb, size_t size)
void notify_freed_val_array(double *p, size_t size)
Symbol * hoc_install(const char *, int, double, Symlist **)
void hoc_free_object(Object *p)
void * hoc_Erealloc(void *ptr, size_t size)
void hoc_free_pstring(char **p)
void notify_pointer_freed(void *pt)
Symbol * hoc_table_lookup(const char *s, Symlist *tab)
void hoc_warning(const char *, const char *)
void * nrn_cacheline_alloc(void **memptr, size_t size)
Symbol * hoc_install_var(const char *name, double *pval)
void hoc_dec_refcount(Object **pobj)
void hoc_install_object_data_index(Symbol *sp)
void hoc_obj_unref(Object *obj)
void hoc_free_allobjects(cTemplate *ctemplate, Symlist *sl, Objectdata *data)
void notify_freed(void *p)
void hoc_link_symbol(Symbol *sp, Symlist *list)
void free_arrayinfo(Arrayinfo *a)
void hoc_l_freelist(hoc_List **)
Symbol * install(char *s, int t)
int const size_t const size_t n
static philox4x32_key_t k
void * erealloc(void *ptr, size_t size)
void hoc_free_val(double *p)
Symlist * hoc_top_level_symlist
void * ecalloc(size_t n, size_t size)
void print_symlist(const char *s, Symlist *tab)
void hoc_free_symspace(Symbol *s1)
Objectdata * hoc_top_level_data
Symlist * hoc_built_in_symlist
void free_list(Symlist **list)
short cpublic
Note: public is a reserved keyword.
HocStruct Object * object_
HocStruct cTemplate * ctemplate