8245600: Clean up libjli

Reviewed-by: dholmes, alanb
This commit is contained in:
Mikael Vidstedt 2020-05-26 10:18:32 -07:00
parent 6aa15ad7ab
commit 44a0a08991
11 changed files with 47 additions and 161 deletions

View file

@ -709,20 +709,3 @@ ProcessPlatformOption(const char *arg)
{
return JNI_FALSE;
}
/*
* Provide a CounterGet() implementation based on gettimeofday() which
* is universally available, even though it may not be 'high resolution'
* compared to platforms that provide gethrtime() (like Solaris). It is
* also subject to time-of-day changes, but alternatives may not be
* known to be available at either build time or run time.
*/
uint64_t CounterGet() {
uint64_t result = 0;
struct timeval tv;
if (gettimeofday(&tv, NULL) != -1) {
result = 1000000LL * (uint64_t)tv.tv_sec;
result += (uint64_t)tv.tv_usec;
}
return result;
}

View file

@ -32,6 +32,8 @@
#include <limits.h>
#include <unistd.h>
#include <sys/param.h>
#include <dlfcn.h>
#include <pthread.h>
#include "manifest_info.h"
#include "jli_util.h"
@ -61,9 +63,11 @@ static jboolean GetJREPath(char *path, jint pathsize, jboolean speculative);
#include "java_md_aix.h"
#endif
#ifdef MACOSX
#include "java_md_macosx.h"
#else /* !MACOSX */
#include "java_md_solinux.h"
#endif /* MACOSX */
#if defined(MACOSX)
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif
#endif /* JAVA_MD_H */

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <sys/time.h>
#include "java.h"
/*
@ -364,3 +365,20 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
{
return NewPlatformStringArray(env, strv, argc);
}
/*
* Provide a CurrentTimeMicros() implementation based on gettimeofday() which
* is universally available, even though it may not be 'high resolution'
* compared to platforms that provide gethrtime() (like Solaris). It is
* also subject to time-of-day changes, but alternatives may not be
* known to be available at either build time or run time.
*/
jlong CurrentTimeMicros() {
jlong result = 0;
struct timeval tv;
if (gettimeofday(&tv, NULL) != -1) {
result = 1000000LL * (jlong)tv.tv_sec;
result += (jlong)tv.tv_usec;
}
return result;
}

View file

@ -1,45 +0,0 @@
/*
* 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 JAVA_MD_SOLINUX_H
#define JAVA_MD_SOLINUX_H
#include <sys/time.h>
uint64_t CounterGet(void);
#define Counter2Micros(counts) (counts)
/* pointer to environment */
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).
*/
static const char *user_dir = "/java";
#include <dlfcn.h>
#include <pthread.h>
#endif /* JAVA_MD_SOLINUX_H */