Changeset 252 for trunk


Ignore:
Timestamp:
Jan 28, 2011, 11:17:17 AM (15 years ago)
Author:
dmik
Message:

hotspot: Use LIBPATH to comprise java.library.path instead of PATH on OS/2.

Location:
trunk/openjdk/hotspot/src/os
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/hotspot/src/os/os2/vm/os_os2.cpp

    r228 r252  
    217217    return MIN2(size, maxMemBlock);
    218218}
     219
     220// Extracts the LIBPATH value from CONFIG.SYS and puts it to the environment
     221// under the JAVA_LIBPATH name unless JAVA_LIBPATH is already set in which
     222// case the existing value is simply returned.
     223const char *getLibPath()
     224{
     225    const char *libPath = ::getenv("JAVA_LIBPATH");
     226    if (libPath)
     227        return libPath;
     228
     229    os2_APIRET arc;
     230    os2_ULONG drive;
     231    arc = DosQuerySysInfo(os2_QSV_BOOT_DRIVE, os2_QSV_BOOT_DRIVE,
     232                          &drive, sizeof(drive));
     233    if (arc != os2_NO_ERROR)
     234        return NULL;
     235
     236    char configSys[] = "?:\\CONFIG.SYS";
     237    *configSys = drive + 'A' - 1;
     238
     239    FILE *f = fopen(configSys, "r");
     240    if (!f)
     241        return NULL;
     242
     243    char buf[1024];
     244    char *libPathBuf = NULL;
     245    while (!feof(f) && !ferror(f)) {
     246        if (fgets(buf, sizeof(buf), f)) {
     247            int len = strlen(buf);
     248            if (libPathBuf) {
     249                // continuation of the LIBPATH string
     250                libPathBuf = (char *)realloc(libPathBuf, strlen(libPathBuf) + len + 2);
     251                if (!libPathBuf)
     252                    break;
     253            }
     254            else if (!strncmp(buf, "LIBPATH", 7)) {
     255                // beginning of the LIBPATH string
     256                libPathBuf = (char *)malloc(len + 1 + 5 /*JAVA_*/);
     257                if (!libPathBuf)
     258                    break;
     259                strcpy(libPathBuf, "JAVA_");
     260            }
     261            if (libPathBuf) {
     262                strcat(libPathBuf, buf);
     263                if (buf[len - 1] == '\n') {
     264                    // this is the last part, terminate and leave
     265                    libPathBuf[strlen(libPathBuf) - 1] = '\0';
     266                    break;
     267                }
     268            }
     269        }
     270    }
     271
     272    fclose(f);
     273
     274    ::putenv(libPathBuf);
     275    return ::getenv("JAVA_LIBPATH");
     276}
  • trunk/openjdk/hotspot/src/os/windows/vm/os_windows.cpp

    r228 r252  
    159159LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo);
    160160#endif
     161
     162#ifdef __WIN32OS2__
     163const char *getLibPath(); // defined in os_os2.cpp
     164#endif
     165
    161166void os::init_system_properties_values() {
    162167  /* sysclasspath, java_home, dll_dir */
     
    216221    char *library_path;
    217222    char tmp[MAX_PATH];
     223
     224#ifdef __WIN32OS2__
     225    /* On OS/2, LIBPATH is used for DLL searching insetad of PATH */
     226    const char *path_str = getLibPath();
     227#else
    218228    char *path_str = ::getenv("PATH");
     229#endif
    219230
    220231    library_path = NEW_C_HEAP_ARRAY(char, MAX_PATH * 5 + sizeof(PACKAGE_DIR) +
Note: See TracChangeset for help on using the changeset viewer.