Path: blob/master/src/hotspot/os/posix/os_posix.inline.hpp
40930 views
/*1* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_POSIX_OS_POSIX_INLINE_HPP25#define OS_POSIX_OS_POSIX_INLINE_HPP2627// os_posix.hpp included by os.hpp2829#include "runtime/os.hpp"3031#include <unistd.h>32#include <sys/socket.h>33#include <netdb.h>3435// macros for restartable system calls3637#define RESTARTABLE(_cmd, _result) do { \38_result = _cmd; \39} while(((int)_result == OS_ERR) && (errno == EINTR))4041#define RESTARTABLE_RETURN_INT(_cmd) do { \42int _result; \43RESTARTABLE(_cmd, _result); \44return _result; \45} while(false)4647// Aix does not have NUMA support but need these for compilation.48inline bool os::numa_has_static_binding() { AIX_ONLY(ShouldNotReachHere();) return true; }49inline bool os::numa_has_group_homing() { AIX_ONLY(ShouldNotReachHere();) return false; }5051// Platform Mutex/Monitor implementation5253inline void os::PlatformMutex::lock() {54int status = pthread_mutex_lock(mutex());55assert_status(status == 0, status, "mutex_lock");56}5758inline void os::PlatformMutex::unlock() {59int status = pthread_mutex_unlock(mutex());60assert_status(status == 0, status, "mutex_unlock");61}6263inline bool os::PlatformMutex::try_lock() {64int status = pthread_mutex_trylock(mutex());65assert_status(status == 0 || status == EBUSY, status, "mutex_trylock");66return status == 0;67}6869inline void os::PlatformMonitor::notify() {70int status = pthread_cond_signal(cond());71assert_status(status == 0, status, "cond_signal");72}7374inline void os::PlatformMonitor::notify_all() {75int status = pthread_cond_broadcast(cond());76assert_status(status == 0, status, "cond_broadcast");77}7879#endif // OS_POSIX_OS_POSIX_INLINE_HPP808182