[MPlayer-users] build error (not sure if this is the right list)

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Nov 13 17:01:25 CET 2008


Hello,
On Thu, Nov 13, 2008 at 04:55:35AM -0800, Steven Miller wrote:
> ... so let me know if there is another list this post should be on. I'm trying to build svn version (dated yesterday) on the latest version of cygwin. All is well until the final linking stage, the actual error is 
> 
> stream/cache2.o:cache2.c:(.text+0x5c1): undefined reference to `__beginthread'
> stream/cache2.o:cache2.c:(.text+0x122a): undefined reference to `__endthread'
> collect2: ld returned 1 exit status
> make: *** [mplayer.exe] Error 1

Seems cygwin's official thread API is pthreads, so try attached patch
(probably better without --disable-pthreads).

Greetings,
Reimar Doeffinger
-------------- next part --------------
Index: stream/cache2.c
===================================================================
--- stream/cache2.c	(revision 27905)
+++ stream/cache2.c	(working copy)
@@ -16,15 +16,22 @@
 #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__) || defined(__CYGWIN__)
+#if defined(__MINGW32__)
 #include <windows.h>
 static void ThreadProc( void *s );
 #elif defined(__OS2__)
 #define INCL_DOS
 #include <os2.h>
 static void ThreadProc( void *s );
+#elif defined(PTHREAD_CACHE)
+#include <pthread.h>
+static void *ThreadProc(void *s);
 #else
 #include <sys/wait.h>
 #endif
@@ -33,6 +40,7 @@
 #include "help_mp.h"
 
 #include "stream.h"
+#include "cache2.h"
 extern int use_gui;
 
 int stream_fill_buffer(stream_t *s);
@@ -244,7 +252,7 @@
 
 cache_vars_t* cache_init(int size,int sector){
   int num;
-#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__)
+#if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__)
   cache_vars_t* s=shmem_alloc(sizeof(cache_vars_t));
 #else
   cache_vars_t* s=malloc(sizeof(cache_vars_t));
@@ -258,14 +266,14 @@
   }//32kb min_size
   s->buffer_size=num*sector;
   s->sector_size=sector;
-#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__)
+#if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__)
   s->buffer=shmem_alloc(s->buffer_size);
 #else
   s->buffer=malloc(s->buffer_size);
 #endif
 
   if(s->buffer == NULL){
-#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__)
+#if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__)
     shmem_free(s,sizeof(cache_vars_t));
 #else
     free(s);
@@ -281,14 +289,14 @@
 void cache_uninit(stream_t *s) {
   cache_vars_t* c = s->cache_data;
   if(!s->cache_pid) return;
-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(__MINGW32__) || defined(PTHREAD_CACHE) || defined(__OS2__)
   cache_do_control(s, -2, NULL);
 #else
   kill(s->cache_pid,SIGKILL);
   waitpid(s->cache_pid,NULL,0);
 #endif
   if(!c) return;
-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(__MINGW32__) || defined(PTHREAD_CACHE) || defined(__OS2__)
   free(c->stream);
   free(c->buffer);
   free(s->cache_data);
@@ -329,17 +337,19 @@
      min = s->buffer_size - s->fill_limit;
   }
   
-#if !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__)
+#if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__)
   if((stream->cache_pid=fork())){
 #else
   {
     stream_t* stream2=malloc(sizeof(stream_t));
     memcpy(stream2,s->stream,sizeof(stream_t));
     s->stream=stream2;
-#if defined(__MINGW32__) || defined(__CYGWIN__)
+#if defined(__MINGW32__)
     stream->cache_pid = _beginthread( ThreadProc, 0, s );
+#elif defined(__OS2__)
+    stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s );
 #else
-    stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s );
+    pthread_create(&stream->cache_pid, NULL, ThreadProc, s);
 #endif
 #endif
     // wait until cache is filled at least prefill_init %
@@ -358,10 +368,14 @@
     return 1; // parent exits
   }
   
-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(__MINGW32__) || defined(PTHREAD_CACHE) || defined(__OS2__)
 }
+#ifdef PTHREAD_CACHE
+static void *ThreadProc( void *s ){
+#else
 static void ThreadProc( void *s ){
 #endif
+#endif
   
 #ifdef CONFIG_GUI
   use_gui = 0; // mp_msg may not use gui stuff in forked code
@@ -374,9 +388,12 @@
     }
 //	 cache_stats(s->cache_data);
   } while (cache_execute_control(s));
-#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__)
+#if defined(__MINGW32__) || defined(__OS2__)
   _endthread();
 #endif
+#ifdef PTHREAD_CACHE
+  return NULL;
+#endif
 }
 
 int cache_stream_fill_buffer(stream_t *s){


More information about the MPlayer-users mailing list