2 * This file is part of the libpayload project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @defgroup malloc Memory allocation functions
39 #if defined(CONFIG_DEBUG_MALLOC) && !defined(IN_MALLOC_C)
42 extern void print_malloc_map(void); \
43 extern void free(void *); \
44 printf("free(%p) called from %s:%s:%d...\n", p, __FILE__, __func__, \
46 printf("PRE free()\n"); \
49 printf("POST free()\n"); \
54 extern void print_malloc_map(void); \
55 extern void *malloc(size_t); \
57 printf("malloc(%u) called from %s:%s:%d...\n", s, __FILE__, __func__, \
59 printf("PRE malloc\n"); \
62 printf("POST malloc (ptr = %p)\n", ptr); \
68 extern void print_malloc_map(void); \
69 extern void *calloc(size_t,size_t); \
71 printf("calloc(%u, %u) called from %s:%s:%d...\n", n, s, __FILE__, \
73 printf("PRE calloc\n"); \
76 printf("POST calloc (ptr = %p)\n", ptr); \
80 #define realloc(p,s) \
82 extern void print_malloc_map(void); \
83 extern void *realloc(void*,size_t); \
85 printf("realloc(%p, %u) called from %s:%s:%d...\n", p, s, __FILE__, \
87 printf("PRE realloc\n"); \
90 printf("POST realloc (ptr = %p)\n", ptr); \
94 #define memalign(a,s) \
96 extern void print_malloc_map(void); \
97 extern void *memalign(size_t, size_t); \
99 printf("memalign(%u, %u) called from %s:%s:%d...\n", a, s, __FILE__, \
100 __func__, __LINE__);\
101 printf("PRE memalign\n"); \
102 print_malloc_map(); \
103 ptr = memalign(a,s); \
104 printf("POST realloc (ptr = %p)\n", ptr); \
105 print_malloc_map(); \
109 void free(void *ptr);
110 void *malloc(size_t size);
111 void *calloc(size_t nmemb, size_t size);
112 void *realloc(void *ptr, size_t size);
113 void *memalign(size_t align, size_t size);
118 * @defgroup stdlib String conversion functions
121 long int strtol(const char *s, char **nptr, int base);
122 unsigned long int strtoul(const char *s, char **nptr, int base);
123 unsigned long long int strtoull(const char *s, char **nptr, int base);
124 long atol(const char *nptr);
129 * @defgroup rand Random number generator functions
132 int rand_r(unsigned int *seed);
134 void srand(unsigned int seed);
138 * Stop execution and halt the processor (this function does not return).
140 void halt(void) __attribute__ ((noreturn));
141 void exit(int status) __attribute__ ((noreturn));
142 #define abort() halt() /**< Alias for the halt() function */
146 void qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *));
147 char *getenv(const char*);