Re: OpenJDK7 on Debian GNU/kFreeBSD
Hi,
On Thu, Jun 23, 2011 at 9:55 PM, Damien Raude-Morvan
<drazzib@drazzib.com> wrote:
> FYI, I'm currently trying to port OpenJDK7 to kfreebsd-i386 and kfreebsd-amd64
> arch. Not ready for prime time yet but I hope to get something working during
> summer.
I'm porting it to hurd-i386. So far I have been able to build a
working zero jvm. I attach my current patches, at a minimum they will
help you figure out where to expect trouble. Eventually, we should
probably work towards a single "non-Linux" patch.
Note that among other things, hurd.diff fixes an os-independent issue
which prevents zero to build on i386 (see
hotspot/src/share/vm/runtime/vmStructs.cpp).
The hotspot version fails to build because Hurd lacks a libthread_db,
which is required by the "serviceability agent" (hotspot/agent). A
shark bootstrap builds but does not work so far.
--
Jérémie Koenig <jk@jk.fr.eu.org>
http://jk.fr.eu.org/
diff --git a/acinclude.m4 b/acinclude.m4
index aefe085..6b93458 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -109,6 +109,10 @@ AC_DEFUN([IT_SET_OS_DIRS],
BUILD_OS_DIR=bsd
OS_PATH=
;;
+ *gnu*)
+ BUILD_OS_DIR=linux
+ OS_PATH=
+ ;;
*)
AC_MSG_ERROR([unsupported operating system ${host_os}])
;;
diff --git a/debian/rules b/debian/rules
index 0d3c440..d0707ce 100755
--- a/debian/rules
+++ b/debian/rules
@@ -14,6 +14,7 @@ DPKG_VARS := $(shell dpkg-architecture)
DEB_HOST_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH)
+DEB_HOST_ARCH_CPU ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_CPU)
PATH := $(CURDIR)/bin:$(PATH)
export PATH
@@ -86,14 +87,14 @@ with_wgy_zenhai = $(if $(filter $(distrel),lenny gutsy feisty edgy dapper),,yes)
arch_map := alpha=alpha arm=arm armel=arm amd64=amd64 hppa=parisc i386=i586 lpia=i586 m68k=m68k mips=mips mipsel=mipsel powerpc=ppc powerpcspe=ppc ppc64=ppc64 sparc=sparc sparc64=sparc64 sh4=sh s390=s390 ia64=ia64
archdir_map := alpha=alpha arm=arm armel=arm amd64=amd64 hppa=parisc i386=i386 lpia=i386 m68k=m68k mips=mips mipsel=mipsel powerpc=ppc powerpcspe=ppc ppc64=ppc64 sparc=sparc sparc64=sparcv9 sh4=sh s390=s390 ia64=ia64
-jvmarch := $(strip $(patsubst $(DEB_HOST_ARCH)=%, %, \
- $(filter $(DEB_HOST_ARCH)=%, $(arch_map))))
-archdir := $(strip $(patsubst $(DEB_HOST_ARCH)=%, %, \
- $(filter $(DEB_HOST_ARCH)=%, $(archdir_map))))
+jvmarch := $(strip $(patsubst $(DEB_HOST_ARCH_CPU)=%, %, \
+ $(filter $(DEB_HOST_ARCH_CPU)=%, $(arch_map))))
+archdir := $(strip $(patsubst $(DEB_HOST_ARCH_CPU)=%, %, \
+ $(filter $(DEB_HOST_ARCH_CPU)=%, $(archdir_map))))
default_vm = $(if $(filter $(DEB_HOST_ARCH), $(hotspot_archs)),hotspot,zero)
-stage1_gcj_archs = amd64 hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 kfreebsd-i386 kfreebsd-amd64
+stage1_gcj_archs = amd64 hppa i386 ia64 lpia powerpc powerpcspe ppc64 m68k mips mipsel sh4 sparc sparc64 s390 kfreebsd-i386 kfreebsd-amd64 hurd-i386
stage1_openjdk_archs = alpha armel
# FIXME, gcj issues
#stage1_gcj_archs = hppa ia64 lpia m68k mips mipsel sh4 sparc sparc64 s390
@@ -351,6 +352,8 @@ ifeq (,$(filter noaltjamvm, $(DEB_BUILD_OPTIONS)))
endif
endif
+DISTRIBUTION_PATCHES += debian/patches/hurd.diff
+
export DISTRIBUTION_PATCHES DISTRIBUTION_ECJ_PATCHES
ifeq ($(STAGE1_JAVA),gcj)
diff --git a/build/openjdk-boot/hotspot/make/defs.make b/build/openjdk-boot/hotspot/make/defs.make
index fe6c4a2..dd66ad5 100644
--- openjdk/hotspot/make/defs.make
+++ openjdk/hotspot/make/defs.make
@@ -121,6 +121,12 @@ ifeq ($(OS),)
HOST := $(shell uname -n)
endif
+# Shortcut Hurd as Linux
+ifeq ($(OS),GNU)
+ OS := Linux
+ DISABLE_HOTSPOT_OS_VERSION_CHECK = ok
+endif
+
# If not SunOS and not Linux, assume Windows
ifneq ($(OS), Linux)
ifneq ($(OS), SunOS)
diff --git a/build/openjdk-boot/hotspot/src/os/linux/vm/attachListener_linux.cpp b/build/openjdk-boot/hotspot/src/os/linux/vm/attachListener_linux.cpp
index 5b9c729..1071060 100644
--- openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp
@@ -335,6 +335,7 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() {
return NULL; // log a warning?
}
+#ifdef SO_PEERCRED
// get the credentials of the peer and check the effective uid/guid
// - check with jeff on this.
struct ucred cred_info;
@@ -352,6 +353,9 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() {
RESTARTABLE(::close(s), res);
continue;
}
+#else
+# warning Authentication disabled
+#endif
// peer credential look okay so we read the request
LinuxAttachOperation* op = read_request(s);
diff --git a/build/openjdk-boot/hotspot/src/os/linux/vm/jvm_linux.cpp b/build/openjdk-boot/hotspot/src/os/linux/vm/jvm_linux.cpp
index 6e305b8..7296d4a 100644
--- openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp
@@ -169,7 +169,9 @@ struct siglabel siglabels[] = {
"WINCH", SIGWINCH, /* Window size change (4.3 BSD, Sun). */
"POLL", SIGPOLL, /* Pollable event occurred (System V). */
"IO", SIGIO, /* I/O now possible (4.2 BSD). */
+#ifdef SIGPWR
"PWR", SIGPWR, /* Power failure restart (System V). */
+#endif
#ifdef SIGSYS
"SYS", SIGSYS /* Bad system call. Only on some Linuxen! */
#endif
diff --git a/build/openjdk-boot/hotspot/src/os/linux/vm/osThread_linux.cpp b/build/openjdk-boot/hotspot/src/os/linux/vm/osThread_linux.cpp
index bf454ff..1d002d1 100644
--- openjdk/hotspot/src/os/linux/vm/osThread_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/osThread_linux.cpp
@@ -49,7 +49,9 @@
void OSThread::pd_initialize() {
assert(this != NULL, "check");
+#ifdef __linux__
_thread_id = 0;
+#endif
_pthread_id = 0;
_siginfo = NULL;
_ucontext = NULL;
diff --git a/build/openjdk-boot/hotspot/src/os/linux/vm/osThread_linux.hpp b/build/openjdk-boot/hotspot/src/os/linux/vm/osThread_linux.hpp
index 2294513..98d27c9 100644
--- openjdk/hotspot/src/os/linux/vm/osThread_linux.hpp
+++ openjdk/hotspot/src/os/linux/vm/osThread_linux.hpp
@@ -39,10 +39,12 @@
private:
+#ifdef __linux__
// _thread_id is kernel thread id (similar to LWP id on Solaris). Each
// thread has a unique thread_id (LinuxThreads or NPTL). It can be used
// to access /proc.
pid_t _thread_id;
+#endif
// _pthread_id is the pthread id, which is used by library calls
// (e.g. pthread_kill).
@@ -56,9 +58,15 @@
sigset_t caller_sigmask() const { return _caller_sigmask; }
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
+#ifdef __linux__
pid_t thread_id() const {
return _thread_id;
}
+#else
+ pthread_t thread_id() const {
+ return _pthread_id;
+ }
+#endif
#ifndef PRODUCT
// Used for debugging, return a unique integer for each thread.
int thread_identifier() const { return _thread_id; }
@@ -70,9 +78,11 @@
return false;
}
#endif // ASSERT
+#ifdef __linux__
void set_thread_id(pid_t id) {
_thread_id = id;
}
+#endif
pthread_t pthread_id() const {
return _pthread_id;
}
diff --git a/build/openjdk-boot/hotspot/src/os/linux/vm/os_linux.cpp b/build/openjdk-boot/hotspot/src/os/linux/vm/os_linux.cpp
index fc9db3c..a78c16f 100644
--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
@@ -115,7 +115,9 @@
# include <semaphore.h>
# include <fcntl.h>
# include <string.h>
+#ifdef __linux__
# include <syscall.h>
+#endif
# include <sys/sysinfo.h>
# include <gnu/libc-version.h>
# include <sys/ipc.h>
@@ -180,11 +182,17 @@ julong os::available_memory() {
}
julong os::Linux::available_memory() {
+#if defined(__LINUX__)
// values in struct sysinfo are "unsigned long"
struct sysinfo si;
sysinfo(&si);
return (julong)si.freeram * si.mem_unit;
+#elif defined(__GNU__)
+ return (julong)get_avphys_pages() * (julong)sysconf(_SC_PAGESIZE);
+#else
+# error Please provide os::Linux::available_memory() for your system
+#endif
}
julong os::physical_memory() {
@@ -232,21 +240,6 @@ bool os::have_special_privileges() {
}
-#ifndef SYS_gettid
-// i386: 224, ia64: 1105, amd64: 186, sparc 143
-#ifdef __ia64__
-#define SYS_gettid 1105
-#elif __i386__
-#define SYS_gettid 224
-#elif __amd64__
-#define SYS_gettid 186
-#elif __sparc__
-#define SYS_gettid 143
-#else
-#error define gettid for the arch
-#endif
-#endif
-
// Cpu architecture string
#if defined(ZERO)
static char cpu_arch[] = ZERO_LIBARCH;
@@ -271,6 +264,21 @@ static char cpu_arch[] = "sparc";
#endif
+#ifdef __linux__
+# ifndef SYS_gettid
+# ifdef __ia64__
+# define SYS_gettid 1105
+# elif __i386__
+# define SYS_gettid 224
+# elif __amd64__
+# define SYS_gettid 186
+# elif __sparc__
+# define SYS_gettid 143
+# else
+# error define gettid for the arch
+# endif
+# endif
+
// pid_t gettid()
//
// Returns the kernel thread id of the currently running thread. Kernel
@@ -288,6 +296,7 @@ pid_t os::Linux::gettid() {
return (pid_t)rslt;
}
}
+#endif
// Most versions of linux have a bug where the number of processors are
// determined by looking at the /proc file system. In a chroot environment,
@@ -300,6 +309,8 @@ static const char *unstable_chroot_error = "/proc file system not found.\n"
void os::Linux::initialize_system_info() {
set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
+#ifdef __LINUX__
+ /* XXX How is this supposed to help anyway? */
if (processor_count() == 1) {
pid_t pid = os::Linux::gettid();
char fname[32];
@@ -311,6 +322,7 @@ void os::Linux::initialize_system_info() {
fclose(fp);
}
}
+#endif
_physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE);
assert(processor_count() > 0, "linux error");
}
@@ -828,8 +840,10 @@ static void *java_start(Thread *thread) {
return NULL;
}
+#ifdef __linux__
// thread_id is kernel thread id (similar to Solaris LWP id)
osthread->set_thread_id(os::Linux::gettid());
+#endif
if (UseNUMA) {
int lgrp_id = os::numa_get_group_id();
@@ -999,7 +1013,9 @@ bool os::create_attached_thread(JavaThread* thread) {
}
// Store pthread info into the OSThread
+#ifdef __linux__
osthread->set_thread_id(os::Linux::gettid());
+#endif
osthread->set_pthread_id(::pthread_self());
// initialize floating point control register
@@ -1309,8 +1325,13 @@ void os::Linux::capture_initial_stack(size_t max_size) {
// thread stack grows on demand, its real bottom is high - RLIMIT_STACK.)
stack_top = (uintptr_t)high;
} else {
+// NB: we need to inhibit the warning on Hurd, because not having
+// /proc/self/maps is expected, and the message breaks the build
+// (it finds its way into template-expanded .java files)
+#ifndef __GNU__
// failed, likely because /proc/self/maps does not exist
warning("Can't detect initial thread stack location - find_vma failed");
+#endif
// best effort: stack_start is normally within a few pages below the real
// stack top, use it as stack top, and reduce stack size so we won't put
// guard page outside stack.
@@ -1411,7 +1432,7 @@ void os::Linux::clock_init() {
#ifndef SYS_clock_getres
-#if defined(IA32) || defined(AMD64)
+#if defined(__linux__) && (defined(IA32) || defined(AMD64))
#define SYS_clock_getres IA32_ONLY(266) AMD64_ONLY(229)
#define sys_clock_getres(x,y) ::syscall(SYS_clock_getres, x, y)
#else
@@ -2020,7 +2041,11 @@ void os::print_dll_info(outputStream *st) {
st->print_cr("Dynamic libraries:");
char fname[32];
+#ifdef __linux__
pid_t pid = os::Linux::gettid();
+#else
+ pid_t pid = getpid();
+#endif
jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
@@ -2124,19 +2149,19 @@ void os::print_memory_info(outputStream* st) {
st->print("Memory:");
st->print(" %dk page", os::vm_page_size()>>10);
-
- // values in struct sysinfo are "unsigned long"
- struct sysinfo si;
- sysinfo(&si);
-
st->print(", physical " UINT64_FORMAT "k",
os::physical_memory() >> 10);
st->print("(" UINT64_FORMAT "k free)",
os::available_memory() >> 10);
+#ifdef __LINUX__
+ // values in struct sysinfo are "unsigned long"
+ struct sysinfo si;
+ sysinfo(&si);
st->print(", swap " UINT64_FORMAT "k",
((jlong)si.totalswap * si.mem_unit) >> 10);
st->print("(" UINT64_FORMAT "k free)",
((jlong)si.freeswap * si.mem_unit) >> 10);
+#endif
st->cr();
}
@@ -3300,13 +3325,19 @@ static int prio_init() {
}
OSReturn os::set_native_priority(Thread* thread, int newpri) {
+#ifdef __linux__
if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK;
int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri);
return (ret == 0) ? OS_OK : OS_ERR;
+#else
+# warning os::set_native_priority has been stubbed
+ return OS_OK;
+#endif
}
OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
+#ifdef __linux__
if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) {
*priority_ptr = java_to_os_priority[NormPriority];
return OS_OK;
@@ -3315,6 +3346,11 @@ OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr)
errno = 0;
*priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR);
+#else
+# warning os::get_native_priority has been stubbed
+ *priority_ptr = java_to_os_priority[NormPriority];
+ return OS_OK;
+#endif
}
// Hint to the underlying OS that a task switch would not be good.
@@ -3996,7 +4032,11 @@ extern void report_error(char* file_name, int line_no, char* title, char* format
extern bool signal_name(int signo, char* buf, size_t len);
const char* os::exception_name(int exception_code, char* buf, size_t size) {
+#ifdef __GNU__
+ if (1) {
+#else
if (0 < exception_code && exception_code <= SIGRTMAX) {
+#endif
// signal
if (!signal_name(exception_code, buf, size)) {
jio_snprintf(buf, size, "SIG%d", exception_code);
@@ -4245,9 +4285,8 @@ ExtendedPC os::get_thread_pc(Thread* thread) {
int os::Linux::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime)
{
- if (is_NPTL()) {
- return pthread_cond_timedwait(_cond, _mutex, _abstime);
- } else {
+#ifdef __linux__
+ if (!is_NPTL()) {
#ifndef IA64
// 6292965: LinuxThreads pthread_cond_timedwait() resets FPU control
// word back to default 64bit precision if condvar is signaled. Java
@@ -4260,6 +4299,8 @@ int os::Linux::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mute
#endif // IA64
return status;
}
+#endif
+ return pthread_cond_timedwait(_cond, _mutex, _abstime);
}
////////////////////////////////////////////////////////////////////////////////
@@ -4389,8 +4430,13 @@ bool os::dir_is_empty(const char* path) {
// This code originates from JDK's sysOpen and open64_w
// from src/solaris/hpi/src/system_md.c
+/* Other definition in jdk/src/solaris/javavm/export/jvm_md.h */
#ifndef O_DELETE
-#define O_DELETE 0x10000
+# ifdef __GNU__
+# define O_DELETE 0x40000000 /* 0x10000 is O_TRUNC on Hurd. */
+# else
+# define O_DELETE 0x10000
+# endif
#endif
// Open a file. Unlink the file immediately after open returns
@@ -4399,6 +4445,11 @@ bool os::dir_is_empty(const char* path) {
int os::open(const char *path, int oflag, int mode) {
+#ifndef __linux__
+ // On Linux, O_RDONLY == 0, but other systems might differ.
+ if (oflag == 0) oflag = O_RDONLY;
+#endif
+
if (strlen(path) > MAX_PATH - 1) {
errno = ENAMETOOLONG;
return -1;
@@ -4631,6 +4682,7 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
// -1 on error.
//
+#ifdef __linux__
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
static bool proc_pid_cpu_avail = true;
static bool proc_task_unchecked = true;
@@ -4716,6 +4768,12 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
return (jlong)user_time * (1000000000 / clock_tics_per_sec);
}
}
+#else
+/* Portable version */
+static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
+ return -1;
+}
+#endif
void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits
@@ -5206,6 +5264,7 @@ extern char** environ;
int os::fork_and_exec(char* cmd) {
const char * argv[4] = {"sh", "-c", cmd, NULL};
+#ifdef __linux__
// fork() in LinuxThreads/NPTL is not async-safe. It needs to run
// pthread_atfork handlers and reset pthread library. All we need is a
// separate process to execve. Make a direct syscall to fork process.
@@ -5213,6 +5272,9 @@ int os::fork_and_exec(char* cmd) {
// the best...
pid_t pid = NOT_IA64(syscall(__NR_fork);)
IA64_ONLY(fork();)
+#else
+ pid_t pid = fork();
+#endif
if (pid < 0) {
// fork failed
@@ -5221,6 +5283,7 @@ int os::fork_and_exec(char* cmd) {
} else if (pid == 0) {
// child process
+#ifdef __linux__
// execve() in LinuxThreads will call pthread_kill_other_threads_np()
// first to kill every thread on the thread list. Because this list is
// not reset by fork() (see notes above), execve() will instead kill
@@ -5230,6 +5293,9 @@ int os::fork_and_exec(char* cmd) {
// above.
NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);)
IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);)
+#else
+ execve("/bin/sh", (char* const*)argv, environ);
+#endif
// execve failed
_exit(-1);
diff --git a/build/openjdk-boot/hotspot/src/os/linux/vm/os_linux.hpp b/build/openjdk-boot/hotspot/src/os/linux/vm/os_linux.hpp
index 18803ac..0b670a4 100644
--- openjdk/hotspot/src/os/linux/vm/os_linux.hpp
+++ openjdk/hotspot/src/os/linux/vm/os_linux.hpp
@@ -91,9 +91,11 @@ class Linux {
static int get_fpu_control_word();
static void set_fpu_control_word(int fpu_control);
static pthread_t main_thread(void) { return _main_thread; }
+#ifdef __linux__
// returns kernel thread id (similar to LWP id on Solaris), which can be
// used to access /proc
static pid_t gettid();
+#endif
static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
static Mutex* createThread_lock(void) { return _createThread_lock; }
static void hotspot_sigmask(Thread* thread);
diff --git a/build/openjdk-boot/hotspot/src/os/posix/launcher/java_md.c b/build/openjdk-boot/hotspot/src/os/posix/launcher/java_md.c
index d88183f..3649f9b 100644
--- openjdk/hotspot/src/os/posix/launcher/java_md.c
+++ openjdk/hotspot/src/os/posix/launcher/java_md.c
@@ -41,12 +41,19 @@
#include "version_comp.h"
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
#include <pthread.h>
#else
#include <thread.h>
#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 4096
+#endif
+#ifndef PATH_MAX
+# define PATH_MAX MAXPATHLEN
+#endif
+
#define JVM_DLL "libjvm.so"
#define JAVA_DLL "libjava.so"
@@ -792,7 +799,7 @@ error:
jboolean
GetApplicationHome(char *buf, jint bufsize)
{
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
char *execname = GetExecname();
if (execname) {
strncpy(buf, execname, bufsize-1);
@@ -1832,7 +1839,7 @@ jlong_format_specifier() {
int
ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
int rslt;
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
pthread_t tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
diff --git a/build/openjdk-boot/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/build/openjdk-boot/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
index b5e1590..6a43b4a 100644
--- openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -792,7 +792,9 @@ void os::print_context(outputStream *st, void *context) {
st->cr();
st->print( "EIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EIP]);
st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]);
+# ifdef __linux__
st->print(", CR2=" INTPTR_FORMAT, uc->uc_mcontext.cr2);
+# endif
#endif // AMD64
st->cr();
st->cr();
diff --git a/build/openjdk-boot/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp b/build/openjdk-boot/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp
index c54cb1d..e8b3c0d 100644
--- openjdk/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp
+++ openjdk/hotspot/src/os_cpu/linux_x86/vm/vmStructs_linux_x86.hpp
@@ -25,6 +25,12 @@
#ifndef OS_CPU_LINUX_X86_VM_VMSTRUCTS_LINUX_X86_HPP
#define OS_CPU_LINUX_X86_VM_VMSTRUCTS_LINUX_X86_HPP
+#ifdef __linux__
+# define __linux__ONLY(code) code
+#else
+# define __linux__ONLY(code)
+#endif
+
// These are the OS and CPU-specific fields, types and integer
// constants required by the Serviceability Agent. This file is
// referenced by vmStructs.cpp.
@@ -34,7 +40,7 @@
/******************************/ \
/* Threads (NOTE: incomplete) */ \
/******************************/ \
- nonstatic_field(OSThread, _thread_id, pid_t) \
+ __linux__ONLY(nonstatic_field(OSThread, _thread_id, pid_t)) \
nonstatic_field(OSThread, _pthread_id, pthread_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -46,7 +52,7 @@
/* Posix Thread IDs */ \
/**********************/ \
\
- declare_integer_type(pid_t) \
+ __linux__ONLY(declare_integer_type(pid_t)) \
declare_unsigned_integer_type(pthread_t) \
\
/* This must be the last entry, and must be present */ \
diff --git a/build/openjdk-boot/hotspot/src/share/vm/runtime/vmStructs.cpp b/build/openjdk-boot/hotspot/src/share/vm/runtime/vmStructs.cpp
index 9f577dd..c1c8ab4 100644
--- openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
+++ openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
@@ -209,6 +209,11 @@ static inline uint64_t cast_uint64_t(size_t x)
return x;
}
+#if !defined(ZERO) && defined(IA32)
+# define NONZERO_IA32_ONLY(code) code
+#else
+# define NONZERO_IA32_ONLY(code)
+#endif
//--------------------------------------------------------------------------------
// VM_STRUCTS
@@ -1278,7 +1283,7 @@ static inline uint64_t cast_uint64_t(size_t x)
\
declare_toplevel_type(StubQueue) \
declare_toplevel_type(StubRoutines) \
- IA32_ONLY(declare_toplevel_type(StubRoutines::x86)) \
+ NONZERO_IA32_ONLY(declare_toplevel_type(StubRoutines::x86)) \
declare_toplevel_type(Stub) \
declare_type(InterpreterCodelet, Stub) \
\
diff --git a/build/openjdk-boot/jdk/make/com/sun/nio/Makefile b/build/openjdk-boot/jdk/make/com/sun/nio/Makefile
index bdff717..d7a1280 100644
--- openjdk/jdk/make/com/sun/nio/Makefile
+++ openjdk/jdk/make/com/sun/nio/Makefile
@@ -30,7 +30,11 @@
BUILDDIR = ../../..
include $(BUILDDIR)/common/Defs.gmk
+ifneq ($(shell uname), GNU)
SUBDIRS = sctp
+else
+SUBDIRS =
+endif
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
diff --git a/build/openjdk-boot/jdk/make/javax/sound/Makefile b/build/openjdk-boot/jdk/make/javax/sound/Makefile
index 9a6659c..88c2b39 100644
--- openjdk/jdk/make/javax/sound/Makefile
+++ openjdk/jdk/make/javax/sound/Makefile
@@ -99,10 +99,12 @@ ifeq ($(PLATFORM), windows)
endif # PLATFORM win32
ifeq ($(PLATFORM), linux)
+ ifneq ($(shell uname), GNU)
# ALSA handles directaudio, ports, and MIDI
SUBDIRS += jsoundalsa
EXTRA_SOUND_JNI_LIBS += jsoundalsa
#MXSPP_ADD = $(PLATFORM)-$(ARCH)/
+ endif
endif # PLATFORM linux
ifeq ($(PLATFORM), solaris)
diff --git a/build/openjdk-boot/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h b/build/openjdk-boot/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
index 803bad6..0ce9cde 100644
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
@@ -111,6 +111,12 @@ typedef long long unsigned julong;
#endif
#define MKDIR(dir) mkdir(dir, 0777);
#endif
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN PATH_MAX
+#endif
#ifdef OLDCC
typedef int bool;
diff --git a/build/openjdk-boot/jdk/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h b/build/openjdk-boot/jdk/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
index 3efdc27..ae882ab 100644
--- openjdk/jdk/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
+++ openjdk/jdk/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
@@ -30,6 +30,8 @@
extern "C" {
#endif
+#include <stdint.h> /* intptr_t */
+
#include "java_awt_AlphaComposite.h"
#include "SurfaceData.h"
diff --git a/build/openjdk-boot/jdk/src/solaris/back/util_md.h b/build/openjdk-boot/jdk/src/solaris/back/util_md.h
index 7a3bc83..d630a12 100644
--- openjdk/jdk/src/solaris/back/util_md.h
+++ openjdk/jdk/src/solaris/back/util_md.h
@@ -40,6 +40,9 @@ typedef unsigned long long UNSIGNED_JLONG;
typedef unsigned long UNSIGNED_JINT;
#endif /* _LP64 */
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN PATH_MAX
#endif
diff --git a/build/openjdk-boot/jdk/src/solaris/bin/java_md.c b/build/openjdk-boot/jdk/src/solaris/bin/java_md.c
index ca2e997..0d5e28f 100644
--- openjdk/jdk/src/solaris/bin/java_md.c
+++ openjdk/jdk/src/solaris/bin/java_md.c
@@ -37,7 +37,7 @@
#include "manifest_info.h"
#include "version_comp.h"
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
#include <pthread.h>
#else
#include <thread.h>
@@ -661,12 +661,21 @@ static const char*
SetExecname(char **argv)
{
char* exec_path = NULL;
-#if defined(__solaris__)
+#if defined(__solaris__) || defined(__GNU__)
{
+# ifdef __GNU__
+ /* We use a dynamic symbol provided by the executable to query its
+ * dli_fname as provided by dladdr. At least on Hurd (and maybe
+ * with glibc elsewhere), "main" isn't one, so we use "stdout"
+ * instead, which seems to work for our purposes. */
+ const char *symname = "__bss_start";
+# else
+ const char *symname = "main";
+# endif
Dl_info dlinfo;
int (*fptr)();
- fptr = (int (*)())dlsym(RTLD_DEFAULT, "main");
+ fptr = (int (*)())dlsym(RTLD_DEFAULT, symname);
if (fptr == NULL) {
JLI_ReportErrorMessage(DLL_ERROR3, dlerror());
return JNI_FALSE;
@@ -675,6 +684,8 @@ SetExecname(char **argv)
if (dladdr((void*)fptr, &dlinfo)) {
char *resolved = (char*)JLI_MemAlloc(PATH_MAX+1);
if (resolved != NULL) {
+ /* XXX on Hurd PATH_MAX is not defined, so there's a
+ * potential overflow here. */
exec_path = realpath(dlinfo.dli_fname, resolved);
if (exec_path == NULL) {
JLI_MemFree(resolved);
@@ -703,10 +714,8 @@ SetExecname(char **argv)
exec_path = JLI_StringDup(buf + prefix_len);
}
}
-#else /* !__solaris__ && !__linux */
- {
- /* Not implemented */
- }
+#else
+# error Can't figure out the executable name on this OS, please implement.
#endif
if (exec_path == NULL) {
@@ -1079,7 +1088,7 @@ jlong_format_specifier() {
int
ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
int rslt;
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
pthread_t tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
@@ -1124,7 +1133,7 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void
void SetJavaLauncherPlatformProps() {
/* Linux only */
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
const char *substr = "-Dsun.java.launcher.pid=";
char *pid_prop_str = (char *)JLI_MemAlloc(JLI_StrLen(substr) + MAX_PID_STR_SZ + 1);
sprintf(pid_prop_str, "%s%d", substr, getpid());
diff --git a/build/openjdk-boot/jdk/src/solaris/bin/java_md.h b/build/openjdk-boot/jdk/src/solaris/bin/java_md.h
index cc72740..6ba1ead 100644
--- openjdk/jdk/src/solaris/bin/java_md.h
+++ openjdk/jdk/src/solaris/bin/java_md.h
@@ -39,6 +39,12 @@
#ifndef MAXNAMELEN
#define MAXNAMELEN PATH_MAX
#endif
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 4096
+#endif
#ifdef HAVE_GETHRTIME
/*
diff --git a/build/openjdk-boot/jdk/src/solaris/bin/jexec.c b/build/openjdk-boot/jdk/src/solaris/bin/jexec.c
index 66012b8..b7d19d8 100644
--- openjdk/jdk/src/solaris/bin/jexec.c
+++ openjdk/jdk/src/solaris/bin/jexec.c
@@ -83,6 +83,10 @@
# include "manifest_info.h"
#endif
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+
static const int CRAZY_EXEC = ENOEXEC;
static const int BAD_MAGIC = ENOEXEC;
diff --git a/build/openjdk-boot/jdk/src/solaris/instrument/FileSystemSupport_md.h b/build/openjdk-boot/jdk/src/solaris/instrument/FileSystemSupport_md.h
index f9070ad..92a6528 100644
--- openjdk/jdk/src/solaris/instrument/FileSystemSupport_md.h
+++ openjdk/jdk/src/solaris/instrument/FileSystemSupport_md.h
@@ -28,3 +28,10 @@
#include <stdlib.h>
#include <sys/param.h> /* For MAXPATHLEN */
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 4096
+#endif
+
diff --git a/build/openjdk-boot/jdk/src/solaris/javavm/export/jvm_md.h b/build/openjdk-boot/jdk/src/solaris/javavm/export/jvm_md.h
index 09213b0..ff15ef3 100644
--- openjdk/jdk/src/solaris/javavm/export/jvm_md.h
+++ openjdk/jdk/src/solaris/javavm/export/jvm_md.h
@@ -37,6 +37,13 @@
#include <stddef.h> /* For ptrdiff_t */
#include <stdint.h> /* For uintptr_t */
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN PATH_MAX
+#endif
+
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}
@@ -68,7 +75,11 @@
#define JVM_O_O_APPEND O_APPEND
#define JVM_O_EXCL O_EXCL
#define JVM_O_CREAT O_CREAT
-#define JVM_O_DELETE 0x10000
+#ifdef __GNU__
+# define JVM_O_DELETE 0x40000000 /* 0x10000 is O_TRUNC on Hurd. */
+#else
+# define JVM_O_DELETE 0x10000
+#endif
/* Signals */
diff --git a/build/openjdk-boot/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c b/build/openjdk-boot/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c
index 0541799..4ea5c69 100644
--- openjdk/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c
+++ openjdk/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c
@@ -44,6 +44,13 @@
#include <stdlib.h>
#include <unistd.h>
+#ifdef __GNU__
+# include <mach.h>
+# include <mach/default_pager.h>
+# include <hurd.h>
+# include <hurd/paths.h>
+#endif
+
static jlong page_size = 0;
/* This gets us the new structured proc interfaces of 5.6 & later */
@@ -124,7 +131,7 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa
free(strtab);
return available ? ((jlong)avail * page_size) :
((jlong)total * page_size);
-#else /* __linux__ */
+#elif defined(__linux__)
int ret;
FILE *fp;
jlong total = 0, avail = 0;
@@ -138,6 +145,25 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa
avail = (jlong)si.freeswap * si.mem_unit;
return available ? avail : total;
+#elif defined(__GNU__)
+ mach_port_t defpager;
+ default_pager_info_t swapinfo;
+ error_t err;
+
+ defpager = file_name_lookup (_SERVERS_DEFPAGER, O_READ, 0);
+ if (defpager == MACH_PORT_NULL) {
+ throw_internal_error(env, "can't lookup defpager");
+ }
+
+ err = default_pager_info (defpager, &swapinfo);
+ mach_port_deallocate (mach_task_self (), defpager);
+ if (err != 0) {
+ throw_internal_error(env, "default_pager_info failed to get swap size");
+ }
+
+ return available ? swapinfo.dpi_free_space : swapinfo.dpi_total_space;
+#else
+# error No know way to query the swap size
#endif
}
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/io/canonicalize_md.c b/build/openjdk-boot/jdk/src/solaris/native/java/io/canonicalize_md.c
index 6f1c5e0..3a76b4d 100644
--- openjdk/jdk/src/solaris/native/java/io/canonicalize_md.c
+++ openjdk/jdk/src/solaris/native/java/io/canonicalize_md.c
@@ -35,6 +35,10 @@
#include <limits.h>
#include <alloca.h>
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+
/* Note: The comments in this file use the terminology
defined in the java.io.File class */
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/lang/java_props_md.c b/build/openjdk-boot/jdk/src/solaris/native/java/lang/java_props_md.c
index c004092..a21c35c 100644
--- openjdk/jdk/src/solaris/native/java/lang/java_props_md.c
+++ openjdk/jdk/src/solaris/native/java/lang/java_props_md.c
@@ -55,6 +55,10 @@
#endif
#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 4096
+#endif
+
/* Take an array of string pairs (map of key->value) and a string (key).
* Examine each pair in the map to see if the first string (key) matches the
* string. If so, store the second string of the pair (value) in the value and
@@ -128,7 +132,7 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
/* Query the locale set for the category */
lc = setlocale(cat, NULL);
-#ifndef __linux__
+#if !defined(__linux__) && !defined(__GNU__)
if (lc == NULL) {
return 0;
}
@@ -144,7 +148,7 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
* Therefore, this code section is Solaris-specific.
*/
lc = strdup(lc); /* keep a copy, setlocale trashes original. */
- strcpy(temp, lc);
+ strcpy(temp, lc); /* XXX temp not initialized ! */
p = strstr(temp, "@euro");
if (p != NULL) {
*p = '\0';
@@ -447,7 +451,7 @@ GetJavaProperties(JNIEnv *env)
sprops.path_separator = ":";
sprops.line_separator = "\n";
-#ifndef __linux__
+#ifndef __solaris__
/* Append CDE message and resource search path to NLSPATH and
* XFILESEARCHPATH, in order to pick localized message for
* FileSelectionDialog window (Bug 4173641).
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/net/Inet4AddressImpl.c b/build/openjdk-boot/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
index 9a5b78e..448c95e 100644
--- openjdk/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
+++ openjdk/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
@@ -42,6 +42,10 @@
#include "java_net_Inet4AddressImpl.h"
+#ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 255
+#endif
+
/* the initial size of our hostent buffers */
#define HENT_BUF_SIZE 1024
#define BIG_HENT_BUF_SIZE 10240 /* a jumbo-sized one */
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/net/NetworkInterface.c b/build/openjdk-boot/jdk/src/solaris/native/java/net/NetworkInterface.c
index ba1c3c7..ccaacc6 100644
--- openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c
+++ openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c
@@ -42,14 +42,14 @@
#include <sys/sockio.h>
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
#include <sys/ioctl.h>
#include <bits/ioctls.h>
#include <sys/utsname.h>
#include <stdio.h>
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
#endif
@@ -1003,7 +1003,7 @@ static int openSocket(JNIEnv *env, int proto){
/** Linux **/
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
/* Open socket for further ioct calls, try v4 socket first and
* if it falls return v6 socket
*/
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/build/openjdk-boot/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
index 0eb2a9b..d6bfa6e 100644
--- openjdk/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
+++ openjdk/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
@@ -2004,14 +2004,13 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
}
/* setsockopt to be correct ttl */
#ifdef AF_INET6
-#ifdef __solaris__
+#if !defined(__linux__)
if (ipv6_available()) {
setHopLimit(env, fd, ttl);
} else {
setTTL(env, fd, ttl);
}
-#endif
-#ifdef __linux__
+#else
setTTL(env, fd, ttl);
if (ipv6_available()) {
setHopLimit(env, fd, ttl);
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/net/linux_close.c b/build/openjdk-boot/jdk/src/solaris/native/java/net/linux_close.c
index 1385519..80e6a4d 100644
--- openjdk/jdk/src/solaris/native/java/net/linux_close.c
+++ openjdk/jdk/src/solaris/native/java/net/linux_close.c
@@ -57,7 +57,11 @@ typedef struct {
/*
* Signal to unblock thread
*/
+#ifdef __GNU__
+static int sigWakeup = SIGURG;
+#else
static int sigWakeup = (__SIGRTMAX - 2);
+#endif
/*
* The fd table and the number of file descriptors
@@ -86,6 +90,11 @@ static void __attribute((constructor)) init() {
*/
getrlimit(RLIMIT_NOFILE, &nbr_files);
fdCount = nbr_files.rlim_max;
+ if(fdCount == RLIM_INFINITY)
+ fdCount = nbr_files.rlim_cur;
+ if(fdCount == RLIM_INFINITY)
+ fdCount = 1024;
+
fdTable = (fdEntry_t *)calloc(fdCount, sizeof(fdEntry_t));
if (fdTable == NULL) {
fprintf(stderr, "library initialization failed - "
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/util/FileSystemPreferences.c b/build/openjdk-boot/jdk/src/solaris/native/java/util/FileSystemPreferences.c
index 256a166..c5ec240 100644
--- openjdk/jdk/src/solaris/native/java/util/FileSystemPreferences.c
+++ openjdk/jdk/src/solaris/native/java/util/FileSystemPreferences.c
@@ -48,7 +48,12 @@ Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env,
}
+#ifdef F_SETLK64
typedef struct flock64 FLOCK;
+#else
+# define F_SETLK64 F_SETLK
+typedef struct flock FLOCK;
+#endif
/**
* Try to open a named lock file.
diff --git a/build/openjdk-boot/jdk/src/solaris/native/java/util/TimeZone_md.c b/build/openjdk-boot/jdk/src/solaris/native/java/util/TimeZone_md.c
index 9a2a0b4..ed53693 100644
--- openjdk/jdk/src/solaris/native/java/util/TimeZone_md.c
+++ openjdk/jdk/src/solaris/native/java/util/TimeZone_md.c
@@ -31,7 +31,7 @@
#include <errno.h>
#include <stddef.h>
-#ifdef __linux__
+#ifdef defined(__linux__) || defined(__GNU__)
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
@@ -41,6 +41,10 @@
#include "jvm.h"
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+
#define SKIP_SPACE(p) while (*p == ' ' || *p == '\t') p++;
#if !defined(__solaris__) || defined(__sparcv9) || defined(amd64)
@@ -49,7 +53,7 @@
#define fileclose fclose
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
@@ -496,10 +500,8 @@ findJavaTZ_md(const char *java_home_dir, const char *country)
#ifdef __linux__
if (tz == NULL) {
#else
-#ifdef __solaris__
if (tz == NULL || *tz == '\0') {
#endif
-#endif
tz = getPlatformTimeZoneID();
freetz = tz;
}
@@ -508,7 +510,7 @@ findJavaTZ_md(const char *java_home_dir, const char *country)
if (*tz == ':') {
tz++;
}
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
/*
* Ignore "posix/" prefix.
*/
diff --git a/build/openjdk-boot/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c b/build/openjdk-boot/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
index 037e657..f5bd041 100644
--- openjdk/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
@@ -40,6 +40,12 @@
static int preCloseFD = -1; /* File descriptor to which we dup other fd's
before closing them for real */
+#ifndef F_SETLK64
+# define F_SETLK64 F_SETLK
+# define F_SETLKW64 F_SETLKW
+# define flock flock64
+#endif
+
JNIEXPORT void JNICALL
Java_sun_nio_ch_FileDispatcherImpl_init(JNIEnv *env, jclass cl)
diff --git a/build/openjdk-boot/jdk/src/solaris/native/sun/nio/ch/Net.c b/build/openjdk-boot/jdk/src/solaris/native/sun/nio/ch/Net.c
index 9f9b466..6188587 100644
--- openjdk/jdk/src/solaris/native/sun/nio/ch/Net.c
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/Net.c
@@ -83,13 +83,11 @@ struct my_group_source_req {
#pragma pack()
#endif
-#endif /* __solaris__ */
-
-
-#ifdef __linux__
+#else /* __solaris__ */
#ifndef IP_BLOCK_SOURCE
+# ifdef __linux__
#define IP_BLOCK_SOURCE 38
#define IP_UNBLOCK_SOURCE 37
#define IP_ADD_SOURCE_MEMBERSHIP 39
@@ -99,6 +97,7 @@ struct my_group_source_req {
#define MCAST_UNBLOCK_SOURCE 44
#define MCAST_JOIN_SOURCE_GROUP 42
#define MCAST_LEAVE_SOURCE_GROUP 45
+# endif
#endif /* IP_BLOCK_SOURCE */
@@ -114,7 +113,7 @@ struct my_group_source_req {
struct sockaddr_storage gsr_source; /* source address */
};
-#endif /* __linux__ */
+#endif /* !__solaris__ */
#define COPY_INET6_ADDRESS(env, source, target) \
@@ -419,12 +418,17 @@ Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobjec
optval = (void*)&mreq;
optlen = sizeof(mreq);
} else {
+#ifdef IP_ADD_SOURCE_MEMBERSHIP
mreq_source.imr_multiaddr.s_addr = htonl(group);
mreq_source.imr_sourceaddr.s_addr = htonl(source);
mreq_source.imr_interface.s_addr = htonl(interf);
opt = (join) ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP;
optval = (void*)&mreq_source;
optlen = sizeof(mreq_source);
+#else
+# warning IP_ADD_SOURCE_MEMBERSHIP not available
+ return IOS_UNAVAILABLE;
+#endif
}
n = setsockopt(fdval(env,fdo), IPPROTO_IP, opt, optval, optlen);
@@ -436,6 +440,7 @@ Java_sun_nio_ch_Net_joinOrDrop4(JNIEnv *env, jobject this, jboolean join, jobjec
return 0;
}
+#ifdef IP_BLOCK_SOURCE
JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_blockOrUnblock4(JNIEnv *env, jobject this, jboolean block, jobject fdo,
jint group, jint interf, jint source)
@@ -457,6 +462,9 @@ Java_sun_nio_ch_Net_blockOrUnblock4(JNIEnv *env, jobject this, jboolean block, j
}
return 0;
}
+#else
+# warning IP_BLOCK_SOURCE not available, Java_sun_nio_ch_Net_blockOrUnblock4 not built
+#endif
JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo,
@@ -475,7 +483,7 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec
optval = (void*)&mreq6;
optlen = sizeof(mreq6);
} else {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
/* Include-mode filtering broken on Linux at least to 2.6.24 */
return IOS_UNAVAILABLE;
#else
@@ -503,7 +511,7 @@ JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo,
jbyteArray group, jint index, jbyteArray source)
{
-#ifdef AF_INET6
+#if defined(AF_INET6) && defined(MCAST_BLOCK_SOURCE)
struct my_group_source_req req;
int n;
int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE;
diff --git a/build/openjdk-boot/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c b/build/openjdk-boot/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
index 1416c71..dfa631e 100644
--- openjdk/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
+++ openjdk/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
@@ -49,13 +49,15 @@
#include <strings.h>
#include <sys/mnttab.h>
#include <sys/mkdev.h>
-#endif
-
-#ifdef __linux__
+#else
#include <string.h>
#include <mntent.h>
#endif
+#ifndef PATH_MAX
+# define PATH_MAX 4096
+#endif
+
#include "jni.h"
#include "jni_util.h"
#include "jlong.h"
diff --git a/build/openjdk-boot/jdk/src/solaris/transport/socket/socket_md.c b/build/openjdk-boot/jdk/src/solaris/transport/socket/socket_md.c
index d897ed4..24dba3a 100644
--- openjdk/jdk/src/solaris/transport/socket/socket_md.c
+++ openjdk/jdk/src/solaris/transport/socket/socket_md.c
@@ -35,8 +35,7 @@
#include <sys/time.h>
#ifdef __solaris__
#include <thread.h>
-#endif
-#ifdef __linux__
+#else
#include <pthread.h>
#include <sys/poll.h>
#endif
@@ -281,9 +280,8 @@ dbgsysTlsGet(int index) {
return r;
}
-#endif
+#else
-#ifdef __linux__
int
dbgsysTlsAlloc() {
pthread_key_t key;
diff --git a/build/openjdk/hotspot/src/os/linux/vm/jvm_linux.h b/build/openjdk/hotspot/src/os/linux/vm/jvm_linux.h
index 795fec1..69204fa 100644
--- openjdk/hotspot/src/os/linux/vm/jvm_linux.h
+++ openjdk/hotspot/src/os/linux/vm/jvm_linux.h
@@ -46,6 +46,17 @@
#include <sys/param.h> /* For MAXPATHLEN */
#include <unistd.h> /* For F_OK, R_OK, W_OK */
+/* Hurd does not have MAXPATHLEN and MAP_NORESERVE is Linux-specific. */
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 4096
+#endif
+#ifndef PATH_MAX
+# define PATH_MAX MAXPATHLEN
+#endif
+#ifndef MAP_NORESERVE
+# define MAP_NORESERVE 0
+#endif
+
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}
#define JVM_ONLOAD_SYMBOLS {"JVM_OnLoad"}
diff --git a/build/openjdk/jdk/make/common/shared/Platform.gmk b/build/openjdk/jdk/make/common/shared/Platform.gmk
index 9a88c2e..90bb6dc 100644
--- openjdk/jdk/make/common/shared/Platform.gmk
+++ openjdk/jdk/make/common/shared/Platform.gmk
@@ -78,6 +78,10 @@ ifndef SYSTEM_UNAME
export SYSTEM_UNAME
endif
+ifeq ($(SYSTEM_UNAME), GNU)
+ SYSTEM_UNAME := Linux
+endif
+
#
# Prune out all known SCM (Source Code Management) directories
# so they will not be included when copying directory trees
Reply to: