mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
Merge
This commit is contained in:
commit
86f7ad735d
124 changed files with 5920 additions and 6593 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2010, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Gamma (Hotspot internal engineering test) launcher based on 1.6.0-b28 JDK,
|
||||
* search "GAMMA" for gamma specific changes.
|
||||
*/
|
||||
|
||||
#ifndef _JAVA_H_
|
||||
#define _JAVA_H_
|
||||
|
||||
/*
|
||||
* Get system specific defines.
|
||||
*/
|
||||
#include "jni.h"
|
||||
#include "java_md.h"
|
||||
|
||||
/*
|
||||
* Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
|
||||
*/
|
||||
typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
|
||||
typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
|
||||
|
||||
typedef struct {
|
||||
CreateJavaVM_t CreateJavaVM;
|
||||
GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
|
||||
} InvocationFunctions;
|
||||
|
||||
/*
|
||||
* Prototypes for launcher functions in the system specific java_md.c.
|
||||
*/
|
||||
|
||||
jboolean
|
||||
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
|
||||
|
||||
void
|
||||
GetXUsagePath(char *buf, jint bufsize);
|
||||
|
||||
jboolean
|
||||
GetApplicationHome(char *buf, jint bufsize);
|
||||
|
||||
const char *
|
||||
GetArch();
|
||||
|
||||
void CreateExecutionEnvironment(int *_argc,
|
||||
char ***_argv,
|
||||
char jrepath[],
|
||||
jint so_jrepath,
|
||||
char jvmpath[],
|
||||
jint so_jvmpath,
|
||||
char **original_argv);
|
||||
|
||||
/*
|
||||
* Report an error message to stderr or a window as appropriate. The
|
||||
* flag always is set to JNI_TRUE if message is to be reported to both
|
||||
* strerr and windows and set to JNI_FALSE if the message should only
|
||||
* be sent to a window.
|
||||
*/
|
||||
void ReportErrorMessage(char * message, jboolean always);
|
||||
void ReportErrorMessage2(char * format, char * string, jboolean always);
|
||||
|
||||
/*
|
||||
* Report an exception which terminates the vm to stderr or a window
|
||||
* as appropriate.
|
||||
*/
|
||||
void ReportExceptionDescription(JNIEnv * env);
|
||||
|
||||
jboolean RemovableMachineDependentOption(char * option);
|
||||
void PrintMachineDependentOptions();
|
||||
|
||||
/*
|
||||
* Functions defined in java.c and used in java_md.c.
|
||||
*/
|
||||
jint ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative);
|
||||
char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
|
||||
void* MemAlloc(size_t size);
|
||||
|
||||
/*
|
||||
* Make launcher spit debug output.
|
||||
*/
|
||||
extern jboolean _launcher_debug;
|
||||
/*
|
||||
* This allows for finding classes from the VM's bootstrap class loader
|
||||
* directly, FindClass uses the application class loader internally, this will
|
||||
* cause unnecessary searching of the classpath for the required classes.
|
||||
*/
|
||||
typedef jclass (JNICALL FindClassFromBootLoader_t(JNIEnv *env,
|
||||
const char *name,
|
||||
jboolean throwError));
|
||||
|
||||
jclass FindBootStrapClass(JNIEnv *env, const char *classname);
|
||||
|
||||
#endif /* _JAVA_H_ */
|
File diff suppressed because it is too large
Load diff
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2010, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Gamma (Hotspot internal engineering test) launcher based on 1.6.0-b28 JDK,
|
||||
* search "GAMMA" for gamma specific changes.
|
||||
*/
|
||||
|
||||
#ifndef JAVA_MD_H
|
||||
#define JAVA_MD_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
#ifndef GAMMA
|
||||
#include "manifest_info.h"
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR ':'
|
||||
#define FILESEP "/"
|
||||
#define FILE_SEPARATOR '/'
|
||||
#ifndef MAXNAMELEN
|
||||
#define MAXNAMELEN PATH_MAX
|
||||
#endif
|
||||
|
||||
#ifdef JAVA_ARGS
|
||||
/*
|
||||
* ApplicationHome is prepended to each of these entries; the resulting
|
||||
* strings are concatenated (separated by PATH_SEPARATOR) and used as the
|
||||
* value of -cp option to the launcher.
|
||||
*/
|
||||
#ifndef APP_CLASSPATH
|
||||
#define APP_CLASSPATH { "/lib/tools.jar", "/classes" }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETHRTIME
|
||||
/*
|
||||
* Support for doing cheap, accurate interval timing.
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#define CounterGet() (gethrtime()/1000)
|
||||
#define Counter2Micros(counts) (counts)
|
||||
#else
|
||||
#define CounterGet() (0)
|
||||
#define Counter2Micros(counts) (1)
|
||||
#endif /* HAVE_GETHRTIME */
|
||||
|
||||
/*
|
||||
* Function prototypes.
|
||||
*/
|
||||
#ifndef GAMMA
|
||||
char *LocateJRE(manifest_info* info);
|
||||
void ExecJRE(char *jre, char **argv);
|
||||
#endif
|
||||
int UnsetEnv(char *name);
|
||||
|
||||
#endif
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2010, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/hpi.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
|
||||
# include <sys/param.h>
|
||||
# include <dlfcn.h>
|
||||
|
||||
typedef jint (JNICALL *init_t)(GetInterfaceFunc *, void *);
|
||||
|
||||
void hpi::initialize_get_interface(vm_calls_t *callbacks) {
|
||||
char buf[JVM_MAXPATHLEN];
|
||||
void *hpi_handle;
|
||||
GetInterfaceFunc& getintf = _get_interface;
|
||||
jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *);
|
||||
|
||||
if (HPILibPath && HPILibPath[0]) {
|
||||
strncpy(buf, HPILibPath, JVM_MAXPATHLEN - 1);
|
||||
buf[JVM_MAXPATHLEN - 1] = '\0';
|
||||
} else {
|
||||
const char *thread_type = "native_threads";
|
||||
|
||||
os::jvm_path(buf, JVM_MAXPATHLEN);
|
||||
|
||||
#ifdef PRODUCT
|
||||
const char * hpi_lib = "/libhpi.so";
|
||||
#else
|
||||
char * ptr = strrchr(buf, '/');
|
||||
assert(strstr(ptr, "/libjvm") == ptr, "invalid library name");
|
||||
const char * hpi_lib = strstr(ptr, "_g") ? "/libhpi_g.so" : "/libhpi.so";
|
||||
#endif
|
||||
|
||||
*(strrchr(buf, '/')) = '\0'; /* get rid of /libjvm.so */
|
||||
char* p = strrchr(buf, '/');
|
||||
if (p != NULL) p[1] = '\0'; /* get rid of hotspot */
|
||||
strcat(buf, thread_type);
|
||||
strcat(buf, hpi_lib);
|
||||
}
|
||||
|
||||
if (TraceHPI) tty->print_cr("Loading HPI %s ", buf);
|
||||
#ifdef SPARC
|
||||
// On 64-bit Ubuntu Sparc RTLD_NOW leads to unresolved deps in libpthread.so
|
||||
# define OPEN_MODE RTLD_LAZY
|
||||
#else
|
||||
// We use RTLD_NOW because of bug 4032715
|
||||
# define OPEN_MODE RTLD_NOW
|
||||
#endif
|
||||
hpi_handle = dlopen(buf, OPEN_MODE);
|
||||
#undef OPEN_MODE
|
||||
|
||||
if (hpi_handle == NULL) {
|
||||
if (TraceHPI) tty->print_cr("HPI dlopen failed: %s", dlerror());
|
||||
return;
|
||||
}
|
||||
DLL_Initialize = CAST_TO_FN_PTR(jint (JNICALL *)(GetInterfaceFunc *, void *),
|
||||
dlsym(hpi_handle, "DLL_Initialize"));
|
||||
if (TraceHPI && DLL_Initialize == NULL) tty->print_cr("HPI dlsym of DLL_Initialize failed: %s", dlerror());
|
||||
if (DLL_Initialize == NULL ||
|
||||
(*DLL_Initialize)(&getintf, callbacks) < 0) {
|
||||
if (TraceHPI) tty->print_cr("HPI DLL_Initialize failed");
|
||||
return;
|
||||
}
|
||||
if (TraceHPI) tty->print_cr("HPI loaded successfully");
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2010, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OS_LINUX_VM_HPI_LINUX_HPP
|
||||
#define OS_LINUX_VM_HPI_LINUX_HPP
|
||||
|
||||
//
|
||||
// Because the interruptible IO has been dropped for HotSpot/Linux,
|
||||
// the following HPI interface is very different from HotSparc.
|
||||
//
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netdb.h>
|
||||
|
||||
// HPI_FileInterface
|
||||
|
||||
inline int hpi::close(int fd) {
|
||||
return ::close(fd);
|
||||
}
|
||||
|
||||
inline size_t hpi::read(int fd, void *buf, unsigned int nBytes) {
|
||||
size_t res;
|
||||
RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline size_t hpi::write(int fd, const void *buf, unsigned int nBytes) {
|
||||
size_t res;
|
||||
RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// HPI_SocketInterface
|
||||
|
||||
inline int hpi::socket_close(int fd) {
|
||||
return ::close(fd);
|
||||
}
|
||||
|
||||
inline int hpi::socket(int domain, int type, int protocol) {
|
||||
return ::socket(domain, type, protocol);
|
||||
}
|
||||
|
||||
inline int hpi::recv(int fd, char *buf, int nBytes, int flags) {
|
||||
RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
|
||||
}
|
||||
|
||||
inline int hpi::send(int fd, char *buf, int nBytes, int flags) {
|
||||
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
|
||||
}
|
||||
|
||||
inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
|
||||
return send(fd, buf, nBytes, flags);
|
||||
}
|
||||
|
||||
inline int hpi::timeout(int fd, long timeout) {
|
||||
julong prevtime,newtime;
|
||||
struct timeval t;
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
prevtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
|
||||
|
||||
for(;;) {
|
||||
struct pollfd pfd;
|
||||
|
||||
pfd.fd = fd;
|
||||
pfd.events = POLLIN | POLLERR;
|
||||
|
||||
int res = ::poll(&pfd, 1, timeout);
|
||||
|
||||
if (res == OS_ERR && errno == EINTR) {
|
||||
|
||||
// On Linux any value < 0 means "forever"
|
||||
|
||||
if(timeout >= 0) {
|
||||
gettimeofday(&t, NULL);
|
||||
newtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
|
||||
timeout -= newtime - prevtime;
|
||||
if(timeout <= 0)
|
||||
return OS_OK;
|
||||
prevtime = newtime;
|
||||
}
|
||||
} else
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
inline int hpi::listen(int fd, int count) {
|
||||
return ::listen(fd, count);
|
||||
}
|
||||
|
||||
inline int hpi::connect(int fd, struct sockaddr *him, int len) {
|
||||
RESTARTABLE_RETURN_INT(::connect(fd, him, len));
|
||||
}
|
||||
|
||||
inline int hpi::accept(int fd, struct sockaddr *him, int *len) {
|
||||
// This cast is from int to unsigned int on linux. Since we
|
||||
// only pass the parameter "len" around the vm and don't try to
|
||||
// fetch it's value, this cast is safe for now. The java.net group
|
||||
// may need and want to change this interface someday if socklen_t goes
|
||||
// to 64 bits on some platform that we support.
|
||||
// Linux doc says this can't return EINTR, unlike accept() on Solaris
|
||||
|
||||
return ::accept(fd, him, (socklen_t *)len);
|
||||
}
|
||||
|
||||
inline int hpi::recvfrom(int fd, char *buf, int nBytes, int flags,
|
||||
sockaddr *from, int *fromlen) {
|
||||
RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
|
||||
}
|
||||
|
||||
inline int hpi::sendto(int fd, char *buf, int len, int flags,
|
||||
struct sockaddr *to, int tolen) {
|
||||
RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen));
|
||||
}
|
||||
|
||||
inline int hpi::socket_available(int fd, jint *pbytes) {
|
||||
// Linux doc says EINTR not returned, unlike Solaris
|
||||
int ret = ::ioctl(fd, FIONREAD, pbytes);
|
||||
|
||||
//%% note ioctl can return 0 when successful, JVM_SocketAvailable
|
||||
// is expected to return 0 on failure and 1 on success to the jdk.
|
||||
return (ret < 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
// following methods have been updated to avoid problems in
|
||||
// hpi's sockets calls based on sys_api_td.c (JDK1.3)
|
||||
|
||||
/*
|
||||
HPIDECL(socket_shutdown, "socket_shutdown", _socket, SocketShutdown,
|
||||
int, "%d",
|
||||
(int fd, int howto),
|
||||
("fd = %d, howto = %d", fd, howto),
|
||||
(fd, howto));
|
||||
*/
|
||||
inline int hpi::socket_shutdown(int fd, int howto){
|
||||
return ::shutdown(fd, howto);
|
||||
}
|
||||
|
||||
/*
|
||||
HPIDECL(bind, "bind", _socket, Bind,
|
||||
int, "%d",
|
||||
(int fd, struct sockaddr *him, int len),
|
||||
("fd = %d, him = %p, len = %d",
|
||||
fd, him, len),
|
||||
(fd, him, len));
|
||||
*/
|
||||
inline int hpi::bind(int fd, struct sockaddr *him, int len){
|
||||
return ::bind(fd, him, len);
|
||||
}
|
||||
|
||||
/*
|
||||
HPIDECL(get_sock_name, "get_sock_name", _socket, GetSocketName,
|
||||
int, "%d",
|
||||
(int fd, struct sockaddr *him, int *len),
|
||||
("fd = %d, him = %p, len = %p",
|
||||
fd, him, len),
|
||||
(fd, him, len));
|
||||
*/
|
||||
inline int hpi::get_sock_name(int fd, struct sockaddr *him, int *len){
|
||||
return ::getsockname(fd, him, (socklen_t *)len);
|
||||
}
|
||||
|
||||
/*
|
||||
HPIDECL(get_host_name, "get_host_name", _socket, GetHostName, int, "%d",
|
||||
(char *hostname, int namelen),
|
||||
("hostname = %p, namelen = %d",
|
||||
hostname, namelen),
|
||||
(hostname, namelen));
|
||||
*/
|
||||
inline int hpi::get_host_name(char* name, int namelen){
|
||||
return ::gethostname(name, namelen);
|
||||
}
|
||||
|
||||
/*
|
||||
HPIDECL(get_sock_opt, "get_sock_opt", _socket, SocketGetOption, int, "%d",
|
||||
(int fd, int level, int optname, char *optval, int* optlen),
|
||||
("fd = %d, level = %d, optname = %d, optval = %p, optlen = %p",
|
||||
fd, level, optname, optval, optlen),
|
||||
(fd, level, optname, optval, optlen));
|
||||
*/
|
||||
inline int hpi::get_sock_opt(int fd, int level, int optname,
|
||||
char *optval, int* optlen){
|
||||
return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen);
|
||||
}
|
||||
|
||||
/*
|
||||
HPIDECL(set_sock_opt, "set_sock_opt", _socket, SocketSetOption, int, "%d",
|
||||
(int fd, int level, int optname, const char *optval, int optlen),
|
||||
("fd = %d, level = %d, optname = %d, optval = %p, optlen = %d",
|
||||
fd, level, optname, optval, optlen),
|
||||
(fd, level, optname, optval, optlen));
|
||||
*/
|
||||
inline int hpi::set_sock_opt(int fd, int level, int optname,
|
||||
const char *optval, int optlen){
|
||||
return ::setsockopt(fd, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
|
||||
// Reconciliation History
|
||||
// hpi_solaris.hpp 1.9 99/08/30 16:31:23
|
||||
// End
|
||||
|
||||
#endif // OS_LINUX_VM_HPI_LINUX_HPP
|
|
@ -44,7 +44,6 @@
|
|||
#include "runtime/arguments.hpp"
|
||||
#include "runtime/extendedPC.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/hpi.hpp"
|
||||
#include "runtime/interfaceSupport.hpp"
|
||||
#include "runtime/java.hpp"
|
||||
#include "runtime/javaCalls.hpp"
|
||||
|
@ -1566,6 +1565,24 @@ void os::die() {
|
|||
// unused on linux for now.
|
||||
void os::set_error_file(const char *logfile) {}
|
||||
|
||||
|
||||
// This method is a copy of JDK's sysGetLastErrorString
|
||||
// from src/solaris/hpi/src/system_md.c
|
||||
|
||||
size_t os::lasterror(char *buf, size_t len) {
|
||||
|
||||
if (errno == 0) return 0;
|
||||
|
||||
const char *s = ::strerror(errno);
|
||||
size_t n = ::strlen(s);
|
||||
if (n >= len) {
|
||||
n = len - 1;
|
||||
}
|
||||
::strncpy(buf, s, n);
|
||||
buf[n] = '\0';
|
||||
return n;
|
||||
}
|
||||
|
||||
intx os::current_thread_id() { return (intx)pthread_self(); }
|
||||
int os::current_process_id() {
|
||||
|
||||
|
@ -1939,19 +1956,19 @@ void* os::dll_lookup(void* handle, const char* name) {
|
|||
}
|
||||
|
||||
|
||||
bool _print_ascii_file(const char* filename, outputStream* st) {
|
||||
int fd = open(filename, O_RDONLY);
|
||||
static bool _print_ascii_file(const char* filename, outputStream* st) {
|
||||
int fd = ::open(filename, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char buf[32];
|
||||
int bytes;
|
||||
while ((bytes = read(fd, buf, sizeof(buf))) > 0) {
|
||||
while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) {
|
||||
st->print_raw(buf, bytes);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
::close(fd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2229,8 +2246,6 @@ void os::jvm_path(char *buf, jint buflen) {
|
|||
// Use current module name "libjvm[_g].so" instead of
|
||||
// "libjvm"debug_only("_g")".so" since for fastdebug version
|
||||
// we should have "libjvm.so" but debug_only("_g") adds "_g"!
|
||||
// It is used when we are choosing the HPI library's name
|
||||
// "libhpi[_g].so" in hpi::initialize_get_interface().
|
||||
len = strlen(buf);
|
||||
snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p);
|
||||
} else {
|
||||
|
@ -2414,18 +2429,18 @@ void linux_wrap_code(char* base, size_t size) {
|
|||
os::get_temp_directory(), os::current_process_id(), num);
|
||||
unlink(buf);
|
||||
|
||||
int fd = open(buf, O_CREAT | O_RDWR, S_IRWXU);
|
||||
int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU);
|
||||
|
||||
if (fd != -1) {
|
||||
off_t rv = lseek(fd, size-2, SEEK_SET);
|
||||
off_t rv = ::lseek(fd, size-2, SEEK_SET);
|
||||
if (rv != (off_t)-1) {
|
||||
if (write(fd, "", 1) == 1) {
|
||||
if (::write(fd, "", 1) == 1) {
|
||||
mmap(base, size,
|
||||
PROT_READ|PROT_WRITE|PROT_EXEC,
|
||||
MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
::close(fd);
|
||||
unlink(buf);
|
||||
}
|
||||
}
|
||||
|
@ -4057,13 +4072,6 @@ jint os::init_2(void)
|
|||
// Initialize lock used to serialize thread creation (see os::create_thread)
|
||||
Linux::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false));
|
||||
|
||||
// Initialize HPI.
|
||||
jint hpi_result = hpi::initialize();
|
||||
if (hpi_result != JNI_OK) {
|
||||
tty->print_cr("There was an error trying to initialize the HPI library.");
|
||||
return hpi_result;
|
||||
}
|
||||
|
||||
// at-exit methods are called in the reverse order of their registration.
|
||||
// atexit functions are called on return from main or as a result of a
|
||||
// call to exit(3C). There can be only 32 of these functions registered
|
||||
|
@ -4261,7 +4269,7 @@ int os::stat(const char *path, struct stat *sbuf) {
|
|||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
hpi::native_path(strcpy(pathbuf, path));
|
||||
os::native_path(strcpy(pathbuf, path));
|
||||
return ::stat(pathbuf, sbuf);
|
||||
}
|
||||
|
||||
|
@ -4293,6 +4301,85 @@ bool os::dir_is_empty(const char* path) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// This code originates from JDK's sysOpen and open64_w
|
||||
// from src/solaris/hpi/src/system_md.c
|
||||
|
||||
#ifndef O_DELETE
|
||||
#define O_DELETE 0x10000
|
||||
#endif
|
||||
|
||||
// Open a file. Unlink the file immediately after open returns
|
||||
// if the specified oflag has the O_DELETE flag set.
|
||||
// O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
|
||||
|
||||
int os::open(const char *path, int oflag, int mode) {
|
||||
|
||||
if (strlen(path) > MAX_PATH - 1) {
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
int fd;
|
||||
int o_delete = (oflag & O_DELETE);
|
||||
oflag = oflag & ~O_DELETE;
|
||||
|
||||
fd = ::open64(path, oflag, mode);
|
||||
if (fd == -1) return -1;
|
||||
|
||||
//If the open succeeded, the file might still be a directory
|
||||
{
|
||||
struct stat64 buf64;
|
||||
int ret = ::fstat64(fd, &buf64);
|
||||
int st_mode = buf64.st_mode;
|
||||
|
||||
if (ret != -1) {
|
||||
if ((st_mode & S_IFMT) == S_IFDIR) {
|
||||
errno = EISDIR;
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
::close(fd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* All file descriptors that are opened in the JVM and not
|
||||
* specifically destined for a subprocess should have the
|
||||
* close-on-exec flag set. If we don't set it, then careless 3rd
|
||||
* party native code might fork and exec without closing all
|
||||
* appropriate file descriptors (e.g. as we do in closeDescriptors in
|
||||
* UNIXProcess.c), and this in turn might:
|
||||
*
|
||||
* - cause end-of-file to fail to be detected on some file
|
||||
* descriptors, resulting in mysterious hangs, or
|
||||
*
|
||||
* - might cause an fopen in the subprocess to fail on a system
|
||||
* suffering from bug 1085341.
|
||||
*
|
||||
* (Yes, the default setting of the close-on-exec flag is a Unix
|
||||
* design flaw)
|
||||
*
|
||||
* See:
|
||||
* 1085341: 32-bit stdio routines should support file descriptors >255
|
||||
* 4843136: (process) pipe file descriptor from Runtime.exec not being closed
|
||||
* 6339493: (process) Runtime.exec does not close all file descriptors on Solaris 9
|
||||
*/
|
||||
#ifdef FD_CLOEXEC
|
||||
{
|
||||
int flags = ::fcntl(fd, F_GETFD);
|
||||
if (flags != -1)
|
||||
::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (o_delete != 0) {
|
||||
::unlink(path);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
// create binary file, rewriting existing file if required
|
||||
int os::create_binary_file(const char* path, bool rewrite_existing) {
|
||||
int oflags = O_WRONLY | O_CREAT;
|
||||
|
@ -4312,6 +4399,40 @@ jlong os::seek_to_file_offset(int fd, jlong offset) {
|
|||
return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET);
|
||||
}
|
||||
|
||||
// This code originates from JDK's sysAvailable
|
||||
// from src/solaris/hpi/src/native_threads/src/sys_api_td.c
|
||||
|
||||
int os::available(int fd, jlong *bytes) {
|
||||
jlong cur, end;
|
||||
int mode;
|
||||
struct stat64 buf64;
|
||||
|
||||
if (::fstat64(fd, &buf64) >= 0) {
|
||||
mode = buf64.st_mode;
|
||||
if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
|
||||
/*
|
||||
* XXX: is the following call interruptible? If so, this might
|
||||
* need to go through the INTERRUPT_IO() wrapper as for other
|
||||
* blocking, interruptible calls in this file.
|
||||
*/
|
||||
int n;
|
||||
if (::ioctl(fd, FIONREAD, &n) >= 0) {
|
||||
*bytes = n;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) {
|
||||
return 0;
|
||||
} else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) {
|
||||
return 0;
|
||||
} else if (::lseek64(fd, cur, SEEK_SET) == -1) {
|
||||
return 0;
|
||||
}
|
||||
*bytes = end - cur;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Map a block of memory.
|
||||
char* os::map_memory(int fd, const char* file_name, size_t file_offset,
|
||||
char *addr, size_t bytes, bool read_only,
|
||||
|
@ -4538,7 +4659,7 @@ void os::pause() {
|
|||
int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd != -1) {
|
||||
struct stat buf;
|
||||
close(fd);
|
||||
::close(fd);
|
||||
while (::stat(filename, &buf) == 0) {
|
||||
(void)::poll(NULL, 0, 100);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,14 @@
|
|||
# include "orderAccess_linux_zero.inline.hpp"
|
||||
#endif
|
||||
|
||||
// System includes
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netdb.h>
|
||||
|
||||
inline void* os::thread_local_storage_at(int index) {
|
||||
return pthread_getspecific((pthread_key_t)index);
|
||||
}
|
||||
|
@ -93,6 +101,12 @@ inline void os::split_reserved_memory(char *base, size_t size,
|
|||
inline void os::bang_stack_shadow_pages() {
|
||||
}
|
||||
|
||||
inline void os::dll_unload(void *lib) {
|
||||
::dlclose(lib);
|
||||
}
|
||||
|
||||
inline const int os::default_file_open_flags() { return 0;}
|
||||
|
||||
inline DIR* os::opendir(const char* dirname)
|
||||
{
|
||||
assert(dirname != NULL, "just checking");
|
||||
|
@ -104,6 +118,22 @@ inline int os::readdir_buf_size(const char *path)
|
|||
return NAME_MAX + sizeof(dirent) + 1;
|
||||
}
|
||||
|
||||
inline jlong os::lseek(int fd, jlong offset, int whence) {
|
||||
return (jlong) ::lseek64(fd, offset, whence);
|
||||
}
|
||||
|
||||
inline int os::fsync(int fd) {
|
||||
return ::fsync(fd);
|
||||
}
|
||||
|
||||
inline char* os::native_path(char *path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
inline int os::ftruncate(int fd, jlong length) {
|
||||
return ::ftruncate64(fd, length);
|
||||
}
|
||||
|
||||
inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
|
||||
{
|
||||
dirent* p;
|
||||
|
@ -121,9 +151,8 @@ inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
|
|||
return p;
|
||||
}
|
||||
|
||||
inline int os::closedir(DIR *dirp)
|
||||
{
|
||||
assert(dirp != NULL, "just checking");
|
||||
inline int os::closedir(DIR *dirp) {
|
||||
assert(dirp != NULL, "argument is NULL");
|
||||
return ::closedir(dirp);
|
||||
}
|
||||
|
||||
|
@ -142,4 +171,139 @@ inline int os::closedir(DIR *dirp)
|
|||
inline bool os::numa_has_static_binding() { return true; }
|
||||
inline bool os::numa_has_group_homing() { return false; }
|
||||
|
||||
inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
|
||||
size_t res;
|
||||
RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
|
||||
size_t res;
|
||||
RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline int os::close(int fd) {
|
||||
return ::close(fd);
|
||||
}
|
||||
|
||||
inline int os::socket_close(int fd) {
|
||||
return ::close(fd);
|
||||
}
|
||||
|
||||
inline int os::socket(int domain, int type, int protocol) {
|
||||
return ::socket(domain, type, protocol);
|
||||
}
|
||||
|
||||
inline int os::recv(int fd, char *buf, int nBytes, int flags) {
|
||||
RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
|
||||
}
|
||||
|
||||
inline int os::send(int fd, char *buf, int nBytes, int flags) {
|
||||
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
|
||||
}
|
||||
|
||||
inline int os::raw_send(int fd, char *buf, int nBytes, int flags) {
|
||||
return os::send(fd, buf, nBytes, flags);
|
||||
}
|
||||
|
||||
inline int os::timeout(int fd, long timeout) {
|
||||
julong prevtime,newtime;
|
||||
struct timeval t;
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
prevtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
|
||||
|
||||
for(;;) {
|
||||
struct pollfd pfd;
|
||||
|
||||
pfd.fd = fd;
|
||||
pfd.events = POLLIN | POLLERR;
|
||||
|
||||
int res = ::poll(&pfd, 1, timeout);
|
||||
|
||||
if (res == OS_ERR && errno == EINTR) {
|
||||
|
||||
// On Linux any value < 0 means "forever"
|
||||
|
||||
if(timeout >= 0) {
|
||||
gettimeofday(&t, NULL);
|
||||
newtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000;
|
||||
timeout -= newtime - prevtime;
|
||||
if(timeout <= 0)
|
||||
return OS_OK;
|
||||
prevtime = newtime;
|
||||
}
|
||||
} else
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
inline int os::listen(int fd, int count) {
|
||||
return ::listen(fd, count);
|
||||
}
|
||||
|
||||
inline int os::connect(int fd, struct sockaddr *him, int len) {
|
||||
RESTARTABLE_RETURN_INT(::connect(fd, him, len));
|
||||
}
|
||||
|
||||
inline int os::accept(int fd, struct sockaddr *him, int *len) {
|
||||
// This cast is from int to unsigned int on linux. Since we
|
||||
// only pass the parameter "len" around the vm and don't try to
|
||||
// fetch it's value, this cast is safe for now. The java.net group
|
||||
// may need and want to change this interface someday if socklen_t goes
|
||||
// to 64 bits on some platform that we support.
|
||||
// Linux doc says this can't return EINTR, unlike accept() on Solaris
|
||||
|
||||
return ::accept(fd, him, (socklen_t *)len);
|
||||
}
|
||||
|
||||
inline int os::recvfrom(int fd, char *buf, int nBytes, int flags,
|
||||
sockaddr *from, int *fromlen) {
|
||||
RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
|
||||
}
|
||||
|
||||
inline int os::sendto(int fd, char *buf, int len, int flags,
|
||||
struct sockaddr *to, int tolen) {
|
||||
RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen));
|
||||
}
|
||||
|
||||
inline int os::socket_available(int fd, jint *pbytes) {
|
||||
// Linux doc says EINTR not returned, unlike Solaris
|
||||
int ret = ::ioctl(fd, FIONREAD, pbytes);
|
||||
|
||||
//%% note ioctl can return 0 when successful, JVM_SocketAvailable
|
||||
// is expected to return 0 on failure and 1 on success to the jdk.
|
||||
return (ret < 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
inline int os::socket_shutdown(int fd, int howto){
|
||||
return ::shutdown(fd, howto);
|
||||
}
|
||||
|
||||
inline int os::bind(int fd, struct sockaddr *him, int len){
|
||||
return ::bind(fd, him, len);
|
||||
}
|
||||
|
||||
inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){
|
||||
return ::getsockname(fd, him, (socklen_t *)len);
|
||||
}
|
||||
|
||||
inline int os::get_host_name(char* name, int namelen){
|
||||
return ::gethostname(name, namelen);
|
||||
}
|
||||
|
||||
inline struct hostent* os::get_host_by_name(char* name) {
|
||||
return ::gethostbyname(name);
|
||||
}
|
||||
inline int os::get_sock_opt(int fd, int level, int optname,
|
||||
char *optval, int* optlen){
|
||||
return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen);
|
||||
}
|
||||
|
||||
inline int os::set_sock_opt(int fd, int level, int optname,
|
||||
const char *optval, int optlen){
|
||||
return ::setsockopt(fd, level, optname, optval, optlen);
|
||||
}
|
||||
#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue