src/os/bsd/vm/os_bsd.cpp

Print this page




 149 
 150 ////////////////////////////////////////////////////////////////////////////////
 151 // utility functions
 152 
 153 static int SR_initialize();
 154 static int SR_finalize();
 155 
 156 julong os::available_memory() {
 157   return Bsd::available_memory();
 158 }
 159 
 160 julong os::Bsd::available_memory() {
 161   // XXXBSD: this is just a stopgap implementation
 162   return physical_memory() >> 2;
 163 }
 164 
 165 julong os::physical_memory() {
 166   return Bsd::physical_memory();
 167 }
 168 
 169 julong os::allocatable_physical_memory(julong size) {
 170 #ifdef _LP64
 171   return size;
 172 #else
 173   julong result = MIN2(size, (julong)3800*M);
 174    if (!is_allocatable(result)) {
 175      // See comments under solaris for alignment considerations
 176      julong reasonable_size = (julong)2*G - 2 * os::vm_page_size();
 177      result =  MIN2(size, reasonable_size);
 178    }
 179    return result;
 180 #endif // _LP64
 181 }
 182 
 183 ////////////////////////////////////////////////////////////////////////////////
 184 // environment support
 185 
 186 bool os::getenv(const char* name, char* buf, int len) {
 187   const char* val = ::getenv(name);
 188   if (val != NULL && strlen(val) < (size_t)len) {
 189     strcpy(buf, val);
 190     return true;
 191   }
 192   if (len > 0) buf[0] = 0;  // return a null string
 193   return false;
 194 }
 195 
 196 
 197 // Return true if user is running as root.
 198 
 199 bool os::have_special_privileges() {
 200   static bool init = false;
 201   static bool privileges = false;
 202   if (!init) {




 149 
 150 ////////////////////////////////////////////////////////////////////////////////
 151 // utility functions
 152 
 153 static int SR_initialize();
 154 static int SR_finalize();
 155 
 156 julong os::available_memory() {
 157   return Bsd::available_memory();
 158 }
 159 
 160 julong os::Bsd::available_memory() {
 161   // XXXBSD: this is just a stopgap implementation
 162   return physical_memory() >> 2;
 163 }
 164 
 165 julong os::physical_memory() {
 166   return Bsd::physical_memory();
 167 }
 168 














 169 ////////////////////////////////////////////////////////////////////////////////
 170 // environment support
 171 
 172 bool os::getenv(const char* name, char* buf, int len) {
 173   const char* val = ::getenv(name);
 174   if (val != NULL && strlen(val) < (size_t)len) {
 175     strcpy(buf, val);
 176     return true;
 177   }
 178   if (len > 0) buf[0] = 0;  // return a null string
 179   return false;
 180 }
 181 
 182 
 183 // Return true if user is running as root.
 184 
 185 bool os::have_special_privileges() {
 186   static bool init = false;
 187   static bool privileges = false;
 188   if (!init) {