< prev index next >

src/os/bsd/vm/os_bsd.cpp

Print this page




1673 
1674   while (map->l_prev != NULL)
1675     map = map->l_prev;
1676 
1677   while (map != NULL) {
1678     st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name);
1679     map = map->l_next;
1680   }
1681 
1682   dlclose(handle);
1683 #elif defined(__APPLE__)
1684   for (uint32_t i = 1; i < _dyld_image_count(); i++) {
1685     st->print_cr(PTR_FORMAT " \t%s", _dyld_get_image_header(i),
1686         _dyld_get_image_name(i));
1687   }
1688 #else
1689   st->print_cr("Error: Cannot print dynamic libraries.");
1690 #endif
1691 }
1692 















































1693 void os::print_os_info_brief(outputStream* st) {
1694   st->print("Bsd");
1695 
1696   os::Posix::print_uname_info(st);
1697 }
1698 
1699 void os::print_os_info(outputStream* st) {
1700   st->print("OS:");
1701   st->print("Bsd");
1702 
1703   os::Posix::print_uname_info(st);
1704 
1705   os::Posix::print_rlimit_info(st);
1706 
1707   os::Posix::print_load_average(st);
1708 }
1709 
1710 void os::pd_print_cpu_info(outputStream* st) {
1711   // Nothing to do for now.
1712 }


2545 
2546   for (int j = 0; j < i; ++j) {
2547     if (base[j] != NULL) {
2548       unmap_memory(base[j], size[j]);
2549     }
2550   }
2551 
2552   if (i < max_tries) {
2553     _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
2554     return requested_addr;
2555   } else {
2556     _highest_vm_reserved_address = old_highest;
2557     return NULL;
2558   }
2559 }
2560 
2561 size_t os::read(int fd, void *buf, unsigned int nBytes) {
2562   RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
2563 }
2564 




2565 // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation.
2566 // Solaris uses poll(), bsd uses park().
2567 // Poll() is likely a better choice, assuming that Thread.interrupt()
2568 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
2569 // SIGSEGV, see 4355769.
2570 
2571 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
2572   assert(thread == Thread::current(),  "thread consistency check");
2573 
2574   ParkEvent * const slp = thread->_SleepEvent ;
2575   slp->reset() ;
2576   OrderAccess::fence() ;
2577 
2578   if (interruptible) {
2579     jlong prevtime = javaTimeNanos();
2580 
2581     for (;;) {
2582       if (os::is_interrupted(thread, true)) {
2583         return OS_INTRPT;
2584       }


3940 
3941 bool os::check_heap(bool force) {
3942   return true;
3943 }
3944 
3945 ATTRIBUTE_PRINTF(3, 0)
3946 int local_vsnprintf(char* buf, size_t count, const char* format, va_list args) {
3947   return ::vsnprintf(buf, count, format, args);
3948 }
3949 
3950 // Is a (classpath) directory empty?
3951 bool os::dir_is_empty(const char* path) {
3952   DIR *dir = NULL;
3953   struct dirent *ptr;
3954 
3955   dir = opendir(path);
3956   if (dir == NULL) return true;
3957 
3958   /* Scan the directory */
3959   bool result = true;
3960   char buf[sizeof(struct dirent) + MAX_PATH];
3961   while (result && (ptr = ::readdir(dir)) != NULL) {
3962     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
3963       result = false;
3964     }
3965   }
3966   closedir(dir);
3967   return result;
3968 }
3969 
3970 // This code originates from JDK's sysOpen and open64_w
3971 // from src/solaris/hpi/src/system_md.c
3972 
3973 #ifndef O_DELETE
3974 #define O_DELETE 0x10000
3975 #endif
3976 
3977 // Open a file. Unlink the file immediately after open returns
3978 // if the specified oflag has the O_DELETE flag set.
3979 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
3980 
3981 int os::open(const char *path, int oflag, int mode) {




1673 
1674   while (map->l_prev != NULL)
1675     map = map->l_prev;
1676 
1677   while (map != NULL) {
1678     st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name);
1679     map = map->l_next;
1680   }
1681 
1682   dlclose(handle);
1683 #elif defined(__APPLE__)
1684   for (uint32_t i = 1; i < _dyld_image_count(); i++) {
1685     st->print_cr(PTR_FORMAT " \t%s", _dyld_get_image_header(i),
1686         _dyld_get_image_name(i));
1687   }
1688 #else
1689   st->print_cr("Error: Cannot print dynamic libraries.");
1690 #endif
1691 }
1692 
1693 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
1694 #ifdef RTLD_DI_LINKMAP
1695   Dl_info dli;
1696   void *handle;
1697   Link_map *map;
1698   Link_map *p;
1699 
1700   if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 ||
1701       dli.dli_fname == NULL) {
1702     return 1;
1703   }
1704   handle = dlopen(dli.dli_fname, RTLD_LAZY);
1705   if (handle == NULL) {
1706     return 1;
1707   }
1708   dlinfo(handle, RTLD_DI_LINKMAP, &map);
1709   if (map == NULL) {
1710     dlclose(handle);
1711     return 1;
1712   }
1713 
1714   while (map->l_prev != NULL)
1715     map = map->l_prev;
1716 
1717   while (map != NULL) {
1718     // Value for top_address is returned as 0 since we don't have any information about module size
1719     if (callback(map->l_name, (address)map->l_addr, (address)0, param)) {
1720       dlclose(handle);
1721       return 1;
1722     }
1723     map = map->l_next;
1724   }
1725 
1726   dlclose(handle);
1727 #elif defined(__APPLE__)
1728   for (uint32_t i = 1; i < _dyld_image_count(); i++) {
1729     // Value for top_address is returned as 0 since we don't have any information about module size
1730     if (callback(_dyld_get_image_name(i), (address)_dyld_get_image_header(i), (address)0, param)) {
1731       return 1;
1732     }
1733   }
1734   return 0;
1735 #else
1736   return 1;
1737 #endif
1738 }
1739 
1740 void os::print_os_info_brief(outputStream* st) {
1741   st->print("Bsd");
1742 
1743   os::Posix::print_uname_info(st);
1744 }
1745 
1746 void os::print_os_info(outputStream* st) {
1747   st->print("OS:");
1748   st->print("Bsd");
1749 
1750   os::Posix::print_uname_info(st);
1751 
1752   os::Posix::print_rlimit_info(st);
1753 
1754   os::Posix::print_load_average(st);
1755 }
1756 
1757 void os::pd_print_cpu_info(outputStream* st) {
1758   // Nothing to do for now.
1759 }


2592 
2593   for (int j = 0; j < i; ++j) {
2594     if (base[j] != NULL) {
2595       unmap_memory(base[j], size[j]);
2596     }
2597   }
2598 
2599   if (i < max_tries) {
2600     _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
2601     return requested_addr;
2602   } else {
2603     _highest_vm_reserved_address = old_highest;
2604     return NULL;
2605   }
2606 }
2607 
2608 size_t os::read(int fd, void *buf, unsigned int nBytes) {
2609   RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
2610 }
2611 
2612 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
2613   RESTARTABLE_RETURN_INT(::pread(fd, buf, nBytes, offset));
2614 }
2615 
2616 // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation.
2617 // Solaris uses poll(), bsd uses park().
2618 // Poll() is likely a better choice, assuming that Thread.interrupt()
2619 // generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
2620 // SIGSEGV, see 4355769.
2621 
2622 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
2623   assert(thread == Thread::current(),  "thread consistency check");
2624 
2625   ParkEvent * const slp = thread->_SleepEvent ;
2626   slp->reset() ;
2627   OrderAccess::fence() ;
2628 
2629   if (interruptible) {
2630     jlong prevtime = javaTimeNanos();
2631 
2632     for (;;) {
2633       if (os::is_interrupted(thread, true)) {
2634         return OS_INTRPT;
2635       }


3991 
3992 bool os::check_heap(bool force) {
3993   return true;
3994 }
3995 
3996 ATTRIBUTE_PRINTF(3, 0)
3997 int local_vsnprintf(char* buf, size_t count, const char* format, va_list args) {
3998   return ::vsnprintf(buf, count, format, args);
3999 }
4000 
4001 // Is a (classpath) directory empty?
4002 bool os::dir_is_empty(const char* path) {
4003   DIR *dir = NULL;
4004   struct dirent *ptr;
4005 
4006   dir = opendir(path);
4007   if (dir == NULL) return true;
4008 
4009   /* Scan the directory */
4010   bool result = true;
4011   while (result && (ptr = readdir(dir)) != NULL) {

4012     if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
4013       result = false;
4014     }
4015   }
4016   closedir(dir);
4017   return result;
4018 }
4019 
4020 // This code originates from JDK's sysOpen and open64_w
4021 // from src/solaris/hpi/src/system_md.c
4022 
4023 #ifndef O_DELETE
4024 #define O_DELETE 0x10000
4025 #endif
4026 
4027 // Open a file. Unlink the file immediately after open returns
4028 // if the specified oflag has the O_DELETE flag set.
4029 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
4030 
4031 int os::open(const char *path, int oflag, int mode) {


< prev index next >