os_linux.inline.hpp revision 0:a61af66fc99e
11592Srgrimes/* 21592Srgrimes * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 31592Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41592Srgrimes * 51592Srgrimes * This code is free software; you can redistribute it and/or modify it 61592Srgrimes * under the terms of the GNU General Public License version 2 only, as 71592Srgrimes * published by the Free Software Foundation. 81592Srgrimes * 91592Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT 101592Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 111592Srgrimes * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121592Srgrimes * version 2 for more details (a copy is included in the LICENSE file that 13262136Sbrueffer * accompanied this code). 141592Srgrimes * 151592Srgrimes * You should have received a copy of the GNU General Public License version 161592Srgrimes * 2 along with this work; if not, write to the Free Software Foundation, 171592Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 181592Srgrimes * 191592Srgrimes * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 201592Srgrimes * CA 95054 USA or visit www.sun.com if you need additional information or 211592Srgrimes * have any questions. 221592Srgrimes * 231592Srgrimes */ 241592Srgrimes 251592Srgrimesinline void* os::thread_local_storage_at(int index) { 261592Srgrimes return pthread_getspecific((pthread_key_t)index); 271592Srgrimes} 281592Srgrimes 291592Srgrimesinline const char* os::file_separator() { 301592Srgrimes return "/"; 3131491Scharnier} 321592Srgrimes 331592Srgrimesinline const char* os::line_separator() { 341592Srgrimes return "\n"; 351592Srgrimes} 361592Srgrimes 3731491Scharnierinline const char* os::path_separator() { 381592Srgrimes return ":"; 3931491Scharnier} 4031491Scharnier 4150476Speterinline const char* os::jlong_format_specifier() { 421592Srgrimes return "%lld"; 431592Srgrimes} 441592Srgrimes 451592Srgrimesinline const char* os::julong_format_specifier() { 468870Srgrimes return "%llu"; 471592Srgrimes} 481592Srgrimes 491592Srgrimes// File names are case-sensitive on windows only 501592Srgrimesinline int os::file_name_strcmp(const char* s1, const char* s2) { 511592Srgrimes return strcmp(s1, s2); 525111Sache} 53112998Sjmallett 541592Srgrimesinline bool os::obsolete_option(const JavaVMOption *option) { 5531491Scharnier return false; 5631491Scharnier} 5731491Scharnier 581592Srgrimesinline bool os::uses_stack_guard_pages() { 5931491Scharnier return true; 6031491Scharnier} 6131491Scharnier 621592Srgrimesinline bool os::allocate_stack_guard_pages() { 631592Srgrimes assert(uses_stack_guard_pages(), "sanity check"); 641592Srgrimes return true; 651592Srgrimes} 6690261Simp 6790261Simp 68241777Sed// On Linux, reservations are made on a page by page basis, nothing to do. 69241777Sedinline void os::split_reserved_memory(char *base, size_t size, 701592Srgrimes size_t split, bool realloc) { 71241777Sed} 72241777Sed 731592Srgrimes 74241777Sed// Bang the shadow pages if they need to be touched to be mapped. 751592Srgrimesinline void os::bang_stack_shadow_pages() { 761592Srgrimes} 771592Srgrimes 781592Srgrimesinline DIR* os::opendir(const char* dirname) 7931491Scharnier{ 8090261Simp assert(dirname != NULL, "just checking"); 811592Srgrimes return ::opendir(dirname); 821592Srgrimes} 831592Srgrimes 84120548Stjrinline int os::readdir_buf_size(const char *path) 851592Srgrimes{ 8641440Sdillon return NAME_MAX + sizeof(dirent) + 1; 8741440Sdillon} 8841440Sdillon 8941440Sdilloninline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) 9031491Scharnier{ 9131491Scharnier dirent* p; 9241440Sdillon int status; 931592Srgrimes assert(dirp != NULL, "just checking"); 9445422Sbrian 951592Srgrimes // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX 961592Srgrimes // version. Here is the doc for this function: 971592Srgrimes // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html 9845422Sbrian 991592Srgrimes if((status = ::readdir_r(dirp, dbuf, &p)) != 0) { 1001592Srgrimes errno = status; 1011592Srgrimes return NULL; 1021592Srgrimes } else 1031592Srgrimes return p; 1041592Srgrimes} 1051592Srgrimes 1061592Srgrimesinline int os::closedir(DIR *dirp) 1071592Srgrimes{ 108130496Sbms assert(dirp != NULL, "just checking"); 1091592Srgrimes return ::closedir(dirp); 1101592Srgrimes} 1111592Srgrimes 1121592Srgrimes// macros for restartable system calls 1131592Srgrimes 1141592Srgrimes#define RESTARTABLE(_cmd, _result) do { \ 115120548Stjr _result = _cmd; \ 116120548Stjr } while(((int)_result == OS_ERR) && (errno == EINTR)) 117120548Stjr 1181592Srgrimes#define RESTARTABLE_RETURN_INT(_cmd) do { \ 1191592Srgrimes int _result; \ 120130495Sbms RESTARTABLE(_cmd, _result); \ 121130496Sbms return _result; \ 1221592Srgrimes} while(false) 1231592Srgrimes