1 /* pthread.h: POSIX pthread interface 2 3 Copyright 1996, 1997, 1998 Cygnus Solutions. 4 5 Written by Marco Fuykschot <marco@ddi.nl> 6 7 This file is part of Cygwin. 8 9 This software is a copyrighted work licensed under the terms of the 10 Cygwin license. Please consult the file "CYGWIN_LICENSE" for 11 details. */ 12 13 #include <sys/types.h> 14 #include <signal.h> 15 16 #ifndef _PTHREAD_H 17 #define _PTHREAD_H 18 19 #ifdef __cplusplus 20 extern "C" 21 { 22 #endif 23 24 #define TFD(n) void*(*n)(void*) 25 26 typedef int pthread_t; 27 typedef int pthread_mutex_t; 28 typedef int sem_t; 29 30 typedef struct pthread_key 31 { 32 } 33 pthread_key_t; 34 35 typedef struct pthread_attr 36 { 37 size_t stacksize; 38 } 39 pthread_attr_t; 40 41 typedef struct pthread_mutexattr 42 { 43 } 44 pthread_mutexattr_t; 45 46 /* ThreadCreation */ 47 int pthread_create (pthread_t * thread, const pthread_attr_t * attr, TFD (function), void *arg); 48 int pthread_attr_init (pthread_attr_t * attr); 49 int pthread_attr_destroy (pthread_attr_t * attr); 50 int pthread_attr_setstacksize (pthread_attr_t * attr, size_t size); 51 int pthread_attr_getstacksize (pthread_attr_t * attr, size_t * size); 52 53 /* Thread Control */ 54 int pthread_detach (pthread_t thread); 55 int pthread_join (pthread_t thread, void **value_ptr); 56 57 /* Thread Exit */ 58 int pthread_exit (void *value_ptr); 59 60 /* Thread SpecificData */ 61 int pthread_key_create (pthread_key_t * key); 62 int pthread_key_delete (pthread_key_t * key); 63 int pthread_setspecific (pthread_key_t * key, const void *value); 64 void *pthread_getspecific (pthread_key_t * key); 65 66 /* Thread signal */ 67 int pthread_kill (pthread_t * thread, int sig); 68 int pthread_sigmask (int operation, const sigset_t * set, sigset_t * old_set); 69 70 /* ID */ 71 pthread_t pthread_self (); 72 int pthread_equal (pthread_t t1, pthread_t t2); 73 74 /* Mutexes */ 75 int pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t *); 76 int pthread_mutex_lock (pthread_mutex_t * mutext); 77 int pthread_mutex_trylock (pthread_mutex_t * mutext); 78 int pthread_mutex_unlock (pthread_mutex_t * mutext); 79 int pthread_mutex_destroy (pthread_mutex_t * mutext); 80 81 /* Solaris Semaphores */ 82 int sem_init (sem_t * sem, int pshared, unsigned int value); 83 int sem_destroy (sem_t * sem); 84 int sem_wait (sem_t * sem); 85 int sem_trywait (sem_t * sem); 86 int sem_post (sem_t * sem); 87 88 #ifdef __cplusplus 89 } 90 #endif 91 92 #endif /* _PTHREAD_H */ |