< prev index next >

src/os/linux/vm/os_linux.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 235   return privileges;
 236 }
 237 
 238 
 239 #ifndef SYS_gettid
 240 // i386: 224, ia64: 1105, amd64: 186, sparc 143
 241 #ifdef __ia64__
 242 #define SYS_gettid 1105
 243 #elif __i386__
 244 #define SYS_gettid 224
 245 #elif __amd64__
 246 #define SYS_gettid 186
 247 #elif __sparc__
 248 #define SYS_gettid 143
 249 #else
 250 #error define gettid for the arch
 251 #endif
 252 #endif
 253 
 254 // Cpu architecture string
 255 #if   defined(ZERO)
 256 static char cpu_arch[] = ZERO_LIBARCH;
 257 #elif defined(IA64)
 258 static char cpu_arch[] = "ia64";
 259 #elif defined(IA32)
 260 static char cpu_arch[] = "i386";
 261 #elif defined(AMD64)
 262 static char cpu_arch[] = "amd64";
 263 #elif defined(ARM)
 264 static char cpu_arch[] = "arm";
 265 #elif defined(PPC32)
 266 static char cpu_arch[] = "ppc";
 267 #elif defined(PPC64)
 268 static char cpu_arch[] = "ppc64";
 269 #elif defined(SPARC)
 270 #  ifdef _LP64
 271 static char cpu_arch[] = "sparcv9";
 272 #  else
 273 static char cpu_arch[] = "sparc";
 274 #  endif
 275 #else
 276 #error Add appropriate cpu_arch setting
 277 #endif
 278 
 279 
 280 // pid_t gettid()
 281 //
 282 // Returns the kernel thread id of the currently running thread. Kernel
 283 // thread id is used to access /proc.
 284 //
 285 // (Note that getpid() on LinuxThreads returns kernel thread id too; but
 286 // on NPTL, it returns the same pid for all threads, as required by POSIX.)
 287 //
 288 pid_t os::Linux::gettid() {
 289   int rslt = syscall(SYS_gettid);
 290   if (rslt == -1) {
 291      // old kernel, no NPTL support
 292      return getpid();
 293   } else {
 294      return (pid_t)rslt;
 295   }
 296 }
 297 
 298 // Most versions of linux have a bug where the number of processors are


   1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 235   return privileges;
 236 }
 237 
 238 
 239 #ifndef SYS_gettid
 240 // i386: 224, ia64: 1105, amd64: 186, sparc 143
 241 #ifdef __ia64__
 242 #define SYS_gettid 1105
 243 #elif __i386__
 244 #define SYS_gettid 224
 245 #elif __amd64__
 246 #define SYS_gettid 186
 247 #elif __sparc__
 248 #define SYS_gettid 143
 249 #else
 250 #error define gettid for the arch
 251 #endif
 252 #endif
 253 
 254 // Cpu architecture string
 255 static char cpu_arch[] = HOTSPOT_LIB_ARCH;























 256 
 257 // pid_t gettid()
 258 //
 259 // Returns the kernel thread id of the currently running thread. Kernel
 260 // thread id is used to access /proc.
 261 //
 262 // (Note that getpid() on LinuxThreads returns kernel thread id too; but
 263 // on NPTL, it returns the same pid for all threads, as required by POSIX.)
 264 //
 265 pid_t os::Linux::gettid() {
 266   int rslt = syscall(SYS_gettid);
 267   if (rslt == -1) {
 268      // old kernel, no NPTL support
 269      return getpid();
 270   } else {
 271      return (pid_t)rslt;
 272   }
 273 }
 274 
 275 // Most versions of linux have a bug where the number of processors are


< prev index next >