summaryrefslogtreecommitdiff
path: root/libjava/sysdep/powerpc
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/sysdep/powerpc
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/sysdep/powerpc')
-rw-r--r--libjava/sysdep/powerpc/descriptor.h9
-rw-r--r--libjava/sysdep/powerpc/locks.h97
2 files changed, 106 insertions, 0 deletions
diff --git a/libjava/sysdep/powerpc/descriptor.h b/libjava/sysdep/powerpc/descriptor.h
new file mode 100644
index 000000000..51296c222
--- /dev/null
+++ b/libjava/sysdep/powerpc/descriptor.h
@@ -0,0 +1,9 @@
+// Given a function pointer, return the code address.
+
+#ifdef _CALL_AIX
+// The function descriptor is actually multiple words,
+// but we don't care about anything except the first.
+# define UNWRAP_FUNCTION_DESCRIPTOR(X) (*(void **)(X))
+#else
+# define UNWRAP_FUNCTION_DESCRIPTOR(X) (X)
+#endif
diff --git a/libjava/sysdep/powerpc/locks.h b/libjava/sysdep/powerpc/locks.h
new file mode 100644
index 000000000..2e9eb0eb3
--- /dev/null
+++ b/libjava/sysdep/powerpc/locks.h
@@ -0,0 +1,97 @@
+// locks.h - Thread synchronization primitives. PowerPC implementation.
+
+/* Copyright (C) 2002,2008 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#ifndef __SYSDEP_LOCKS_H__
+#define __SYSDEP_LOCKS_H__
+
+#ifdef __LP64__
+#define _LARX "ldarx "
+#define _STCX "stdcx. "
+#else
+#define _LARX "lwarx "
+#ifdef __PPC405__
+#define _STCX "sync; stwcx. "
+#else
+#define _STCX "stwcx. "
+#endif
+#endif
+
+typedef size_t obj_addr_t; /* Integer type big enough for object */
+ /* address. */
+
+inline static bool
+compare_and_swap (volatile obj_addr_t *addr, obj_addr_t old,
+ obj_addr_t new_val)
+{
+ obj_addr_t ret;
+
+ __asm__ __volatile__ (
+ " " _LARX "%0,0,%1 \n"
+ " xor. %0,%3,%0\n"
+ " bne $+12\n"
+ " " _STCX "%2,0,%1\n"
+ " bne- $-16\n"
+ : "=&r" (ret)
+ : "r" (addr), "r" (new_val), "r" (old)
+ : "cr0", "memory");
+
+ /* This version of __compare_and_swap is to be used when acquiring
+ a lock, so we don't need to worry about whether other memory
+ operations have completed, but we do need to be sure that any loads
+ after this point really occur after we have acquired the lock. */
+ __asm__ __volatile__ ("isync" : : : "memory");
+ return ret == 0;
+}
+
+inline static void
+release_set (volatile obj_addr_t *addr, obj_addr_t new_val)
+{
+ __asm__ __volatile__ ("sync" : : : "memory");
+ *addr = new_val;
+}
+
+inline static bool
+compare_and_swap_release (volatile obj_addr_t *addr, obj_addr_t old,
+ obj_addr_t new_val)
+{
+ obj_addr_t ret;
+
+ __asm__ __volatile__ ("sync" : : : "memory");
+
+ __asm__ __volatile__ (
+ " " _LARX "%0,0,%1 \n"
+ " xor. %0,%3,%0\n"
+ " bne $+12\n"
+ " " _STCX "%2,0,%1\n"
+ " bne- $-16\n"
+ : "=&r" (ret)
+ : "r" (addr), "r" (new_val), "r" (old)
+ : "cr0", "memory");
+
+ return ret == 0;
+}
+
+// Ensure that subsequent instructions do not execute on stale
+// data that was loaded from memory before the barrier.
+inline static void
+read_barrier ()
+{
+ __asm__ __volatile__ ("isync" : : : "memory");
+}
+
+// Ensure that prior stores to memory are completed with respect to other
+// processors.
+inline static void
+write_barrier ()
+{
+ __asm__ __volatile__ ("sync" : : : "memory");
+}
+
+#endif