Tue, 29 Apr 2008 13:51:26 +0400
6684395: Port NUMA-aware allocator to linux
Summary: NUMA-aware allocator port to Linux
Reviewed-by: jmasa, apetrusenko
1 /*
2 * Copyright 1999-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 inline void* os::thread_local_storage_at(int index) {
26 return pthread_getspecific((pthread_key_t)index);
27 }
29 inline const char* os::file_separator() {
30 return "/";
31 }
33 inline const char* os::line_separator() {
34 return "\n";
35 }
37 inline const char* os::path_separator() {
38 return ":";
39 }
41 inline const char* os::jlong_format_specifier() {
42 return "%lld";
43 }
45 inline const char* os::julong_format_specifier() {
46 return "%llu";
47 }
49 // File names are case-sensitive on windows only
50 inline int os::file_name_strcmp(const char* s1, const char* s2) {
51 return strcmp(s1, s2);
52 }
54 inline bool os::obsolete_option(const JavaVMOption *option) {
55 return false;
56 }
58 inline bool os::uses_stack_guard_pages() {
59 return true;
60 }
62 inline bool os::allocate_stack_guard_pages() {
63 assert(uses_stack_guard_pages(), "sanity check");
64 return true;
65 }
68 // On Linux, reservations are made on a page by page basis, nothing to do.
69 inline void os::split_reserved_memory(char *base, size_t size,
70 size_t split, bool realloc) {
71 }
74 // Bang the shadow pages if they need to be touched to be mapped.
75 inline void os::bang_stack_shadow_pages() {
76 }
78 inline DIR* os::opendir(const char* dirname)
79 {
80 assert(dirname != NULL, "just checking");
81 return ::opendir(dirname);
82 }
84 inline int os::readdir_buf_size(const char *path)
85 {
86 return NAME_MAX + sizeof(dirent) + 1;
87 }
89 inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
90 {
91 dirent* p;
92 int status;
93 assert(dirp != NULL, "just checking");
95 // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
96 // version. Here is the doc for this function:
97 // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
99 if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
100 errno = status;
101 return NULL;
102 } else
103 return p;
104 }
106 inline int os::closedir(DIR *dirp)
107 {
108 assert(dirp != NULL, "just checking");
109 return ::closedir(dirp);
110 }
112 // macros for restartable system calls
114 #define RESTARTABLE(_cmd, _result) do { \
115 _result = _cmd; \
116 } while(((int)_result == OS_ERR) && (errno == EINTR))
118 #define RESTARTABLE_RETURN_INT(_cmd) do { \
119 int _result; \
120 RESTARTABLE(_cmd, _result); \
121 return _result; \
122 } while(false)
124 inline bool os::numa_has_static_binding() { return true; }
125 inline bool os::numa_has_group_homing() { return false; }