[MPlayer-dev-eng] [PATCH] use pthreads for cache on cygwin

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Nov 15 23:24:35 CET 2008


On Sat, Nov 15, 2008 at 09:34:56PM +0100, Diego Biurrun wrote:
> On Fri, Nov 14, 2008 at 08:27:55PM +0100, Reimar Döffinger wrote:
> > the "native" thread API for cygwin is pthreads, the threading API we
> > currently use for MinGW is not available for it (my fault for not
> > checking), and the one we used before to the best of my knowledge would
> > have memleaks on cygwin, too.
> > Thus I propose attached patch which uses pthread_create etc.
> > It depends on the PTHREAD_CACHE define so it will be easy to activate on
> > other systems, too (I tested it on Linux, someone on -users tested it
> > for cygwin), but for now will only be used on Cygwin.
> > Any objections to it?
> > 
> > --- stream/cache2.c	(revision 27905)
> > +++ stream/cache2.c	(working copy)
> > @@ -16,15 +16,22 @@
> >  
> > +#ifdef __CYGWIN__
> > +#define PTHREAD_CACHE 1
> > +#endif
> 
> This should be in configure.

I know, I just was not sure about the best logic.
I still don't have Cygwin to test myself, but attached patch would
probably work.
I don't like it much though because it leaves the cache checks a bit spread all
over the place.
-------------- next part --------------
Index: configure
===================================================================
--- configure	(revision 27928)
+++ configure	(working copy)
@@ -696,6 +697,7 @@
 _asmalign_pot=auto
 _stream_cache=yes
 _def_stream_cache="#define CONFIG_STREAM_CACHE 1"
+_def_pthread_cache="#undef PTHREAD_CACHE"
 _need_shmem=yes
 for ac_option do
   case "$ac_option" in
@@ -3070,6 +3086,15 @@
 fi
 echores "$_pthreads"
 
+if cygwin ; then
+  if test "$_pthreads" = yes ; then
+    _def_pthread_cache="#define PTHREAD_CACHE 1"
+  else
+    _stream_cache=no
+    _def_stream_cache="#undef CONFIG_STREAM_CACHE"
+  fi
+fi
+
 echocheck "w32threads"
 if test "$_pthreads" = yes ; then
   _res_comment="using pthread instead"
Index: stream/cache2.c
===================================================================
--- stream/cache2.c	(revision 27930)
+++ stream/cache2.c	(working copy)
@@ -16,10 +16,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#ifdef __CYGWIN__
-#define PTHREAD_CACHE 1
-#endif
-
 #include "osdep/shmem.h"
 #include "osdep/timer.h"
 #if defined(__MINGW32__)


More information about the MPlayer-dev-eng mailing list