aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/decompress/mm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/decompress/mm.h')
-rw-r--r--include/linux/decompress/mm.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
index 12ff8c3f1d05..ad5ec1d0475e 100644
--- a/include/linux/decompress/mm.h
+++ b/include/linux/decompress/mm.h
@@ -14,18 +14,28 @@
14 14
15/* Code active when included from pre-boot environment: */ 15/* Code active when included from pre-boot environment: */
16 16
17/*
18 * Some architectures want to ensure there is no local data in their
19 * pre-boot environment, so that data can arbitarily relocated (via
20 * GOT references). This is achieved by defining STATIC_RW_DATA to
21 * be null.
22 */
23#ifndef STATIC_RW_DATA
24#define STATIC_RW_DATA static
25#endif
26
17/* A trivial malloc implementation, adapted from 27/* A trivial malloc implementation, adapted from
18 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 28 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
19 */ 29 */
20static unsigned long malloc_ptr; 30STATIC_RW_DATA unsigned long malloc_ptr;
21static int malloc_count; 31STATIC_RW_DATA int malloc_count;
22 32
23static void *malloc(int size) 33static void *malloc(int size)
24{ 34{
25 void *p; 35 void *p;
26 36
27 if (size < 0) 37 if (size < 0)
28 error("Malloc error"); 38 return NULL;
29 if (!malloc_ptr) 39 if (!malloc_ptr)
30 malloc_ptr = free_mem_ptr; 40 malloc_ptr = free_mem_ptr;
31 41
@@ -35,7 +45,7 @@ static void *malloc(int size)
35 malloc_ptr += size; 45 malloc_ptr += size;
36 46
37 if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr) 47 if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
38 error("Out of memory"); 48 return NULL;
39 49
40 malloc_count++; 50 malloc_count++;
41 return p; 51 return p;