On Sun, 24 Apr 2011, Enlightenment SVN wrote:
> Log: > eina: put global into namespace and add lock abort > > > Author: cedric > Date: 2011-04-24 13:22:17 -0700 (Sun, 24 Apr 2011) > New Revision: 58875 > Trac: http://trac.enlightenment.org/e/changeset/58875 > > Modified: > trunk/eina/src/include/eina_inline_lock_posix.x > trunk/eina/src/lib/eina_main.c > > Modified: trunk/eina/src/include/eina_inline_lock_posix.x > =================================================================== > --- trunk/eina/src/include/eina_inline_lock_posix.x 2011-04-24 20:21:07 UTC > (rev 58874) > +++ trunk/eina/src/include/eina_inline_lock_posix.x 2011-04-24 20:22:17 UTC > (rev 58875) > @@ -23,12 +23,29 @@ > > typedef pthread_mutex_t Eina_Lock; > > -EAPI extern Eina_Bool _threads_activated; > +EAPI extern Eina_Bool _eina_threads_activated; you forgot to update other lock files (win32 and wince) Vincent > > +#ifdef EINA_HAVE_DEBUG_THREADS > +# include <sys/time.h> > + > +EAPI extern int _eina_threads_debug; > +#endif > + > static inline Eina_Bool > eina_lock_new(Eina_Lock *mutex) > { > - return (pthread_mutex_init(mutex, NULL) == 0) ? EINA_TRUE : EINA_FALSE; > + pthread_mutexattr_t attr; > + > + if (pthread_mutexattr_init(&attr) != 0) > + return EINA_FALSE; > + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) > + return EINA_FALSE; > + if (pthread_mutex_init(mutex, &attr) != 0) > + return EINA_FALSE; > + > + pthread_mutexattr_destroy(&attr); > + > + return EINA_TRUE; > } > > static inline void > @@ -40,15 +57,37 @@ > static inline Eina_Bool > eina_lock_take(Eina_Lock *mutex) > { > - if (_threads_activated) > - return (pthread_mutex_lock(mutex) == 0) ? EINA_TRUE : EINA_FALSE; > + if (_eina_threads_activated) > + { > +#ifdef EINA_HAVE_DEBUG_THREADS > + if (_eina_threads_debug) > + { > + struct timeval t0, t1; > + int dt; > + > + gettimeofday(&t0, NULL); > + pthread_mutex_lock(&(x)); > + gettimeofday(&t1, NULL); > + > + dt = (t1.tv_sec - t0.tv_sec) * 1000000; > + if (t1.tv_usec > t0.tv_usec) > + dt += (t1.tv_usec - t0.tv_usec); > + else > + dt -= t0.tv_usec - t1.tv_usec; > + dt /= 1000; > + > + if (dt > _eina_threads_debug) abort(); > + } > +#endif > + return (pthread_mutex_lock(mutex) == 0) ? EINA_TRUE : EINA_FALSE; > + } > return EINA_FALSE; > } > > static inline Eina_Bool > eina_lock_take_try(Eina_Lock *mutex) > { > - if (_threads_activated) > + if (_eina_threads_activated) > return (pthread_mutex_trylock(mutex) == 0) ? EINA_TRUE : EINA_FALSE; > return EINA_FALSE; > } > @@ -56,7 +95,7 @@ > static inline Eina_Bool > eina_lock_release(Eina_Lock *mutex) > { > - if (_threads_activated) > + if (_eina_threads_activated) > return (pthread_mutex_unlock(mutex) == 0) ? EINA_TRUE : EINA_FALSE; > return EINA_FALSE; > } > > Modified: trunk/eina/src/lib/eina_main.c > =================================================================== > --- trunk/eina/src/lib/eina_main.c 2011-04-24 20:21:07 UTC (rev 58874) > +++ trunk/eina/src/lib/eina_main.c 2011-04-24 20:22:17 UTC (rev 58875) > @@ -74,8 +74,12 @@ > #endif > #define DBG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__) > > -EAPI Eina_Bool _threads_activated = EINA_FALSE; > +EAPI Eina_Bool _eina_threads_activated = EINA_FALSE; > > +#ifdef EINA_HAVE_DEBUG_THREADS > +EAPI int _eina_threads_debug = 0; > +#endif > + > static Eina_Lock _mutex; > > /* place module init/shutdown functions here to avoid other modules > @@ -213,6 +217,10 @@ > } > > eina_lock_new(&_mutex); > +#ifdef EINA_HAVE_DEBUG_THREADS > + if (getenv("EINA_DEBUG_THREADS")) > + _eina_threads_debug = atoi(getenv("EINA_DEBUG_THREADS"); > +#endif > > _eina_main_count = 1; > return 1; > @@ -252,7 +260,7 @@ > > eina_share_common_threads_init(); > eina_log_threads_init(); > - _threads_activated = EINA_TRUE; > + _eina_threads_activated = EINA_TRUE; > > eina_lock_release(&_mutex); > > @@ -281,7 +289,7 @@ > > eina_lock_release(&_mutex); > > - _threads_activated = EINA_FALSE; > + _eina_threads_activated = EINA_FALSE; > > return ret; > #else > > > ------------------------------------------------------------------------------ > Fulfilling the Lean Software Promise > Lean software platforms are now widely adopted and the benefits have been > demonstrated beyond question. Learn why your peers are replacing JEE > containers with lightweight application servers - and what you can gain > from the move. http://p.sf.net/sfu/vmware-sfemails > _______________________________________________ > enlightenment-svn mailing list > enlightenment-...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > > ------------------------------------------------------------------------------ Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel