8244224: Implementation of JEP 381: Remove the Solaris and SPARC Ports

Reviewed-by: alanb, bchristi, dcubed, dfuchs, eosterlund, erikj, glaubitz, ihse, iignatyev, jjiang, kbarrett, ksrini, kvn, naoto, prr, rriggs, serb, sspitsyn, stefank, tschatzl, valeriep, weijun, weijun
This commit is contained in:
Mikael Vidstedt 2020-05-20 17:33:37 -07:00
parent 9fe4b69c1a
commit 071bd521bc
954 changed files with 1093 additions and 127816 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -77,9 +77,6 @@ final class ProcessImpl extends Process {
private /* final */ InputStream stdout;
private /* final */ InputStream stderr;
// only used on Solaris
private /* final */ DeferredCloseInputStream stdout_inner_stream;
private static enum LaunchMechanism {
// order IS important!
FORK,
@ -93,8 +90,6 @@ final class ProcessImpl extends Process {
BSD(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
SOLARIS(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
AIX(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK);
final LaunchMechanism defaultLaunchMechanism;
@ -139,7 +134,6 @@ final class ProcessImpl extends Process {
if (osName.equals("Linux")) { return LINUX; }
if (osName.contains("OS X")) { return BSD; }
if (osName.equals("SunOS")) { return SOLARIS; }
if (osName.equals("AIX")) { return AIX; }
throw new Error(osName + " is not a supported OS platform.");
@ -385,41 +379,6 @@ final class ProcessImpl extends Process {
});
break;
case SOLARIS:
stdin = (fds[0] == -1) ?
ProcessBuilder.NullOutputStream.INSTANCE :
new BufferedOutputStream(
new FileOutputStream(newFileDescriptor(fds[0])));
stdout = (fds[1] == -1 || forceNullOutputStream) ?
ProcessBuilder.NullInputStream.INSTANCE :
new BufferedInputStream(
stdout_inner_stream =
new DeferredCloseInputStream(
newFileDescriptor(fds[1])));
stderr = (fds[2] == -1) ?
ProcessBuilder.NullInputStream.INSTANCE :
new DeferredCloseInputStream(newFileDescriptor(fds[2]));
/*
* For each subprocess forked a corresponding reaper task
* is submitted. That task is the only thread which waits
* for the subprocess to terminate and it doesn't hold any
* locks while doing so. This design allows waitFor() and
* exitStatus() to be safely executed in parallel (and they
* need no native code).
*/
ProcessHandleImpl.completion(pid, true).handle((exitcode, throwable) -> {
synchronized (this) {
this.exitcode = (exitcode == null) ? -1 : exitcode.intValue();
this.hasExited = true;
this.notifyAll();
}
return null;
});
break;
case AIX:
stdin = (fds[0] == -1) ?
ProcessBuilder.NullOutputStream.INSTANCE :
@ -522,29 +481,6 @@ final class ProcessImpl extends Process {
try { stderr.close(); } catch (IOException ignored) {}
break;
case SOLARIS:
// There is a risk that pid will be recycled, causing us to
// kill the wrong process! So we only terminate processes
// that appear to still be running. Even with this check,
// there is an unavoidable race condition here, but the window
// is very small, and OSes try hard to not recycle pids too
// soon, so this is quite safe.
synchronized (this) {
if (!hasExited)
processHandle.destroyProcess(force);
try {
stdin.close();
if (stdout_inner_stream != null)
stdout_inner_stream.closeDeferred(stdout);
if (stderr instanceof DeferredCloseInputStream)
((DeferredCloseInputStream) stderr)
.closeDeferred(stderr);
} catch (IOException e) {
// ignore
}
}
break;
default: throw new AssertionError("Unsupported platform: " + platform);
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -46,9 +46,6 @@ public final class PortConfig {
if (os.startsWith("Linux")) {
defaultLower = 32768;
defaultUpper = 61000;
} else if (os.startsWith("SunOS")) {
defaultLower = 32768;
defaultUpper = 65535;
} else if (os.contains("OS X")) {
defaultLower = 49152;
defaultUpper = 65535;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -177,16 +177,6 @@ public class ResolverConfigurationImpl
// No search keyword so use local domain
// LOCALDOMAIN has absolute priority on Solaris
String localDomain = localDomain0();
if (localDomain != null && !localDomain.isEmpty()) {
sl = new LinkedList<>();
sl.add(localDomain);
return sl;
}
// try domain keyword in /etc/resolv.conf
sl = java.security.AccessController.doPrivileged(
@ -254,8 +244,6 @@ public class ResolverConfigurationImpl
// --- Native methods --
static native String localDomain0();
static native String fallbackDomain0();
static {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,10 +31,6 @@
#include <fcntl.h>
#include <sys/stat.h>
/* On Solaris, "sun" is defined as a macro. Undefine to make package
declaration valid */
#undef sun
/* To be able to name the Java constants the same as the C constants without
having the preprocessor rewrite those identifiers, add PREFIX_ to all
identifiers matching a C constant. The PREFIX_ is filtered out in the

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -92,10 +92,6 @@ abstract class UnixFileSystem
return rootDirectory;
}
boolean isSolaris() {
return false;
}
static List<String> standardFileAttributeViews() {
return Arrays.asList("basic", "posix", "unix", "owner");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -801,15 +801,7 @@ class UnixPath implements Path {
("NOFOLLOW_LINKS is not supported on this platform");
flags |= O_NOFOLLOW;
}
try {
return open(this, flags, 0);
} catch (UnixException x) {
// HACK: EINVAL instead of ELOOP on Solaris 10 prior to u4 (see 6460380)
if (getFileSystem().isSolaris() && x.errno() == EINVAL)
x.setError(ELOOP);
throw x;
}
return open(this, flags, 0);
}
void checkRead() {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,7 +33,7 @@ import java.util.Arrays;
import sun.security.util.Debug;
/**
* Native PRNG implementation for Solaris/Linux/MacOS.
* Native PRNG implementation for Linux/MacOS.
* <p>
* It obtains seed and random numbers by reading system files such as
* the special device files /dev/random and /dev/urandom. This

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,20 +45,10 @@
#include <sys/stat.h>
#include <sys/wait.h>
/* For POSIX-compliant getpwuid_r on Solaris */
#if defined(__solaris__)
#define _POSIX_PTHREAD_SEMANTICS
#endif
#include <pwd.h>
#ifdef _AIX
#include <sys/procfs.h>
#endif
#ifdef __solaris__
#include <procfs.h>
#endif
#if defined(_AIX)
#include <sys/procfs.h>
#define DIR DIR64
#define dirent dirent64
#define opendir opendir64
@ -138,18 +128,13 @@
#define WTERMSIG(status) ((status)&0x7F)
#endif
#ifdef __solaris__
/* The child exited because of a signal.
* The best value to return is 0x80 + signal number,
* because that is what all Unix shells do, and because
* it allows callers to distinguish between process exit and
* process death by signal.
* Unfortunately, the historical behavior on Solaris is to return
* the signal number, and we preserve this for compatibility. */
#define WTERMSIG_RETURN(status) WTERMSIG(status)
#else
*/
#define WTERMSIG_RETURN(status) (WTERMSIG(status) + 0x80)
#endif
#define RESTARTABLE(_cmd, _result) do { \
do { \
@ -503,7 +488,7 @@ void unix_getUserInfo(JNIEnv* env, jobject jinfo, uid_t uid) {
* The following functions are common on Solaris, Linux and AIX.
*/
#if defined(__solaris__) || defined (__linux__) || defined(_AIX)
#if defined (__linux__) || defined(_AIX)
/*
* Returns the children of the requested pid and optionally each parent and
@ -622,13 +607,13 @@ jint unix_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray,
return count;
}
#endif // defined(__solaris__) || defined (__linux__) || defined(_AIX)
#endif // defined (__linux__) || defined(_AIX)
/*
* The following functions are common on Solaris and AIX.
* The following functions are for AIX.
*/
#if defined(__solaris__) || defined(_AIX)
#if defined(_AIX)
/**
* Helper function to get the 'psinfo_t' data from "/proc/%d/psinfo".
@ -691,19 +676,6 @@ void unix_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) {
jstring cmdexe = NULL;
int ret;
/*
* On Solaris, the full path to the executable command is the link in
* /proc/<pid>/paths/a.out. But it is only readable for processes we own.
*/
#if defined(__solaris__)
snprintf(fn, sizeof fn, "/proc/%d/path/a.out", pid);
if ((ret = readlink(fn, exePath, PATH_MAX - 1)) > 0) {
// null terminate and create String to store for command
exePath[ret] = '\0';
CHECK_NULL(cmdexe = JNU_NewStringPlatform(env, exePath));
}
#endif
/*
* Now try to open /proc/%d/psinfo
*/
@ -733,4 +705,4 @@ void unix_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) {
prargs[0] == '\0' ? NULL : prargs);
}
#endif // defined(__solaris__) || defined(_AIX)
#endif // defined(_AIX)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,7 +29,7 @@
* Declaration of ProcessHandleImpl functions common on all Unix platforms.
* 'unix_' functions have a single implementation in ProcessHandleImpl_unix.c
* 'os_' prefixed functions have different, os-specific implementations in the
* various ProcessHandleImpl_{linux,macosx,solaris,aix}.c files.
* various ProcessHandleImpl_{linux,macosx,aix}.c files.
* See ProcessHandleImpl_unix.c for more details.
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -230,14 +230,7 @@ xmalloc(JNIEnv *env, size_t size)
static const char*
defaultPath(void)
{
#ifdef __solaris__
/* These really are the Solaris defaults! */
return (geteuid() == 0 || getuid() == 0) ?
"/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:/usr/sbin" :
"/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:";
#else
return ":/bin:/usr/bin"; /* glibc */
#endif
return ":/bin:/usr/bin";
}
static const char*
@ -452,7 +445,6 @@ __attribute_noinline__
#endif
/* vfork(2) is deprecated on Solaris */
#ifndef __solaris__
static pid_t
vforkChild(ChildStuff *c) {
volatile pid_t resultPid;
@ -471,7 +463,6 @@ vforkChild(ChildStuff *c) {
assert(resultPid != 0); /* childProcess never returns */
return resultPid;
}
#endif
static pid_t
forkChild(ChildStuff *c) {
@ -583,10 +574,8 @@ static pid_t
startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) {
switch (c->mode) {
/* vfork(2) is deprecated on Solaris */
#ifndef __solaris__
case MODE_VFORK:
return vforkChild(c);
#endif
case MODE_FORK:
return forkChild(c);
case MODE_POSIX_SPAWN:

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,9 +35,6 @@
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#if defined(__solaris__)
#include <libscf.h>
#endif
#include "jvm.h"
#include "TimeZone_md.h"
@ -52,11 +49,9 @@ static char *isFileIdentical(char* buf, size_t size, char *pathname);
} while((_result == -1) && (errno == EINTR)); \
} while(0)
#if !defined(__solaris__) || defined(__sparcv9) || defined(amd64)
#define fileopen fopen
#define filegets fgets
#define fileclose fclose
#endif
#if defined(_ALLBSD_SOURCE)
#define stat64 stat
@ -80,7 +75,7 @@ static const char popularZones[][4] = {"UTC", "GMT"};
static const char *ETC_ENVIRONMENT_FILE = "/etc/environment";
#endif
#if defined(__linux__) || defined(MACOSX) || defined(__solaris__)
#if defined(__linux__) || defined(MACOSX)
/*
* Returns a pointer to the zone ID portion of the given zoneinfo file
@ -164,13 +159,6 @@ findZoneinfoFile(char *buf, size_t size, const char *dir)
*/
if ((strcmp(dp->d_name, "ROC") == 0)
|| (strcmp(dp->d_name, "posixrules") == 0)
#if defined(__solaris__)
/*
* Skip the "src" and "tab" directories on Solaris.
*/
|| (strcmp(dp->d_name, "src") == 0)
|| (strcmp(dp->d_name, "tab") == 0)
#endif
|| (strcmp(dp->d_name, "localtime") == 0)) {
continue;
}
@ -242,8 +230,6 @@ isFileIdentical(char *buf, size_t size, char *pathname)
return possibleMatch;
}
#if defined(__linux__) || defined(MACOSX)
/*
* Performs Linux specific mapping and returns a zone ID
* if found. Otherwise, NULL is returned.
@ -353,311 +339,6 @@ getPlatformTimeZoneID()
return tz;
}
#elif defined(__solaris__)
#if !defined(__sparcv9) && !defined(amd64)
/*
* Those file* functions mimic the UNIX stream io functions. This is
* because of the limitation of the number of open files on Solaris
* (32-bit mode only) due to the System V ABI.
*/
#define BUFFER_SIZE 4096
static struct iobuffer {
int magic; /* -1 to distinguish from the real FILE */
int fd; /* file descriptor */
char *buffer; /* pointer to buffer */
char *ptr; /* current read pointer */
char *endptr; /* end pointer */
};
static int
fileclose(FILE *stream)
{
struct iobuffer *iop = (struct iobuffer *) stream;
if (iop->magic != -1) {
return fclose(stream);
}
if (iop == NULL) {
return 0;
}
close(iop->fd);
free((void *)iop->buffer);
free((void *)iop);
return 0;
}
static FILE *
fileopen(const char *fname, const char *fmode)
{
FILE *fp;
int fd;
struct iobuffer *iop;
if ((fp = fopen(fname, fmode)) != NULL) {
return fp;
}
/*
* It assumes read open.
*/
RESTARTABLE(open(fname, O_RDONLY), fd);
if (fd == -1) {
return NULL;
}
/*
* Allocate struct iobuffer and its buffer
*/
iop = malloc(sizeof(struct iobuffer));
if (iop == NULL) {
(void) close(fd);
errno = ENOMEM;
return NULL;
}
iop->magic = -1;
iop->fd = fd;
iop->buffer = malloc(BUFFER_SIZE);
if (iop->buffer == NULL) {
(void) close(fd);
free((void *) iop);
errno = ENOMEM;
return NULL;
}
iop->ptr = iop->buffer;
iop->endptr = iop->buffer;
return (FILE *)iop;
}
/*
* This implementation assumes that n is large enough and the line
* separator is '\n'.
*/
static char *
filegets(char *s, int n, FILE *stream)
{
struct iobuffer *iop = (struct iobuffer *) stream;
char *p;
if (iop->magic != -1) {
return fgets(s, n, stream);
}
p = s;
for (;;) {
char c;
if (iop->ptr == iop->endptr) {
ssize_t len;
RESTARTABLE(read(iop->fd, (void *)iop->buffer, BUFFER_SIZE), len);
if (len == -1) {
return NULL;
}
if (len == 0) {
*p = 0;
if (s == p) {
return NULL;
}
return s;
}
iop->ptr = iop->buffer;
iop->endptr = iop->buffer + len;
}
c = *iop->ptr++;
*p++ = c;
if ((p - s) == (n - 1)) {
*p = 0;
return s;
}
if (c == '\n') {
*p = 0;
return s;
}
}
/*NOTREACHED*/
}
#endif /* !defined(__sparcv9) && !defined(amd64) */
/*
* Performs Solaris dependent mapping. Returns a zone ID if
* found. Otherwise, NULL is returned. Solaris libc looks up
* "/etc/default/init" to get the default TZ value if TZ is not defined
* as an environment variable.
*/
static char *
getPlatformTimeZoneID()
{
char *tz = NULL;
FILE *fp;
/*
* Try the TZ entry in /etc/default/init.
*/
if ((fp = fileopen(SYS_INIT_FILE, "r")) != NULL) {
char line[256];
char quote = '\0';
while (filegets(line, sizeof(line), fp) != NULL) {
char *p = line;
char *s;
char c;
/* quick check for comment lines */
if (*p == '#') {
continue;
}
if (strncmp(p, "TZ=", 3) == 0) {
p += 3;
SKIP_SPACE(p);
c = *p;
if (c == '"' || c == '\'') {
quote = c;
p++;
}
/*
* PSARC/2001/383: quoted string support
*/
for (s = p; (c = *s) != '\0' && c != '\n'; s++) {
/* No '\\' is supported here. */
if (c == quote) {
quote = '\0';
break;
}
if (c == ' ' && quote == '\0') {
break;
}
}
if (quote != '\0') {
jio_fprintf(stderr, "ZoneInfo: unterminated time zone name in /etc/TIMEZONE\n");
}
*s = '\0';
tz = strdup(p);
break;
}
}
(void) fileclose(fp);
}
return tz;
}
#define TIMEZONE_FMRI "svc:/system/timezone:default"
#define TIMEZONE_PG "timezone"
#define LOCALTIME_PROP "localtime"
static void
cleanupScf(scf_handle_t *h,
scf_snapshot_t *snap,
scf_instance_t *inst,
scf_propertygroup_t *pg,
scf_property_t *prop,
scf_value_t *val,
char *buf) {
if (buf != NULL) {
free(buf);
}
if (snap != NULL) {
scf_snapshot_destroy(snap);
}
if (val != NULL) {
scf_value_destroy(val);
}
if (prop != NULL) {
scf_property_destroy(prop);
}
if (pg != NULL) {
scf_pg_destroy(pg);
}
if (inst != NULL) {
scf_instance_destroy(inst);
}
if (h != NULL) {
scf_handle_destroy(h);
}
}
/*
* Returns a zone ID of Solaris when the TZ value is "localtime".
* First, it tries scf. If scf fails, it looks for the same file as
* /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/.
*/
static char *
getSolarisDefaultZoneID() {
char *tz = NULL;
struct stat64 statbuf;
size_t size;
char *buf;
int fd;
int res;
/* scf specific variables */
scf_handle_t *h = NULL;
scf_snapshot_t *snap = NULL;
scf_instance_t *inst = NULL;
scf_propertygroup_t *pg = NULL;
scf_property_t *prop = NULL;
scf_value_t *val = NULL;
if ((h = scf_handle_create(SCF_VERSION)) != NULL
&& scf_handle_bind(h) == 0
&& (inst = scf_instance_create(h)) != NULL
&& (snap = scf_snapshot_create(h)) != NULL
&& (pg = scf_pg_create(h)) != NULL
&& (prop = scf_property_create(h)) != NULL
&& (val = scf_value_create(h)) != NULL
&& scf_handle_decode_fmri(h, TIMEZONE_FMRI, NULL, NULL, inst,
NULL, NULL, SCF_DECODE_FMRI_REQUIRE_INSTANCE) == 0
&& scf_instance_get_snapshot(inst, "running", snap) == 0
&& scf_instance_get_pg_composed(inst, snap, TIMEZONE_PG, pg) == 0
&& scf_pg_get_property(pg, LOCALTIME_PROP, prop) == 0
&& scf_property_get_value(prop, val) == 0) {
ssize_t len;
/* Gets the length of the zone ID string */
len = scf_value_get_astring(val, NULL, 0);
if (len != -1) {
tz = malloc(++len); /* +1 for a null byte */
if (tz != NULL && scf_value_get_astring(val, tz, len) != -1) {
cleanupScf(h, snap, inst, pg, prop, val, NULL);
return tz;
}
}
}
cleanupScf(h, snap, inst, pg, prop, val, tz);
RESTARTABLE(stat64(DEFAULT_ZONEINFO_FILE, &statbuf), res);
if (res == -1) {
return NULL;
}
size = (size_t) statbuf.st_size;
buf = malloc(size);
if (buf == NULL) {
return NULL;
}
RESTARTABLE(open(DEFAULT_ZONEINFO_FILE, O_RDONLY), fd);
if (fd == -1) {
free((void *) buf);
return NULL;
}
RESTARTABLE(read(fd, buf, size), res);
if (res != (ssize_t) size) {
(void) close(fd);
free((void *) buf);
return NULL;
}
(void) close(fd);
tz = findZoneinfoFile(buf, size, ZONEINFO_DIR);
free((void *) buf);
return tz;
}
#endif /* defined(__solaris__) */
#elif defined(_AIX)
static char *
@ -824,15 +505,6 @@ findJavaTZ_md(const char *java_home_dir)
free((void *) freetz);
}
#else
#if defined(__solaris__)
/* Solaris might use localtime, so handle it here. */
if (strcmp(tz, "localtime") == 0) {
javatz = getSolarisDefaultZoneID();
if (freetz != NULL) {
free((void *) freetz);
}
} else
#endif
if (freetz == NULL) {
/* strdup if we are still working on getenv result. */
javatz = strdup(tz);
@ -890,19 +562,7 @@ getGMTOffsetID()
{
time_t offset;
char sign, buf[32];
#if defined(__solaris__)
struct tm localtm;
time_t currenttime;
currenttime = time(NULL);
if (localtime_r(&currenttime, &localtm) == NULL) {
return strdup("GMT");
}
offset = localtm.tm_isdst ? altzone : timezone;
#else
offset = timezone;
#endif
if (offset == 0) {
return strdup("GMT");

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,10 +63,6 @@
#define stat stat64
#endif
#if defined(__solaris__) && !defined(NAME_MAX)
#define NAME_MAX MAXNAMLEN
#endif
#if defined(_ALLBSD_SOURCE)
#ifndef MACOSX
#define statvfs64 statvfs

View file

@ -30,10 +30,6 @@
#include <string.h>
#include <unistd.h>
#ifdef __solaris__
#include <sys/filio.h>
#endif
#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
#include <sys/ioctl.h>
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -313,27 +313,6 @@ static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_s
}
#endif
#ifdef __solaris__
if (strcmp(p,"eucJP") == 0) {
/* For Solaris use customized vendor defined character
* customized EUC-JP converter
*/
*std_encoding = "eucJP-open";
} else if (strcmp(p, "Big5") == 0 || strcmp(p, "BIG5") == 0) {
/*
* Remap the encoding string to Big5_Solaris which augments
* the default converter for Solaris Big5 locales to include
* seven additional ideographic characters beyond those included
* in the Java "Big5" converter.
*/
*std_encoding = "Big5_Solaris";
} else if (strcmp(p, "Big5-HKSCS") == 0) {
/*
* Solaris uses HKSCS2001
*/
*std_encoding = "Big5-HKSCS-2001";
}
#endif
#ifdef MACOSX
/*
* For the case on MacOS X where encoding is set to US-ASCII, but we

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,11 +27,7 @@
#define JDK_UTIL_MD_H
// checking for nanness
#ifdef __solaris__
#include <ieeefp.h>
#define ISNANF(f) isnanf(f)
#define ISNAND(d) isnand(d)
#elif defined(MACOSX)
#if defined(MACOSX)
#include <math.h>
#define ISNANF(f) isnan(f)
#define ISNAND(d) isnan(d)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,8 +23,8 @@
* questions.
*/
#ifndef _SOLARIS_JLONG_MD_H_
#define _SOLARIS_JLONG_MD_H_
#ifndef _UNIX_JLONG_MD_H_
#define _UNIX_JLONG_MD_H_
/* Make sure ptrdiff_t is defined */
#include <stddef.h>
@ -97,4 +97,4 @@
#define size_to_jlong(a) ((jlong)(a))
#define long_to_jlong(a) ((jlong)(a))
#endif /* !_SOLARIS_JLONG_MD_H_ */
#endif /* !_UNIX_JLONG_MD_H_ */

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,7 @@
#define JAVA_MD_H
/*
* This file contains common defines and includes for Solaris, Linux and MacOSX.
* This file contains common defines and includes for unix.
*/
#include <limits.h>
#include <unistd.h>

View file

@ -51,12 +51,6 @@
#define SETENV_REQUIRED
#endif
#ifdef __solaris__
# include <sys/systeminfo.h>
# include <sys/elf.h>
# include <stdio.h>
#endif
/*
* Flowchart of launcher execs and options processing on unix
*
@ -242,9 +236,6 @@ RequiresSetenv(const char *jvmpath) {
#endif
llp = getenv("LD_LIBRARY_PATH");
#ifdef __solaris__
dmllp = getenv("LD_LIBRARY_PATH_64");
#endif /* __solaris__ */
/* no environment variable is a good environment variable */
if (llp == NULL && dmllp == NULL) {
return JNI_FALSE;
@ -304,9 +295,6 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
#ifdef SETENV_REQUIRED
jboolean mustsetenv = JNI_FALSE;
#ifdef __solaris__
char *llp64 = NULL; /* existing LD_LIBRARY_PATH_64 setting */
#endif // __solaris__
char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */
char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
@ -371,12 +359,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
* any.
*/
#ifdef __solaris__
llp64 = getenv("LD_LIBRARY_PATH_64");
runpath = (llp64 == NULL) ? getenv(LD_LIBRARY_PATH) : llp64;
#else
runpath = getenv(LD_LIBRARY_PATH);
#endif /* __solaris__ */
/* runpath contains current effective LD_LIBRARY_PATH setting */
{ /* New scope to declare local variable */
@ -449,14 +432,6 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
* once at startup, so we have to re-exec the current executable
* to get the changed environment variable to have an effect.
*/
#ifdef __solaris__
/*
* new LD_LIBRARY_PATH took over for LD_LIBRARY_PATH_64
*/
if (llp64 != NULL) {
UnsetEnv("LD_LIBRARY_PATH_64");
}
#endif // __solaris__
newenvp = environ;
}
@ -556,51 +531,6 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
if (libjvm == NULL) {
#if defined(__solaris__) && defined(__sparc) && !defined(_LP64) /* i.e. 32-bit sparc */
FILE * fp;
Elf32_Ehdr elf_head;
int count;
int location;
fp = fopen(jvmpath, "r");
if (fp == NULL) {
JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
}
/* read in elf header */
count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp);
fclose(fp);
if (count < 1) {
JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
}
/*
* Check for running a server vm (compiled with -xarch=v8plus)
* on a stock v8 processor. In this case, the machine type in
* the elf header would not be included the architecture list
* provided by the isalist command, which is turn is gotten from
* sysinfo. This case cannot occur on 64-bit hardware and thus
* does not have to be checked for in binaries with an LP64 data
* model.
*/
if (elf_head.e_machine == EM_SPARC32PLUS) {
char buf[257]; /* recommended buffer size from sysinfo man
page */
long length;
char* location;
length = sysinfo(SI_ISALIST, buf, 257);
if (length > 0) {
location = JLI_StrStr(buf, "sparcv8plus ");
if (location == NULL) {
JLI_ReportErrorMessage(JVM_ERROR3);
return JNI_FALSE;
}
}
}
#endif
JLI_ReportErrorMessage(DLL_ERROR1, __LINE__);
JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
@ -647,28 +577,7 @@ const char*
SetExecname(char **argv)
{
char* exec_path = NULL;
#if defined(__solaris__)
{
Dl_info dlinfo;
int (*fptr)();
fptr = (int (*)())dlsym(RTLD_DEFAULT, "main");
if (fptr == NULL) {
JLI_ReportErrorMessage(DLL_ERROR3, dlerror());
return JNI_FALSE;
}
if (dladdr((void*)fptr, &dlinfo)) {
char *resolved = (char*)JLI_MemAlloc(PATH_MAX+1);
if (resolved != NULL) {
exec_path = realpath(dlinfo.dli_fname, resolved);
if (exec_path == NULL) {
JLI_MemFree(resolved);
}
}
}
}
#elif defined(__linux__)
#if defined(__linux__)
{
const char* self = "/proc/self/exe";
char buf[PATH_MAX+1];
@ -678,7 +587,7 @@ SetExecname(char **argv)
exec_path = JLI_StringDup(buf);
}
}
#else /* !__solaris__ && !__linux__ */
#else /* !__linux__ */
{
/* Not implemented */
}
@ -740,7 +649,6 @@ static void* ThreadJavaMain(void* args) {
int
CallJavaMainInNewThread(jlong stack_size, void* args) {
int rslt;
#ifndef __solaris__
pthread_t tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
@ -766,18 +674,6 @@ CallJavaMainInNewThread(jlong stack_size, void* args) {
}
pthread_attr_destroy(&attr);
#else /* __solaris__ */
thread_t tid;
long flags = 0;
if (thr_create(NULL, stack_size, ThreadJavaMain, args, flags, &tid) == 0) {
void* tmp;
thr_join(tid, NULL, &tmp);
rslt = (int)(intptr_t)tmp;
} else {
/* See above. Continue in current thread if thr_create() failed */
rslt = JavaMain(args);
}
#endif /* !__solaris__ */
return rslt;
}
@ -814,8 +710,6 @@ ProcessPlatformOption(const char *arg)
return JNI_FALSE;
}
#ifndef __solaris__
/*
* Provide a CounterGet() implementation based on gettimeofday() which
* is universally available, even though it may not be 'high resolution'
@ -832,5 +726,3 @@ uint64_t CounterGet() {
}
return result;
}
#endif // !__solaris__

View file

@ -27,16 +27,8 @@
#define JAVA_MD_SOLINUX_H
#include <sys/time.h>
#ifdef __solaris__
/*
* Support for doing cheap, accurate interval timing.
*/
#define CounterGet() (gethrtime()/1000)
#define Counter2Micros(counts) (counts)
#else /* ! __solaris__ */
uint64_t CounterGet(void);
#define Counter2Micros(counts) (counts)
#endif /* __solaris__ */
/* pointer to environment */
extern char **environ;
@ -45,17 +37,9 @@ extern char **environ;
* A collection of useful strings. One should think of these as #define
* entries, but actual strings can be more efficient (with many compilers).
*/
#ifdef __solaris__
static const char *user_dir = "/jdk";
#else /* !__solaris__, i.e. Linux, AIX,.. */
static const char *user_dir = "/java";
#endif
static const char *user_dir = "/java";
#include <dlfcn.h>
#ifdef __solaris__
#include <thread.h>
#else
#include <pthread.h>
#endif
#endif /* JAVA_MD_SOLINUX_H */

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -33,16 +33,6 @@
#include "jni.h"
#ifdef SOLARIS
/* Our redeclarations of the system functions must not have a less
* restrictive linker scoping, so we have to declare them as JNIEXPORT
* before including signal.h */
#include "sys/signal.h"
JNIEXPORT void (*signal(int sig, void (*disp)(int)))(int);
JNIEXPORT void (*sigset(int sig, void (*disp)(int)))(int);
JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *oact);
#endif
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
@ -59,16 +49,9 @@ JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *
#define false 0
#endif
#ifdef SOLARIS
#define MAX_SIGNALS (SIGRTMAX+1)
/* On solaris, MAX_SIGNALS is a macro, not a constant, so we must allocate sact dynamically. */
static struct sigaction *sact = (struct sigaction *)NULL; /* saved signal handlers */
#else
#define MAX_SIGNALS NSIG
static struct sigaction sact[MAX_SIGNALS]; /* saved signal handlers */
#endif
static sigset_t jvmsigs; /* Signals used by jvm. */
@ -93,20 +76,6 @@ static bool jvm_signal_installing = false;
static bool jvm_signal_installed = false;
/* assume called within signal_lock */
static void allocate_sact() {
#ifdef SOLARIS
if (sact == NULL) {
sact = (struct sigaction *)malloc((MAX_SIGNALS) * (size_t)sizeof(struct sigaction));
if (sact == NULL) {
printf("%s\n", "libjsig.so unable to allocate memory");
exit(0);
}
memset(sact, 0, (MAX_SIGNALS) * (size_t)sizeof(struct sigaction));
}
#endif
}
static void signal_lock() {
pthread_mutex_lock(&mutex);
/* When the jvm is installing its set of signal handlers, threads
@ -162,18 +131,7 @@ static void save_signal_handler(int sig, sa_handler_t disp, bool is_sigset) {
sact[sig].sa_handler = disp;
sigemptyset(&set);
sact[sig].sa_mask = set;
if (!is_sigset) {
#ifdef SOLARIS
sact[sig].sa_flags = SA_NODEFER;
if (sig != SIGILL && sig != SIGTRAP && sig != SIGPWR) {
sact[sig].sa_flags |= SA_RESETHAND;
}
#else
sact[sig].sa_flags = 0;
#endif
} else {
sact[sig].sa_flags = 0;
}
sact[sig].sa_flags = 0;
}
static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
@ -182,7 +140,6 @@ static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
bool sigblocked;
signal_lock();
allocate_sact();
sigused = sigismember(&jvmsigs, sig);
if (jvm_signal_installed && sigused) {
@ -194,13 +151,6 @@ static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
oldhandler = sact[sig].sa_handler;
save_signal_handler(sig, disp, is_sigset);
#ifdef SOLARIS
if (is_sigset && sigblocked) {
/* We won't honor the SIG_HOLD request to change the signal mask */
oldhandler = SIG_HOLD;
}
#endif
signal_unlock();
return oldhandler;
} else if (jvm_signal_installing) {
@ -278,7 +228,6 @@ JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *
signal_lock();
allocate_sact();
sigused = sigismember(&jvmsigs, sig);
if (jvm_signal_installed && sigused) {
/* jvm has installed its signal handler for this signal. */
@ -334,7 +283,6 @@ JNIEXPORT void JVM_end_signal_setting() {
}
JNIEXPORT struct sigaction *JVM_get_signal_action(int sig) {
allocate_sact();
/* Does race condition make sense here? */
if (sigismember(&jvmsigs, sig)) {
return &sact[sig];

View file

@ -64,27 +64,8 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
if (gethostname(hostname, sizeof(hostname)) != 0) {
strcpy(hostname, "localhost");
} else {
#if defined(__solaris__)
// try to resolve hostname via nameservice
// if it is known but getnameinfo fails, hostname will still be the
// value from gethostname
struct addrinfo hints, *res;
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_INET;
if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
getnameinfo(res->ai_addr, res->ai_addrlen, hostname, sizeof(hostname),
NULL, 0, NI_NAMEREQD);
freeaddrinfo(res);
}
#else
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
#endif
}
return (*env)->NewStringUTF(env, hostname);
}

View file

@ -65,27 +65,8 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
if (gethostname(hostname, sizeof(hostname)) != 0) {
strcpy(hostname, "localhost");
} else {
#if defined(__solaris__)
// try to resolve hostname via nameservice
// if it is known but getnameinfo fails, hostname will still be the
// value from gethostname
struct addrinfo hints, *res;
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
getnameinfo(res->ai_addr, res->ai_addrlen, hostname, sizeof(hostname),
NULL, 0, NI_NAMEREQD);
freeaddrinfo(res);
}
#else
// make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
#endif
}
return (*env)->NewStringUTF(env, hostname);
}

View file

@ -37,12 +37,6 @@
#include <strings.h>
#endif
#if defined(__solaris__)
#include <stropts.h>
#include <sys/dlpi.h>
#include <sys/sockio.h>
#endif
#if defined(_ALLBSD_SOURCE)
#include <net/ethernet.h>
#include <net/if_dl.h>
@ -55,11 +49,6 @@
#if defined(__linux__)
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
#elif defined(__solaris__)
#ifndef SIOCGLIFHWADDR
#define SIOCGLIFHWADDR _IOWR('i', 192, struct lifreq)
#endif
#define DEV_PREFIX "/dev/"
#endif
#ifdef LIFNAMSIZ
@ -147,11 +136,6 @@ static int getMacAddress(JNIEnv *env, const char *ifname,
const struct in_addr *addr, unsigned char *buf);
static int getMTU(JNIEnv *env, int sock, const char *ifname);
#if defined(__solaris__)
static int getMacFromDevice(JNIEnv *env, const char *ifname,
unsigned char *retbuf);
#endif
/******************* Java entry points *****************************/
/*
@ -1672,372 +1656,6 @@ static int getFlags(int sock, const char *ifname, int *flags) {
#endif /* _AIX */
/** Solaris **/
#if defined(__solaris__)
/*
* Opens a socket for further ioctl calls. Tries AF_INET socket first and
* if it fails return AF_INET6 socket.
*/
static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
int sock, alreadyV6 = 0;
struct lifreq if2;
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
alreadyV6 = 1;
} else { // errno is not NOSUPPORT
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
// Solaris requires that we have an IPv6 socket to query an interface
// without an IPv4 address - check it here. POSIX 1 require the kernel to
// return ENOTTY if the call is inappropriate for a device e.g. the NETMASK
// for a device having IPv6 only address but not all devices follow the
// standard so fall back on any error. It's not an ecologically friendly
// gesture but more reliable.
if (!alreadyV6) {
memset((char *)&if2, 0, sizeof(if2));
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
close(sock);
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
}
}
return sock;
}
/*
* Enumerates and returns all IPv4 interfaces on Solaris.
*/
static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
struct lifconf ifc;
struct lifreq *ifreqP;
struct lifnum numifs;
char *buf = NULL;
unsigned i;
// call SIOCGLIFNUM to get the interface count
numifs.lifn_family = AF_INET;
numifs.lifn_flags = 0;
if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
return ifs;
}
// call SIOCGLIFCONF to enumerate the interfaces
ifc.lifc_len = numifs.lifn_count * sizeof(struct lifreq);
CHECKED_MALLOC3(buf, char *, ifc.lifc_len);
ifc.lifc_buf = buf;
ifc.lifc_family = AF_INET;
ifc.lifc_flags = 0;
if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
free(buf);
return ifs;
}
// iterate through each interface
ifreqP = ifc.lifc_req;
for (i = 0; i < numifs.lifn_count; i++, ifreqP++) {
struct sockaddr addr, *broadaddrP = NULL;
// ignore non IPv4 addresses
if (ifreqP->lifr_addr.ss_family != AF_INET) {
continue;
}
// save socket address
memcpy(&addr, &(ifreqP->lifr_addr), sizeof(struct sockaddr));
// determine broadcast address, if applicable
if ((ioctl(sock, SIOCGLIFFLAGS, ifreqP) == 0) &&
ifreqP->lifr_flags & IFF_BROADCAST) {
// restore socket address to ifreqP
memcpy(&(ifreqP->lifr_addr), &addr, sizeof(struct sockaddr));
// query broadcast address and set pointer to it
if (ioctl(sock, SIOCGLIFBRDADDR, ifreqP) == 0) {
broadaddrP = (struct sockaddr *)&(ifreqP->lifr_broadaddr);
}
}
// add to the list
ifs = addif(env, sock, ifreqP->lifr_name, ifs,
&addr, broadaddrP, AF_INET, (short)ifreqP->lifr_addrlen);
// if an exception occurred we return immediately
if ((*env)->ExceptionOccurred(env)) {
free(buf);
return ifs;
}
}
// free buffer
free(buf);
return ifs;
}
/*
* Enumerates and returns all IPv6 interfaces on Solaris.
*/
static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
struct lifconf ifc;
struct lifreq *ifreqP;
struct lifnum numifs;
char *buf = NULL;
unsigned i;
// call SIOCGLIFNUM to get the interface count
numifs.lifn_family = AF_INET6;
numifs.lifn_flags = 0;
if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
return ifs;
}
// call SIOCGLIFCONF to enumerate the interfaces
ifc.lifc_len = numifs.lifn_count * sizeof(struct lifreq);
CHECKED_MALLOC3(buf, char *, ifc.lifc_len);
ifc.lifc_buf = buf;
ifc.lifc_family = AF_INET6;
ifc.lifc_flags = 0;
if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
free(buf);
return ifs;
}
// iterate through each interface
ifreqP = ifc.lifc_req;
for (i = 0; i < numifs.lifn_count; i++, ifreqP++) {
// ignore non IPv6 addresses
if (ifreqP->lifr_addr.ss_family != AF_INET6) {
continue;
}
// set scope ID to interface index
((struct sockaddr_in6 *)&(ifreqP->lifr_addr))->sin6_scope_id =
getIndex(sock, ifreqP->lifr_name);
// add to the list
ifs = addif(env, sock, ifreqP->lifr_name, ifs,
(struct sockaddr *)&(ifreqP->lifr_addr),
NULL, AF_INET6, (short)ifreqP->lifr_addrlen);
// if an exception occurred we return immediately
if ((*env)->ExceptionOccurred(env)) {
free(buf);
return ifs;
}
}
// free buffer
free(buf);
return ifs;
}
/*
* Try to get the interface index.
* (Not supported on Solaris 2.6 or 7)
*/
static int getIndex(int sock, const char *name) {
struct lifreq if2;
memset((char *)&if2, 0, sizeof(if2));
strncpy(if2.lifr_name, name, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFINDEX, (char *)&if2) < 0) {
return -1;
}
return if2.lifr_index;
}
/*
* Solaris specific DLPI code to get hardware address from a device.
* Unfortunately, at least up to Solaris X, you have to have special
* privileges (i.e. be root).
*/
static int getMacFromDevice
(JNIEnv *env, const char *ifname, unsigned char *retbuf)
{
char style1dev[MAXPATHLEN];
int fd;
dl_phys_addr_req_t dlpareq;
dl_phys_addr_ack_t *dlpaack;
dl_error_ack_t *dlerack;
struct strbuf msg;
char buf[128];
int flags = 0;
// Device is in /dev. e.g.: /dev/bge0
strcpy(style1dev, DEV_PREFIX);
strcat(style1dev, ifname);
if ((fd = open(style1dev, O_RDWR)) < 0) {
// Can't open it. We probably are missing the privilege.
// We'll have to try something else
return 0;
}
dlpareq.dl_primitive = DL_PHYS_ADDR_REQ;
dlpareq.dl_addr_type = DL_CURR_PHYS_ADDR;
msg.buf = (char *)&dlpareq;
msg.len = DL_PHYS_ADDR_REQ_SIZE;
if (putmsg(fd, &msg, NULL, 0) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "putmsg() failed");
return -1;
}
dlpaack = (dl_phys_addr_ack_t *)buf;
msg.buf = (char *)buf;
msg.len = 0;
msg.maxlen = sizeof (buf);
if (getmsg(fd, &msg, NULL, &flags) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getmsg() failed");
return -1;
}
if (dlpaack->dl_primitive == DL_ERROR_ACK) {
dlerack = (dl_error_ack_t *)buf;
if (dlerack->dl_error_primitive != DL_PHYS_ADDR_REQ) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Couldn't obtain physical address\n");
return -1;
}
if (dlerack->dl_errno == DL_UNSUPPORTED) {
// fallback to lookup in the ARP table
return 0;
}
}
if (msg.len < DL_PHYS_ADDR_ACK_SIZE || dlpaack->dl_primitive != DL_PHYS_ADDR_ACK) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Couldn't obtain phys addr\n");
return -1;
}
memcpy(retbuf, &buf[dlpaack->dl_addr_offset], dlpaack->dl_addr_length);
return dlpaack->dl_addr_length;
}
/*
* Gets the Hardware address (usually MAC address) for the named interface.
* On return puts the data in buf, and returns the length, in byte, of the
* MAC address. Returns -1 if there is no hardware address on that interface.
*/
static int getMacAddress
(JNIEnv *env, const char *ifname, const struct in_addr *addr,
unsigned char *buf)
{
struct lifreq if2;
int len, i, sock;
if ((sock = openSocketWithFallback(env, ifname)) < 0) {
return -1;
}
// First, try the new (S11) SIOCGLIFHWADDR ioctl(). If that fails
// try the old way.
memset((char *)&if2, 0, sizeof(if2));
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFHWADDR, &if2) != -1) {
struct sockaddr_dl *sp;
sp = (struct sockaddr_dl *)&if2.lifr_addr;
memcpy(buf, &sp->sdl_data[0], sp->sdl_alen);
close(sock);
return sp->sdl_alen;
}
// On Solaris we have to use DLPI, but it will only work if we have
// privileged access (i.e. root). If that fails, we try a lookup
// in the ARP table, which requires an IPv4 address.
if (((len = getMacFromDevice(env, ifname, buf)) == 0) && (addr != NULL)) {
struct arpreq arpreq;
struct sockaddr_in *sin;
struct sockaddr_in ipAddr;
len = 6; //???
sin = (struct sockaddr_in *)&arpreq.arp_pa;
memset((char *)&arpreq, 0, sizeof(struct arpreq));
ipAddr.sin_port = 0;
ipAddr.sin_family = AF_INET;
memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr));
memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
arpreq.arp_flags= ATF_PUBL;
if (ioctl(sock, SIOCGARP, &arpreq) < 0) {
close(sock);
return -1;
}
memcpy(buf, &arpreq.arp_ha.sa_data[0], len);
}
close(sock);
// all bytes to 0 means no hardware address
for (i = 0; i < len; i++) {
if (buf[i] != 0)
return len;
}
return -1;
}
static int getMTU(JNIEnv *env, int sock, const char *ifname) {
struct lifreq if2;
memset((char *)&if2, 0, sizeof(if2));
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFMTU, (char *)&if2) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFMTU) failed");
return -1;
}
return if2.lifr_mtu;
}
static int getFlags(int sock, const char *ifname, int *flags) {
struct lifreq if2;
memset((char *)&if2, 0, sizeof(if2));
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFFLAGS, (char *)&if2) < 0) {
return -1;
}
*flags = if2.lifr_flags;
return 0;
}
#endif /* __solaris__ */
/** BSD **/
#if defined(_ALLBSD_SOURCE)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,10 +27,6 @@
#include <string.h>
#include <sys/ioctl.h>
#if defined(__solaris__)
#include <sys/filio.h>
#endif
#include "net_util.h"
#include "java_net_PlainDatagramSocketImpl.h"
@ -52,12 +48,6 @@
#endif
#endif // __linux__
#ifdef __solaris__
#ifndef BSD_COMP
#define BSD_COMP
#endif
#endif
#ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e
#endif
@ -498,14 +488,6 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
n = NET_RecvFrom(fd, buf, 1, MSG_PEEK, &rmtaddr.sa, &slen);
if (n == -1) {
#ifdef __solaris__
if (errno == ECONNREFUSED) {
int orig_errno = errno;
recv(fd, buf, 1, 0);
errno = orig_errno;
}
#endif
if (errno == ECONNREFUSED) {
JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException",
"ICMP Port Unreachable");
@ -632,14 +614,6 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
n = packetBufferLen;
}
if (n == -1) {
#ifdef __solaris__
if (errno == ECONNREFUSED) {
int orig_errno = errno;
(void) recv(fd, fullPacket, 1, 0);
errno = orig_errno;
}
#endif
(*env)->SetIntField(env, packet, dp_offsetID, 0);
(*env)->SetIntField(env, packet, dp_lengthID, 0);
if (errno == ECONNREFUSED) {
@ -1853,10 +1827,9 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
* we must use the IPv4 socket options. This is because the IPv6 socket options
* don't support IPv4-mapped addresses. This is true as per 2.2.19 and 2.4.7
* kernel releases. In the future it's possible that IP_ADD_MEMBERSHIP
* will be updated to return ENOPROTOOPT if uses with an IPv6 socket (Solaris
* already does this). Thus to cater for this we first try with the IPv4
* socket options and if they fail we use the IPv6 socket options. This
* seems a reasonable failsafe solution.
* will be updated to return ENOPROTOOPT if uses with an IPv6 socket. Thus to
* cater for this we first try with the IPv4 socket options and if they fail we
* use the IPv6 socket options. This seems a reasonable failsafe solution.
*/
static void mcast_join_leave(JNIEnv *env, jobject this,
jobject iaObj, jobject niObj,

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -266,45 +266,6 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
if (timeout <= 0) {
connect_rv = NET_Connect(fd, &sa.sa, len);
#ifdef __solaris__
if (connect_rv == -1 && errno == EINPROGRESS ) {
/* This can happen if a blocking connect is interrupted by a signal.
* See 6343810.
*/
while (1) {
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLOUT;
connect_rv = NET_Poll(&pfd, 1, -1);
if (connect_rv == -1) {
if (errno == EINTR) {
continue;
} else {
break;
}
}
if (connect_rv > 0) {
socklen_t optlen;
/* has connection been established */
optlen = sizeof(connect_rv);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR,
(void*)&connect_rv, &optlen) <0) {
connect_rv = errno;
}
if (connect_rv != 0) {
/* restore errno */
errno = connect_rv;
connect_rv = -1;
}
break;
}
}
}
#endif
} else {
/*
* A timeout was specified. We put the socket into non-blocking
@ -893,16 +854,16 @@ Java_java_net_PlainSocketImpl_socketSetOption0
}
if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) {
#if defined(__solaris__) || defined(_AIX)
#if defined(_AIX)
if (errno == EINVAL) {
// On Solaris setsockopt will set errno to EINVAL if the socket
// On AIX setsockopt will set errno to EINVAL if the socket
// is closed. The default error message is then confusing
char fullMsg[128];
jio_snprintf(fullMsg, sizeof(fullMsg), "Invalid option or socket reset by remote peer");
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", fullMsg);
return;
}
#endif /* __solaris__ */
#endif /* _AIX */
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,10 +28,6 @@
#include <unistd.h>
#include <errno.h>
#ifdef __solaris__
#include <sys/systeminfo.h>
#endif
#include <string.h>
#include "jni.h"
@ -41,30 +37,6 @@
#endif
/*
* Class: sun_net_dns_ResolverConfigurationImpl
* Method: localDomain0
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_sun_net_dns_ResolverConfigurationImpl_localDomain0(JNIEnv *env, jclass cls)
{
/*
* On Solaris the LOCALDOMAIN environment variable has absolute
* priority.
*/
#ifdef __solaris__
{
char *cp = getenv("LOCALDOMAIN");
if (cp != NULL) {
jstring s = (*env)->NewStringUTF(env, cp);
return s;
}
}
#endif
return (jstring)NULL;
}
/*
* Class: sun_net_dns_ResolverConfigurationImpl
* Method: loadConfig0
@ -76,36 +48,10 @@ Java_sun_net_dns_ResolverConfigurationImpl_fallbackDomain0(JNIEnv *env, jclass c
char buf[MAXDNAME];
/*
* On Solaris if domain or search directives aren't specified
* in /etc/resolv.conf then sysinfo or gethostname is used to
* determine the domain name.
*
* On Linux if domain or search directives aren't specified
* If domain or search directives aren't specified
* then gethostname is used.
*/
#ifdef __solaris__
{
int ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf));
if ((ret > 0) && (ret<sizeof(buf))) {
char *cp;
jstring s;
if (buf[0] == '+') {
buf[0] = '.';
}
cp = strchr(buf, '.');
if (cp == NULL) {
s = (*env)->NewStringUTF(env, buf);
} else {
s = (*env)->NewStringUTF(env, cp+1);
}
return s;
}
}
#endif
if (gethostname(buf, sizeof(buf)) == 0) {
char *cp;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,11 +27,7 @@
#include <sys/socket.h>
#include <errno.h>
#if defined(__solaris__)
#if !defined(PROTO_SDP)
#define PROTO_SDP 257
#endif
#elif defined(__linux__)
#if defined(__linux__)
#if !defined(AF_INET_SDP)
#define AF_INET_SDP 27
#endif
@ -55,10 +51,7 @@ static int create(JNIEnv* env)
{
int s;
#if defined(__solaris__)
int domain = ipv6_available() ? AF_INET6 : AF_INET;
s = socket(domain, SOCK_STREAM, PROTO_SDP);
#elif defined(__linux__)
#if defined(__linux__)
/**
* IPv6 not supported by SDP on Linux
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,14 +37,6 @@
#include <sys/utsname.h>
#endif
#if defined(__solaris__)
#include <inet/nd.h>
#include <limits.h>
#include <stropts.h>
#include <sys/filio.h>
#include <sys/sockio.h>
#endif
#if defined(MACOSX)
#include <sys/sysctl.h>
#endif
@ -59,20 +51,6 @@
#define IPV6_FLOWINFO_SEND 33
#endif
#if defined(__solaris__) && !defined(MAXINT)
#define MAXINT INT_MAX
#endif
/*
* EXCLBIND socket options only on Solaris
*/
#if defined(__solaris__) && !defined(TCP_EXCLBIND)
#define TCP_EXCLBIND 0x21
#endif
#if defined(__solaris__) && !defined(UDP_EXCLBIND)
#define UDP_EXCLBIND 0x0101
#endif
#define RESTARTABLE(_cmd, _result) do { \
do { \
_result = _cmd; \
@ -85,94 +63,6 @@ int NET_SocketAvailable(int s, int *pbytes) {
return result;
}
#ifdef __solaris__
static int init_tcp_max_buf, init_udp_max_buf;
static int tcp_max_buf;
static int udp_max_buf;
static int useExclBind = 0;
/*
* Get the specified parameter from the specified driver. The value
* of the parameter is assumed to be an 'int'. If the parameter
* cannot be obtained return -1
*/
int net_getParam(char *driver, char *param)
{
struct strioctl stri;
char buf [64];
int s;
int value;
s = open (driver, O_RDWR);
if (s < 0) {
return -1;
}
strncpy (buf, param, sizeof(buf));
stri.ic_cmd = ND_GET;
stri.ic_timout = 0;
stri.ic_dp = buf;
stri.ic_len = sizeof(buf);
if (ioctl (s, I_STR, &stri) < 0) {
value = -1;
} else {
value = atoi(buf);
}
close (s);
return value;
}
/*
* Iterative way to find the max value that SO_SNDBUF or SO_RCVBUF
* for Solaris versions that do not support the ioctl() in net_getParam().
* Ugly, but only called once (for each sotype).
*
* As an optimization, we make a guess using the default values for Solaris
* assuming they haven't been modified with ndd.
*/
#define MAX_TCP_GUESS 1024 * 1024
#define MAX_UDP_GUESS 2 * 1024 * 1024
#define FAIL_IF_NOT_ENOBUFS if (errno != ENOBUFS) return -1
static int findMaxBuf(int fd, int opt, int sotype) {
int a = 0;
int b = MAXINT;
int initial_guess;
int limit = -1;
if (sotype == SOCK_DGRAM) {
initial_guess = MAX_UDP_GUESS;
} else {
initial_guess = MAX_TCP_GUESS;
}
if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess, sizeof(int)) == 0) {
initial_guess++;
if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess,sizeof(int)) < 0) {
FAIL_IF_NOT_ENOBUFS;
return initial_guess - 1;
}
a = initial_guess;
} else {
FAIL_IF_NOT_ENOBUFS;
b = initial_guess - 1;
}
do {
int mid = a + (b-a)/2;
if (setsockopt(fd, SOL_SOCKET, opt, &mid, sizeof(int)) == 0) {
limit = mid;
a = mid + 1;
} else {
FAIL_IF_NOT_ENOBUFS;
b = mid - 1;
}
} while (b >= a);
return limit;
}
#endif
void
NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultDetail) {
@ -283,50 +173,6 @@ jint IPv6_supported()
}
#endif
/**
* On Solaris 8 it's possible to create INET6 sockets even
* though IPv6 is not enabled on all interfaces. Thus we
* query the number of IPv6 addresses to verify that IPv6
* has been configured on at least one interface.
*
* On Linux it doesn't matter - if IPv6 is built-in the
* kernel then IPv6 addresses will be bound automatically
* to all interfaces.
*/
#ifdef __solaris__
#ifdef SIOCGLIFNUM
{
struct lifnum numifs;
numifs.lifn_family = AF_INET6;
numifs.lifn_flags = 0;
if (ioctl(fd, SIOCGLIFNUM, (char *)&numifs) < 0) {
/**
* SIOCGLIFNUM failed - assume IPv6 not configured
*/
close(fd);
return JNI_FALSE;
}
/**
* If no IPv6 addresses then return false. If count > 0
* it's possible that all IPv6 addresses are "down" but
* that's okay as they may be brought "up" while the
* VM is running.
*/
if (numifs.lifn_count == 0) {
close(fd);
return JNI_FALSE;
}
}
#else
/* SIOCGLIFNUM not defined in build environment ??? */
close(fd);
return JNI_FALSE;
#endif
#endif /* __solaris */
/*
* OK we may have the stack available in the kernel,
* we should also check if the APIs are available.
@ -403,26 +249,6 @@ void platformInit () {}
#endif
void parseExclusiveBindProperty(JNIEnv *env) {
#ifdef __solaris__
jstring s, flagSet;
jclass iCls;
jmethodID mid;
s = (*env)->NewStringUTF(env, "sun.net.useExclusiveBind");
CHECK_NULL(s);
iCls = (*env)->FindClass(env, "java/lang/System");
CHECK_NULL(iCls);
mid = (*env)->GetStaticMethodID(env, iCls, "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;");
CHECK_NULL(mid);
flagSet = (*env)->CallStaticObjectMethod(env, iCls, mid, s);
if (flagSet != NULL) {
useExclBind = 1;
}
#endif
}
JNIEXPORT jint JNICALL
NET_EnableFastTcpLoopback(int fd) {
return 0;
@ -588,7 +414,7 @@ NET_MapSocketOption(jint cmd, int *level, int *optname) {
*level = IPPROTO_IPV6;
*optname = IPV6_MULTICAST_LOOP;
return 0;
#if (defined(__solaris__) || defined(MACOSX))
#if defined(MACOSX)
// Map IP_TOS request to IPV6_TCLASS
case java_net_SocketOptions_IP_TOS:
*level = IPPROTO_IPV6;
@ -737,65 +563,6 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
*iptos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
}
/*
* SOL_SOCKET/{SO_SNDBUF,SO_RCVBUF} - On Solaris we may need to clamp
* the value when it exceeds the system limit.
*/
#ifdef __solaris__
if (level == SOL_SOCKET) {
if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
int sotype=0;
socklen_t arglen;
int *bufsize, maxbuf;
int ret;
/* Attempt with the original size */
ret = setsockopt(fd, level, opt, arg, len);
if ((ret == 0) || (ret == -1 && errno != ENOBUFS))
return ret;
/* Exceeded system limit so clamp and retry */
arglen = sizeof(sotype);
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype,
&arglen) < 0) {
return -1;
}
/*
* We try to get tcp_maxbuf (and udp_max_buf) using
* an ioctl() that isn't available on all versions of Solaris.
* If that fails, we use the search algorithm in findMaxBuf()
*/
if (!init_tcp_max_buf && sotype == SOCK_STREAM) {
tcp_max_buf = net_getParam("/dev/tcp", "tcp_max_buf");
if (tcp_max_buf == -1) {
tcp_max_buf = findMaxBuf(fd, opt, SOCK_STREAM);
if (tcp_max_buf == -1) {
return -1;
}
}
init_tcp_max_buf = 1;
} else if (!init_udp_max_buf && sotype == SOCK_DGRAM) {
udp_max_buf = net_getParam("/dev/udp", "udp_max_buf");
if (udp_max_buf == -1) {
udp_max_buf = findMaxBuf(fd, opt, SOCK_DGRAM);
if (udp_max_buf == -1) {
return -1;
}
}
init_udp_max_buf = 1;
}
maxbuf = (sotype == SOCK_STREAM) ? tcp_max_buf : udp_max_buf;
bufsize = (int *)arg;
if (*bufsize > maxbuf) {
*bufsize = maxbuf;
}
}
}
#endif
#ifdef _AIX
if (level == SOL_SOCKET) {
if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
@ -908,19 +675,10 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg,
*
* Linux allows a socket to bind to 127.0.0.255 which must be
* caught.
*
* On Solaris with IPv6 enabled we must use an exclusive
* bind to guarantee a unique port number across the IPv4 and
* IPv6 port spaces.
*
*/
int
NET_Bind(int fd, SOCKETADDRESS *sa, int len)
{
#if defined(__solaris__)
int level = -1;
int exclbind = -1;
#endif
int rv;
int arg, alen;
@ -938,61 +696,8 @@ NET_Bind(int fd, SOCKETADDRESS *sa, int len)
}
#endif
#if defined(__solaris__)
/*
* Solaris has separate IPv4 and IPv6 port spaces so we
* use an exclusive bind when SO_REUSEADDR is not used to
* give the illusion of a unified port space.
* This also avoids problems with IPv6 sockets connecting
* to IPv4 mapped addresses whereby the socket conversion
* results in a late bind that fails because the
* corresponding IPv4 port is in use.
*/
alen = sizeof(arg);
if (useExclBind ||
getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg, &alen) == 0)
{
if (useExclBind || arg == 0) {
/*
* SO_REUSEADDR is disabled or sun.net.useExclusiveBind
* property is true so enable TCP_EXCLBIND or
* UDP_EXCLBIND
*/
alen = sizeof(arg);
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg, &alen) == 0)
{
if (arg == SOCK_STREAM) {
level = IPPROTO_TCP;
exclbind = TCP_EXCLBIND;
} else {
level = IPPROTO_UDP;
exclbind = UDP_EXCLBIND;
}
}
arg = 1;
setsockopt(fd, level, exclbind, (char *)&arg, sizeof(arg));
}
}
#endif
rv = bind(fd, &sa->sa, len);
#if defined(__solaris__)
if (rv < 0) {
int en = errno;
/* Restore *_EXCLBIND if the bind fails */
if (exclbind != -1) {
int arg = 0;
setsockopt(fd, level, exclbind, (char *)&arg,
sizeof(arg));
}
errno = en;
}
#endif
return rv;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -47,8 +47,6 @@
#ifndef SO_REUSEPORT
#ifdef __linux__
#define SO_REUSEPORT 15
#elif defined(__solaris__)
#define SO_REUSEPORT 0x100e
#elif defined(AIX) || defined(MACOSX)
#define SO_REUSEPORT 0x0200
#else
@ -98,8 +96,4 @@ void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultDetail);
void NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass);
#ifdef __solaris__
int net_getParam(char *driver, char *param);
#endif
#endif /* NET_UTILS_MD_H */

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -60,13 +60,6 @@ static int getPortRange(struct portrange *range)
}
return -1;
}
#elif defined(__solaris__)
{
range->higher = net_getParam("/dev/tcp", "tcp_largest_anon_port");
range->lower = net_getParam("/dev/tcp", "tcp_smallest_anon_port");
return 0;
}
#elif defined(_ALLBSD_SOURCE)
{
int ret;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -50,9 +50,6 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jclass clazz,
jint fd = fdval(env, fdo);
int rv;
#if defined(__solaris__)
rv = connect(fd, 0, 0);
#else
SOCKETADDRESS sa;
socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in);
@ -78,8 +75,6 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jclass clazz,
rv = errno = 0;
#endif // defined(_ALLBSD_SOURCE) || defined(_AIX)
#endif // defined(__solaris__)
if (rv < 0)
handleSocketError(env, errno);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,7 +29,7 @@
#include <sys/types.h>
#include <unistd.h>
#if defined(__linux__) || defined(__solaris__)
#if defined(__linux__)
#include <sys/sendfile.h>
#elif defined(_AIX)
#include <string.h>
@ -182,36 +182,6 @@ Java_sun_nio_ch_FileChannelImpl_transferTo0(JNIEnv *env, jobject this,
return IOS_THROWN;
}
return n;
#elif defined (__solaris__)
sendfilevec64_t sfv;
size_t numBytes = 0;
jlong result;
sfv.sfv_fd = srcFD;
sfv.sfv_flag = 0;
sfv.sfv_off = (off64_t)position;
sfv.sfv_len = count;
result = sendfilev64(dstFD, &sfv, 1, &numBytes);
/* Solaris sendfilev() will return -1 even if some bytes have been
* transferred, so we check numBytes first.
*/
if (numBytes > 0)
return numBytes;
if (result < 0) {
if (errno == EAGAIN)
return IOS_UNAVAILABLE;
if (errno == EOPNOTSUPP)
return IOS_UNSUPPORTED_CASE;
if ((errno == EINVAL) && ((ssize_t)count >= 0))
return IOS_UNSUPPORTED_CASE;
if (errno == EINTR)
return IOS_INTERRUPTED;
JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");
return IOS_THROWN;
}
return result;
#elif defined(__APPLE__)
off_t numBytes;
int result;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -41,9 +41,6 @@
#include <pthread.h>
/* Also defined in net/aix_close.c */
#define INTERRUPT_SIGNAL (SIGRTMAX - 1)
#elif defined(__solaris__)
#include <thread.h>
#define INTERRUPT_SIGNAL (SIGRTMAX - 2)
#elif defined(_ALLBSD_SOURCE)
#include <pthread.h>
/* Also defined in net/bsd_close.c */
@ -79,22 +76,14 @@ Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
JNIEXPORT jlong JNICALL
Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
{
#ifdef __solaris__
return (jlong)thr_self();
#else
return (jlong)pthread_self();
#endif
}
JNIEXPORT void JNICALL
Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
{
int ret;
#ifdef __solaris__
ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL);
#else
ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL);
#endif
#ifdef MACOSX
if (ret != 0 && ret != ESRCH)
#else

View file

@ -170,7 +170,7 @@ Java_sun_nio_ch_Net_shouldSetBothIPv4AndIPv6Options0(JNIEnv* env, jclass cl)
JNIEXPORT jboolean JNICALL
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl)
{
#if defined(__linux__) || defined(__APPLE__) || defined(__solaris__)
#if defined(__linux__) || defined(__APPLE__)
/* IPv6 sockets can join IPv4 multicast groups */
return JNI_TRUE;
#else
@ -182,7 +182,7 @@ Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl)
JNIEXPORT jboolean JNICALL
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl)
{
#if defined(__APPLE__) || defined(__solaris__)
#if defined(__APPLE__)
/* IPV6_ADD_MEMBERSHIP can be used to join IPv4 multicast groups */
return JNI_TRUE;
#else

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,8 +40,6 @@
#ifndef SO_REUSEPORT
#ifdef __linux__
#define SO_REUSEPORT 15
#elif defined(__solaris__)
#define SO_REUSEPORT 0x100e
#elif defined(AIX) || defined(MACOSX)
#define SO_REUSEPORT 0x0200
#else

View file

@ -41,17 +41,10 @@
#endif
#include <sys/time.h>
/* For POSIX-compliant getpwuid_r, getgrgid_r on Solaris */
#if defined(__solaris__)
#define _POSIX_PTHREAD_SEMANTICS
#endif
/* For POSIX-compliant getpwuid_r */
#include <pwd.h>
#include <grp.h>
#ifdef __solaris__
#include <strings.h>
#endif
#ifdef __linux__
#include <sys/syscall.h>
#endif
@ -263,8 +256,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
/* system calls that might not be available at run time */
#if (defined(__solaris__) && defined(_LP64)) || defined(_ALLBSD_SOURCE)
/* Solaris 64-bit does not have openat64/fstatat64 */
#if defined(_ALLBSD_SOURCE)
my_openat64_func = (openat64_func*)dlsym(RTLD_DEFAULT, "openat");
my_fstatat64_func = (fstatat64_func*)dlsym(RTLD_DEFAULT, "fstatat");
#else