< prev index next >

src/os/solaris/vm/os_solaris.cpp

Print this page
rev 13166 : read/write APIs in class os shall return ssize_t

@@ -1599,21 +1599,20 @@
   if (diag_msg_max_length==0) {
     // No more space in ebuf for additional diagnostics message
     return NULL;
   }
 
-
   int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK);
 
   if (file_descriptor < 0) {
     // Can't open library, report dlerror() message
     return NULL;
   }
 
   bool failed_to_read_elf_head=
-    (sizeof(elf_head)!=
-     (::read(file_descriptor, &elf_head,sizeof(elf_head))));
+    (sizeof(elf_head) !=
+     (::read(file_descriptor, &elf_head, sizeof(elf_head))));
 
   ::close(file_descriptor);
   if (failed_to_read_elf_head) {
     // file i/o error - report dlerror() msg
     return NULL;

@@ -1824,11 +1823,11 @@
     char *mbuff = (char *) calloc(read_chunk, sizeof(prmap_t));
     if (NULL == mbuff) {
       ::close(fd);
       return status;
     }
-    while ((ret = ::read(fd, mbuff, read_chunk*sizeof(prmap_t))) > 0) {
+    while ((ret = ::read(fd, mbuff, read_chunk * sizeof(prmap_t))) > 0) {
       //check if read() has not read partial data
       if( 0 != ret % sizeof(prmap_t)){
         break;
       }
       nmap = ret / sizeof(prmap_t);

@@ -2944,36 +2943,42 @@
 bool os::can_execute_large_page_memory() {
   return true;
 }
 
 // Read calls from inside the vm need to perform state transitions
-size_t os::read(int fd, void *buf, unsigned int nBytes) {
-  size_t res;
+ssize_t os::read(int fd, void *buf, unsigned int nBytes) {
+  ssize_t res;
   JavaThread* thread = (JavaThread*)Thread::current();
   assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
   ThreadBlockInVM tbiv(thread);
   RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
   return res;
 }
 
-size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
-  size_t res;
+ssize_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+  ssize_t res;
   JavaThread* thread = (JavaThread*)Thread::current();
   assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
   ThreadBlockInVM tbiv(thread);
   RESTARTABLE(::pread(fd, buf, (size_t) nBytes, offset), res);
   return res;
 }
 
-size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
-  size_t res;
+ssize_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
+  ssize_t res;
   assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
          "Assumed _thread_in_native");
   RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
   return res;
 }
 
+ssize_t os::write(int fd, const void *buf, unsigned int nBytes) {
+  ssize_t res;
+  RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
+  return res;
+}
+
 void os::naked_short_sleep(jlong ms) {
   assert(ms < 1000, "Un-interruptable sleep, short time use only");
 
   // usleep is deprecated and removed from POSIX, in favour of nanosleep, but
   // Solaris requires -lrt for this.

@@ -5490,16 +5495,10 @@
   if (::stat(libmawtpath, &statbuf) == 0) return false;
 
   return true;
 }
 
-size_t os::write(int fd, const void *buf, unsigned int nBytes) {
-  size_t res;
-  RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
-  return res;
-}
-
 int os::close(int fd) {
   return ::close(fd);
 }
 
 int os::socket_close(int fd) {
< prev index next >