hotspot/src/os/linux/vm/os_linux.inline.hpp
author iveresov
Tue, 29 Apr 2008 13:51:26 +0400
changeset 388 bcc631c5bbec
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6684395: Port NUMA-aware allocator to linux Summary: NUMA-aware allocator port to Linux Reviewed-by: jmasa, apetrusenko
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
inline void* os::thread_local_storage_at(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
  return pthread_getspecific((pthread_key_t)index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
inline const char* os::file_separator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  return "/";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
inline const char* os::line_separator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  return "\n";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
inline const char* os::path_separator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  return ":";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
inline const char* os::jlong_format_specifier() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  return "%lld";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
inline const char* os::julong_format_specifier() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  return "%llu";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// File names are case-sensitive on windows only
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
inline int os::file_name_strcmp(const char* s1, const char* s2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  return strcmp(s1, s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
inline bool os::obsolete_option(const JavaVMOption *option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
inline bool os::uses_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
inline bool os::allocate_stack_guard_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  assert(uses_stack_guard_pages(), "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// On Linux, reservations are made on a page by page basis, nothing to do.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
inline void os::split_reserved_memory(char *base, size_t size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
                                      size_t split, bool realloc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// Bang the shadow pages if they need to be touched to be mapped.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
inline void os::bang_stack_shadow_pages() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
inline DIR* os::opendir(const char* dirname)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  assert(dirname != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  return ::opendir(dirname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
inline int os::readdir_buf_size(const char *path)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  return NAME_MAX + sizeof(dirent) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  dirent* p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  int status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  assert(dirp != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // version. Here is the doc for this function:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    errno = status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    return p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
inline int os::closedir(DIR *dirp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  assert(dirp != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  return ::closedir(dirp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// macros for restartable system calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
#define RESTARTABLE(_cmd, _result) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    _result = _cmd; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  } while(((int)_result == OS_ERR) && (errno == EINTR))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
#define RESTARTABLE_RETURN_INT(_cmd) do { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  int _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  RESTARTABLE(_cmd, _result); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  return _result; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
} while(false)
388
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   123
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   124
inline bool os::numa_has_static_binding()   { return true; }
bcc631c5bbec 6684395: Port NUMA-aware allocator to linux
iveresov
parents: 1
diff changeset
   125
inline bool os::numa_has_group_homing()     { return false;  }