pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:8096:    *!    *! @seealso    *! @[_verify_internals()]    */   PMOD_EXPORT void f__memory_usage(INT32 args)   {    size_t num,size;    struct svalue *ss;   #ifdef USE_DL_MALLOC    struct mallinfo mi = dlmallinfo(); + #elif HAVE_MALLINFO2 +  struct mallinfo2 mi = mallinfo2();   #elif HAVE_MALLINFO    struct mallinfo mi = mallinfo();   #endif       pop_n_elems(args);    ss=Pike_sp;       /* TODO: If USE_DL_MALLOC is defined then this will report the    * statistics from our bundled Doug Lea malloc, and not the    * underlying system malloc. Ideally we should include both. */    - #if defined(HAVE_MALLINFO) || defined(USE_DL_MALLOC) + #if defined(HAVE_MALLINFO2) || defined(HAVE_MALLINFO) || defined(USE_DL_MALLOC)       push_static_text("num_malloc_blocks");    push_ulongest(1 + mi.hblks); /* 1 for the arena. */    push_static_text("malloc_block_bytes"); -  + #ifdef HAVE_MALLINFO2 +  size = mi.arena + mi.hblkhd; + #else    if (mi.arena < 0) {    /* Kludge for broken Linux libc, where the fields are ints.    *    * 31-bit overflow, so perform an unsigned read.    */    size = (unsigned int)mi.arena;    } else {    /* On Solaris the fields are unsigned long (and may thus be 64-bit). */    size = mi.arena;    }
pike.git/src/builtin_functions.c:8136: Inside #if defined(HAVE_MALLINFO) || defined(USE_DL_MALLOC)
   *    * The hblkhd value on proper implementations should be    * small enough not to affect the total much, so no need    * for a special case.    */    if (mi.hblkhd < 0) {    size += (unsigned int)mi.hblkhd;    } else {    size += mi.hblkhd;    } + #endif    push_ulongest(size);       push_static_text("num_malloc");    push_ulongest(mi.ordblks + mi.smblks);    push_static_text("malloc_bytes"); -  + #ifdef HAVE_MALLINFO2 +  size = mi.uordblks + mi.usmblks; + #else    if (mi.uordblks < 0) {    size = (unsigned int)mi.uordblks;    } else {    size = mi.uordblks;    }    if (mi.smblks) {    /* NB: Not dlmalloc where usmblks contains the max uordblks value. */    if (mi.usmblks < 0) {    size += (unsigned int)mi.usmblks;    } else {    size += mi.usmblks;    }    } -  + #endif    push_ulongest(size);       push_static_text("num_free_blocks");    push_int(1);    push_static_text("free_block_bytes"); -  + #ifdef HAVE_MALLINFO2 +  size = mi.fsmblks + mi.fordblks; + #else    if (mi.fsmblks < 0) {    size = (unsigned int)mi.fsmblks;    } else {    size = mi.fsmblks;    }    if (mi.fordblks < 0) {    size += (unsigned int)mi.fordblks;    } else {    size += mi.fordblks;    } -  + #endif    push_ulongest(size);       count_string_types();      #endif      #define COUNT(TYPE) do { \    PIKE_CONCAT3(count_memory_in_, TYPE, s)(&num, &size); \    push_static_text("num_" #TYPE "s"); \    push_ulongest(num); \