Siddhesh Poyarekar 17b00f
/* libc-internal interface for mutex locks.  LinuxThreads version.
Siddhesh Poyarekar 17b00f
   Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
Siddhesh Poyarekar 17b00f
	Free Software Foundation, Inc.
Siddhesh Poyarekar 17b00f
   This file is part of the GNU C Library.
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
   The GNU C Library is free software; you can redistribute it and/or
Siddhesh Poyarekar 17b00f
   modify it under the terms of the GNU Lesser General Public License as
Siddhesh Poyarekar 17b00f
   published by the Free Software Foundation; either version 2.1 of the
Siddhesh Poyarekar 17b00f
   License, or (at your option) any later version.
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
   The GNU C Library is distributed in the hope that it will be useful,
Siddhesh Poyarekar 17b00f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Siddhesh Poyarekar 17b00f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Siddhesh Poyarekar 17b00f
   Lesser General Public License for more details.
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
   You should have received a copy of the GNU Lesser General Public
Siddhesh Poyarekar 17b00f
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
Siddhesh Poyarekar 17b00f
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Siddhesh Poyarekar 17b00f
   Boston, MA 02111-1307, USA.  */
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#ifndef _BITS_LIBC_LOCK_H
Siddhesh Poyarekar 17b00f
#define _BITS_LIBC_LOCK_H 1
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#include <pthread.h>
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Mutex type.  */
Siddhesh Poyarekar 17b00f
#ifdef _IO_MTSAFE_IO
Siddhesh Poyarekar 17b00f
typedef pthread_mutex_t __libc_lock_t;
Siddhesh Poyarekar 17b00f
typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
Siddhesh Poyarekar 17b00f
# ifdef __USE_UNIX98
Siddhesh Poyarekar 17b00f
typedef pthread_rwlock_t __libc_rwlock_t;
Siddhesh Poyarekar 17b00f
# else
Siddhesh Poyarekar 17b00f
typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
Siddhesh Poyarekar 17b00f
# endif
Siddhesh Poyarekar 17b00f
typedef __libc_lock_recursive_t __rtld_lock_recursive_t;
Siddhesh Poyarekar 17b00f
#else
Siddhesh Poyarekar 17b00f
typedef struct __libc_lock_opaque__ __libc_lock_t;
Siddhesh Poyarekar 17b00f
typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
Siddhesh Poyarekar 17b00f
typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
Siddhesh Poyarekar 17b00f
#endif
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Type for key to thread-specific data.  */
Siddhesh Poyarekar 17b00f
typedef pthread_key_t __libc_key_t;
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Define a lock variable NAME with storage class CLASS.  The lock must be
Siddhesh Poyarekar 17b00f
   initialized with __libc_lock_init before it can be used (or define it
Siddhesh Poyarekar 17b00f
   with __libc_lock_define_initialized, below).  Use `extern' for CLASS to
Siddhesh Poyarekar 17b00f
   declare a lock defined in another module.  In public structure
Siddhesh Poyarekar 17b00f
   definitions you must use a pointer to the lock structure (i.e., NAME
Siddhesh Poyarekar 17b00f
   begins with a `*'), because its storage size will not be known outside
Siddhesh Poyarekar 17b00f
   of libc.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_define(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_lock_t NAME;
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_define(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_rwlock_t NAME;
Siddhesh Poyarekar 17b00f
#define __libc_lock_define_recursive(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_lock_recursive_t NAME;
Siddhesh Poyarekar 17b00f
#define __rtld_lock_define_recursive(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __rtld_lock_recursive_t NAME;
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Define an initialized lock variable NAME with storage class CLASS.
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
   For the C library we take a deeper look at the initializer.  For
Siddhesh Poyarekar 17b00f
   this implementation all fields are initialized to zero.  Therefore
Siddhesh Poyarekar 17b00f
   we don't initialize the variable which allows putting it into the
Siddhesh Poyarekar 17b00f
   BSS section.  (Except on PA-RISC and other odd architectures, where
Siddhesh Poyarekar 17b00f
   initialized locks must be set to one due to the lack of normal
Siddhesh Poyarekar 17b00f
   atomic operations.) */
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#if __LT_SPINLOCK_INIT == 0
Siddhesh Poyarekar 17b00f
#  define __libc_lock_define_initialized(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_lock_t NAME;
Siddhesh Poyarekar 17b00f
#else
Siddhesh Poyarekar 17b00f
#  define __libc_lock_define_initialized(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_lock_t NAME = PTHREAD_MUTEX_INITIALIZER;
Siddhesh Poyarekar 17b00f
#endif
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_define_initialized(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Define an initialized recursive lock variable NAME with storage
Siddhesh Poyarekar 17b00f
   class CLASS.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_define_initialized_recursive(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
Siddhesh Poyarekar 17b00f
#define _LIBC_LOCK_RECURSIVE_INITIALIZER \
Siddhesh Poyarekar 17b00f
  {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#define __rtld_lock_define_initialized_recursive(CLASS,NAME) \
Siddhesh Poyarekar 17b00f
  CLASS __rtld_lock_recursive_t NAME = _RTLD_LOCK_RECURSIVE_INITIALIZER;
Siddhesh Poyarekar 17b00f
#define _RTLD_LOCK_RECURSIVE_INITIALIZER \
Siddhesh Poyarekar 17b00f
  {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#if defined __PIC__
Siddhesh Poyarekar 17b00f
# define __libc_maybe_call(FUNC, ARGS, ELSE) \
Siddhesh Poyarekar 17b00f
  (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
Siddhesh Poyarekar 17b00f
                    _fn != NULL ? (*_fn) ARGS : ELSE; }))
Siddhesh Poyarekar 17b00f
#else
Siddhesh Poyarekar 17b00f
# define __libc_maybe_call(FUNC, ARGS, ELSE) \
Siddhesh Poyarekar 17b00f
  (FUNC != NULL ? FUNC ARGS : ELSE)
Siddhesh Poyarekar 17b00f
#endif
Siddhesh Poyarekar 17b00f
#define __libc_maybe_call2(FUNC, ARGS, ELSE) __libc_maybe_call (__##FUNC, ARGS, ELSE)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Initialize the named lock variable, leaving it in a consistent, unlocked
Siddhesh Poyarekar 17b00f
   state.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_init(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call2 (pthread_mutex_init, (&(NAME), NULL), 0))
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_init(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Same as last but this time we initialize a recursive mutex.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_init_recursive(NAME) \
Siddhesh Poyarekar 17b00f
  do {									      \
Siddhesh Poyarekar 17b00f
    if (__pthread_mutex_init != NULL)					      \
Siddhesh Poyarekar 17b00f
      {									      \
Siddhesh Poyarekar 17b00f
	pthread_mutexattr_t __attr;					      \
Siddhesh Poyarekar 17b00f
	__pthread_mutexattr_init (&__attr);				      \
Siddhesh Poyarekar 17b00f
	__pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
Siddhesh Poyarekar 17b00f
	__pthread_mutex_init (&(NAME).mutex, &__attr);			      \
Siddhesh Poyarekar 17b00f
	__pthread_mutexattr_destroy (&__attr);				      \
Siddhesh Poyarekar 17b00f
      }									      \
Siddhesh Poyarekar 17b00f
  } while (0);
Siddhesh Poyarekar 17b00f
#define __rtld_lock_init_recursive(NAME) \
Siddhesh Poyarekar 17b00f
  __libc_lock_init_recursive (NAME)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Finalize the named lock variable, which must be locked.  It cannot be
Siddhesh Poyarekar 17b00f
   used again until __libc_lock_init is called again on it.  This must be
Siddhesh Poyarekar 17b00f
   called on a lock variable before the containing storage is reused.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_fini(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call2 (pthread_mutex_destroy, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_fini(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_destroy, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Finalize recursive named lock.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_fini_recursive(NAME) __libc_lock_fini ((NAME).mutex)
Siddhesh Poyarekar 17b00f
#define __rtld_lock_fini_recursive(NAME) __libc_lock_fini_recursive (NAME)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Lock the named lock variable.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_lock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call2 (pthread_mutex_lock, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_rdlock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_rdlock, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_wrlock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_wrlock, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Lock the recursive named lock variable.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_lock_recursive(NAME) __libc_lock_lock ((NAME).mutex)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Try to lock the named lock variable.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_trylock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call2 (pthread_mutex_trylock, (&(NAME)), 0))
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_tryrdlock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_tryrdlock, (&(NAME)), 0))
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_trywrlock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_trywrlock, (&(NAME)), 0))
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Try to lock the recursive named lock variable.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_trylock_recursive(NAME) __libc_lock_trylock ((NAME).mutex)
Siddhesh Poyarekar 17b00f
#define __rtld_lock_trylock_recursive(NAME) \
Siddhesh Poyarekar 17b00f
  __libc_lock_trylock_recursive (NAME)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Unlock the named lock variable.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_unlock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call2 (pthread_mutex_unlock, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
#define __libc_rwlock_unlock(NAME) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_rwlock_unlock, (&(NAME)), 0));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Unlock the recursive named lock variable.  */
Siddhesh Poyarekar 17b00f
#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#define __rtld_lock_lock_recursive(NAME) __libc_lock_lock_recursive (NAME)
Siddhesh Poyarekar 17b00f
#define __rtld_lock_unlock_recursive(NAME) __libc_lock_unlock_recursive (NAME)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Define once control variable.  */
Siddhesh Poyarekar 17b00f
#if PTHREAD_ONCE_INIT == 0
Siddhesh Poyarekar 17b00f
/* Special case for static variables where we can avoid the initialization
Siddhesh Poyarekar 17b00f
   if it is zero.  */
Siddhesh Poyarekar 17b00f
# define __libc_once_define(CLASS, NAME) \
Siddhesh Poyarekar 17b00f
  CLASS pthread_once_t NAME
Siddhesh Poyarekar 17b00f
#else
Siddhesh Poyarekar 17b00f
# define __libc_once_define(CLASS, NAME) \
Siddhesh Poyarekar 17b00f
  CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT
Siddhesh Poyarekar 17b00f
#endif
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Call handler iff the first call.  */
Siddhesh Poyarekar 17b00f
#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
Siddhesh Poyarekar 17b00f
  do {									      \
Siddhesh Poyarekar 17b00f
    if (__pthread_once != NULL)						      \
Siddhesh Poyarekar 17b00f
      __pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION));		      \
Siddhesh Poyarekar 17b00f
    else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) {			      \
Siddhesh Poyarekar 17b00f
      INIT_FUNCTION ();							      \
Siddhesh Poyarekar 17b00f
      (ONCE_CONTROL) = 2;						      \
Siddhesh Poyarekar 17b00f
    }									      \
Siddhesh Poyarekar 17b00f
  } while (0)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Start critical region with cleanup.  */
Siddhesh Poyarekar 17b00f
#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
Siddhesh Poyarekar 17b00f
  { struct _pthread_cleanup_buffer _buffer;				      \
Siddhesh Poyarekar 17b00f
    int _avail = (DOIT) && _pthread_cleanup_push_defer != NULL;		      \
Siddhesh Poyarekar 17b00f
    if (_avail) {							      \
Siddhesh Poyarekar 17b00f
      _pthread_cleanup_push_defer (&_buffer, (FCT), (ARG));		      \
Siddhesh Poyarekar 17b00f
    }
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* End critical region with cleanup.  */
Siddhesh Poyarekar 17b00f
#define __libc_cleanup_region_end(DOIT) \
Siddhesh Poyarekar 17b00f
    if (_avail) {							      \
Siddhesh Poyarekar 17b00f
      _pthread_cleanup_pop_restore (&_buffer, (DOIT));			      \
Siddhesh Poyarekar 17b00f
    }									      \
Siddhesh Poyarekar 17b00f
  }
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Sometimes we have to exit the block in the middle.  */
Siddhesh Poyarekar 17b00f
#define __libc_cleanup_end(DOIT) \
Siddhesh Poyarekar 17b00f
    if (_avail) {							      \
Siddhesh Poyarekar 17b00f
      _pthread_cleanup_pop_restore (&_buffer, (DOIT));			      \
Siddhesh Poyarekar 17b00f
    }
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#define __libc_cleanup_push(fct, arg) \
Siddhesh Poyarekar 17b00f
    { struct _pthread_cleanup_buffer _buffer;				      \
Siddhesh Poyarekar 17b00f
    __libc_maybe_call (_pthread_cleanup_push, (&_buffer, (fct), (arg)), 0)
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#define __libc_cleanup_pop(execute) \
Siddhesh Poyarekar 17b00f
    __libc_maybe_call (_pthread_cleanup_pop, (&_buffer, execute), 0);	      \
Siddhesh Poyarekar 17b00f
    }
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Create thread-specific key.  */
Siddhesh Poyarekar 17b00f
#define __libc_key_create(KEY, DESTRUCTOR) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_key_create, (KEY, DESTRUCTOR), 1))
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Get thread-specific data.  */
Siddhesh Poyarekar 17b00f
#define __libc_getspecific(KEY) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_getspecific, (KEY), NULL))
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Set thread-specific data.  */
Siddhesh Poyarekar 17b00f
#define __libc_setspecific(KEY, VALUE) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_setspecific, (KEY, VALUE), 0))
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Register handlers to execute before and after `fork'.  */
Siddhesh Poyarekar 17b00f
#define __libc_atfork(PREPARE, PARENT, CHILD) \
Siddhesh Poyarekar 17b00f
  (__libc_maybe_call (__pthread_atfork, (PREPARE, PARENT, CHILD), 0))
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
__BEGIN_DECLS
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
Siddhesh Poyarekar 17b00f
                                         void (*__routine) (void *),
Siddhesh Poyarekar 17b00f
                                         void *__arg) __THROW;
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
Siddhesh Poyarekar 17b00f
                                          int __execute) __THROW;
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Functions that are used by this file and are internal to the GNU C
Siddhesh Poyarekar 17b00f
   library.  */
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
Siddhesh Poyarekar 17b00f
				 __const pthread_mutexattr_t *__mutex_attr);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
Siddhesh Poyarekar 17b00f
					int __kind);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#ifdef __USE_UNIX98
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
Siddhesh Poyarekar 17b00f
				  __const pthread_rwlockattr_t *__attr);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
Siddhesh Poyarekar 17b00f
#endif
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_key_create (pthread_key_t *__key,
Siddhesh Poyarekar 17b00f
				 void (*__destr_function) (void *));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_setspecific (pthread_key_t __key,
Siddhesh Poyarekar 17b00f
				  __const void *__pointer);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern void *__pthread_getspecific (pthread_key_t __key);
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_once (pthread_once_t *__once_control,
Siddhesh Poyarekar 17b00f
			   void (*__init_routine) (void));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
extern int __pthread_atfork (void (*__prepare) (void),
Siddhesh Poyarekar 17b00f
			     void (*__parent) (void),
Siddhesh Poyarekar 17b00f
			     void (*__child) (void));
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
__END_DECLS
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* Make the pthread functions weak so that we can elide them from
Siddhesh Poyarekar 17b00f
   single-threaded processes.  */
Siddhesh Poyarekar 17b00f
#ifndef __NO_WEAK_PTHREAD_ALIASES
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutex_init
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutex_destroy
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutex_lock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutex_trylock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutex_unlock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutexattr_init
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutexattr_destroy
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_mutexattr_settype
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_rwlock_destroy
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_rwlock_rdlock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_rwlock_tryrdlock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_rwlock_wrlock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_rwlock_trywrlock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_rwlock_unlock
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_key_create
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_setspecific
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_getspecific
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_once
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_initialize
Siddhesh Poyarekar 17b00f
# pragma weak __pthread_atfork
Siddhesh Poyarekar 17b00f
# pragma weak _pthread_cleanup_push_defer
Siddhesh Poyarekar 17b00f
# pragma weak _pthread_cleanup_pop_restore
Siddhesh Poyarekar 17b00f
# pragma weak _pthread_cleanup_push
Siddhesh Poyarekar 17b00f
# pragma weak _pthread_cleanup_pop
Siddhesh Poyarekar 17b00f
#endif
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
/* We need portable names for some functions.  E.g., when they are
Siddhesh Poyarekar 17b00f
   used as argument to __libc_cleanup_region_start.  */
Siddhesh Poyarekar 17b00f
#define __libc_mutex_unlock __pthread_mutex_unlock
Siddhesh Poyarekar 17b00f
Siddhesh Poyarekar 17b00f
#endif	/* bits/libc-lock.h */