Skip to content

Commit

Permalink
Move mapping function to aix specific file.
Browse files Browse the repository at this point in the history
  • Loading branch information
suchismith1993 committed Nov 16, 2023
1 parent 6e1694a commit 91da7fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
13 changes: 13 additions & 0 deletions src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3059,3 +3059,16 @@ int os::Aix::stat64x_via_LIBPATH(const char* path, struct stat64x* stat) {
FREE_C_HEAP_ARRAY(char*, libpath);
return ret;
}

// Provide alternate path for shared objects in AIX
void os::Aix::mapAlternateName(char* buffer,const char *extension){

unsigned long end=strlen(buffer);
while(end>0 && buffer[end]!='.')
{
end--;
}
buffer[end]='\0';
strcat(buffer,extension);
}

2 changes: 2 additions & 0 deletions src/hotspot/os/aix/os_aix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class os::Aix {

// Simulate the library search algorithm of dlopen() (in os::dll_load)
static int stat64x_via_LIBPATH(const char* path, struct stat64x* stat);
static void mapAlternateName(char* buffer, const char *extension);

};

#endif // OS_AIX_OS_AIX_HPP
23 changes: 7 additions & 16 deletions src/hotspot/share/prims/jvmtiAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "runtime/os.inline.hpp"
#include "runtime/thread.inline.hpp"
#include "utilities/defaultStream.hpp"

static inline const char* copy_string(const char* str) {
return str != nullptr ? os::strdup(str, mtServiceability) : nullptr;
}
Expand Down Expand Up @@ -320,16 +321,6 @@ static void* load_agent_from_absolute_path(JvmtiAgent* agent, bool vm_exit_on_er
AIX_ONLY(if (library != nullptr) save_library_signature(agent, agent->name());)
return library;
}
static void mapAlternateName(char* buffer,const char *extension)
{
unsigned long end=strlen(buffer);
while(end>0 && buffer[end]!='.')
{
end--;
}
buffer[end]='\0';
strcat(buffer,extension);
}

// Agents with relative paths are loaded from the standard dll directory.
static void* load_agent_from_relative_path(JvmtiAgent* agent, bool vm_exit_on_error) {
Expand All @@ -348,17 +339,17 @@ static void* load_agent_from_relative_path(JvmtiAgent* agent, bool vm_exit_on_er
if (library != nullptr) {
AIX_ONLY(save_library_signature(agent, &buffer[0]);)
return library;
}
AIX_ONLY(
if (library == nullptr){
mapAlternateName(buffer,AIX_EXTENSION);
}
#ifdef AIX
if (library == nullptr) {
os::Aix::mapAlternateName(buffer,AIX_EXTENSION);
library=os::dll_load(&buffer[0], &ebuf[0], sizeof ebuf);
if(library!=nullptr){
if(library!=nullptr) {
save_library_signature(agent, &buffer[0]);
return library;
}
}
)
#endif
if (vm_exit_on_error) {
vm_exit(agent, " on the library path, with error: ", missing_module_error_msg);
}
Expand Down

0 comments on commit 91da7fa

Please sign in to comment.