Mercurial > hg > truffle
comparison src/share/vm/runtime/os.cpp @ 691:956304450e80
6819213: revive sun.boot.library.path
Summary: Support multiplex and mutable sun.boot.library.path
Reviewed-by: acorn, dcubed, xlu
author | phh |
---|---|
date | Wed, 01 Apr 2009 16:38:01 -0400 |
parents | 7bb995fbd3c0 |
children | 4ce7240d622c |
comparison
equal
deleted
inserted
replaced
690:d142f1feeed5 | 691:956304450e80 |
---|---|
861 return formatted_path; | 861 return formatted_path; |
862 } | 862 } |
863 | 863 |
864 | 864 |
865 bool os::set_boot_path(char fileSep, char pathSep) { | 865 bool os::set_boot_path(char fileSep, char pathSep) { |
866 | |
867 const char* home = Arguments::get_java_home(); | 866 const char* home = Arguments::get_java_home(); |
868 int home_len = (int)strlen(home); | 867 int home_len = (int)strlen(home); |
869 | 868 |
870 static const char* meta_index_dir_format = "%/lib/"; | 869 static const char* meta_index_dir_format = "%/lib/"; |
871 static const char* meta_index_format = "%/lib/meta-index"; | 870 static const char* meta_index_format = "%/lib/meta-index"; |
889 char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep); | 888 char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep); |
890 if (sysclasspath == NULL) return false; | 889 if (sysclasspath == NULL) return false; |
891 Arguments::set_sysclasspath(sysclasspath); | 890 Arguments::set_sysclasspath(sysclasspath); |
892 | 891 |
893 return true; | 892 return true; |
893 } | |
894 | |
895 /* | |
896 * Splits a path, based on its separator, the number of | |
897 * elements is returned back in n. | |
898 * It is the callers responsibility to: | |
899 * a> check the value of n, and n may be 0. | |
900 * b> ignore any empty path elements | |
901 * c> free up the data. | |
902 */ | |
903 char** os::split_path(const char* path, int* n) { | |
904 *n = 0; | |
905 if (path == NULL || strlen(path) == 0) { | |
906 return NULL; | |
907 } | |
908 const char psepchar = *os::path_separator(); | |
909 char* inpath = (char*)NEW_C_HEAP_ARRAY(char, strlen(path) + 1); | |
910 if (inpath == NULL) { | |
911 return NULL; | |
912 } | |
913 strncpy(inpath, path, strlen(path)); | |
914 int count = 1; | |
915 char* p = strchr(inpath, psepchar); | |
916 // Get a count of elements to allocate memory | |
917 while (p != NULL) { | |
918 count++; | |
919 p++; | |
920 p = strchr(p, psepchar); | |
921 } | |
922 char** opath = (char**) NEW_C_HEAP_ARRAY(char*, count); | |
923 if (opath == NULL) { | |
924 return NULL; | |
925 } | |
926 | |
927 // do the actual splitting | |
928 p = inpath; | |
929 for (int i = 0 ; i < count ; i++) { | |
930 size_t len = strcspn(p, os::path_separator()); | |
931 if (len > JVM_MAXPATHLEN) { | |
932 return NULL; | |
933 } | |
934 // allocate the string and add terminator storage | |
935 char* s = (char*)NEW_C_HEAP_ARRAY(char, len + 1); | |
936 if (s == NULL) { | |
937 return NULL; | |
938 } | |
939 strncpy(s, p, len); | |
940 s[len] = '\0'; | |
941 opath[i] = s; | |
942 p += len + 1; | |
943 } | |
944 FREE_C_HEAP_ARRAY(char, inpath); | |
945 *n = count; | |
946 return opath; | |
894 } | 947 } |
895 | 948 |
896 void os::set_memory_serialize_page(address page) { | 949 void os::set_memory_serialize_page(address page) { |
897 int count = log2_intptr(sizeof(class JavaThread)) - log2_intptr(64); | 950 int count = log2_intptr(sizeof(class JavaThread)) - log2_intptr(64); |
898 _mem_serialize_page = (volatile int32_t *)page; | 951 _mem_serialize_page = (volatile int32_t *)page; |