< prev index next >

src/os/posix/vm/os_posix.cpp

Print this page


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


 147 
 148   // [  |                                       |  ]
 149   // ^ extra_base
 150   //    ^ extra_base + begin_offset == aligned_base
 151   //     extra_base + begin_offset + size       ^
 152   //                       extra_base + extra_size ^
 153   // |<>| == begin_offset
 154   //                              end_offset == |<>|
 155   size_t begin_offset = aligned_base - extra_base;
 156   size_t end_offset = (extra_base + extra_size) - (aligned_base + size);
 157 
 158   if (begin_offset > 0) {
 159       os::release_memory(extra_base, begin_offset);
 160   }
 161 
 162   if (end_offset > 0) {
 163       os::release_memory(extra_base + begin_offset + size, end_offset);
 164   }
 165 
 166   return aligned_base;










 167 }
 168 
 169 void os::Posix::print_load_average(outputStream* st) {
 170   st->print("load average:");
 171   double loadavg[3];
 172   os::loadavg(loadavg, 3);
 173   st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
 174   st->cr();
 175 }
 176 
 177 void os::Posix::print_rlimit_info(outputStream* st) {
 178   st->print("rlimit:");
 179   struct rlimit rlim;
 180 
 181   st->print(" STACK ");
 182   getrlimit(RLIMIT_STACK, &rlim);
 183   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 184   else st->print("%uk", rlim.rlim_cur >> 10);
 185 
 186   st->print(", CORE ");


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


 147 
 148   // [  |                                       |  ]
 149   // ^ extra_base
 150   //    ^ extra_base + begin_offset == aligned_base
 151   //     extra_base + begin_offset + size       ^
 152   //                       extra_base + extra_size ^
 153   // |<>| == begin_offset
 154   //                              end_offset == |<>|
 155   size_t begin_offset = aligned_base - extra_base;
 156   size_t end_offset = (extra_base + extra_size) - (aligned_base + size);
 157 
 158   if (begin_offset > 0) {
 159       os::release_memory(extra_base, begin_offset);
 160   }
 161 
 162   if (end_offset > 0) {
 163       os::release_memory(extra_base + begin_offset + size, end_offset);
 164   }
 165 
 166   return aligned_base;
 167 }
 168 
 169 int os::vsnprintf(char* buf, size_t len, const char* fmt, va_list args) {
 170   int result = ::vsnprintf(buf, len, fmt, args);
 171   // If an encoding error occurred (result < 0) then it's not clear
 172   // whether the buffer is NUL terminated, so ensure it is.
 173   if ((result < 0) && (len > 0)) {
 174     buf[len - 1] = '\0';
 175   }
 176   return result;
 177 }
 178 
 179 void os::Posix::print_load_average(outputStream* st) {
 180   st->print("load average:");
 181   double loadavg[3];
 182   os::loadavg(loadavg, 3);
 183   st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
 184   st->cr();
 185 }
 186 
 187 void os::Posix::print_rlimit_info(outputStream* st) {
 188   st->print("rlimit:");
 189   struct rlimit rlim;
 190 
 191   st->print(" STACK ");
 192   getrlimit(RLIMIT_STACK, &rlim);
 193   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 194   else st->print("%uk", rlim.rlim_cur >> 10);
 195 
 196   st->print(", CORE ");


< prev index next >