174 175 static int SR_initialize(); 176 static int SR_finalize(); 177 178 julong os::available_memory() { 179 return Linux::available_memory(); 180 } 181 182 julong os::Linux::available_memory() { 183 // values in struct sysinfo are "unsigned long" 184 struct sysinfo si; 185 sysinfo(&si); 186 187 return (julong)si.freeram * si.mem_unit; 188 } 189 190 julong os::physical_memory() { 191 return Linux::physical_memory(); 192 } 193 194 julong os::allocatable_physical_memory(julong size) { 195 #ifdef _LP64 196 return size; 197 #else 198 julong result = MIN2(size, (julong)3800*M); 199 if (!is_allocatable(result)) { 200 // See comments under solaris for alignment considerations 201 julong reasonable_size = (julong)2*G - 2 * os::vm_page_size(); 202 result = MIN2(size, reasonable_size); 203 } 204 return result; 205 #endif // _LP64 206 } 207 208 //////////////////////////////////////////////////////////////////////////////// 209 // environment support 210 211 bool os::getenv(const char* name, char* buf, int len) { 212 const char* val = ::getenv(name); 213 if (val != NULL && strlen(val) < (size_t)len) { 214 strcpy(buf, val); 215 return true; 216 } 217 if (len > 0) buf[0] = 0; // return a null string 218 return false; 219 } 220 221 222 // Return true if user is running as root. 223 224 bool os::have_special_privileges() { 225 static bool init = false; 226 static bool privileges = false; 227 if (!init) { | 174 175 static int SR_initialize(); 176 static int SR_finalize(); 177 178 julong os::available_memory() { 179 return Linux::available_memory(); 180 } 181 182 julong os::Linux::available_memory() { 183 // values in struct sysinfo are "unsigned long" 184 struct sysinfo si; 185 sysinfo(&si); 186 187 return (julong)si.freeram * si.mem_unit; 188 } 189 190 julong os::physical_memory() { 191 return Linux::physical_memory(); 192 } 193 194 //////////////////////////////////////////////////////////////////////////////// 195 // environment support 196 197 bool os::getenv(const char* name, char* buf, int len) { 198 const char* val = ::getenv(name); 199 if (val != NULL && strlen(val) < (size_t)len) { 200 strcpy(buf, val); 201 return true; 202 } 203 if (len > 0) buf[0] = 0; // return a null string 204 return false; 205 } 206 207 208 // Return true if user is running as root. 209 210 bool os::have_special_privileges() { 211 static bool init = false; 212 static bool privileges = false; 213 if (!init) { |