Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1:/tmp/cvs-serv8043/source
Modified Files: flext.h flsupport.cpp flsupport.h flthr.cpp Log Message: ""
Index: flext.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flext.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** flext.h 12 Dec 2003 22:46:40 -0000 1.18 --- flext.h 27 Dec 2003 03:32:55 -0000 1.19 *************** *** 24,31 ****
//! \brief flext version number ! #define FLEXT_VERSION 405
//! \brief flext version string ! #define FLEXT_VERSTR "0.4.5"
//! @} --- 24,31 ----
//! \brief flext version number ! #define FLEXT_VERSION 406
//! \brief flext version string ! #define FLEXT_VERSTR "0.4.6pre"
//! @}
Index: flsupport.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** flsupport.cpp 10 Dec 2003 03:32:53 -0000 1.26 --- flsupport.cpp 27 Dec 2003 03:32:55 -0000 1.27 *************** *** 36,39 **** --- 36,40 ---- const char *flext::VersionStr() { return FLEXT_VERSTR; }
+ void flext::Setup() { *************** *** 69,72 **** --- 70,113 ----
#ifdef FLEXT_THREADS + + #if FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_MAC && FLEXT_THREADS == FLEXT_THR_POSIX + // for Max OSX/CFM MachO functions have to be imported + CFBundleRef bundle = NULL; + if (bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon"))) + { + //load pthread function pointers + pthread_self = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_self")); + pthread_equal = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_equal")); + pthread_create = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_create")); + pthread_cancel = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_cancel")); + pthread_testcancel = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_testcancel")); + pthread_join = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_join")); + pthread_exit = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_exit")); + + pthread_attr_init = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_attr_init")); + pthread_attr_destroy = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_attr_destroy")); + pthread_attr_setdetachstate = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_attr_setdetachstate")); + + pthread_attr_getschedparam = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_attr_getschedparam")); + pthread_attr_setschedparam = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_attr_setschedparam")); + + pthread_mutex_init = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_mutex_init")); + pthread_mutex_destroy = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_mutex_destroy")); + pthread_mutex_lock = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_mutex_lock")); + pthread_mutex_unlock = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_mutex_unlock")); + pthread_mutex_trylock = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_mutex_trylock")); + + pthread_cond_init = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_cond_init")); + pthread_cond_destroy = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_cond_destroy")); + pthread_cond_signal = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_cond_signal")); + pthread_cond_wait = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_cond_wait")); + pthread_cond_timedwait = CFBundleGetFunctionPointerForName(bundle, CFSTR("pthread_cond_timedwait")); + + sched_yield = CFBundleGetFunctionPointerForName(bundle, CFSTR("sched_yield")); + sched_get_priority_min = CFBundleGetFunctionPointerForName(bundle, CFSTR("sched_get_priority_min")); + sched_get_priority_max = CFBundleGetFunctionPointerForName(bundle, CFSTR("sched_get_priority_max")); + } + #endif + thrid = GetThreadId(); StartHelper();
Index: flsupport.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** flsupport.h 12 Dec 2003 22:46:40 -0000 1.60 --- flsupport.h 27 Dec 2003 03:32:55 -0000 1.61 *************** *** 650,653 **** --- 650,688 ---- */
+ #if FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_MAC && FLEXT_THREADS == FLEXT_THR_POSIX + // These are function pointers of MachO functions imported to the CFM world + + static pthread_t (*pthread_self)(); + static int (*pthread_equal)(pthread_t,pthread_t); + static int (*pthread_create)(pthread_t *,const pthread_attr_t *,void *(*)(void *),void *); + static int (*pthread_cancel)(pthread_t); + static void (*pthread_testcancel)(void); + static int (*pthread_join)(pthread_t,void **); + static void (*pthread_exit)(void *); + + static int (*pthread_attr_init)(pthread_attr_t *); + static int (*pthread_attr_destroy)(pthread_attr_t *); + static int (*pthread_attr_setdetachstate)(pthread_attr_t *,int); + + static int (*pthread_getschedparam)(pthread_t,int *,struct sched_param *); + static int (*pthread_setschedparam)(pthread_t,int,const struct sched_param *); + + static int (*pthread_mutex_init)(pthread_mutex_t *,const pthread_mutexattr_t *); + static int (*pthread_mutex_destroy)(pthread_mutex_t *); + static int (*pthread_mutex_lock)(pthread_mutex_t *); + static int (*pthread_mutex_unlock)(pthread_mutex_t *); + static int (*pthread_mutex_trylock)(pthread_mutex_t *); + + static int (*pthread_cond_init)(pthread_cond_t *,const pthread_condattr_t *); + static int (*pthread_cond_destroy)(pthread_cond_t *); + static int (*pthread_cond_signal)(pthread_cond_t *); + static int (*pthread_cond_wait)(pthread_cond_t *,pthread_mutex_t *); + static int (*pthread_cond_timedwait)(pthread_cond_t *,pthread_mutex_t *,const struct timespec *); + + static int (*sched_yield)(void); + static int (*sched_get_priority_min)(int); + static int (*sched_get_priority_max)(int); + #endif + //! thread type #if FLEXT_THREADS == FLEXT_THR_MP
Index: flthr.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flthr.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** flthr.cpp 12 Dec 2003 22:46:40 -0000 1.22 --- flthr.cpp 27 Dec 2003 03:32:55 -0000 1.23 *************** *** 51,54 **** --- 51,77 ----
+ #if defined(FLEXT_THREADS) && FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_MAC && FLEXT_THREADS == FLEXT_THR_POSIX + // utility code taken from from Apple's CFM_MachO_CFM example: + // + // This function allocates a block of CFM glue code which contains the instructions to call CFM routines + // + (void (*)(void *))MachOFunctionPointerForCFMFunctionPointer( (void (*)(void *))cfmfp ) + { + // Apple utility code for CFM callback glue + static const UInt32 tmpl[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420}; + UInt32 *mfp = (UInt32*) NewPtr( sizeof(tmpl) ); // Must later dispose of allocated memory + // (this is freed with app heap in this object) + mfp[0] = tmpl[0] | ((UInt32)cfmfp >> 16); + mfp[1] = tmpl[1] | ((UInt32)cfmfp & 0xFFFF); + mfp[2] = tmpl[2]; + mfp[3] = tmpl[3]; + mfp[4] = tmpl[4]; + mfp[5] = tmpl[5]; + MakeDataExecutable( mfp, sizeof(tmpl) ); + return (void (*)(void *))mfp; + } + #endif + + flext::thrid_t flext::GetSysThreadId() { return thrid; }
*************** *** 78,82 **** --- 101,110 ----
thrhelpexit = false; + #if FLEXT_SYS == FLEXT_SYS_MAX && FLEXT_OS == FLEXT_OS_MAC + void (*CFMThrHelper)(void *) = MachOFunctionPointerForCFMFunctionPointer(ThrHelper); + int ret = pthread_create (&thrhelpid,&attr,(void *(*)(void *))CFMThrHelper,NULL); + #else int ret = pthread_create (&thrhelpid,&attr,(void *(*)(void *))ThrHelper,NULL); + #endif ok = !ret; #elif FLEXT_THREADS == FLEXT_THR_MP *************** *** 100,103 **** --- 128,135 ---- // we are ready for threading now! } + + #if FLEXT_THREADS == FLEXT_THR_POSIX + pthread_attr_destroy(&attr); + #endif return ok; } *************** *** 191,194 **** --- 223,230 ---- delete thrhelpcond; thrhelpcond = NULL; + + #if FLEXT_THREADS == FLEXT_THR_POSIX + pthread_attr_destroy(&attr); + #endif }