Changeset 1925 for trunk/src/kmk/make.h


Ignore:
Timestamp:
Oct 24, 2008, 5:32:21 AM (17 years ago)
Author:
bird
Message:

kmk: some stats adjustments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/make.h

    r1918 r1925  
    196196#endif
    197197
     198#ifdef CONFIG_WITH_MAKE_STATS
     199extern long make_stats_allocations;
     200extern unsigned long make_stats_allocated;
     201extern unsigned long make_stats_allocated_sum;
     202extern unsigned long make_stats_ht_lookups;
     203extern unsigned long make_stats_ht_collisions;
     204
     205# ifdef __APPLE__
     206#  include <malloc/malloc.h>
     207#  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_size(ptr)
     208
     209# elif defined(__linux__) /* glibc */
     210#  include <malloc.h>
     211#  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_usable_size(ptr)
     212
     213# elif defined(_MSC_VER) || defined(__OS2__)
     214#  define SIZE_OF_HEAP_BLOCK(ptr)   _msize(ptr)
     215
     216# else
     217#  include <stdlib.h>
     218#  define SIZE_OF_HEAP_BLOCK(ptr)   0
     219#endif
     220
     221# if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
     222#  define free xfree
     223extern void xfree (void *);
     224# endif
     225
     226# define MAKE_STATS_3(expr) do { expr; } while (0)
     227# define MAKE_STATS_2(expr) do { expr; } while (0)
     228# define MAKE_STATS(expr)   do { expr; } while (0)
     229#else
     230# define MAKE_STATS_3(expr) do { } while (0)
     231# define MAKE_STATS_2(expr) do { } while (0)
     232# define MAKE_STATS(expr)   do { } while (0)
     233#endif
     234
     235
    198236#ifndef CHAR_BIT
    199237# define CHAR_BIT 8
     
    514552  struct alloccache_free_ent *free_head;
    515553  unsigned int size;
    516   unsigned int alloc_count;
    517554  unsigned int total_count;
     555  unsigned long alloc_count;
     556  unsigned long free_count;
    518557  const char *name;
    519558  struct alloccache *next;
     
    545584  else
    546585    f = alloccache_alloc_grow (cache);
    547   cache->alloc_count++;
     586  MAKE_STATS(cache->alloc_count++;);
    548587  return f;
    549588}
     
    573612  f->next = cache->free_head;
    574613  cache->free_head = f;
    575   cache->alloc_count--;
     614  MAKE_STATS(cache->free_count++;);
    576615}
    577616
     
    855894#endif /* __EMX__ (bird) */
    856895
    857 #ifdef CONFIG_WITH_MAKE_STATS
    858 extern long make_stats_allocations;
    859 extern unsigned long make_stats_allocated;
    860 extern unsigned long make_stats_allocated_sum;
    861 extern unsigned long make_stats_ht_lookups;
    862 extern unsigned long make_stats_ht_collisions;
    863 
    864 # ifdef __APPLE__
    865 #  include <malloc/malloc.h>
    866 #  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_size(ptr)
    867 
    868 # elif defined(__linux__) /* glibc */
    869 #  include <malloc.h>
    870 #  define SIZE_OF_HEAP_BLOCK(ptr)   malloc_usable_size(ptr)
    871 
    872 # elif defined(_MSC_VER) || defined(__OS2__)
    873 #  define SIZE_OF_HEAP_BLOCK(ptr)   _msize(ptr)
    874 
    875 # else
    876 #  include <stdlib.h>
    877 #  define SIZE_OF_HEAP_BLOCK(ptr)   0
    878 #endif
    879 
    880 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
    881 #  define free xfree
    882 extern void xfree (void *);
    883 # endif
    884 
    885 # define MAKE_STATS_3(expr) do { expr; } while (0)
    886 # define MAKE_STATS_2(expr) do { expr; } while (0)
    887 # define MAKE_STATS(expr)   do { expr; } while (0)
    888 #else
    889 # define MAKE_STATS_3(expr) do { } while (0)
    890 # define MAKE_STATS_2(expr) do { } while (0)
    891 # define MAKE_STATS(expr)   do { } while (0)
    892 #endif
    893 
    894896#ifdef CONFIG_WITH_IF_CONDITIONALS
    895897extern int expr_eval_if_conditionals(char *line, const struct floc *flocp);
Note: See TracChangeset for help on using the changeset viewer.