summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/h8300/brk.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-07-15 07:34:00 +0000
committerEric Andersen <andersen@codepoet.org>2004-07-15 07:34:00 +0000
commit71150804d1ac8ed2f7b9c6d3025fd415c58b129e (patch)
treeaab8c892a813847614070f73e711178cd3c9ec74 /libc/sysdeps/linux/h8300/brk.c
parent255fbb6abcef56c5f8c36383d49a902686f258f5 (diff)
h8300 updates from Yoshinori Sato
Diffstat (limited to 'libc/sysdeps/linux/h8300/brk.c')
-rw-r--r--libc/sysdeps/linux/h8300/brk.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/h8300/brk.c b/libc/sysdeps/linux/h8300/brk.c
new file mode 100644
index 000000000..71de9501f
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/brk.c
@@ -0,0 +1,33 @@
+/* brk on H8/300 by ysato */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+
+/* This must be initialized data because commons can't have aliases. */
+void *___brk_addr = 0;
+
+
+int brk (void *addr)
+{
+ void *newbrk;
+
+ asm ("mov.l %2,er1\n\t"
+ "mov.l %1,er0\n\t"
+ "trapa #0\n\t"
+ "mov.l er0,%0"
+ : "=r" (newbrk)
+ : "0" (__NR_brk), "g" (addr)
+ : "er0","er1");
+
+ ___brk_addr = newbrk;
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}