303 // Only enable glibc guard pages for non-Java threads 304 // (Java threads have HotSpot guard pages) 305 return (thr_type == java_thread ? 0 : page_size()); 306 } 307 308 static void current_stack_region(address *bottom, size_t *size) { 309 address stack_bottom; 310 address stack_top; 311 size_t stack_bytes; 312 313 #ifdef __APPLE__ 314 pthread_t self = pthread_self(); 315 stack_top = (address) pthread_get_stackaddr_np(self); 316 stack_bytes = pthread_get_stacksize_np(self); 317 stack_bottom = stack_top - stack_bytes; 318 #elif defined(__OpenBSD__) 319 stack_t ss; 320 int rslt = pthread_stackseg_np(pthread_self(), &ss); 321 322 if (rslt != 0) 323 fatal(err_msg("pthread_stackseg_np failed with err = " INT32_FORMAT, 324 rslt)); 325 326 stack_top = (address) ss.ss_sp; 327 stack_bytes = ss.ss_size; 328 stack_bottom = stack_top - stack_bytes; 329 #else 330 pthread_attr_t attr; 331 332 int rslt = pthread_attr_init(&attr); 333 334 // JVM needs to know exact stack location, abort if it fails 335 if (rslt != 0) 336 fatal(err_msg("pthread_attr_init failed with err = " INT32_FORMAT, rslt)); 337 338 rslt = pthread_attr_get_np(pthread_self(), &attr); 339 340 if (rslt != 0) 341 fatal(err_msg("pthread_attr_get_np failed with err = " INT32_FORMAT, 342 rslt)); 343 344 if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 || 345 pthread_attr_getstacksize(&attr, &stack_bytes) != 0) { 346 fatal("Can not locate current stack attributes!"); 347 } 348 349 pthread_attr_destroy(&attr); 350 351 stack_top = stack_bottom + stack_bytes; 352 #endif 353 354 assert(os::current_stack_pointer() >= stack_bottom, "should do"); 355 assert(os::current_stack_pointer() < stack_top, "should do"); 356 357 *bottom = stack_bottom; 358 *size = stack_top - stack_bottom; 359 } 360 361 address os::current_stack_base() { 362 address bottom; | 303 // Only enable glibc guard pages for non-Java threads 304 // (Java threads have HotSpot guard pages) 305 return (thr_type == java_thread ? 0 : page_size()); 306 } 307 308 static void current_stack_region(address *bottom, size_t *size) { 309 address stack_bottom; 310 address stack_top; 311 size_t stack_bytes; 312 313 #ifdef __APPLE__ 314 pthread_t self = pthread_self(); 315 stack_top = (address) pthread_get_stackaddr_np(self); 316 stack_bytes = pthread_get_stacksize_np(self); 317 stack_bottom = stack_top - stack_bytes; 318 #elif defined(__OpenBSD__) 319 stack_t ss; 320 int rslt = pthread_stackseg_np(pthread_self(), &ss); 321 322 if (rslt != 0) 323 fatal("pthread_stackseg_np failed with err = " INT32_FORMAT, rslt); 324 325 stack_top = (address) ss.ss_sp; 326 stack_bytes = ss.ss_size; 327 stack_bottom = stack_top - stack_bytes; 328 #else 329 pthread_attr_t attr; 330 331 int rslt = pthread_attr_init(&attr); 332 333 // JVM needs to know exact stack location, abort if it fails 334 if (rslt != 0) 335 fatal("pthread_attr_init failed with err = " INT32_FORMAT, rslt); 336 337 rslt = pthread_attr_get_np(pthread_self(), &attr); 338 339 if (rslt != 0) 340 fatal("pthread_attr_get_np failed with err = " INT32_FORMAT, rslt); 341 342 if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 || 343 pthread_attr_getstacksize(&attr, &stack_bytes) != 0) { 344 fatal("Can not locate current stack attributes!"); 345 } 346 347 pthread_attr_destroy(&attr); 348 349 stack_top = stack_bottom + stack_bytes; 350 #endif 351 352 assert(os::current_stack_pointer() >= stack_bottom, "should do"); 353 assert(os::current_stack_pointer() < stack_top, "should do"); 354 355 *bottom = stack_bottom; 356 *size = stack_top - stack_bottom; 357 } 358 359 address os::current_stack_base() { 360 address bottom; |