]> sourceware.org Git - newlib-cygwin.git/commitdiff
* libc/sys/mmixware/sbrk.c (_sbrk): Drop unused extern declaration
authorHans-Peter Nilsson <hp@axis.com>
Sun, 21 Oct 2012 03:41:42 +0000 (03:41 +0000)
committerHans-Peter Nilsson <hp@axis.com>
Sun, 21 Oct 2012 03:41:42 +0000 (03:41 +0000)
of "end".  Mark allocated memory by applying PRELD.

newlib/ChangeLog
newlib/libc/sys/mmixware/sbrk.c

index ce3a390e9f72bf8ae3c8259c78c1c87f18c60da8..e89ae0dc6e8dcc2cfa7a16362d70181c1bfbff46 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-21  Hans-Peter Nilsson  <hp@bitrange.com>
+
+       * libc/sys/mmixware/sbrk.c (_sbrk): Drop unused extern declaration
+       of "end".  Mark allocated memory by applying PRELD.
+
 2012-10-16  Gregory Pietsch  <gpietsch@comcast.net>
 
        * libc/stdlib/getopt.c (getopt_internal): Align handling of colon to
index de5ce5dac1d91090ba37e0298252e1d2a782cc53..f50886df86cc8d827a6dbf1f44bea3afd7653773 100644 (file)
@@ -1,6 +1,6 @@
 /* sbrk for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2012 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -34,10 +34,26 @@ __asm__ (" .global _Sbrk_high\n"
 caddr_t
 _sbrk (size_t incr)
 {
-  extern char end;             /* Defined by the linker */
   char *prev_heap_end;
 
   prev_heap_end = _Sbrk_high;
+
+  /* A simulator that requires explicit memory allocation is expected
+     to hook that to the PRELD data prefetch insn, which is otherwise
+     typically a nop.  */
+  if ((long) incr > 0)
+    {
+      size_t n = incr;
+      char *p = prev_heap_end;
+#define A(N) __asm__ ("preld " #N ",%0,0" : : "r" (p))
+#define PRELDOWNTO(N) while (n >= N + 1) { A(N); n -= N + 1; p += N + 1; }
+
+      PRELDOWNTO (255);
+      PRELDOWNTO (31);
+      PRELDOWNTO (3);
+      PRELDOWNTO (0);
+    }
+
   _Sbrk_high += incr;
   return (caddr_t) prev_heap_end;
 }
This page took 0.212776 seconds and 5 git commands to generate.