1584 void * result= ::dlopen(filename, RTLD_LAZY);
1585 if (result != NULL) {
1586 // Successful loading
1587 return result;
1588 }
1589
1590 Elf32_Ehdr elf_head;
1591
1592 // Read system error message into ebuf
1593 // It may or may not be overwritten below
1594 ::strncpy(ebuf, ::dlerror(), ebuflen-1);
1595 ebuf[ebuflen-1]='\0';
1596 int diag_msg_max_length=ebuflen-strlen(ebuf);
1597 char* diag_msg_buf=ebuf+strlen(ebuf);
1598
1599 if (diag_msg_max_length==0) {
1600 // No more space in ebuf for additional diagnostics message
1601 return NULL;
1602 }
1603
1604
1605 int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK);
1606
1607 if (file_descriptor < 0) {
1608 // Can't open library, report dlerror() message
1609 return NULL;
1610 }
1611
1612 bool failed_to_read_elf_head=
1613 (sizeof(elf_head)!=
1614 (::read(file_descriptor, &elf_head,sizeof(elf_head))));
1615
1616 ::close(file_descriptor);
1617 if (failed_to_read_elf_head) {
1618 // file i/o error - report dlerror() msg
1619 return NULL;
1620 }
1621
1622 typedef struct {
1623 Elf32_Half code; // Actual value as defined in elf.h
1624 Elf32_Half compat_class; // Compatibility of archs at VM's sense
1625 char elf_class; // 32 or 64 bit
1626 char endianess; // MSB or LSB
1627 char* name; // String representation
1628 } arch_t;
1629
1630 static const arch_t arch_array[]={
1631 {EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
1632 {EM_486, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
1633 {EM_IA_64, EM_IA_64, ELFCLASS64, ELFDATA2LSB, (char*)"IA 64"},
1634 {EM_X86_64, EM_X86_64, ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"},
1809 }
1810
1811 void os::Solaris::print_libversion_info(outputStream* st) {
1812 st->print(" (T2 libthread)");
1813 st->cr();
1814 }
1815
1816 static bool check_addr0(outputStream* st) {
1817 jboolean status = false;
1818 const int read_chunk = 200;
1819 int ret = 0;
1820 int nmap = 0;
1821 int fd = ::open("/proc/self/map",O_RDONLY);
1822 if (fd >= 0) {
1823 prmap_t *p = NULL;
1824 char *mbuff = (char *) calloc(read_chunk, sizeof(prmap_t));
1825 if (NULL == mbuff) {
1826 ::close(fd);
1827 return status;
1828 }
1829 while ((ret = ::read(fd, mbuff, read_chunk*sizeof(prmap_t))) > 0) {
1830 //check if read() has not read partial data
1831 if( 0 != ret % sizeof(prmap_t)){
1832 break;
1833 }
1834 nmap = ret / sizeof(prmap_t);
1835 p = (prmap_t *)mbuff;
1836 for(int i = 0; i < nmap; i++){
1837 if (p->pr_vaddr == 0x0) {
1838 st->print("Warning: Address: " PTR_FORMAT ", Size: " SIZE_FORMAT "K, ",p->pr_vaddr, p->pr_size/1024);
1839 st->print("Mapped file: %s, ", p->pr_mapname[0] == '\0' ? "None" : p->pr_mapname);
1840 st->print("Access: ");
1841 st->print("%s",(p->pr_mflags & MA_READ) ? "r" : "-");
1842 st->print("%s",(p->pr_mflags & MA_WRITE) ? "w" : "-");
1843 st->print("%s",(p->pr_mflags & MA_EXEC) ? "x" : "-");
1844 st->cr();
1845 status = true;
1846 }
1847 p++;
1848 }
1849 }
2929 bool os::release_memory_special(char* base, size_t bytes) {
2930 fatal("os::release_memory_special should not be called on Solaris.");
2931 return false;
2932 }
2933
2934 size_t os::large_page_size() {
2935 return _large_page_size;
2936 }
2937
2938 // MPSS allows application to commit large page memory on demand; with ISM
2939 // the entire memory region must be allocated as shared memory.
2940 bool os::can_commit_large_page_memory() {
2941 return true;
2942 }
2943
2944 bool os::can_execute_large_page_memory() {
2945 return true;
2946 }
2947
2948 // Read calls from inside the vm need to perform state transitions
2949 size_t os::read(int fd, void *buf, unsigned int nBytes) {
2950 size_t res;
2951 JavaThread* thread = (JavaThread*)Thread::current();
2952 assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
2953 ThreadBlockInVM tbiv(thread);
2954 RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
2955 return res;
2956 }
2957
2958 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
2959 size_t res;
2960 JavaThread* thread = (JavaThread*)Thread::current();
2961 assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
2962 ThreadBlockInVM tbiv(thread);
2963 RESTARTABLE(::pread(fd, buf, (size_t) nBytes, offset), res);
2964 return res;
2965 }
2966
2967 size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
2968 size_t res;
2969 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
2970 "Assumed _thread_in_native");
2971 RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
2972 return res;
2973 }
2974
2975 void os::naked_short_sleep(jlong ms) {
2976 assert(ms < 1000, "Un-interruptable sleep, short time use only");
2977
2978 // usleep is deprecated and removed from POSIX, in favour of nanosleep, but
2979 // Solaris requires -lrt for this.
2980 usleep((ms * 1000));
2981
2982 return;
2983 }
2984
2985 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
2986 void os::infinite_sleep() {
2987 while (true) { // sleep forever ...
2988 ::sleep(100); // ... 100 seconds at a time
2989 }
2990 }
2991
2992 // Used to convert frequent JVM_Yield() to nops
2993 bool os::dont_yield() {
2994 if (DontYieldALot) {
5473
5474 // Get rid of client or server
5475 p = strrchr(buf, '/');
5476 if (p == NULL) {
5477 return false;
5478 } else {
5479 *p = '\0';
5480 }
5481
5482 // check xawt/libmawt.so
5483 strcpy(libmawtpath, buf);
5484 strcat(libmawtpath, xawtstr);
5485 if (::stat(libmawtpath, &statbuf) == 0) return false;
5486
5487 // check libawt_xawt.so
5488 strcpy(libmawtpath, buf);
5489 strcat(libmawtpath, new_xawtstr);
5490 if (::stat(libmawtpath, &statbuf) == 0) return false;
5491
5492 return true;
5493 }
5494
5495 size_t os::write(int fd, const void *buf, unsigned int nBytes) {
5496 size_t res;
5497 RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
5498 return res;
5499 }
5500
5501 int os::close(int fd) {
5502 return ::close(fd);
5503 }
5504
5505 int os::socket_close(int fd) {
5506 return ::close(fd);
5507 }
5508
5509 int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
5510 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
5511 "Assumed _thread_in_native");
5512 RESTARTABLE_RETURN_INT((int)::recv(fd, buf, nBytes, flags));
5513 }
5514
5515 int os::send(int fd, char* buf, size_t nBytes, uint flags) {
5516 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
5517 "Assumed _thread_in_native");
5518 RESTARTABLE_RETURN_INT((int)::send(fd, buf, nBytes, flags));
|
1584 void * result= ::dlopen(filename, RTLD_LAZY);
1585 if (result != NULL) {
1586 // Successful loading
1587 return result;
1588 }
1589
1590 Elf32_Ehdr elf_head;
1591
1592 // Read system error message into ebuf
1593 // It may or may not be overwritten below
1594 ::strncpy(ebuf, ::dlerror(), ebuflen-1);
1595 ebuf[ebuflen-1]='\0';
1596 int diag_msg_max_length=ebuflen-strlen(ebuf);
1597 char* diag_msg_buf=ebuf+strlen(ebuf);
1598
1599 if (diag_msg_max_length==0) {
1600 // No more space in ebuf for additional diagnostics message
1601 return NULL;
1602 }
1603
1604 int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK);
1605
1606 if (file_descriptor < 0) {
1607 // Can't open library, report dlerror() message
1608 return NULL;
1609 }
1610
1611 bool failed_to_read_elf_head=
1612 (sizeof(elf_head) !=
1613 (::read(file_descriptor, &elf_head, sizeof(elf_head))));
1614
1615 ::close(file_descriptor);
1616 if (failed_to_read_elf_head) {
1617 // file i/o error - report dlerror() msg
1618 return NULL;
1619 }
1620
1621 typedef struct {
1622 Elf32_Half code; // Actual value as defined in elf.h
1623 Elf32_Half compat_class; // Compatibility of archs at VM's sense
1624 char elf_class; // 32 or 64 bit
1625 char endianess; // MSB or LSB
1626 char* name; // String representation
1627 } arch_t;
1628
1629 static const arch_t arch_array[]={
1630 {EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
1631 {EM_486, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
1632 {EM_IA_64, EM_IA_64, ELFCLASS64, ELFDATA2LSB, (char*)"IA 64"},
1633 {EM_X86_64, EM_X86_64, ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"},
1808 }
1809
1810 void os::Solaris::print_libversion_info(outputStream* st) {
1811 st->print(" (T2 libthread)");
1812 st->cr();
1813 }
1814
1815 static bool check_addr0(outputStream* st) {
1816 jboolean status = false;
1817 const int read_chunk = 200;
1818 int ret = 0;
1819 int nmap = 0;
1820 int fd = ::open("/proc/self/map",O_RDONLY);
1821 if (fd >= 0) {
1822 prmap_t *p = NULL;
1823 char *mbuff = (char *) calloc(read_chunk, sizeof(prmap_t));
1824 if (NULL == mbuff) {
1825 ::close(fd);
1826 return status;
1827 }
1828 while ((ret = ::read(fd, mbuff, read_chunk * sizeof(prmap_t))) > 0) {
1829 //check if read() has not read partial data
1830 if( 0 != ret % sizeof(prmap_t)){
1831 break;
1832 }
1833 nmap = ret / sizeof(prmap_t);
1834 p = (prmap_t *)mbuff;
1835 for(int i = 0; i < nmap; i++){
1836 if (p->pr_vaddr == 0x0) {
1837 st->print("Warning: Address: " PTR_FORMAT ", Size: " SIZE_FORMAT "K, ",p->pr_vaddr, p->pr_size/1024);
1838 st->print("Mapped file: %s, ", p->pr_mapname[0] == '\0' ? "None" : p->pr_mapname);
1839 st->print("Access: ");
1840 st->print("%s",(p->pr_mflags & MA_READ) ? "r" : "-");
1841 st->print("%s",(p->pr_mflags & MA_WRITE) ? "w" : "-");
1842 st->print("%s",(p->pr_mflags & MA_EXEC) ? "x" : "-");
1843 st->cr();
1844 status = true;
1845 }
1846 p++;
1847 }
1848 }
2928 bool os::release_memory_special(char* base, size_t bytes) {
2929 fatal("os::release_memory_special should not be called on Solaris.");
2930 return false;
2931 }
2932
2933 size_t os::large_page_size() {
2934 return _large_page_size;
2935 }
2936
2937 // MPSS allows application to commit large page memory on demand; with ISM
2938 // the entire memory region must be allocated as shared memory.
2939 bool os::can_commit_large_page_memory() {
2940 return true;
2941 }
2942
2943 bool os::can_execute_large_page_memory() {
2944 return true;
2945 }
2946
2947 // Read calls from inside the vm need to perform state transitions
2948 ssize_t os::read(int fd, void *buf, unsigned int nBytes) {
2949 ssize_t res;
2950 JavaThread* thread = (JavaThread*)Thread::current();
2951 assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
2952 ThreadBlockInVM tbiv(thread);
2953 RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
2954 return res;
2955 }
2956
2957 ssize_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
2958 ssize_t res;
2959 JavaThread* thread = (JavaThread*)Thread::current();
2960 assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
2961 ThreadBlockInVM tbiv(thread);
2962 RESTARTABLE(::pread(fd, buf, (size_t) nBytes, offset), res);
2963 return res;
2964 }
2965
2966 ssize_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
2967 ssize_t res;
2968 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
2969 "Assumed _thread_in_native");
2970 RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
2971 return res;
2972 }
2973
2974 ssize_t os::write(int fd, const void *buf, unsigned int nBytes) {
2975 ssize_t res;
2976 RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
2977 return res;
2978 }
2979
2980 void os::naked_short_sleep(jlong ms) {
2981 assert(ms < 1000, "Un-interruptable sleep, short time use only");
2982
2983 // usleep is deprecated and removed from POSIX, in favour of nanosleep, but
2984 // Solaris requires -lrt for this.
2985 usleep((ms * 1000));
2986
2987 return;
2988 }
2989
2990 // Sleep forever; naked call to OS-specific sleep; use with CAUTION
2991 void os::infinite_sleep() {
2992 while (true) { // sleep forever ...
2993 ::sleep(100); // ... 100 seconds at a time
2994 }
2995 }
2996
2997 // Used to convert frequent JVM_Yield() to nops
2998 bool os::dont_yield() {
2999 if (DontYieldALot) {
5478
5479 // Get rid of client or server
5480 p = strrchr(buf, '/');
5481 if (p == NULL) {
5482 return false;
5483 } else {
5484 *p = '\0';
5485 }
5486
5487 // check xawt/libmawt.so
5488 strcpy(libmawtpath, buf);
5489 strcat(libmawtpath, xawtstr);
5490 if (::stat(libmawtpath, &statbuf) == 0) return false;
5491
5492 // check libawt_xawt.so
5493 strcpy(libmawtpath, buf);
5494 strcat(libmawtpath, new_xawtstr);
5495 if (::stat(libmawtpath, &statbuf) == 0) return false;
5496
5497 return true;
5498 }
5499
5500 int os::close(int fd) {
5501 return ::close(fd);
5502 }
5503
5504 int os::socket_close(int fd) {
5505 return ::close(fd);
5506 }
5507
5508 int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
5509 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
5510 "Assumed _thread_in_native");
5511 RESTARTABLE_RETURN_INT((int)::recv(fd, buf, nBytes, flags));
5512 }
5513
5514 int os::send(int fd, char* buf, size_t nBytes, uint flags) {
5515 assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
5516 "Assumed _thread_in_native");
5517 RESTARTABLE_RETURN_INT((int)::send(fd, buf, nBytes, flags));
|