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