DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_pthread.h00001 /*****************************************************************************/ 00002 // Copyright 2002-2008 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_pthread.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 00013 00014 /*****************************************************************************/ 00015 00016 #ifndef __dng_pthread__ 00017 #define __dng_pthread__ 00018 00019 /*****************************************************************************/ 00020 00021 #include "dng_flags.h" 00022 00023 /*****************************************************************************/ 00024 00025 #if !qWinOS 00026 00027 /*****************************************************************************/ 00028 00029 /* Try generic POSIX compile */ 00030 00031 #include <sys/errno.h> 00032 #include <pthread.h> 00033 00034 #define dng_pthread_disassociate() 00035 00036 /*****************************************************************************/ 00037 00038 #else 00039 00040 /*****************************************************************************/ 00041 00042 #include <stdlib.h> 00043 00044 #ifdef __cplusplus 00045 extern "C" 00046 { 00047 #endif 00048 00049 /*****************************************************************************/ 00050 00051 #define DNG_ETIMEDOUT 60 /* Operation timed out */ 00052 00053 struct dng_timespec { 00054 long tv_sec; 00055 long tv_nsec; 00056 }; 00057 00058 00059 typedef unsigned long dng_pthread_t; 00060 00061 typedef struct dng_pthread_mutex_impl *dng_pthread_mutex_t; 00062 typedef struct dng_pthread_cond_impl *dng_pthread_cond_t; 00063 typedef unsigned long dng_pthread_key_t; 00064 00065 00066 #define DNG_PTHREAD_MUTEX_INITIALIZER ((struct dng_pthread_mutex_impl *)-1) 00067 #define DNG_PTHREAD_COND_INITIALIZER ((struct dng_pthread_cond_impl *)-1) 00068 00069 struct _dng_pthread_once_t { 00070 int inited; 00071 long semaphore; 00072 }; 00073 00074 typedef struct _dng_pthread_once_t dng_pthread_once_t; 00075 #define DNG_PTHREAD_ONCE_INIT { 0, -1 } 00076 00077 #define dng_pthread_equal(t1, t2) ((t1) == (t2)) 00078 00079 typedef struct dng_pthread_attr_impl *dng_pthread_attr_t; 00080 00081 int dng_pthread_attr_init(dng_pthread_attr_t *attr); 00082 int dng_pthread_attr_destroy(dng_pthread_attr_t *attr); 00083 00084 int dng_pthread_attr_setstacksize(dng_pthread_attr_t *attr, size_t stacksize); 00085 int dng_pthread_attr_getstacksize(const dng_pthread_attr_t *attr, size_t *stacksize); 00086 00087 int dng_pthread_create(dng_pthread_t *thread, const dng_pthread_attr_t * /* attrs */, void * (*func)(void *), void *arg); 00088 int dng_pthread_detach(dng_pthread_t thread); 00089 int dng_pthread_join(dng_pthread_t thread, void **result); 00090 dng_pthread_t dng_pthread_self(); 00091 void dng_pthread_exit(void *result); 00092 00093 #define DNG_PTHREAD_MUTEX_RECURSIVE 0 00094 typedef unsigned long dng_pthread_mutexattr_t; 00095 00096 int dng_pthread_mutexattr_init(dng_pthread_mutexattr_t *mutexattr); 00097 int dng_pthread_mutexattr_settype(dng_pthread_mutexattr_t *mutexattr, int /*the options*/); 00098 00099 int dng_pthread_mutex_init(dng_pthread_mutex_t *mutex, void * /* attrs */); 00100 int dng_pthread_mutex_destroy(dng_pthread_mutex_t *mutex); 00101 int dng_pthread_mutex_lock(dng_pthread_mutex_t *mutex); 00102 int dng_pthread_mutex_unlock(dng_pthread_mutex_t *mutex); 00103 00104 int dng_pthread_cond_init(dng_pthread_cond_t *cond, void * /* attrs */); 00105 int dng_pthread_cond_destroy(dng_pthread_cond_t *cond); 00106 int dng_pthread_cond_wait(dng_pthread_cond_t *cond, dng_pthread_mutex_t *mutex); 00107 int dng_pthread_cond_timedwait(dng_pthread_cond_t *cond, dng_pthread_mutex_t *mutex, struct dng_timespec *latest_time); 00108 int dng_pthread_cond_signal(dng_pthread_cond_t *cond); 00109 int dng_pthread_cond_broadcast(dng_pthread_cond_t *cond); 00110 00111 int dng_pthread_once(dng_pthread_once_t *once, void (*init_func)()); 00112 00113 int dng_pthread_key_create(dng_pthread_key_t * key, void (*destructor) (void *)); 00114 int dng_pthread_key_delete(dng_pthread_key_t key); 00115 int dng_pthread_setspecific(dng_pthread_key_t key, const void *value); 00116 void *dng_pthread_getspecific(dng_pthread_key_t key); 00117 00118 typedef struct dng_pthread_rwlock_impl *dng_pthread_rwlock_t; 00119 typedef void *pthread_rwlockattr_t; 00120 00121 int dng_pthread_rwlock_destroy(dng_pthread_rwlock_t * rwlock); 00122 int dng_pthread_rwlock_init(dng_pthread_rwlock_t * rwlock, const pthread_rwlockattr_t * attrs); 00123 int dng_pthread_rwlock_rdlock(dng_pthread_rwlock_t * rwlock); 00124 int dng_pthread_rwlock_tryrdlock(dng_pthread_rwlock_t * rwlock); 00125 int dng_pthread_rwlock_trywrlock(dng_pthread_rwlock_t * rwlock); 00126 int dng_pthread_rwlock_unlock(dng_pthread_rwlock_t * rwlock); 00127 int dng_pthread_rwlock_wrlock(dng_pthread_rwlock_t * rwlock); 00128 00129 typedef struct dng_pthread_rwlock_impl *dng_pthread_rwlock_t; 00130 typedef void *pthread_rwlockattr_t; 00131 00132 int dng_pthread_rwlock_destroy(dng_pthread_rwlock_t * rwlock); 00133 int dng_pthread_rwlock_init(dng_pthread_rwlock_t * rwlock, const pthread_rwlockattr_t * attrs); 00134 int dng_pthread_rwlock_rdlock(dng_pthread_rwlock_t * rwlock); 00135 int dng_pthread_rwlock_tryrdlock(dng_pthread_rwlock_t * rwlock); 00136 int dng_pthread_rwlock_trywrlock(dng_pthread_rwlock_t * rwlock); 00137 int dng_pthread_rwlock_unlock(dng_pthread_rwlock_t * rwlock); 00138 int dng_pthread_rwlock_wrlock(dng_pthread_rwlock_t * rwlock); 00139 00140 // dng_pthread may maintain per-thread global state. This routine frees that global state. 00141 // there is no need to call this for threads created by dng_pthread and one can call 00142 // dng_pthread routines of a thread after dng_pthread_disassociate as the global state will 00143 // be recreated as necessary. However dng_pthread_disassociate will need to be called again 00144 // and there is a slight performance cost. Do not call this routine while holding a mutex, etc. 00145 void dng_pthread_disassociate (); 00146 00147 /*****************************************************************************/ 00148 00149 // Map symbols back to plain pthread names. This whole mechanism is so the DNG pthreads library 00150 // symbols do not collide with another pthread emulation library 00151 // that may be in use in the same linked entity. However if that is the case, it would be far better 00152 // to have the DNG code use the same pthread library as the rest of the code. 00153 00154 #define pthread_t dng_pthread_t 00155 #define pthread_mutex_t dng_pthread_mutex_t 00156 #define pthread_cond_t dng_pthread_cond_t 00157 #define pthread_once_t dng_pthread_once_t 00158 #define pthread_key_t dng_pthread_key_t 00159 00160 #undef PTHREAD_MUTEX_INITIALIZER 00161 #define PTHREAD_MUTEX_INITIALIZER DNG_PTHREAD_MUTEX_INITIALIZER 00162 #undef PTHREAD_COND_INITIALIZER 00163 #define PTHREAD_COND_INITIALIZER DNG_PTHREAD_COND_INITIALIZER 00164 00165 #undef PTHREAD_ONCE_INIT 00166 #define PTHREAD_ONCE_INIT DNG_PTHREAD_ONCE_INIT 00167 00168 #define timespec dng_timespec 00169 00170 /* If it is defined on Windows, it probably has the wrong value... */ 00171 #if defined(WIN32) || !defined(ETIMEDOUT) 00172 #define ETIMEDOUT DNG_ETIMEDOUT 00173 #endif 00174 00175 #define pthread_equal dng_pthread_equal 00176 00177 #define pthread_attr_t dng_pthread_attr_t 00178 00179 #define pthread_attr_init dng_pthread_attr_init 00180 #define pthread_attr_destroy dng_pthread_attr_destroy 00181 00182 #define pthread_attr_setstacksize dng_pthread_attr_setstacksize 00183 #define pthread_attr_getstacksize dng_pthread_attr_getstacksize 00184 00185 #define pthread_create dng_pthread_create 00186 #define pthread_detach dng_pthread_detach 00187 #define pthread_join dng_pthread_join 00188 #define pthread_self dng_pthread_self 00189 #define pthread_exit dng_pthread_exit 00190 00191 #define pthread_mutex_init dng_pthread_mutex_init 00192 #define pthread_mutex_destroy dng_pthread_mutex_destroy 00193 #define pthread_mutex_lock dng_pthread_mutex_lock 00194 #define pthread_mutex_unlock dng_pthread_mutex_unlock 00195 00196 #define pthread_cond_init dng_pthread_cond_init 00197 #define pthread_cond_destroy dng_pthread_cond_destroy 00198 #define pthread_cond_wait dng_pthread_cond_wait 00199 #define pthread_cond_timedwait dng_pthread_cond_timedwait 00200 #define pthread_cond_signal dng_pthread_cond_signal 00201 #define pthread_cond_broadcast dng_pthread_cond_broadcast 00202 00203 #define pthread_once dng_pthread_once 00204 00205 #define pthread_key_create dng_pthread_key_create 00206 #define pthread_key_delete dng_pthread_key_delete 00207 #define pthread_setspecific dng_pthread_setspecific 00208 #define pthread_getspecific dng_pthread_getspecific 00209 00210 #define pthread_rwlock_t dng_pthread_rwlock_t 00211 00212 #define pthread_rwlock_destroy dng_pthread_rwlock_destroy 00213 #define pthread_rwlock_init dng_pthread_rwlock_init 00214 #define pthread_rwlock_rdlock dng_pthread_rwlock_rdlock 00215 #define pthread_rwlock_tryrdlock dng_pthread_rwlock_tryrdlock 00216 #define pthread_rwlock_trywrlock dng_pthread_rwlock_trywrlock 00217 #define pthread_rwlock_unlock dng_pthread_rwlock_unlock 00218 #define pthread_rwlock_wrlock dng_pthread_rwlock_wrlock 00219 00220 /*****************************************************************************/ 00221 00222 #ifdef __cplusplus 00223 } 00224 #endif 00225 00226 /*****************************************************************************/ 00227 00228 #endif 00229 00230 /*****************************************************************************/ 00231 00232 #ifdef __cplusplus 00233 extern "C" 00234 { 00235 #endif 00236 00237 int dng_pthread_now (struct timespec *now); 00238 00239 #ifdef __cplusplus 00240 } 00241 #endif 00242 00243 /*****************************************************************************/ 00244 00245 #endif 00246 00247 /*****************************************************************************/ | |||
