avr-libc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-commit] [2125] New file: malloc() test against external memory


From: Joerg Wunsch
Subject: [avr-libc-commit] [2125] New file: malloc() test against external memory setup.
Date: Mon, 07 Jun 2010 14:15:10 +0000

Revision: 2125
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2125
Author:   joerg_wunsch
Date:     2010-06-07 14:15:10 +0000 (Mon, 07 Jun 2010)
Log Message:
-----------
New file: malloc() test against external memory setup.

Modified Paths:
--------------
    trunk/avr-libc/ChangeLog

Added Paths:
-----------
    trunk/avr-libc/tests/simulate/stdlib/malloc-4.c

Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog    2010-06-04 14:41:36 UTC (rev 2124)
+++ trunk/avr-libc/ChangeLog    2010-06-07 14:15:10 UTC (rev 2125)
@@ -1,3 +1,7 @@
+2010-06-07  Joerg Wunsch <address@hidden>
+
+       * tests/simulate/stdlib/malloc-4.c: New file.
+
 2010-06-04  Joerg Wunsch <address@hidden>
 
        Patch submitted by Stefan Ernst:

Added: trunk/avr-libc/tests/simulate/stdlib/malloc-4.c
===================================================================
--- trunk/avr-libc/tests/simulate/stdlib/malloc-4.c                             
(rev 0)
+++ trunk/avr-libc/tests/simulate/stdlib/malloc-4.c     2010-06-07 14:15:10 UTC 
(rev 2125)
@@ -0,0 +1,81 @@
+/* Copyright (c) 2010  Joerg Wunsch
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   * Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+   * Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+   * Neither the name of the copyright holders nor the names of
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* $Id$ */
+
+/* Test heap in external memory, including correctly obeying the top
+   limit. */
+
+#ifndef        __AVR__
+
+/* There is no sense to check on host computer. */
+int main ()
+{
+    return 0;
+}
+
+#else
+
+#include <stdint.h>
+#include <stdlib.h>
+
+struct __freelist {
+        size_t sz;
+        struct __freelist *nx;
+};
+
+extern char *__brkval;          /* first location not yet allocated */
+extern struct __freelist *__flp; /* freelist pointer (head of freelist) */
+extern char *__malloc_heap_start;
+extern char *__malloc_heap_end;
+
+#define HEAP_START 0xe000
+#define HEAP_END   0xffff
+#define ALLOC_FAILS 0x2000
+#define ALLOC_WORKS 0x1ffd
+
+
+int main(void)
+{
+    void *p;
+
+    __malloc_heap_start = (void *)HEAP_START;
+    __malloc_heap_end = (void *)HEAP_END;
+
+    p = malloc(ALLOC_FAILS);
+    if (p != NULL) return __LINE__;
+
+    p = malloc(ALLOC_WORKS);
+    if (p == NULL) return __LINE__;
+    if (p != (void *)(HEAP_START + 2)) return __LINE__;
+
+    return 0;
+}
+
+#endif  /* !AVR */


Property changes on: trunk/avr-libc/tests/simulate/stdlib/malloc-4.c
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Author Id Date
Added: svn:eol-style
   + native




reply via email to

[Prev in Thread] Current Thread [Next in Thread]