OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright 2000, International Business Machines Corporation and others. 00003 * All Rights Reserved. 00004 * 00005 * This software has been released under the terms of the IBM Public 00006 * License. For details, see the LICENSE file in the top-level source 00007 * directory or online at http://www.openafs.org/dl/license10.html 00008 */ 00009 00010 #ifndef AFS_PTHREAD_H 00011 #define AFS_PTHREAD_H 00012 00013 #include <windows.h> 00014 #include <time.h> 00015 #include <afs/errmap_nt.h> 00016 #include <rx/rx_queue.h> 00017 00018 typedef struct { 00019 int call_started; 00020 int call_running; 00021 } pthread_once_t; 00022 00023 #define PTHREAD_CREATE_JOINABLE 1 00024 #define PTHREAD_CREATE_DETACHED 0 00025 00026 typedef struct { 00027 int is_joinable; 00028 } pthread_attr_t; 00029 00030 #define PTHREAD_KEYS_MAX 32 00031 00032 typedef int pthread_condattr_t; 00033 typedef int pthread_mutexattr_t; 00034 typedef int pthread_rwlockattr_t; 00035 typedef int pthread_key_t; 00036 typedef void *pthread_t; 00037 00038 typedef struct timespec { 00039 time_t tv_sec; 00040 long tv_nsec; 00041 } timespec_t; 00042 00043 00044 typedef struct { 00045 DWORD tid; 00046 int isLocked; 00047 CRITICAL_SECTION cs; 00048 } pthread_mutex_t; 00049 00050 typedef struct cond_waiter { 00051 struct rx_queue wait_queue; 00052 HANDLE event; 00053 } cond_waiters_t; 00054 00055 typedef struct { 00056 CRITICAL_SECTION cs; 00057 struct rx_queue waiting_threads; 00058 } pthread_cond_t; 00059 00060 typedef struct { 00061 pthread_mutex_t write_access_mutex; 00062 pthread_mutex_t read_access_completion_mutex; 00063 pthread_cond_t read_access_completion_wait; 00064 int readers; 00065 } pthread_rwlock_t; 00066 00067 #define PTHREAD_ONCE_INIT {0,1} 00068 00069 extern int pthread_cond_broadcast(pthread_cond_t *cond); 00070 extern int pthread_cond_destroy(pthread_cond_t *cond); 00071 extern int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); 00072 extern int pthread_cond_signal(pthread_cond_t *cond); 00073 extern int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); 00074 extern int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime); 00075 extern int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *), void *arg); 00076 extern void *pthread_getspecific(pthread_key_t key); 00077 extern int pthread_join(pthread_t target_thread, void **status); 00078 extern int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value)); 00079 extern int pthread_key_delete(pthread_key_t key); 00080 00081 extern int pthread_mutex_destroy(pthread_mutex_t *mp); 00082 extern int pthread_mutex_init(pthread_mutex_t *mp, const pthread_mutexattr_t *attr); 00083 extern int pthread_mutex_lock(pthread_mutex_t *mp); 00084 extern int pthread_mutex_trylock(pthread_mutex_t *mp); 00085 extern int pthread_mutex_unlock(pthread_mutex_t *mp); 00086 00087 extern int pthread_rwlock_destroy(pthread_rwlock_t *rwp); 00088 extern int pthread_rwlock_init(pthread_rwlock_t *rwp, const pthread_rwlockattr_t *attr); 00089 extern int pthread_rwlock_rdlock(pthread_rwlock_t *rwp); 00090 extern int pthread_rwlock_wrlock(pthread_rwlock_t *rwp); 00091 extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwp); 00092 extern int pthread_rwlock_trywrlock(pthread_rwlock_t *rwp); 00093 extern int pthread_rwlock_unlock(pthread_rwlock_t *rwp); 00094 00095 extern int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)); 00096 extern int pthread_setspecific(pthread_key_t key, const void *value); 00097 extern pthread_t pthread_self(void); 00098 extern int pthread_equal(pthread_t t1, pthread_t t2); 00099 extern int pthread_attr_destroy(pthread_attr_t *attr); 00100 extern int pthread_attr_init(pthread_attr_t *attr); 00101 extern int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate); 00102 extern int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); 00103 extern void pthread_exit(void *status); 00104 00105 #endif