This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] enable libjava on HP-UX PA
- From: Andreas Tobler <toa at pop dot agri dot ch>
- To: Java Patches <java-patches at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>, John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Sat, 20 May 2006 00:02:13 +0200
- Subject: [patch] enable libjava on HP-UX PA
Hello all,
this patch brings libjava support for the HP-UX PA 32-bit platform.
To use it/try it you should have at least PHSS_33033 (actual is
PHSS_33035), a linker patch, and the kernel parameters maxssiz set to >=
16MB.
It does not work on HP-UX 10.20/11.00 and it also doesn't work yet on
hppa64-hp-hpux*. This is future work.
This contribution is done by Dave Anglin and me.
Thanks to Dave to for the very detailed help.
There is one bit which is missing, but this is a separate patch.
Coming soon...
Results for this port can be found on the results mailing list.
Ok for main?
Thanks,
Andreas
2006-05-19 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
Andreas Tobler <a.tobler@schweiz.ch>
* configure.in: Enable libgcj for hppa*-hp-hpux11*.
* configure: Rebuilt.
2006-05-19 Andreas Tobler <a.tobler@schweiz.ch>
John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* configure.ac: Add the POSIX thread libs to the HP-UX PA
configuration. Add signal specification for HP-UX PA.
* configure: Rebuilt.
* configure.host: Add defaults for the HP-UX PA architecture.
Add descriptor files for HP-UX PA 32-bit and 64-bit.
* include/hppa-signal.h: New file.
* include/posix.h: Add shared library suffix for HP-UX.
* sysdep/pa/descriptor-pa32-hpux.h: New file.
* sysdep/pa/descriptor-pa64-hpux.h: Likewise.
Index: configure.in
===================================================================
--- configure.in (revision 113913)
+++ configure.in (working copy)
@@ -584,6 +584,9 @@
hppa*64*-*-*)
noconfigdirs="$noconfigdirs ${libgcj}"
;;
+ hppa*-hp-hpux11*)
+ noconfigdirs="$noconfigdirs ld shellutils"
+ ;;
hppa*-*-*)
# According to Alexandre Oliva <aoliva@redhat.com>, libjava won't
# build on HP-UX 10.20.
Index: configure.ac
===================================================================
--- configure.ac (revision 113913)
+++ configure.ac (working copy)
@@ -805,7 +805,7 @@
THREADLDFLAGS=-pthread
THREADSPEC=-lpthread
;;
- alpha*-dec-osf*)
+ alpha*-dec-osf* | hppa*-hp-hpux*)
THREADCXXFLAGS=-pthread
# boehm-gc needs some functions from librt, so link that too.
THREADLIBS='-lpthread -lrt'
@@ -1371,6 +1371,9 @@
hppa*-*-linux*)
SIGNAL_HANDLER=include/pa-signal.h
;;
+ hppa*-hp-hpux*)
+ SIGNAL_HANDLER=include/hppa-signal.h
+ ;;
ia64-*-linux*)
SIGNAL_HANDLER=include/dwarf2-signal.h
;;
Index: configure.host
===================================================================
--- configure.host (revision 113913)
+++ configure.host (working copy)
@@ -127,7 +127,7 @@
enable_hash_synchronization_default=yes
IEEESPEC=-mieee
;;
- hppa-*)
+ hppa*-*)
sysdeps_dir=pa
libgcj_interpreter=yes
enable_hash_synchronization_default=yes
@@ -273,6 +273,11 @@
enable_hash_synchronization_default=no
slow_pthread_self=
;;
+ hppa*-hp-hpux11.*)
+ slow_pthread_self=no
+ can_unwind_signal=yes
+ DIVIDESPEC=-fuse-divide-subroutine
+ ;;
esac
case "${host}" in
@@ -288,6 +293,14 @@
descriptor_h=sysdep/descriptor-y.h
;;
+ hppa*64*-*-hpux*)
+ descriptor_h=sysdep/pa/descriptor-pa64-hpux.h
+ ;;
+
+ hppa*-*-hpux*)
+ descriptor_h=sysdep/pa/descriptor-pa32-hpux.h
+ ;;
+
hppa*-*)
descriptor_h=sysdep/pa/descriptor.h
;;
Index: include/posix.h
===================================================================
--- include/posix.h (revision 113913)
+++ include/posix.h (working copy)
@@ -44,6 +44,8 @@
#define _Jv_platform_solib_prefix "lib"
#if defined(__APPLE__) && defined(__MACH__)
#define _Jv_platform_solib_suffix ".dylib"
+#elif defined(HPUX) && defined(HP_PA)
+#define _Jv_platform_solib_suffix ".sl"
#else
#define _Jv_platform_solib_suffix ".so"
#endif
Index: include/hppa-signal.h
===================================================================
--- include/hppa-signal.h (revision 0)
+++ include/hppa-signal.h (revision 0)
@@ -0,0 +1,68 @@
+/* hppa-signal.h - Catch runtime signals and turn them into exceptions,
+ on a HP-UX 11 PA system. */
+
+/* Copyright (C) 2006 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. */
+
+/* This file is really more of a specification. The rest of the system
+ should be arranged so that this Just Works. */
+
+#ifndef JAVA_SIGNAL_H
+# define JAVA_SIGNAL_H 1
+
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+# define HANDLE_SEGV 1
+# undef HANDLE_FPE
+
+#define SIGNAL_HANDLER(_name) \
+ static void _name (int _dummy __attribute__ ((unused)), \
+ siginfo_t *_info __attribute__ ((__unused__)), \
+ void *arg __attribute__ ((__unused__)))
+
+#define MAKE_THROW_FRAME(_exception) \
+do \
+{ \
+ ucontext_t *_context = (ucontext_t *) arg; \
+ (void)_dummy; \
+ (void)_info; \
+ mcontext_t *mc = &(_context->uc_mcontext); \
+ SetSSReg (mc, ss_pcoq_head, GetSSReg (mc, ss_pcoq_tail)); \
+ SetSSReg (mc, ss_pcsq_head, GetSSReg (mc, ss_pcsq_tail)); \
+ /* This part is not quit right if the head pc was pointing \
+ at a branch. The tail needs to be adjusted to the branch \
+ target if the branch is taken. The tail space register \
+ may need adjustment as well if the branch is an interspace \
+ branch. */ \
+ SetSSReg (mc, ss_pcoq_tail, (GetSSReg (mc, ss_pcoq_tail) + 4)); \
+ \
+ } \
+while (0)
+
+# define INIT_SEGV \
+ do { \
+ struct sigaction sa; \
+ sa.sa_sigaction = catch_segv; \
+ sigemptyset (&sa.sa_mask); \
+ sa.sa_flags = SA_SIGINFO | SA_NODEFER; \
+ sigaction (SIGSEGV, &sa, NULL); \
+ } while (0)
+
+# define INIT_FPE \
+ do { \
+ struct sigaction sa; \
+ sa.sa_sigaction = catch_fpe; \
+ sigemptyset (&sa.sa_mask); \
+ sa.sa_flags = SA_SIGINFO | SA_NODEFER; \
+ sigaction (SIGFPE, &sa, NULL); \
+ } while (0)
+
+#endif /* JAVA_SIGNAL_H */
Index: sysdep/pa/descriptor-pa32-hpux.h
===================================================================
--- sysdep/pa/descriptor-pa32-hpux.h (revision 0)
+++ sysdep/pa/descriptor-pa32-hpux.h (revision 0)
@@ -0,0 +1,91 @@
+/* descriptor-pa32-hpux.h - Given a function pointer, extract and return the
+ actual code address of the corresponding function.
+
+ This is done by checking if the plabel bit is set. If it's not set,
+ return the function pointer. If it's set, mask it off and extract
+ the address from the function descriptor. This address may point
+ to an export stub. If so, extract the branch target from the stub
+ and return it. Otherwise, the address from the function descriptor
+ is returned.
+
+ Copyright (C) 2006 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. */
+
+#define UNWRAP_FUNCTION_DESCRIPTOR pa_unwrap_function_descriptor
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Extract bit field from word using HP's numbering (MSB = 0). */
+#define GET_FIELD(X, FROM, TO) \
+ ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
+
+static inline int
+sign_extend (int x, int len)
+{
+ int signbit = (1 << (len - 1));
+ int mask = (signbit << 1) - 1;
+ return ((x & mask) ^ signbit) - signbit;
+}
+
+/* Extract a 17-bit signed constant from branch instructions. */
+static inline int
+extract_17 (unsigned word)
+{
+ return sign_extend (GET_FIELD (word, 19, 28)
+ | GET_FIELD (word, 29, 29) << 10
+ | GET_FIELD (word, 11, 15) << 11
+ | (word & 0x1) << 16, 17);
+}
+
+/* Extract a 22-bit signed constant from branch instructions. */
+static inline int
+extract_22 (unsigned word)
+{
+ return sign_extend (GET_FIELD (word, 19, 28)
+ | GET_FIELD (word, 29, 29) << 10
+ | GET_FIELD (word, 11, 15) << 11
+ | GET_FIELD (word, 6, 10) << 16
+ | (word & 0x1) << 21, 22);
+}
+
+static void *
+pa_unwrap_function_descriptor (void *addr)
+{
+ unsigned int *tmp_addr;
+
+ /* Check if plabel bit is set in function pointer. */
+ if (!((unsigned int) addr & 2))
+ return addr;
+
+ tmp_addr = *(unsigned int **) ((unsigned int) addr & ~3);
+
+ /* If TMP_ADDR points to an export stub, adjust it so that it points
+ to the branch target of the stub. */
+ if ((*tmp_addr & 0xffe0e002) == 0xe8400000 /* bl x,r2 */
+ && *(tmp_addr + 1) == 0x08000240 /* nop */
+ && *(tmp_addr + 2) == 0x4bc23fd1 /* ldw -18(sp),rp */
+ && *(tmp_addr + 3) == 0x004010a1 /* ldsid (rp),r1 */
+ && *(tmp_addr + 4) == 0x00011820 /* mtsp r1,sr0 */
+ && *(tmp_addr + 5) == 0xe0400002) /* be,n 0(sr0,rp) */
+ /* Extract target address from PA 1.x 17-bit branch. */
+ tmp_addr += extract_17 (*tmp_addr) + 2;
+ else if ((*tmp_addr & 0xfc00e002) == 0xe800a000 /* b,l x,r2 */
+ && *(tmp_addr + 1) == 0x08000240 /* nop */
+ && *(tmp_addr + 2) == 0x4bc23fd1 /* ldw -18(sp),rp */
+ && *(tmp_addr + 3) == 0xe840d002) /* bve,n (rp) */
+ /* Extract target address from PA 2.0 22-bit branch. */
+ tmp_addr += extract_22 (*tmp_addr) + 2;
+
+ return (void *) tmp_addr;
+}
+
+#ifdef __cplusplus
+}
+#endif
Index: sysdep/pa/descriptor-pa64-hpux.h
===================================================================
--- sysdep/pa/descriptor-pa64-hpux.h (revision 0)
+++ sysdep/pa/descriptor-pa64-hpux.h (revision 0)
@@ -0,0 +1,6 @@
+// Given a function pointer, return the code address.
+// If the plabel bit is set, mask it off and return the code from the
+// first word of the function descriptor. Otherwise, the function
+// pointer is the code address.
+
+#define UNWRAP_FUNCTION_DESCRIPTOR(X) *(void **)((unsigned long) (X) + 16)