Blame sysdeps/htl/libc-lockP.h

Packit 6c4009
/* Private libc-internal interface for mutex locks.
Packit 6c4009
   Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public License as
Packit 6c4009
   published by the Free Software Foundation; either version 2.1 of the
Packit 6c4009
   License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; see the file COPYING.LIB.  If
Packit 6c4009
   not, see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _BITS_LIBC_LOCKP_H
Packit 6c4009
#define _BITS_LIBC_LOCKP_H 1
Packit 6c4009
Packit 6c4009
#include <pthread.h>
Packit 6c4009
#include <pthread-functions.h>
Packit 6c4009
Packit 6c4009
/* Type for key to thread-specific data.  */
Packit 6c4009
typedef pthread_key_t __libc_key_t;
Packit 6c4009
Packit 6c4009
/* If we check for a weakly referenced symbol and then perform a
Packit 6c4009
   normal jump to it te code generated for some platforms in case of
Packit 6c4009
   PIC is unnecessarily slow.  What would happen is that the function
Packit 6c4009
   is first referenced as data and then it is called indirectly
Packit 6c4009
   through the PLT.  We can make this a direct jump.  */
Packit 6c4009
#ifdef __PIC__
Packit 6c4009
# define __libc_maybe_call(FUNC, ARGS, ELSE) \
Packit 6c4009
  (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
Packit 6c4009
		    _fn != NULL ? (*_fn) ARGS : ELSE; }))
Packit 6c4009
#else
Packit 6c4009
# define __libc_maybe_call(FUNC, ARGS, ELSE) \
Packit 6c4009
  (FUNC != NULL ? FUNC ARGS : ELSE)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Call thread functions through the function pointer table.  */
Packit 6c4009
#if defined SHARED && IS_IN (libc)
Packit 6c4009
# define PTFAVAIL(NAME) __libc_pthread_functions_init
Packit 6c4009
# define __libc_ptf_call(FUNC, ARGS, ELSE) \
Packit 6c4009
  (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE)
Packit 6c4009
# define __libc_ptf_call_always(FUNC, ARGS) \
Packit 6c4009
  PTHFCT_CALL (ptr_##FUNC, ARGS)
Packit 6c4009
#elif IS_IN (libpthread)
Packit 6c4009
# define PTFAVAIL(NAME) 1
Packit 6c4009
# define __libc_ptf_call(FUNC, ARGS, ELSE) \
Packit 6c4009
  FUNC ARGS
Packit 6c4009
# define __libc_ptf_call_always(FUNC, ARGS) \
Packit 6c4009
  FUNC ARGS
Packit 6c4009
#else
Packit 6c4009
# define PTFAVAIL(NAME) (NAME != NULL)
Packit 6c4009
# define __libc_ptf_call(FUNC, ARGS, ELSE) \
Packit 6c4009
  __libc_maybe_call (FUNC, ARGS, ELSE)
Packit 6c4009
# define __libc_ptf_call_always(FUNC, ARGS) \
Packit 6c4009
  FUNC ARGS
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Create thread-specific key.  */
Packit 6c4009
#define __libc_key_create(KEY, DESTRUCTOR) \
Packit 6c4009
  __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)
Packit 6c4009
Packit 6c4009
/* Get thread-specific data.  */
Packit 6c4009
#define __libc_getspecific(KEY) \
Packit 6c4009
  __libc_ptf_call (__pthread_getspecific, (KEY), NULL)
Packit 6c4009
Packit 6c4009
/* Set thread-specific data.  */
Packit 6c4009
#define __libc_setspecific(KEY, VALUE) \
Packit 6c4009
  __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions that are used by this file and are internal to the GNU C
Packit 6c4009
   library.  */
Packit 6c4009
Packit 6c4009
extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
Packit 6c4009
				 const pthread_mutexattr_t *__mutex_attr);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
Packit 6c4009
Packit 6c4009
extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
Packit 6c4009
					int __kind);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
Packit 6c4009
				  const pthread_rwlockattr_t *__attr);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
Packit 6c4009
Packit 6c4009
extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
Packit 6c4009
Packit 6c4009
extern int __pthread_key_create (pthread_key_t *__key,
Packit 6c4009
				 void (*__destr_function) (void *));
Packit 6c4009
Packit 6c4009
extern int __pthread_setspecific (pthread_key_t __key,
Packit 6c4009
				  const void *__pointer);
Packit 6c4009
Packit 6c4009
extern void *__pthread_getspecific (pthread_key_t __key);
Packit 6c4009
Packit 6c4009
extern int __pthread_once (pthread_once_t *__once_control,
Packit 6c4009
			   void (*__init_routine) (void));
Packit 6c4009
Packit 6c4009
extern int __pthread_atfork (void (*__prepare) (void),
Packit 6c4009
			     void (*__parent) (void),
Packit 6c4009
			     void (*__child) (void));
Packit 6c4009
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Make the pthread functions weak so that we can elide them from
Packit 6c4009
   single-threaded processes.  */
Packit 6c4009
#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread)
Packit 6c4009
# ifdef weak_extern
Packit 6c4009
weak_extern (__pthread_mutex_init)
Packit 6c4009
weak_extern (__pthread_mutex_destroy)
Packit 6c4009
weak_extern (__pthread_mutex_lock)
Packit 6c4009
weak_extern (__pthread_mutex_trylock)
Packit 6c4009
weak_extern (__pthread_mutex_unlock)
Packit 6c4009
weak_extern (__pthread_mutexattr_init)
Packit 6c4009
weak_extern (__pthread_mutexattr_destroy)
Packit 6c4009
weak_extern (__pthread_mutexattr_settype)
Packit 6c4009
weak_extern (__pthread_rwlock_init)
Packit 6c4009
weak_extern (__pthread_rwlock_destroy)
Packit 6c4009
weak_extern (__pthread_rwlock_rdlock)
Packit 6c4009
weak_extern (__pthread_rwlock_tryrdlock)
Packit 6c4009
weak_extern (__pthread_rwlock_wrlock)
Packit 6c4009
weak_extern (__pthread_rwlock_trywrlock)
Packit 6c4009
weak_extern (__pthread_rwlock_unlock)
Packit 6c4009
weak_extern (__pthread_key_create)
Packit 6c4009
weak_extern (__pthread_setspecific)
Packit 6c4009
weak_extern (__pthread_getspecific)
Packit 6c4009
weak_extern (__pthread_once)
Packit 6c4009
weak_extern (__pthread_initialize)
Packit 6c4009
weak_extern (__pthread_atfork)
Packit 6c4009
weak_extern (__pthread_setcancelstate)
Packit 6c4009
# else
Packit 6c4009
#  pragma weak __pthread_mutex_init
Packit 6c4009
#  pragma weak __pthread_mutex_destroy
Packit 6c4009
#  pragma weak __pthread_mutex_lock
Packit 6c4009
#  pragma weak __pthread_mutex_trylock
Packit 6c4009
#  pragma weak __pthread_mutex_unlock
Packit 6c4009
#  pragma weak __pthread_mutexattr_init
Packit 6c4009
#  pragma weak __pthread_mutexattr_destroy
Packit 6c4009
#  pragma weak __pthread_mutexattr_settype
Packit 6c4009
#  pragma weak __pthread_rwlock_destroy
Packit 6c4009
#  pragma weak __pthread_rwlock_rdlock
Packit 6c4009
#  pragma weak __pthread_rwlock_tryrdlock
Packit 6c4009
#  pragma weak __pthread_rwlock_wrlock
Packit 6c4009
#  pragma weak __pthread_rwlock_trywrlock
Packit 6c4009
#  pragma weak __pthread_rwlock_unlock
Packit 6c4009
#  pragma weak __pthread_key_create
Packit 6c4009
#  pragma weak __pthread_setspecific
Packit 6c4009
#  pragma weak __pthread_getspecific
Packit 6c4009
#  pragma weak __pthread_once
Packit 6c4009
#  pragma weak __pthread_initialize
Packit 6c4009
#  pragma weak __pthread_atfork
Packit 6c4009
#  pragma weak __pthread_setcancelstate
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#endif	/* bits/libc-lockP.h */