167 // utility functions 168 169 static int SR_initialize(); 170 171 julong os::available_memory() { 172 return Linux::available_memory(); 173 } 174 175 julong os::Linux::available_memory() { 176 // values in struct sysinfo are "unsigned long" 177 struct sysinfo si; 178 sysinfo(&si); 179 180 return (julong)si.freeram * si.mem_unit; 181 } 182 183 julong os::physical_memory() { 184 return Linux::physical_memory(); 185 } 186 187 //////////////////////////////////////////////////////////////////////////////// 188 // environment support 189 190 bool os::getenv(const char* name, char* buf, int len) { 191 const char* val = ::getenv(name); 192 if (val != NULL && strlen(val) < (size_t)len) { 193 strcpy(buf, val); 194 return true; 195 } 196 if (len > 0) buf[0] = 0; // return a null string 197 return false; 198 } 199 200 201 // Return true if user is running as root. 202 203 bool os::have_special_privileges() { 204 static bool init = false; 205 static bool privileges = false; 206 if (!init) { 207 privileges = (getuid() != geteuid()) || (getgid() != getegid()); 208 init = true; 209 } 210 return privileges; 211 } 212 213 214 #ifndef SYS_gettid 215 // i386: 224, ia64: 1105, amd64: 186, sparc 143 216 #ifdef __ia64__ 217 #define SYS_gettid 1105 218 #elif __i386__ 219 #define SYS_gettid 224 220 #elif __amd64__ | 167 // utility functions 168 169 static int SR_initialize(); 170 171 julong os::available_memory() { 172 return Linux::available_memory(); 173 } 174 175 julong os::Linux::available_memory() { 176 // values in struct sysinfo are "unsigned long" 177 struct sysinfo si; 178 sysinfo(&si); 179 180 return (julong)si.freeram * si.mem_unit; 181 } 182 183 julong os::physical_memory() { 184 return Linux::physical_memory(); 185 } 186 187 // Return true if user is running as root. 188 189 bool os::have_special_privileges() { 190 static bool init = false; 191 static bool privileges = false; 192 if (!init) { 193 privileges = (getuid() != geteuid()) || (getgid() != getegid()); 194 init = true; 195 } 196 return privileges; 197 } 198 199 200 #ifndef SYS_gettid 201 // i386: 224, ia64: 1105, amd64: 186, sparc 143 202 #ifdef __ia64__ 203 #define SYS_gettid 1105 204 #elif __i386__ 205 #define SYS_gettid 224 206 #elif __amd64__ |