1  /* Declaration of libc stubs for pthread functions.  Hurd version.
       2     Copyright (C) 2003-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library;  if not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #ifndef _PTHREAD_FUNCTIONS_H
      20  #define _PTHREAD_FUNCTIONS_H	1
      21  
      22  #include <pthread.h>
      23  
      24  int __pthread_attr_destroy (pthread_attr_t *);
      25  int __pthread_attr_init (pthread_attr_t *);
      26  int __pthread_attr_getdetachstate (const pthread_attr_t *, int *);
      27  int __pthread_attr_setdetachstate (pthread_attr_t *, int);
      28  int __pthread_attr_getinheritsched (const pthread_attr_t *, int *);
      29  int __pthread_attr_setinheritsched (pthread_attr_t *, int);
      30  int __pthread_attr_getschedparam (const pthread_attr_t *,
      31  				 struct sched_param *);
      32  int __pthread_attr_setschedparam (pthread_attr_t *,
      33  				 const struct sched_param *);
      34  int __pthread_attr_getschedpolicy (const pthread_attr_t *, int *);
      35  int __pthread_attr_setschedpolicy (pthread_attr_t *, int);
      36  int __pthread_attr_getscope (const pthread_attr_t *, int *);
      37  int __pthread_attr_setscope (pthread_attr_t *, int);
      38  int __pthread_condattr_destroy (pthread_condattr_t *);
      39  int __pthread_condattr_init (pthread_condattr_t *);
      40  int __pthread_cond_broadcast (pthread_cond_t *);
      41  int __pthread_cond_destroy (pthread_cond_t *);
      42  int __pthread_cond_init (pthread_cond_t *,
      43  		       const pthread_condattr_t *);
      44  int __pthread_cond_signal (pthread_cond_t *);
      45  int __pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *);
      46  int __pthread_cond_timedwait (pthread_cond_t *, pthread_mutex_t *,
      47  			     const struct timespec *);
      48  int __pthread_equal (pthread_t, pthread_t);
      49  void __pthread_exit (void *) __attribute__ ((__noreturn__));
      50  int __pthread_getschedparam (pthread_t, int *, struct sched_param *);
      51  int __pthread_setschedparam (pthread_t, int,
      52  			    const struct sched_param *);
      53  int _pthread_mutex_destroy (pthread_mutex_t *);
      54  int _pthread_mutex_init (pthread_mutex_t *,
      55  			 const pthread_mutexattr_t *);
      56  int __pthread_mutex_lock (pthread_mutex_t *);
      57  int __pthread_mutex_trylock (pthread_mutex_t *);
      58  int __pthread_mutex_unlock (pthread_mutex_t *);
      59  int __pthread_setcancelstate (int, int *);
      60  int __pthread_setcanceltype (int, int *);
      61  struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void);
      62  int __pthread_once (pthread_once_t *, void (*) (void));
      63  int __pthread_rwlock_rdlock (pthread_rwlock_t *);
      64  int __pthread_rwlock_wrlock (pthread_rwlock_t *);
      65  int __pthread_rwlock_unlock (pthread_rwlock_t *);
      66  int __pthread_key_create (pthread_key_t *, void (*) (void *));
      67  void *__pthread_getspecific (pthread_key_t);
      68  int __pthread_setspecific (pthread_key_t, const void *);
      69  
      70  void _cthreads_flockfile (FILE *);
      71  void _cthreads_funlockfile (FILE *);
      72  int _cthreads_ftrylockfile (FILE *);
      73  
      74  /* Data type shared with libc.  The libc uses it to pass on calls to
      75     the thread functions.  Wine pokes directly into this structure,
      76     so if possible avoid breaking it and append new hooks to the end.  */
      77  struct pthread_functions
      78  {
      79    int (*ptr_pthread_attr_destroy) (pthread_attr_t *);
      80    int (*ptr_pthread_attr_init) (pthread_attr_t *);
      81    int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *);
      82    int (*ptr_pthread_attr_setdetachstate) (pthread_attr_t *, int);
      83    int (*ptr_pthread_attr_getinheritsched) (const pthread_attr_t *, int *);
      84    int (*ptr_pthread_attr_setinheritsched) (pthread_attr_t *, int);
      85    int (*ptr_pthread_attr_getschedparam) (const pthread_attr_t *,
      86  					 struct sched_param *);
      87    int (*ptr_pthread_attr_setschedparam) (pthread_attr_t *,
      88  					 const struct sched_param *);
      89    int (*ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *);
      90    int (*ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int);
      91    int (*ptr_pthread_attr_getscope) (const pthread_attr_t *, int *);
      92    int (*ptr_pthread_attr_setscope) (pthread_attr_t *, int);
      93    int (*ptr_pthread_condattr_destroy) (pthread_condattr_t *);
      94    int (*ptr_pthread_condattr_init) (pthread_condattr_t *);
      95    int (*ptr_pthread_cond_broadcast) (pthread_cond_t *);
      96    int (*ptr_pthread_cond_destroy) (pthread_cond_t *);
      97    int (*ptr_pthread_cond_init) (pthread_cond_t *,
      98  			       const pthread_condattr_t *);
      99    int (*ptr_pthread_cond_signal) (pthread_cond_t *);
     100    int (*ptr_pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *);
     101    int (*ptr_pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
     102  				     const struct timespec *);
     103    int (*ptr_pthread_equal) (pthread_t, pthread_t);
     104    void (*ptr___pthread_exit) (void *) __attribute__ ((__noreturn__));
     105    int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
     106    int (*ptr_pthread_setschedparam) (pthread_t, int,
     107  				    const struct sched_param *);
     108    int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *);
     109    int (*ptr_pthread_mutex_init) (pthread_mutex_t *,
     110  				 const pthread_mutexattr_t *);
     111    int (*ptr_pthread_mutex_lock) (pthread_mutex_t *);
     112    int (*ptr_pthread_mutex_trylock) (pthread_mutex_t *);
     113    int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *);
     114    int (*ptr___pthread_setcancelstate) (int, int *);
     115    int (*ptr_pthread_setcanceltype) (int, int *);
     116    struct __pthread_cancelation_handler **(*ptr___pthread_get_cleanup_stack) (void);
     117    int (*ptr_pthread_once) (pthread_once_t *, void (*) (void));
     118    int (*ptr_pthread_rwlock_rdlock) (pthread_rwlock_t *);
     119    int (*ptr_pthread_rwlock_wrlock) (pthread_rwlock_t *);
     120    int (*ptr_pthread_rwlock_unlock) (pthread_rwlock_t *);
     121    int (*ptr___pthread_key_create) (pthread_key_t *, void (*) (void *));
     122    void *(*ptr___pthread_getspecific) (pthread_key_t);
     123    int (*ptr___pthread_setspecific) (pthread_key_t, const void *);
     124    void (*ptr__IO_flockfile) (FILE *);
     125    void (*ptr__IO_funlockfile) (FILE *);
     126    int (*ptr__IO_ftrylockfile) (FILE *);
     127  };
     128  
     129  /* Variable in libc.so.  */
     130  extern struct pthread_functions __libc_pthread_functions attribute_hidden;
     131  extern int __libc_pthread_functions_init attribute_hidden;
     132  
     133  void __libc_pthread_init (const struct pthread_functions *functions);
     134  
     135  #define PTHFCT_CALL(fct, params) \
     136      __libc_pthread_functions.fct params
     137  
     138  #endif	/* pthread-functions.h */