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) {
203 privileges = (getuid() != geteuid()) || (getgid() != getegid());
204 init = true;
205 }
206 return privileges;
207 }
208
209
210 #ifndef SYS_gettid
211 // i386: 224, ia64: 1105, amd64: 186, sparc 143
212 #ifdef __ia64__
213 #define SYS_gettid 1105
214 #elif __i386__
215 #define SYS_gettid 224
216 #elif __amd64__
217 #define SYS_gettid 186
218 #elif __sparc__
219 #define SYS_gettid 143
220 #else
221 #error define gettid for the arch
222 #endif
223 #endif
224
225 // Cpu architecture string
226 static char cpu_arch[] = HOTSPOT_LIB_ARCH;
227
228 // pid_t gettid()
229 //
230 // Returns the kernel thread id of the currently running thread. Kernel
231 // thread id is used to access /proc.
232 //
233 // (Note that getpid() on LinuxThreads returns kernel thread id too; but
234 // on NPTL, it returns the same pid for all threads, as required by POSIX.)
235 //
236 pid_t os::Linux::gettid() {
237 int rslt = syscall(SYS_gettid);
238 if (rslt == -1) {
239 // old kernel, no NPTL support
240 return getpid();
241 } else {
242 return (pid_t)rslt;
|
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) {
203 privileges = (getuid() != geteuid()) || (getgid() != getegid());
204 init = true;
205 }
206 return privileges;
207 }
208
209
210 #ifndef SYS_gettid
211 // i386: 224, ia64: 1105, amd64: 186, sparc 143
212 #ifdef __ia64__
213 #define SYS_gettid 1105
214 #else
215 #ifdef __i386__
216 #define SYS_gettid 224
217 #else
218 #ifdef __amd64__
219 #define SYS_gettid 186
220 #else
221 #ifdef __sparc__
222 #define SYS_gettid 143
223 #else
224 #error define gettid for the arch
225 #endif
226 #endif
227 #endif
228 #endif
229 #endif
230
231 // Cpu architecture string
232 static char cpu_arch[] = HOTSPOT_LIB_ARCH;
233
234 // pid_t gettid()
235 //
236 // Returns the kernel thread id of the currently running thread. Kernel
237 // thread id is used to access /proc.
238 //
239 // (Note that getpid() on LinuxThreads returns kernel thread id too; but
240 // on NPTL, it returns the same pid for all threads, as required by POSIX.)
241 //
242 pid_t os::Linux::gettid() {
243 int rslt = syscall(SYS_gettid);
244 if (rslt == -1) {
245 // old kernel, no NPTL support
246 return getpid();
247 } else {
248 return (pid_t)rslt;
|