Mercurial > hg > graal-compiler
comparison src/os/aix/vm/os_aix.cpp @ 17793:c668f307a4c0
8031319: PPC64: Some fixes in ppc and aix coding.
Reviewed-by: kvn
author | goetz |
---|---|
date | Tue, 07 Jan 2014 17:24:59 +0100 |
parents | 3068270ba476 |
children | a13badbb8b8e 9200402b42d5 |
comparison
equal
deleted
inserted
replaced
17792:4345c6a92f35 | 17793:c668f307a4c0 |
---|---|
1150 // Return the real, user, and system times in seconds from an | 1150 // Return the real, user, and system times in seconds from an |
1151 // arbitrary fixed point in the past. | 1151 // arbitrary fixed point in the past. |
1152 bool os::getTimesSecs(double* process_real_time, | 1152 bool os::getTimesSecs(double* process_real_time, |
1153 double* process_user_time, | 1153 double* process_user_time, |
1154 double* process_system_time) { | 1154 double* process_system_time) { |
1155 Unimplemented(); | 1155 struct tms ticks; |
1156 return false; | 1156 clock_t real_ticks = times(&ticks); |
1157 | |
1158 if (real_ticks == (clock_t) (-1)) { | |
1159 return false; | |
1160 } else { | |
1161 double ticks_per_second = (double) clock_tics_per_sec; | |
1162 *process_user_time = ((double) ticks.tms_utime) / ticks_per_second; | |
1163 *process_system_time = ((double) ticks.tms_stime) / ticks_per_second; | |
1164 *process_real_time = ((double) real_ticks) / ticks_per_second; | |
1165 | |
1166 return true; | |
1167 } | |
1157 } | 1168 } |
1158 | 1169 |
1159 | 1170 |
1160 char * os::local_time_string(char *buf, size_t buflen) { | 1171 char * os::local_time_string(char *buf, size_t buflen) { |
1161 struct tm t; | 1172 struct tm t; |
2438 } | 2449 } |
2439 | 2450 |
2440 // trace | 2451 // trace |
2441 if (Verbose && !addr) { | 2452 if (Verbose && !addr) { |
2442 if (requested_addr != NULL) { | 2453 if (requested_addr != NULL) { |
2443 warning("failed to shm-allocate 0x%llX bytes at with address 0x%p.", size, requested_addr); | 2454 warning("failed to shm-allocate 0x%llX bytes at wish address 0x%p.", size, requested_addr); |
2444 } else { | 2455 } else { |
2445 warning("failed to shm-allocate 0x%llX bytes at any address.", size); | 2456 warning("failed to shm-allocate 0x%llX bytes at any address.", size); |
2446 } | 2457 } |
2447 } | 2458 } |
2448 | 2459 |
2519 shmbk_register(p_block); | 2530 shmbk_register(p_block); |
2520 UNLOCK_SHMBK | 2531 UNLOCK_SHMBK |
2521 | 2532 |
2522 cleanup_mmap: | 2533 cleanup_mmap: |
2523 | 2534 |
2524 if (addr) { | 2535 // trace |
2525 if (Verbose) { | 2536 if (Verbose) { |
2537 if (addr) { | |
2526 fprintf(stderr, "mmap-allocated 0x%p .. 0x%p (0x%llX bytes)\n", addr, addr + bytes, bytes); | 2538 fprintf(stderr, "mmap-allocated 0x%p .. 0x%p (0x%llX bytes)\n", addr, addr + bytes, bytes); |
2527 } | 2539 } |
2528 } | 2540 else { |
2529 else { | 2541 if (requested_addr != NULL) { |
2530 if (requested_addr != NULL) { | 2542 warning("failed to mmap-allocate 0x%llX bytes at wish address 0x%p.", bytes, requested_addr); |
2531 warning("failed to mmap-allocate 0x%llX bytes at wish address 0x%p.", bytes, requested_addr); | 2543 } else { |
2532 } else { | 2544 warning("failed to mmap-allocate 0x%llX bytes at any address.", bytes); |
2533 warning("failed to mmap-allocate 0x%llX bytes at any address.", bytes); | 2545 } |
2534 } | 2546 } |
2535 } | 2547 } |
2536 | 2548 |
2537 return addr; | 2549 return addr; |
2538 | 2550 |
3357 return actp; | 3369 return actp; |
3358 } | 3370 } |
3359 | 3371 |
3360 static bool call_chained_handler(struct sigaction *actp, int sig, | 3372 static bool call_chained_handler(struct sigaction *actp, int sig, |
3361 siginfo_t *siginfo, void *context) { | 3373 siginfo_t *siginfo, void *context) { |
3362 Unimplemented(); | 3374 // Call the old signal handler |
3375 if (actp->sa_handler == SIG_DFL) { | |
3376 // It's more reasonable to let jvm treat it as an unexpected exception | |
3377 // instead of taking the default action. | |
3378 return false; | |
3379 } else if (actp->sa_handler != SIG_IGN) { | |
3380 if ((actp->sa_flags & SA_NODEFER) == 0) { | |
3381 // automaticlly block the signal | |
3382 sigaddset(&(actp->sa_mask), sig); | |
3383 } | |
3384 | |
3385 sa_handler_t hand = NULL; | |
3386 sa_sigaction_t sa = NULL; | |
3387 bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0; | |
3388 // retrieve the chained handler | |
3389 if (siginfo_flag_set) { | |
3390 sa = actp->sa_sigaction; | |
3391 } else { | |
3392 hand = actp->sa_handler; | |
3393 } | |
3394 | |
3395 if ((actp->sa_flags & SA_RESETHAND) != 0) { | |
3396 actp->sa_handler = SIG_DFL; | |
3397 } | |
3398 | |
3399 // try to honor the signal mask | |
3400 sigset_t oset; | |
3401 pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset); | |
3402 | |
3403 // call into the chained handler | |
3404 if (siginfo_flag_set) { | |
3405 (*sa)(sig, siginfo, context); | |
3406 } else { | |
3407 (*hand)(sig); | |
3408 } | |
3409 | |
3410 // restore the signal mask | |
3411 pthread_sigmask(SIG_SETMASK, &oset, 0); | |
3412 } | |
3413 // Tell jvm's signal handler the signal is taken care of. | |
3363 return true; | 3414 return true; |
3364 } | 3415 } |
3365 | 3416 |
3366 bool os::Aix::chained_handler(int sig, siginfo_t* siginfo, void* context) { | 3417 bool os::Aix::chained_handler(int sig, siginfo_t* siginfo, void* context) { |
3367 bool chained = false; | 3418 bool chained = false; |
4039 else | 4090 else |
4040 return (address)(intptr_t(y) & page_bits); | 4091 return (address)(intptr_t(y) & page_bits); |
4041 } | 4092 } |
4042 | 4093 |
4043 bool os::find(address addr, outputStream* st) { | 4094 bool os::find(address addr, outputStream* st) { |
4044 Unimplemented(); | 4095 |
4096 st->print(PTR_FORMAT ": ", addr); | |
4097 | |
4098 const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(addr); | |
4099 if (lib) { | |
4100 lib->print(st); | |
4101 return true; | |
4102 } else { | |
4103 lib = LoadedLibraries::find_for_data_address(addr); | |
4104 if (lib) { | |
4105 lib->print(st); | |
4106 return true; | |
4107 } else { | |
4108 st->print_cr("(outside any module)"); | |
4109 } | |
4110 } | |
4111 | |
4045 return false; | 4112 return false; |
4046 } | 4113 } |
4047 | 4114 |
4048 //////////////////////////////////////////////////////////////////////////////// | 4115 //////////////////////////////////////////////////////////////////////////////// |
4049 // misc | 4116 // misc |
4097 // return ::vsnprintf(buf, count, format, args); | 4164 // return ::vsnprintf(buf, count, format, args); |
4098 // } | 4165 // } |
4099 | 4166 |
4100 // Is a (classpath) directory empty? | 4167 // Is a (classpath) directory empty? |
4101 bool os::dir_is_empty(const char* path) { | 4168 bool os::dir_is_empty(const char* path) { |
4102 Unimplemented(); | 4169 DIR *dir = NULL; |
4103 return false; | 4170 struct dirent *ptr; |
4171 | |
4172 dir = opendir(path); | |
4173 if (dir == NULL) return true; | |
4174 | |
4175 /* Scan the directory */ | |
4176 bool result = true; | |
4177 char buf[sizeof(struct dirent) + MAX_PATH]; | |
4178 while (result && (ptr = ::readdir(dir)) != NULL) { | |
4179 if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) { | |
4180 result = false; | |
4181 } | |
4182 } | |
4183 closedir(dir); | |
4184 return result; | |
4104 } | 4185 } |
4105 | 4186 |
4106 // This code originates from JDK's sysOpen and open64_w | 4187 // This code originates from JDK's sysOpen and open64_w |
4107 // from src/solaris/hpi/src/system_md.c | 4188 // from src/solaris/hpi/src/system_md.c |
4108 | 4189 |
4125 oflag = oflag & ~O_DELETE; | 4206 oflag = oflag & ~O_DELETE; |
4126 | 4207 |
4127 fd = ::open64(path, oflag, mode); | 4208 fd = ::open64(path, oflag, mode); |
4128 if (fd == -1) return -1; | 4209 if (fd == -1) return -1; |
4129 | 4210 |
4130 //If the open succeeded, the file might still be a directory | 4211 // If the open succeeded, the file might still be a directory. |
4131 { | 4212 { |
4132 struct stat64 buf64; | 4213 struct stat64 buf64; |
4133 int ret = ::fstat64(fd, &buf64); | 4214 int ret = ::fstat64(fd, &buf64); |
4134 int st_mode = buf64.st_mode; | 4215 int st_mode = buf64.st_mode; |
4135 | 4216 |
4180 } | 4261 } |
4181 | 4262 |
4182 | 4263 |
4183 // create binary file, rewriting existing file if required | 4264 // create binary file, rewriting existing file if required |
4184 int os::create_binary_file(const char* path, bool rewrite_existing) { | 4265 int os::create_binary_file(const char* path, bool rewrite_existing) { |
4185 Unimplemented(); | 4266 int oflags = O_WRONLY | O_CREAT; |
4186 return 0; | 4267 if (!rewrite_existing) { |
4268 oflags |= O_EXCL; | |
4269 } | |
4270 return ::open64(path, oflags, S_IREAD | S_IWRITE); | |
4187 } | 4271 } |
4188 | 4272 |
4189 // return current position of file pointer | 4273 // return current position of file pointer |
4190 jlong os::current_file_offset(int fd) { | 4274 jlong os::current_file_offset(int fd) { |
4191 return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR); | 4275 return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR); |