Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2012-10-21 07:41:42 +0400
committerHans-Peter Nilsson <hp@axis.com>2012-10-21 07:41:42 +0400
commit1ad660ece1c5ce9d76beb7a9756c6d111c452e81 (patch)
tree50bd0e991af970e6df6aac46cf5f8465e7ec1891 /newlib/libc/sys/mmixware
parent821d6519174d700c99184db0485fde8b53419a18 (diff)
* libc/sys/mmixware/sbrk.c (_sbrk): Drop unused extern declaration
of "end". Mark allocated memory by applying PRELD.
Diffstat (limited to 'newlib/libc/sys/mmixware')
-rw-r--r--newlib/libc/sys/mmixware/sbrk.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/newlib/libc/sys/mmixware/sbrk.c b/newlib/libc/sys/mmixware/sbrk.c
index de5ce5dac..f50886df8 100644
--- a/newlib/libc/sys/mmixware/sbrk.c
+++ b/newlib/libc/sys/mmixware/sbrk.c
@@ -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;
}