173 julong os::Bsd::available_memory() { 174 uint64_t available = physical_memory() >> 2; 175 #ifdef __APPLE__ 176 mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; 177 vm_statistics64_data_t vmstat; 178 kern_return_t kerr = host_statistics64(mach_host_self(), HOST_VM_INFO64, 179 (host_info64_t)&vmstat, &count); 180 assert(kerr == KERN_SUCCESS, 181 "host_statistics64 failed - check mach_host_self() and count"); 182 if (kerr == KERN_SUCCESS) { 183 available = vmstat.free_count * os::vm_page_size(); 184 } 185 #endif 186 return available; 187 } 188 189 julong os::physical_memory() { 190 return Bsd::physical_memory(); 191 } 192 193 //////////////////////////////////////////////////////////////////////////////// 194 // environment support 195 196 bool os::getenv(const char* name, char* buf, int len) { 197 const char* val = ::getenv(name); 198 if (val != NULL && strlen(val) < (size_t)len) { 199 strcpy(buf, val); 200 return true; 201 } 202 if (len > 0) buf[0] = 0; // return a null string 203 return false; 204 } 205 206 207 // Return true if user is running as root. 208 209 bool os::have_special_privileges() { 210 static bool init = false; 211 static bool privileges = false; 212 if (!init) { 213 privileges = (getuid() != geteuid()) || (getgid() != getegid()); 214 init = true; 215 } 216 return privileges; 217 } 218 219 220 221 // Cpu architecture string 222 #if defined(ZERO) 223 static char cpu_arch[] = ZERO_LIBARCH; 224 #elif defined(IA64) 225 static char cpu_arch[] = "ia64"; 226 #elif defined(IA32) | 173 julong os::Bsd::available_memory() { 174 uint64_t available = physical_memory() >> 2; 175 #ifdef __APPLE__ 176 mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; 177 vm_statistics64_data_t vmstat; 178 kern_return_t kerr = host_statistics64(mach_host_self(), HOST_VM_INFO64, 179 (host_info64_t)&vmstat, &count); 180 assert(kerr == KERN_SUCCESS, 181 "host_statistics64 failed - check mach_host_self() and count"); 182 if (kerr == KERN_SUCCESS) { 183 available = vmstat.free_count * os::vm_page_size(); 184 } 185 #endif 186 return available; 187 } 188 189 julong os::physical_memory() { 190 return Bsd::physical_memory(); 191 } 192 193 // Return true if user is running as root. 194 195 bool os::have_special_privileges() { 196 static bool init = false; 197 static bool privileges = false; 198 if (!init) { 199 privileges = (getuid() != geteuid()) || (getgid() != getegid()); 200 init = true; 201 } 202 return privileges; 203 } 204 205 206 207 // Cpu architecture string 208 #if defined(ZERO) 209 static char cpu_arch[] = ZERO_LIBARCH; 210 #elif defined(IA64) 211 static char cpu_arch[] = "ia64"; 212 #elif defined(IA32) |