$extrastylesheet
avr-libc
2.0.0
Standard C library for AVR-GCC
|
AVR Libc Home Page |
![]() |
AVR Libc Development Pages |
|||
Main Page |
User Manual |
Library Reference |
FAQ |
Example Projects |
00001 /* Copyright (c) 2004, Joerg Wunsch 00002 All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions are met: 00006 00007 * Redistributions of source code must retain the above copyright 00008 notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright 00010 notice, this list of conditions and the following disclaimer in 00011 the documentation and/or other materials provided with the 00012 distribution. 00013 * Neither the name of the copyright holders nor the names of 00014 contributors may be used to endorse or promote products derived 00015 from this software without specific prior written permission. 00016 00017 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 /* $Id: stdlib_private.h 1657 2008-03-24 17:11:08Z arcanum $ */ 00031 00032 #include <inttypes.h> 00033 #include <stdlib.h> 00034 #include <avr/io.h> 00035 00036 #if !defined(__DOXYGEN__) 00037 00038 struct __freelist { 00039 size_t sz; 00040 struct __freelist *nx; 00041 }; 00042 00043 #endif 00044 00045 extern char *__brkval; /* first location not yet allocated */ 00046 extern struct __freelist *__flp; /* freelist pointer (head of freelist) */ 00047 extern size_t __malloc_margin; /* user-changeable before the first malloc() */ 00048 extern char *__malloc_heap_start; 00049 extern char *__malloc_heap_end; 00050 00051 #ifndef __AVR__ 00052 00053 /* 00054 * When compiling malloc.c/realloc.c natively on a host machine, it will 00055 * include a main() that performs a regression test. This is meant as 00056 * a debugging aid, where a normal source-level debugger will help to 00057 * verify that the various allocator structures have the desired 00058 * appearance at each stage. 00059 * 00060 * When cross-compiling with avr-gcc, it will compile into just the 00061 * library functions malloc() and free(). 00062 */ 00063 #define MALLOC_TEST 00064 00065 #endif /* !__AVR__ */ 00066 00067 #ifdef MALLOC_TEST 00068 00069 extern void *mymalloc(size_t); 00070 extern void myfree(void *); 00071 extern void *myrealloc(void *, size_t); 00072 00073 #define malloc mymalloc 00074 #define free myfree 00075 #define realloc myrealloc 00076 00077 #define __heap_start mymem[0] 00078 #define __heap_end mymem[256] 00079 extern char mymem[]; 00080 #define STACK_POINTER() (mymem + 256) 00081 00082 #else /* !MALLOC_TEST */ 00083 00084 extern char __heap_start; 00085 extern char __heap_end; 00086 00087 /* Needed for definition of AVR_STACK_POINTER_REG. */ 00088 #include <avr/io.h> 00089 00090 #define STACK_POINTER() ((char *)AVR_STACK_POINTER_REG) 00091 00092 #endif /* MALLOC_TEST */