mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
6819213: revive sun.boot.library.path
Support multiplex and mutable sun.boot.library.path Reviewed-by: acorn, dcubed, xlu
This commit is contained in:
parent
d37d544754
commit
4be7c3c672
9 changed files with 345 additions and 50 deletions
|
@ -1518,21 +1518,51 @@ const char* os::dll_file_extension() { return ".so"; }
|
|||
|
||||
const char* os::get_temp_directory() { return "/tmp/"; }
|
||||
|
||||
void os::dll_build_name(
|
||||
char* buffer, size_t buflen, const char* pname, const char* fname) {
|
||||
// copied from libhpi
|
||||
static bool file_exists(const char* filename) {
|
||||
struct stat statbuf;
|
||||
if (filename == NULL || strlen(filename) == 0) {
|
||||
return false;
|
||||
}
|
||||
return os::stat(filename, &statbuf) == 0;
|
||||
}
|
||||
|
||||
void os::dll_build_name(char* buffer, size_t buflen,
|
||||
const char* pname, const char* fname) {
|
||||
// Copied from libhpi
|
||||
const size_t pnamelen = pname ? strlen(pname) : 0;
|
||||
|
||||
/* Quietly truncate on buffer overflow. Should be an error. */
|
||||
// Quietly truncate on buffer overflow. Should be an error.
|
||||
if (pnamelen + strlen(fname) + 10 > (size_t) buflen) {
|
||||
*buffer = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
if (pnamelen == 0) {
|
||||
sprintf(buffer, "lib%s.so", fname);
|
||||
snprintf(buffer, buflen, "lib%s.so", fname);
|
||||
} else if (strchr(pname, *os::path_separator()) != NULL) {
|
||||
int n;
|
||||
char** pelements = split_path(pname, &n);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
// Really shouldn't be NULL, but check can't hurt
|
||||
if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
|
||||
continue; // skip the empty path values
|
||||
}
|
||||
snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname);
|
||||
if (file_exists(buffer)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// release the storage
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
if (pelements[i] != NULL) {
|
||||
FREE_C_HEAP_ARRAY(char, pelements[i]);
|
||||
}
|
||||
}
|
||||
if (pelements != NULL) {
|
||||
FREE_C_HEAP_ARRAY(char*, pelements);
|
||||
}
|
||||
} else {
|
||||
sprintf(buffer, "%s/lib%s.so", pname, fname);
|
||||
snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue