1650 lib_arch.name, arch_array[running_arch_index].name); 1651 } else { 1652 ::snprintf(diag_msg_buf, diag_msg_max_length-1, 1653 " (Possible cause: can't load this .so (machine code=0x%x) on a %s-bit platform)", 1654 lib_arch.code, 1655 arch_array[running_arch_index].name); 1656 } 1657 } 1658 1659 return NULL; 1660 } 1661 1662 void* os::dll_lookup(void* handle, const char* name) { 1663 return dlsym(handle, name); 1664 } 1665 1666 void* os::get_default_process_handle() { 1667 return (void*)::dlopen(NULL, RTLD_LAZY); 1668 } 1669 1670 int os::stat(const char *path, struct stat *sbuf) { 1671 char pathbuf[MAX_PATH]; 1672 if (strlen(path) > MAX_PATH - 1) { 1673 errno = ENAMETOOLONG; 1674 return -1; 1675 } 1676 os::native_path(strcpy(pathbuf, path)); 1677 return ::stat(pathbuf, sbuf); 1678 } 1679 1680 static inline time_t get_mtime(const char* filename) { 1681 struct stat st; 1682 int ret = os::stat(filename, &st); 1683 assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno)); 1684 return st.st_mtime; 1685 } 1686 1687 int os::compare_file_modified_times(const char* file1, const char* file2) { 1688 time_t t1 = get_mtime(file1); 1689 time_t t2 = get_mtime(file2); 1690 return t1 - t2; 1691 } 1692 1693 static bool _print_ascii_file(const char* filename, outputStream* st) { 1694 int fd = ::open(filename, O_RDONLY); 1695 if (fd == -1) { 1696 return false; 1697 } 1698 1699 char buf[32]; 4455 int os::create_binary_file(const char* path, bool rewrite_existing) { 4456 int oflags = O_WRONLY | O_CREAT; 4457 if (!rewrite_existing) { 4458 oflags |= O_EXCL; 4459 } 4460 return ::open64(path, oflags, S_IREAD | S_IWRITE); 4461 } 4462 4463 // return current position of file pointer 4464 jlong os::current_file_offset(int fd) { 4465 return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR); 4466 } 4467 4468 // move file pointer to the specified offset 4469 jlong os::seek_to_file_offset(int fd, jlong offset) { 4470 return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET); 4471 } 4472 4473 jlong os::lseek(int fd, jlong offset, int whence) { 4474 return (jlong) ::lseek64(fd, offset, whence); 4475 } 4476 4477 char * os::native_path(char *path) { 4478 return path; 4479 } 4480 4481 int os::ftruncate(int fd, jlong length) { 4482 return ::ftruncate64(fd, length); 4483 } 4484 4485 int os::fsync(int fd) { 4486 RESTARTABLE_RETURN_INT(::fsync(fd)); 4487 } 4488 4489 int os::available(int fd, jlong *bytes) { 4490 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native, 4491 "Assumed _thread_in_native"); 4492 jlong cur, end; 4493 int mode; 4494 struct stat64 buf64; 4495 4496 if (::fstat64(fd, &buf64) >= 0) { 4497 mode = buf64.st_mode; 4498 if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { | 1650 lib_arch.name, arch_array[running_arch_index].name); 1651 } else { 1652 ::snprintf(diag_msg_buf, diag_msg_max_length-1, 1653 " (Possible cause: can't load this .so (machine code=0x%x) on a %s-bit platform)", 1654 lib_arch.code, 1655 arch_array[running_arch_index].name); 1656 } 1657 } 1658 1659 return NULL; 1660 } 1661 1662 void* os::dll_lookup(void* handle, const char* name) { 1663 return dlsym(handle, name); 1664 } 1665 1666 void* os::get_default_process_handle() { 1667 return (void*)::dlopen(NULL, RTLD_LAZY); 1668 } 1669 1670 static inline time_t get_mtime(const char* filename) { 1671 struct stat st; 1672 int ret = os::stat(filename, &st); 1673 assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno)); 1674 return st.st_mtime; 1675 } 1676 1677 int os::compare_file_modified_times(const char* file1, const char* file2) { 1678 time_t t1 = get_mtime(file1); 1679 time_t t2 = get_mtime(file2); 1680 return t1 - t2; 1681 } 1682 1683 static bool _print_ascii_file(const char* filename, outputStream* st) { 1684 int fd = ::open(filename, O_RDONLY); 1685 if (fd == -1) { 1686 return false; 1687 } 1688 1689 char buf[32]; 4445 int os::create_binary_file(const char* path, bool rewrite_existing) { 4446 int oflags = O_WRONLY | O_CREAT; 4447 if (!rewrite_existing) { 4448 oflags |= O_EXCL; 4449 } 4450 return ::open64(path, oflags, S_IREAD | S_IWRITE); 4451 } 4452 4453 // return current position of file pointer 4454 jlong os::current_file_offset(int fd) { 4455 return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR); 4456 } 4457 4458 // move file pointer to the specified offset 4459 jlong os::seek_to_file_offset(int fd, jlong offset) { 4460 return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET); 4461 } 4462 4463 jlong os::lseek(int fd, jlong offset, int whence) { 4464 return (jlong) ::lseek64(fd, offset, whence); 4465 } 4466 4467 int os::ftruncate(int fd, jlong length) { 4468 return ::ftruncate64(fd, length); 4469 } 4470 4471 int os::fsync(int fd) { 4472 RESTARTABLE_RETURN_INT(::fsync(fd)); 4473 } 4474 4475 int os::available(int fd, jlong *bytes) { 4476 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native, 4477 "Assumed _thread_in_native"); 4478 jlong cur, end; 4479 int mode; 4480 struct stat64 buf64; 4481 4482 if (::fstat64(fd, &buf64) >= 0) { 4483 mode = buf64.st_mode; 4484 if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { |