X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=vppinfra%2Fvppinfra%2Fmem_mheap.c;h=9b2af520ca658f253bcd049bdb096b55a4c9ae31;hb=9876520f9ba746ed4d9923f392911c4f1888a105;hp=e25ae35b77aa332cea7ebb7645bedd247b08f776;hpb=cb9cadad578297ffd78fa8a33670bdf1ab669e7e;p=vpp.git diff --git a/vppinfra/vppinfra/mem_mheap.c b/vppinfra/vppinfra/mem_mheap.c index e25ae35b77a..9b2af520ca6 100644 --- a/vppinfra/vppinfra/mem_mheap.c +++ b/vppinfra/vppinfra/mem_mheap.c @@ -43,18 +43,12 @@ #include #include -clib_smp_main_t clib_smp_main = { - .n_cpus = 0, - .log2_n_per_cpu_stack_bytes = 20, - .log2_n_per_cpu_vm_bytes = 28, - .n_tls_4k_pages = 1, -}; +void *clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]; -void * clib_per_cpu_mheaps[32]; - -void clib_mem_exit (void) +void +clib_mem_exit (void) { - u8 * heap = clib_mem_get_per_cpu_heap (); + u8 *heap = clib_mem_get_per_cpu_heap (); if (heap) mheap_free (heap); clib_mem_set_per_cpu_heap (0); @@ -62,18 +56,19 @@ void clib_mem_exit (void) /* Initialize CLIB heap based on memory/size given by user. Set memory to 0 and CLIB will try to allocate its own heap. */ -void * clib_mem_init (void * memory, uword memory_size) +void * +clib_mem_init (void *memory, uword memory_size) { - u8 * heap; + u8 *heap; if (memory || memory_size) heap = mheap_alloc (memory, memory_size); else { /* Allocate lots of address space since this will limit - the amount of memory the program can allocate. - In the kernel we're more conservative since some architectures - (e.g. mips) have pretty small kernel virtual address spaces. */ + the amount of memory the program can allocate. + In the kernel we're more conservative since some architectures + (e.g. mips) have pretty small kernel virtual address spaces. */ #ifdef __KERNEL__ #define MAX_VM_MEG 64 #else @@ -103,34 +98,48 @@ void * clib_mem_init (void * memory, uword memory_size) #ifdef CLIB_LINUX_KERNEL #include -uword clib_mem_get_page_size (void) -{ return PAGE_SIZE; } +uword +clib_mem_get_page_size (void) +{ + return PAGE_SIZE; +} #endif #ifdef CLIB_UNIX -uword clib_mem_get_page_size (void) -{ return getpagesize (); } +uword +clib_mem_get_page_size (void) +{ + return getpagesize (); +} #endif /* Make a guess for standalone. */ #ifdef CLIB_STANDALONE -uword clib_mem_get_page_size (void) -{ return 4096; } +uword +clib_mem_get_page_size (void) +{ + return 4096; +} #endif -u8 * format_clib_mem_usage (u8 * s, va_list * va) +u8 * +format_clib_mem_usage (u8 * s, va_list * va) { - int verbose = va_arg (*va, int); - return format (s, "%U", format_mheap, clib_mem_get_heap (), verbose); + int verbose = va_arg (*va, int); + return format (s, "%U", format_mheap, clib_mem_get_heap (), verbose); } -void clib_mem_usage (clib_mem_usage_t * u) -{ mheap_usage (clib_mem_get_heap (), u); } +void +clib_mem_usage (clib_mem_usage_t * u) +{ + mheap_usage (clib_mem_get_heap (), u); +} /* Call serial number for debugger breakpoints. */ uword clib_mem_validate_serial = 0; -void clib_mem_validate (void) +void +clib_mem_validate (void) { if (MHEAP_HAVE_SMALL_OBJECT_CACHE) clib_warning ("clib_mem_validate disabled (small object cache is ON)"); @@ -141,5 +150,16 @@ void clib_mem_validate (void) } } -void clib_mem_trace (int enable) -{ mheap_trace (clib_mem_get_heap (), enable); } +void +clib_mem_trace (int enable) +{ + mheap_trace (clib_mem_get_heap (), enable); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */