2777 }
2778
2779 size_t os::numa_get_leaf_groups(int *ids, size_t size) {
2780 for (size_t i = 0; i < size; i++) {
2781 ids[i] = i;
2782 }
2783 return size;
2784 }
2785
2786 bool os::get_page_info(char *start, page_info* info) {
2787 return false;
2788 }
2789
2790 char *os::scan_pages(char *start, char* end, page_info* page_expected,
2791 page_info* page_found) {
2792 return end;
2793 }
2794
2795
2796 int os::Linux::sched_getcpu_syscall(void) {
2797 unsigned int cpu;
2798 int retval = -1;
2799
2800 #if defined(IA32)
2801 #ifndef SYS_getcpu
2802 #define SYS_getcpu 318
2803 #endif
2804 retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
2805 #elif defined(AMD64)
2806 // Unfortunately we have to bring all these macros here from vsyscall.h
2807 // to be able to compile on old linuxes.
2808 #define __NR_vgetcpu 2
2809 #define VSYSCALL_START (-10UL << 20)
2810 #define VSYSCALL_SIZE 1024
2811 #define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
2812 typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache);
2813 vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu);
2814 retval = vgetcpu(&cpu, NULL, NULL);
2815 #endif
2816
2817 return (retval == -1) ? retval : cpu;
4170 // Retrieve the preinstalled signal handler from jvm
4171 actp = get_preinstalled_handler(sig);
4172 }
4173
4174 return actp;
4175 }
4176
4177 static bool call_chained_handler(struct sigaction *actp, int sig,
4178 siginfo_t *siginfo, void *context) {
4179 // Call the old signal handler
4180 if (actp->sa_handler == SIG_DFL) {
4181 // It's more reasonable to let jvm treat it as an unexpected exception
4182 // instead of taking the default action.
4183 return false;
4184 } else if (actp->sa_handler != SIG_IGN) {
4185 if ((actp->sa_flags & SA_NODEFER) == 0) {
4186 // automaticlly block the signal
4187 sigaddset(&(actp->sa_mask), sig);
4188 }
4189
4190 sa_handler_t hand;
4191 sa_sigaction_t sa;
4192 bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0;
4193 // retrieve the chained handler
4194 if (siginfo_flag_set) {
4195 sa = actp->sa_sigaction;
4196 } else {
4197 hand = actp->sa_handler;
4198 }
4199
4200 if ((actp->sa_flags & SA_RESETHAND) != 0) {
4201 actp->sa_handler = SIG_DFL;
4202 }
4203
4204 // try to honor the signal mask
4205 sigset_t oset;
4206 pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
4207
4208 // call into the chained handler
4209 if (siginfo_flag_set) {
4210 (*sa)(sig, siginfo, context);
4211 } else {
4376 struct timespec tp;
4377 int rc = os::Linux::clock_gettime(clockid, &tp);
4378 assert(rc == 0, "clock_gettime is expected to return 0 code");
4379
4380 return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec;
4381 }
4382
4383 /////
4384 // glibc on Linux platform uses non-documented flag
4385 // to indicate, that some special sort of signal
4386 // trampoline is used.
4387 // We will never set this flag, and we should
4388 // ignore this flag in our diagnostic
4389 #ifdef SIGNIFICANT_SIGNAL_MASK
4390 #undef SIGNIFICANT_SIGNAL_MASK
4391 #endif
4392 #define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
4393
4394 static const char* get_signal_handler_name(address handler,
4395 char* buf, int buflen) {
4396 int offset;
4397 bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
4398 if (found) {
4399 // skip directory names
4400 const char *p1, *p2;
4401 p1 = buf;
4402 size_t len = strlen(os::file_separator());
4403 while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len;
4404 jio_snprintf(buf, buflen, "%s+0x%x", p1, offset);
4405 } else {
4406 jio_snprintf(buf, buflen, PTR_FORMAT, handler);
4407 }
4408 return buf;
4409 }
4410
4411 static void print_signal_handler(outputStream* st, int sig,
4412 char* buf, size_t buflen) {
4413 struct sigaction sa;
4414
4415 sigaction(sig, NULL, &sa);
4416
|
2777 }
2778
2779 size_t os::numa_get_leaf_groups(int *ids, size_t size) {
2780 for (size_t i = 0; i < size; i++) {
2781 ids[i] = i;
2782 }
2783 return size;
2784 }
2785
2786 bool os::get_page_info(char *start, page_info* info) {
2787 return false;
2788 }
2789
2790 char *os::scan_pages(char *start, char* end, page_info* page_expected,
2791 page_info* page_found) {
2792 return end;
2793 }
2794
2795
2796 int os::Linux::sched_getcpu_syscall(void) {
2797 unsigned int cpu = 0;
2798 int retval = -1;
2799
2800 #if defined(IA32)
2801 #ifndef SYS_getcpu
2802 #define SYS_getcpu 318
2803 #endif
2804 retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
2805 #elif defined(AMD64)
2806 // Unfortunately we have to bring all these macros here from vsyscall.h
2807 // to be able to compile on old linuxes.
2808 #define __NR_vgetcpu 2
2809 #define VSYSCALL_START (-10UL << 20)
2810 #define VSYSCALL_SIZE 1024
2811 #define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
2812 typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache);
2813 vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu);
2814 retval = vgetcpu(&cpu, NULL, NULL);
2815 #endif
2816
2817 return (retval == -1) ? retval : cpu;
4170 // Retrieve the preinstalled signal handler from jvm
4171 actp = get_preinstalled_handler(sig);
4172 }
4173
4174 return actp;
4175 }
4176
4177 static bool call_chained_handler(struct sigaction *actp, int sig,
4178 siginfo_t *siginfo, void *context) {
4179 // Call the old signal handler
4180 if (actp->sa_handler == SIG_DFL) {
4181 // It's more reasonable to let jvm treat it as an unexpected exception
4182 // instead of taking the default action.
4183 return false;
4184 } else if (actp->sa_handler != SIG_IGN) {
4185 if ((actp->sa_flags & SA_NODEFER) == 0) {
4186 // automaticlly block the signal
4187 sigaddset(&(actp->sa_mask), sig);
4188 }
4189
4190 sa_handler_t hand = NULL;
4191 sa_sigaction_t sa = NULL;
4192 bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0;
4193 // retrieve the chained handler
4194 if (siginfo_flag_set) {
4195 sa = actp->sa_sigaction;
4196 } else {
4197 hand = actp->sa_handler;
4198 }
4199
4200 if ((actp->sa_flags & SA_RESETHAND) != 0) {
4201 actp->sa_handler = SIG_DFL;
4202 }
4203
4204 // try to honor the signal mask
4205 sigset_t oset;
4206 pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
4207
4208 // call into the chained handler
4209 if (siginfo_flag_set) {
4210 (*sa)(sig, siginfo, context);
4211 } else {
4376 struct timespec tp;
4377 int rc = os::Linux::clock_gettime(clockid, &tp);
4378 assert(rc == 0, "clock_gettime is expected to return 0 code");
4379
4380 return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec;
4381 }
4382
4383 /////
4384 // glibc on Linux platform uses non-documented flag
4385 // to indicate, that some special sort of signal
4386 // trampoline is used.
4387 // We will never set this flag, and we should
4388 // ignore this flag in our diagnostic
4389 #ifdef SIGNIFICANT_SIGNAL_MASK
4390 #undef SIGNIFICANT_SIGNAL_MASK
4391 #endif
4392 #define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
4393
4394 static const char* get_signal_handler_name(address handler,
4395 char* buf, int buflen) {
4396 int offset = 0;
4397 bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
4398 if (found) {
4399 // skip directory names
4400 const char *p1, *p2;
4401 p1 = buf;
4402 size_t len = strlen(os::file_separator());
4403 while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len;
4404 jio_snprintf(buf, buflen, "%s+0x%x", p1, offset);
4405 } else {
4406 jio_snprintf(buf, buflen, PTR_FORMAT, handler);
4407 }
4408 return buf;
4409 }
4410
4411 static void print_signal_handler(outputStream* st, int sig,
4412 char* buf, size_t buflen) {
4413 struct sigaction sa;
4414
4415 sigaction(sig, NULL, &sa);
4416
|