Blame lib/replace/system/threads.h

rpm-build 95f51c
#ifndef _system_threads_h
rpm-build 95f51c
#define _system_threads_h
rpm-build 95f51c
/*
rpm-build 95f51c
   Unix SMB/CIFS implementation.
rpm-build 95f51c
rpm-build 95f51c
   macros to go along with the lib/replace/ portability layer code
rpm-build 95f51c
rpm-build 95f51c
   Copyright (C) Volker Lendecke 2012
rpm-build 95f51c
rpm-build 95f51c
     ** NOTE! The following LGPL license applies to the replace
rpm-build 95f51c
     ** library. This does NOT imply that all of Samba is released
rpm-build 95f51c
     ** under the LGPL
rpm-build 95f51c
rpm-build 95f51c
   This library is free software; you can redistribute it and/or
rpm-build 95f51c
   modify it under the terms of the GNU Lesser General Public
rpm-build 95f51c
   License as published by the Free Software Foundation; either
rpm-build 95f51c
   version 3 of the License, or (at your option) any later version.
rpm-build 95f51c
rpm-build 95f51c
   This library is distributed in the hope that it will be useful,
rpm-build 95f51c
   but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 95f51c
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 95f51c
   Lesser General Public License for more details.
rpm-build 95f51c
rpm-build 95f51c
   You should have received a copy of the GNU Lesser General Public
rpm-build 95f51c
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
rpm-build 95f51c
*/
rpm-build 95f51c
rpm-build 95f51c
#include <pthread.h>
rpm-build 95f51c
rpm-build 95f51c
#if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) && \
rpm-build 95f51c
	!defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST)
rpm-build 95f51c
#define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#if defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST_NP) && \
rpm-build 95f51c
	!defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST)
rpm-build 95f51c
#define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#if defined(HAVE_PTHREAD_MUTEX_CONSISTENT_NP) && \
rpm-build 95f51c
	!defined(HAVE_PTHREAD_MUTEX_CONSISTENT)
rpm-build 95f51c
#define pthread_mutex_consistent pthread_mutex_consistent_np
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifdef HAVE_STDATOMIC_H
rpm-build 95f51c
#include <stdatomic.h>
rpm-build 95f51c
#endif
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_ATOMIC_THREAD_FENCE
rpm-build 95f51c
#ifdef HAVE___ATOMIC_THREAD_FENCE
rpm-build 95f51c
#define atomic_thread_fence(__ignore_order) __atomic_thread_fence(__ATOMIC_SEQ_CST)
rpm-build 95f51c
#define HAVE_ATOMIC_THREAD_FENCE 1
rpm-build 95f51c
#endif /* HAVE___ATOMIC_THREAD_FENCE */
rpm-build 95f51c
#endif /* not HAVE_ATOMIC_THREAD_FENCE */
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_ATOMIC_THREAD_FENCE
rpm-build 95f51c
#ifdef HAVE___SYNC_SYNCHRONIZE
rpm-build 95f51c
#define atomic_thread_fence(__ignore_order) __sync_synchronize()
rpm-build 95f51c
#define HAVE_ATOMIC_THREAD_FENCE 1
rpm-build 95f51c
#endif /* HAVE___SYNC_SYNCHRONIZE */
rpm-build 95f51c
#endif /* not HAVE_ATOMIC_THREAD_FENCE */
rpm-build 95f51c
rpm-build 95f51c
#ifndef HAVE_ATOMIC_THREAD_FENCE
rpm-build 95f51c
#ifdef HAVE_ATOMIC_THREAD_FENCE_SUPPORT
rpm-build 95f51c
#error mismatch_error_between_configure_test_and_header
rpm-build 95f51c
#endif
rpm-build 95f51c
/* make sure the build fails if someone uses it without checking the define */
rpm-build 95f51c
#define atomic_thread_fence(__order) \
rpm-build 95f51c
        __function__atomic_thread_fence_not_available_on_this_platform__()
rpm-build 95f51c
#endif /* not HAVE_ATOMIC_THREAD_FENCE */
rpm-build 95f51c
rpm-build 95f51c
#endif