< prev index next >

hotspot/src/os/bsd/vm/os_bsd.cpp

Print this page
rev 7342 : 8077674: BSD build failures due to undefined macros
Reviewed-by: dsamersoff, kbarrett, hseigel


1180   size_t n = ::strlen(s);
1181   if (n >= len) {
1182     n = len - 1;
1183   }
1184   ::strncpy(buf, s, n);
1185   buf[n] = '\0';
1186   return n;
1187 }
1188 
1189 // Information of current thread in variety of formats
1190 pid_t os::Bsd::gettid() {
1191   int retval = -1;
1192 
1193 #ifdef __APPLE__ //XNU kernel
1194   // despite the fact mach port is actually not a thread id use it
1195   // instead of syscall(SYS_thread_selfid) as it certainly fits to u4
1196   retval = ::pthread_mach_thread_np(::pthread_self());
1197   guarantee(retval != 0, "just checking");
1198   return retval;
1199 
1200 #elif __FreeBSD__

1201   retval = syscall(SYS_thr_self);
1202 #elif __OpenBSD__

1203   retval = syscall(SYS_getthrid);
1204 #elif __NetBSD__

1205   retval = (pid_t) syscall(SYS__lwp_self);



1206 #endif
1207 
1208   if (retval == -1) {
1209     return getpid();
1210   }
1211 }
1212 
1213 intx os::current_thread_id() {
1214 #ifdef __APPLE__
1215   return (intx)::pthread_mach_thread_np(::pthread_self());
1216 #else
1217   return (intx)::pthread_self();
1218 #endif
1219 }
1220 
1221 int os::current_process_id() {
1222 
1223   // Under the old bsd thread library, bsd gives each thread
1224   // its own process id. Because of this each thread will return
1225   // a different pid if this method were to return the result




1180   size_t n = ::strlen(s);
1181   if (n >= len) {
1182     n = len - 1;
1183   }
1184   ::strncpy(buf, s, n);
1185   buf[n] = '\0';
1186   return n;
1187 }
1188 
1189 // Information of current thread in variety of formats
1190 pid_t os::Bsd::gettid() {
1191   int retval = -1;
1192 
1193 #ifdef __APPLE__ //XNU kernel
1194   // despite the fact mach port is actually not a thread id use it
1195   // instead of syscall(SYS_thread_selfid) as it certainly fits to u4
1196   retval = ::pthread_mach_thread_np(::pthread_self());
1197   guarantee(retval != 0, "just checking");
1198   return retval;
1199 
1200 #else
1201   #ifdef __FreeBSD__
1202   retval = syscall(SYS_thr_self);
1203   #else
1204     #ifdef __OpenBSD__
1205   retval = syscall(SYS_getthrid);
1206     #else
1207       #ifdef __NetBSD__
1208   retval = (pid_t) syscall(SYS__lwp_self);
1209       #endif
1210     #endif
1211   #endif
1212 #endif
1213 
1214   if (retval == -1) {
1215     return getpid();
1216   }
1217 }
1218 
1219 intx os::current_thread_id() {
1220 #ifdef __APPLE__
1221   return (intx)::pthread_mach_thread_np(::pthread_self());
1222 #else
1223   return (intx)::pthread_self();
1224 #endif
1225 }
1226 
1227 int os::current_process_id() {
1228 
1229   // Under the old bsd thread library, bsd gives each thread
1230   // its own process id. Because of this each thread will return
1231   // a different pid if this method were to return the result


< prev index next >