AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Reference FAQ Example Projects

stdlib_private.h

01	1 Copyright (c) 2004, Joerg Wunsch
022All rights reserved. 033
044Redistribution and use in source and binary forms, with or without 055modification, are permitted provided that the following conditions are met: 066 077* Redistributions of source code must retain the above copyright 088notice, this list of conditions and the following disclaimer. 099* Redistributions in binary form must reproduce the above copyright 1010notice, this list of conditions and the following disclaimer in 1111the documentation and/or other materials provided with the 1212distribution. 1313* Neither the name of the copyright holders nor the names of 1414contributors may be used to endorse or promote products derived 1515from this software without specific prior written permission. 1616 1717THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1818AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1919IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2020ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2121LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2222CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2323SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2424INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2525CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2626ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2727POSSIBILITY OF SUCH DAMAGE. 2828*/ 2929 3030/* $Id: stdlib_private.h 1657 2008-03-24 17:11:08Z arcanum $ */ 3131 3232#include <inttypes.h> 3333#include <stdlib.h> 3434#include <avr/io.h> 3535 3636#if !defined(__DOXYGEN__) 3737 3838struct __freelist { 3939size_t sz; 4040struct __freelist *nx; 4141}; 4242 4343#endif 4444 4545extern char *__brkval; /* first location not yet allocated */ 4646extern struct __freelist *__flp; /* freelist pointer (head of freelist) */ 4747extern size_t __malloc_margin; /* user-changeable before the first malloc() */ 4848extern char *__malloc_heap_start; 4949extern char *__malloc_heap_end; 5050 5151#ifndef __AVR__ 5252 5353/* 5454* When compiling malloc.c/realloc.c natively on a host machine, it will 5555* include a main() that performs a regression test. This is meant as 5656* a debugging aid, where a normal source-level debugger will help to 5757* verify that the various allocator structures have the desired 5858* appearance at each stage. 5959* 6060* When cross-compiling with avr-gcc, it will compile into just the 6161* library functions malloc() and free(). 6262*/ 6363#define MALLOC_TEST 6464 6565#endif /* !__AVR__ */ 6666 6767#ifdef MALLOC_TEST 6868 6969extern void *mymalloc(size_t); 7070extern void myfree(void *); 7171extern void *myrealloc(void *, size_t); 7272 7373#define malloc mymalloc 7474#define free myfree 7575#define realloc myrealloc 7676 7777#define __heap_start mymem[0] 7878#define __heap_end mymem[256] 7979extern char mymem[]; 8080#define STACK_POINTER() (mymem + 256) 8181 8282#else /* !MALLOC_TEST */ 83838484extern char __heap_start; 8585extern char __heap_end; 8686 8787/* Needed for definition of AVR_STACK_POINTER_REG. */ 8888#include <avr/io.h> 8989 9090#define STACK_POINTER() ((char *)AVR_STACK_POINTER_REG) 9191 9292#endif /* MALLOC_TEST */

__malloc_heap_end char * __malloc_heap_end

Definition: malloc.c:61

io.h

__malloc_heap_start char * __malloc_heap_start

Definition: malloc.c:60

inttypes.h

__malloc_margin size_t __malloc_margin

Definition: malloc.c:59

stdlib.h