summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/h8300/ptrace.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-02-02 19:03:57 +0000
committerEric Andersen <andersen@codepoet.org>2002-02-02 19:03:57 +0000
commit8dc1d08d0c3a5abe3856b04a5a864227fe0ba62d (patch)
tree65d254a60aec64fb933cf3c4c11ffa7235e02413 /libc/sysdeps/linux/h8300/ptrace.c
parent327b0c83302af0a288c65a03f4f2c82af321bd28 (diff)
Add in support for the Hitach H8/300H architecture,
contributed by Yoshinori Sato <qzb04471@nifty.ne.jp>
Diffstat (limited to 'libc/sysdeps/linux/h8300/ptrace.c')
-rw-r--r--libc/sysdeps/linux/h8300/ptrace.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/h8300/ptrace.c b/libc/sysdeps/linux/h8300/ptrace.c
new file mode 100644
index 000000000..acd6db0b4
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/ptrace.c
@@ -0,0 +1,33 @@
+
+#include <errno.h>
+#include <asm/ptrace.h>
+#include <sys/syscall.h>
+
+int
+ptrace(int request, int pid, int addr, int data)
+{
+ long ret;
+ long res;
+ if (request > 0 && request < 4) (long *)data = &ret;
+
+ __asm__ volatile ("mov.l %1,er0\n\t"
+ "mov.l %2,er1\n\t"
+ "mov.l %3,er2\n\t"
+ "mov.l %4,er3\n\t"
+ "mov.l %5,er4\n\t"
+ "trapa #0\n\t"
+ "mov.l er0,%0"
+ :"=g" (res)
+ :"i" (__NR_ptrace), "g" (request), "g" (pid),
+ "g" (addr), "g" (data) : "er0", "er1", "er2", "er3", "er4");
+
+ if (res >= 0) {
+ if (request > 0 && request < 4) {
+ __set_errno(0);
+ return (ret);
+ }
+ return (int) res;
+ }
+ __set_errno(-res);
+ return -1;
+}