1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
$NetBSD: patch-aa,v 1.14 2015/02/21 20:20:03 tnn Exp $
DragonFly support.
Add workaround for missing sem_timedwait() in NetBSD < 6.99.4
--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig 2015-01-26 15:21:44.000000000 +0000
+++ hotspot/src/os/bsd/vm/os_bsd.cpp
@@ -126,8 +126,11 @@
# include <inttypes.h>
# include <sys/ioctl.h>
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
# include <elf.h>
+#if !defined(EM_ALPHA)
+#define EM_ALPHA 0x9026
+#endif
#endif
#ifdef __APPLE__
@@ -340,6 +343,7 @@ void os::Bsd::initialize_system_info() {
size_t len;
int cpu_val;
julong mem_val;
+ struct rlimit limits;
/* get processors count via hw.ncpus sysctl */
mib[0] = CTL_HW;
@@ -372,14 +376,11 @@ void os::Bsd::initialize_system_info() {
_physical_memory = 256*1024*1024; // fallback (XXXBSD?)
}
-#ifdef __OpenBSD__
- {
- // limit _physical_memory memory view on OpenBSD since
- // datasize rlimit restricts us anyway.
- struct rlimit limits;
- getrlimit(RLIMIT_DATA, &limits);
- _physical_memory = MIN2(_physical_memory, (julong)limits.rlim_cur);
- }
+ getrlimit(RLIMIT_DATA, &limits);
+ _physical_memory = MIN2(_physical_memory, (julong)limits.rlim_cur);
+#if defined(RLIMIT_AS)
+ getrlimit(RLIMIT_AS, &limits);
+ _physical_memory = MIN2(_physical_memory, (julong)limits.rlim_cur);
#endif
}
#else
@@ -458,7 +459,7 @@ void os::init_system_properties_values()
* 7: The default directories, normally /lib and /usr/lib.
*/
#ifndef DEFAULT_LIBPATH
-#define DEFAULT_LIBPATH "/lib:/usr/lib"
+#define DEFAULT_LIBPATH "@PREFIX@/lib/jni:@PREFIX@/lib:/lib:/usr/lib"
#endif
#define EXTENSIONS_DIR "/lib/ext"
@@ -2232,7 +2233,9 @@ void * os::dll_load(const char *filename
{EM_PPC, EM_PPC, ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"},
{EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"},
{EM_ARM, EM_ARM, ELFCLASS32, ELFDATA2LSB, (char*)"ARM"},
+#if 0
{EM_S390, EM_S390, ELFCLASSNONE, ELFDATA2MSB, (char*)"IBM System/390"},
+#endif
{EM_ALPHA, EM_ALPHA, ELFCLASS64, ELFDATA2LSB, (char*)"Alpha"},
{EM_MIPS_RS3_LE, EM_MIPS_RS3_LE, ELFCLASS32, ELFDATA2LSB, (char*)"MIPSel"},
{EM_MIPS, EM_MIPS, ELFCLASS32, ELFDATA2MSB, (char*)"MIPS"},
@@ -2829,6 +2832,33 @@ bool Semaphore::timedwait(unsigned int s
#else
+#if defined(__NetBSD__) && (__NetBSD_Version__ < 699000400)
+static inline int sem_timedwait(sem_t *sem, struct timespec *ts) {
+ struct timespec onems = { 0, 1000000 };
+ struct timespec total = { 0, 0 };
+ struct timespec unslept;
+ struct timespec elapsed;
+ struct timespec tmp;
+
+ while (timespeccmp(ts, &total, >)) {
+ if (sem_trywait(sem) == 0)
+ return 0;
+
+ if (errno != EAGAIN)
+ return -1;
+
+ (void)nanosleep(&onems, &unslept);
+
+ timespecsub(&onems, &unslept, &elapsed);
+ timespecadd(&total, &elapsed, &tmp);
+ total.tv_sec = tmp.tv_sec;
+ total.tv_nsec = tmp.tv_nsec;
+ }
+ errno = ETIMEDOUT;
+ return -1;
+}
+#endif /* __NetBSD__ */
+
bool Semaphore::trywait() {
return sem_trywait(&_semaphore) == 0;
}
@@ -2979,7 +3009,7 @@ static void warn_fail_commit_memory(char
// problem.
bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__NetBSD__)
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
if (::mprotect(addr, size, prot) == 0) {
return true;
@@ -3893,7 +3923,7 @@ OSReturn os::set_native_priority(Thread*
#ifdef __OpenBSD__
// OpenBSD pthread_setprio starves low priority threads
return OS_OK;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri);
return (ret == 0) ? OS_OK : OS_ERR;
#elif defined(__APPLE__) || defined(__NetBSD__)
@@ -3922,7 +3952,7 @@ OSReturn os::get_native_priority(const T
}
errno = 0;
-#if defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
*priority_ptr = pthread_getprio(thread->osthread()->pthread_id());
#elif defined(__APPLE__) || defined(__NetBSD__)
int policy;
|