< prev index next >

src/os/aix/vm/os_aix.cpp

Print this page
rev 13166 : read/write APIs in class os shall return ssize_t
   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


2527   char* addr = NULL;
2528 
2529   // Always round to os::vm_page_size(), which may be larger than 4K.
2530   bytes = align_size_up(bytes, os::vm_page_size());
2531 
2532   // In 4K mode always use mmap.
2533   // In 64K mode allocate small sizes with mmap, large ones with 64K shmatted.
2534   if (os::vm_page_size() == 4*K) {
2535     return reserve_mmaped_memory(bytes, requested_addr, 0);
2536   } else {
2537     if (bytes >= Use64KPagesThreshold) {
2538       return reserve_shmated_memory(bytes, requested_addr, 0);
2539     } else {
2540       return reserve_mmaped_memory(bytes, requested_addr, 0);
2541     }
2542   }
2543 
2544   return addr;
2545 }
2546 
2547 size_t os::read(int fd, void *buf, unsigned int nBytes) {
2548   return ::read(fd, buf, nBytes);
2549 }
2550 
2551 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
2552   return ::pread(fd, buf, nBytes, offset);
2553 }
2554 
2555 void os::naked_short_sleep(jlong ms) {
2556   struct timespec req;
2557 
2558   assert(ms < 1000, "Un-interruptable sleep, short time use only");
2559   req.tv_sec = 0;
2560   if (ms > 0) {
2561     req.tv_nsec = (ms % 1000) * 1000000;
2562   }
2563   else {
2564     req.tv_nsec = 1;
2565   }
2566 
2567   nanosleep(&req, NULL);
2568 
2569   return;
2570 }
2571 


   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2017, SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


2527   char* addr = NULL;
2528 
2529   // Always round to os::vm_page_size(), which may be larger than 4K.
2530   bytes = align_size_up(bytes, os::vm_page_size());
2531 
2532   // In 4K mode always use mmap.
2533   // In 64K mode allocate small sizes with mmap, large ones with 64K shmatted.
2534   if (os::vm_page_size() == 4*K) {
2535     return reserve_mmaped_memory(bytes, requested_addr, 0);
2536   } else {
2537     if (bytes >= Use64KPagesThreshold) {
2538       return reserve_shmated_memory(bytes, requested_addr, 0);
2539     } else {
2540       return reserve_mmaped_memory(bytes, requested_addr, 0);
2541     }
2542   }
2543 
2544   return addr;
2545 }
2546 
2547 ssize_t os::read(int fd, void *buf, unsigned int nBytes) {
2548   return ::read(fd, buf, nBytes);
2549 }
2550 
2551 ssize_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
2552   return ::pread(fd, buf, nBytes, offset);
2553 }
2554 
2555 void os::naked_short_sleep(jlong ms) {
2556   struct timespec req;
2557 
2558   assert(ms < 1000, "Un-interruptable sleep, short time use only");
2559   req.tv_sec = 0;
2560   if (ms > 0) {
2561     req.tv_nsec = (ms % 1000) * 1000000;
2562   }
2563   else {
2564     req.tv_nsec = 1;
2565   }
2566 
2567   nanosleep(&req, NULL);
2568 
2569   return;
2570 }
2571 


< prev index next >