1.1 --- a/src/os/linux/vm/os_linux.cpp Tue Jun 10 16:39:20 2008 -0700 1.2 +++ b/src/os/linux/vm/os_linux.cpp Tue Jun 17 09:59:59 2008 -0700 1.3 @@ -75,8 +75,8 @@ 1.4 bool os::Linux::_is_floating_stack = false; 1.5 bool os::Linux::_is_NPTL = false; 1.6 bool os::Linux::_supports_fast_thread_cpu_time = false; 1.7 -char * os::Linux::_glibc_version = NULL; 1.8 -char * os::Linux::_libpthread_version = NULL; 1.9 +const char * os::Linux::_glibc_version = NULL; 1.10 +const char * os::Linux::_libpthread_version = NULL; 1.11 1.12 static jlong initial_time_count=0; 1.13 1.14 @@ -213,9 +213,9 @@ 1.15 // the system call returns 1. This causes the VM to act as if it is 1.16 // a single processor and elide locking (see is_MP() call). 1.17 static bool unsafe_chroot_detected = false; 1.18 -static char *unstable_chroot_error = "/proc file system not found.\n" 1.19 - "Java may be unstable running multithreaded in a chroot " 1.20 - "environment on Linux when /proc filesystem is not mounted."; 1.21 +static const char *unstable_chroot_error = "/proc file system not found.\n" 1.22 + "Java may be unstable running multithreaded in a chroot " 1.23 + "environment on Linux when /proc filesystem is not mounted."; 1.24 1.25 void os::Linux::initialize_system_info() { 1.26 _processor_count = sysconf(_SC_NPROCESSORS_CONF); 1.27 @@ -544,26 +544,23 @@ 1.28 if (n > 0) { 1.29 char *str = (char *)malloc(n); 1.30 confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n); 1.31 - 1.32 // Vanilla RH-9 (glibc 2.3.2) has a bug that confstr() always tells 1.33 // us "NPTL-0.29" even we are running with LinuxThreads. Check if this 1.34 - // is the case: 1.35 + // is the case. LinuxThreads has a hard limit on max number of threads. 1.36 + // So sysconf(_SC_THREAD_THREADS_MAX) will return a positive value. 1.37 + // On the other hand, NPTL does not have such a limit, sysconf() 1.38 + // will return -1 and errno is not changed. Check if it is really NPTL. 1.39 if (strcmp(os::Linux::glibc_version(), "glibc 2.3.2") == 0 && 1.40 - strstr(str, "NPTL")) { 1.41 - // LinuxThreads has a hard limit on max number of threads. So 1.42 - // sysconf(_SC_THREAD_THREADS_MAX) will return a positive value. 1.43 - // On the other hand, NPTL does not have such a limit, sysconf() 1.44 - // will return -1 and errno is not changed. Check if it is really 1.45 - // NPTL: 1.46 - if (sysconf(_SC_THREAD_THREADS_MAX) > 0) { 1.47 - free(str); 1.48 - str = "linuxthreads"; 1.49 - } 1.50 + strstr(str, "NPTL") && 1.51 + sysconf(_SC_THREAD_THREADS_MAX) > 0) { 1.52 + free(str); 1.53 + os::Linux::set_libpthread_version("linuxthreads"); 1.54 + } else { 1.55 + os::Linux::set_libpthread_version(str); 1.56 } 1.57 - os::Linux::set_libpthread_version(str); 1.58 } else { 1.59 - // glibc before 2.3.2 only has LinuxThreads. 1.60 - os::Linux::set_libpthread_version("linuxthreads"); 1.61 + // glibc before 2.3.2 only has LinuxThreads. 1.62 + os::Linux::set_libpthread_version("linuxthreads"); 1.63 } 1.64 1.65 if (strstr(libpthread_version(), "NPTL")) { 1.66 @@ -4632,11 +4629,7 @@ 1.67 // Unlike system(), this function can be called from signal handler. It 1.68 // doesn't block SIGINT et al. 1.69 int os::fork_and_exec(char* cmd) { 1.70 - char * argv[4]; 1.71 - argv[0] = "sh"; 1.72 - argv[1] = "-c"; 1.73 - argv[2] = cmd; 1.74 - argv[3] = NULL; 1.75 + const char * argv[4] = {"sh", "-c", cmd, NULL}; 1.76 1.77 // fork() in LinuxThreads/NPTL is not async-safe. It needs to run 1.78 // pthread_atfork handlers and reset pthread library. All we need is a 1.79 @@ -4661,7 +4654,7 @@ 1.80 // IA64 should use normal execve() from glibc to match the glibc fork() 1.81 // above. 1.82 NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);) 1.83 - IA64_ONLY(execve("/bin/sh", argv, environ);) 1.84 + IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);) 1.85 1.86 // execve failed 1.87 _exit(-1);