Skip to content

Commit

Permalink
[EagerAppCDS] remove platform-dependent include in quickStart.cpp
Browse files Browse the repository at this point in the history
Summary: as title. Otherwise, the win build will fail.

Test Plan: win build

Reviewed-by: lingjun-cg, yuleil

Issue: #571
CR:
  • Loading branch information
jia-wei-tang committed Jul 24, 2023
1 parent 0382101 commit ce756bc
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions hotspot/src/share/vm/runtime/quickStart.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include <limits.h>
#include <stdlib.h>
#include <strings.h>
#include "precompiled.hpp"
#include "classfile/vmSymbols.hpp"
#include "classfile/javaClasses.hpp"
#include "memory/resourceArea.hpp"
Expand Down Expand Up @@ -440,7 +438,7 @@ void QuickStart::check_features(const char* &str) {
}

bool QuickStart::load_and_validate(const JavaVMInitArgs* options_args) {
char line[PATH_MAX];
char line[JVM_MAXPATHLEN];
const char* tail = NULL;
bool feature_checked = false;
bool version_checked = false;
Expand Down Expand Up @@ -575,8 +573,8 @@ void QuickStart::calculate_cache_path() {
tty->print_cr("Cannot get temp directory");
vm_exit(1);
}
char buf[PATH_MAX];
jio_snprintf(buf, PATH_MAX, "%s%s%s_%d_%ld", temp, os::file_separator(), DEFAULT_SHARED_DIRECTORY, os::current_process_id(), os::javaTimeMillis());
char buf[JVM_MAXPATHLEN];
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s_%d_%ld", temp, os::file_separator(), DEFAULT_SHARED_DIRECTORY, os::current_process_id(), os::javaTimeMillis());
_cache_path = os::strdup(buf);
} else {
const char* home = ::getenv("HOME");
Expand All @@ -588,8 +586,8 @@ void QuickStart::calculate_cache_path() {
vm_exit(1);
}
}
char buf[PATH_MAX];
jio_snprintf(buf, PATH_MAX, "%s%s%s", home, os::file_separator(), DEFAULT_SHARED_DIRECTORY);
char buf[JVM_MAXPATHLEN];
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", home, os::file_separator(), DEFAULT_SHARED_DIRECTORY);
_cache_path = os::strdup(buf);
}
tty->print_cr("cache path is set as default with %s", _cache_path);
Expand Down Expand Up @@ -741,7 +739,7 @@ void QuickStart::add_CDSDumpHook(TRAPS) {

bool QuickStart::determine_role(const JavaVMInitArgs* options_args) {
struct stat st;
char buf[PATH_MAX];
char buf[JVM_MAXPATHLEN];
int ret = os::stat(_cache_path, &st);
if (ret != 0) {
if (_print_stat_enabled) {
Expand All @@ -761,23 +759,23 @@ bool QuickStart::determine_role(const JavaVMInitArgs* options_args) {
}

// check whether the metadata file exists.
jio_snprintf(buf, PATH_MAX, "%s%s%s", _cache_path, os::file_separator(), METADATA_FILE);
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", _cache_path, os::file_separator(), METADATA_FILE);
_metadata_file_path = os::strdup(buf, mtInternal);
ret = os::stat(_metadata_file_path, &st);
if (ret < 0 && errno == ENOENT) {
if (_print_stat_enabled) {
print_stat(false);
}
// Create a LOCK file
jio_snprintf(buf, PATH_MAX, "%s%s%s", _cache_path, os::file_separator(), LOCK_FILE);
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", _cache_path, os::file_separator(), LOCK_FILE);
_lock_path = os::strdup(buf, mtInternal);
// if the lock exists, it returns -1.
_lock_file_fd = os::create_binary_file(_lock_path, false);
if (_lock_file_fd == -1) {
tty->print_cr("Fail to create LOCK file");
return false;
}
jio_snprintf(buf, PATH_MAX, "%s%s%s", _cache_path, os::file_separator(), TEMP_METADATA_FILE);
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", _cache_path, os::file_separator(), TEMP_METADATA_FILE);
_temp_metadata_file_path = os::strdup(buf, mtInternal);
ret = os::stat(buf, &st);
if (ret == 0) {
Expand Down Expand Up @@ -812,26 +810,26 @@ bool QuickStart::determine_role(const JavaVMInitArgs* options_args) {

bool QuickStart::prepare_dump(const JavaVMInitArgs *options_args) {
struct stat st;
char buf[PATH_MAX];
char buf[JVM_MAXPATHLEN];
// check whether the metadata file exists.
// when run quickstart with profile,then dump.In the profile stage,the metadata.tmp not rename to metadata.
jio_snprintf(buf, PATH_MAX, "%s%s%s", _cache_path, os::file_separator(), TEMP_METADATA_FILE);
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", _cache_path, os::file_separator(), TEMP_METADATA_FILE);
_temp_metadata_file_path = os::strdup(buf);
int ret = os::stat(_temp_metadata_file_path, &st);
if (ret < 0 && errno == ENOENT) {
tty->print_cr("The %s file not exists\n", _temp_metadata_file_path);
return false;
} else if (ret == 0 && check_integrity(options_args, _temp_metadata_file_path)) {
// Create a LOCK file
jio_snprintf(buf, PATH_MAX, "%s%s%s", _cache_path, os::file_separator(), LOCK_FILE);
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", _cache_path, os::file_separator(), LOCK_FILE);
_lock_path = os::strdup(buf);
// if the lock exists, it returns -1.
_lock_file_fd = os::create_binary_file(_lock_path, false);
if (_lock_file_fd == -1) {
tty->print_cr("Fail to create LOCK file");
return false;
}
jio_snprintf(buf, PATH_MAX, "%s%s%s", _cache_path, os::file_separator(), METADATA_FILE);
jio_snprintf(buf, JVM_MAXPATHLEN, "%s%s%s", _cache_path, os::file_separator(), METADATA_FILE);
_metadata_file_path = os::strdup(buf);
_role = Dumper;
tty->print_cr("Running as dumper");
Expand Down Expand Up @@ -898,7 +896,7 @@ void QuickStart::generate_metadata_file(bool rename_metafile) {
int QuickStart::remove_dir(const char* dir) {
char cur_dir[] = ".";
char up_dir[] = "..";
char dir_name[PATH_MAX];
char dir_name[JVM_MAXPATHLEN];
DIR *dirp = NULL;
struct dirent *dp;
struct stat dir_stat;
Expand All @@ -917,7 +915,7 @@ int QuickStart::remove_dir(const char* dir) {
if ((strcmp(cur_dir, dp->d_name) == 0) || (strcmp(up_dir, dp->d_name) == 0)) {
continue;
}
jio_snprintf(dir_name, PATH_MAX, "%s%s%s", dir, os::file_separator(), dp->d_name);
jio_snprintf(dir_name, JVM_MAXPATHLEN, "%s%s%s", dir, os::file_separator(), dp->d_name);
ret = remove_dir(dir_name);
if (ret != 0) {
break;
Expand Down

0 comments on commit ce756bc

Please sign in to comment.