diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-22 08:06:44 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-22 08:06:44 +0200 |
commit | 4c05bb1445f87756c0f1f8c00ef87fbe96d737f2 (patch) | |
tree | f85a6bfe97e419209f9fbada2b3b7d5a5928ee48 /common | |
parent | ccf0e4b4d143f8648bd63142c5fa3fad650d9a0e (diff) | |
parent | 151d21bc3dd326f434d9fdd7fedbed42c255cda0 (diff) | |
download | barebox-4c05bb1445f87756c0f1f8c00ef87fbe96d737f2.tar.gz barebox-4c05bb1445f87756c0f1f8c00ef87fbe96d737f2.tar.xz |
Merge branch 'for-next/misc' into for-next/usb-gadget
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 2 | ||||
-rw-r--r-- | common/dlmalloc.c | 169 | ||||
-rw-r--r-- | common/hush.c | 2 |
3 files changed, 3 insertions, 170 deletions
diff --git a/common/Kconfig b/common/Kconfig index bba7f159c1..e7c22e5bae 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -676,6 +676,7 @@ config COMPILE_LOGLEVEL 5 normal but significant condition (notice) 6 informational (info) 7 debug-level messages (debug) + 8 verbose debug messages (vdebug) config DEFAULT_LOGLEVEL int "default loglevel" @@ -692,6 +693,7 @@ config DEFAULT_LOGLEVEL 5 normal but significant condition (notice) 6 informational (info) 7 debug-level messages (debug) + 8 verbose debug messages (vdebug) config DEBUG_INFO bool diff --git a/common/dlmalloc.c b/common/dlmalloc.c index d831e90fe3..499ec93c28 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1712,29 +1712,6 @@ void *memalign(size_t alignment, size_t bytes) return chunk2mem(p); } -#if 0 -/* - * valloc just invokes memalign with alignment argument equal - * to the page size of the system (or as near to this as can - * be figured out from all the includes/defines above.) - */ -void *valloc(size_t bytes) -{ - return memalign(malloc_getpagesize, bytes); -} -#endif - -/* - * pvalloc just invokes valloc for the nearest pagesize - * that will accommodate request - */ -void *pvalloc (size_t bytes) -{ - size_t pagesize = malloc_getpagesize; - - return memalign(pagesize, (bytes + pagesize - 1) & ~(pagesize - 1)); -} - /* * * calloc calls malloc, then zeroes out the allocated chunk. @@ -1774,115 +1751,6 @@ void *calloc(size_t n, size_t elem_size) } } -/* - * - * cfree just calls free. It is needed/defined on some systems - * that pair it with calloc, presumably for odd historical reasons. - */ -#if !defined(INTERNAL_LINUX_C_LIB) || !defined(__ELF__) -void cfree(void *mem) -{ - free(mem); -} -#endif - -/* - Malloc_trim gives memory back to the system (via negative - arguments to sbrk) if there is unused memory at the `high' end of - the malloc pool. You can call this after freeing large blocks of - memory to potentially reduce the system-level memory requirements - of a program. However, it cannot guarantee to reduce memory. Under - some allocation patterns, some large free blocks of memory will be - locked between two used chunks, so they cannot be given back to - the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, - only the minimum amount of memory to maintain internal data - structures will be left (one page or less). Non-zero arguments - can be supplied to maintain enough trailing space to service - future expected allocations without having to re-obtain memory - from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. -*/ -#ifdef USE_MALLOC_TRIM -int malloc_trim(size_t pad) -{ - long top_size; /* Amount of top-most memory */ - long extra; /* Amount to release */ - char *current_brk; /* address returned by pre-check sbrk call */ - char *new_brk; /* address returned by negative sbrk call */ - - unsigned long pagesz = malloc_getpagesize; - - top_size = chunksize(top); - extra = ((top_size - pad - MINSIZE + (pagesz - 1)) / pagesz - - 1) * pagesz; - - if (extra < (long)pagesz) /* Not enough memory to release */ - return 0; - - else { - /* Test to make sure no one else called sbrk */ - current_brk = (char*)(sbrk(0)); - if (current_brk != (char*)(top) + top_size) - return 0; /* Apparently we don't own memory; must fail */ - - else { - new_brk = (char *) (sbrk(-extra)); - - if (new_brk == (char*)(NULL)) { /* sbrk failed? */ - /* Try to figure out what we have */ - current_brk = (char*)(sbrk (0)); - top_size = current_brk - (char*) top; - if (top_size >= (long)MINSIZE) { /* if not, we are very very dead! */ - sbrked_mem = current_brk - sbrk_base; - set_head(top, top_size | PREV_INUSE); - } - return 0; - } - - else { - /* Success. Adjust top accordingly. */ - set_head(top, (top_size - extra) | PREV_INUSE); - sbrked_mem -= extra; - return 1; - } - } - } -} -#endif - -/* - * malloc_usable_size: - * - * This routine tells you how many bytes you can actually use in an - * allocated chunk, which may be more than you requested (although - * often not). You can use this many bytes without worrying about - * overwriting other allocated objects. Not a particularly great - * programming practice, but still sometimes useful. - */ -size_t malloc_usable_size(void *mem) -{ - mchunkptr p; - - if (!mem) - return 0; - else { - p = mem2chunk(mem); - if (!chunk_is_mmapped(p)) { - if (!inuse(p)) - return 0; - return chunksize(p) - SIZE_SZ; - } - return chunksize(p) - 2 * SIZE_SZ; - } -} - - - - /* Utility to update current_mallinfo for malloc_stats and mallinfo() */ #ifdef CONFIG_CMD_MEMINFO @@ -1956,43 +1824,6 @@ void malloc_stats(void) #endif /* CONFIG_CMD_MEMINFO */ /* - mallopt: - - mallopt is the general SVID/XPG interface to tunable parameters. - The format is to provide a (parameter-number, parameter-value) pair. - mallopt then sets the corresponding parameter to the argument - value if it can (i.e., so long as the value is meaningful), - and returns 1 if successful else 0. - - See descriptions of tunable parameters above. -*/ -#ifndef __BAREBOX__ -int mallopt(int param_number, int value) -{ - switch (param_number) { - case M_TRIM_THRESHOLD: - trim_threshold = value; - return 1; - case M_TOP_PAD: - top_pad = value; - return 1; - case M_MMAP_THRESHOLD: - mmap_threshold = value; - return 1; - case M_MMAP_MAX: - if (value != 0) - return 0; - else - n_mmaps_max = value; - return 1; - - default: - return 0; - } -} -#endif - -/* History: diff --git a/common/hush.c b/common/hush.c index 6be43cf8ea..f6aaa03514 100644 --- a/common/hush.c +++ b/common/hush.c @@ -1724,7 +1724,7 @@ static int parse_stream_outer(struct p_context *ctx, struct in_str *inp, int fla b_free(&temp); } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP)); /* loop on syntax errors, return on EOF */ - return (code != 0) ? 1 : 0; + return code; } static int parse_string_outer(struct p_context *ctx, const char *s, int flag) |