ericmckean / webm

Automatically exported from code.google.com/p/webm
0 stars 0 forks source link

Pthread used incorrectly #687

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a problem with mingw-w64 / msys2 on x86 Windows 7.

In vp9_thread.h

shouldn't it read as

#if defined(_WIN32)
#ifndef __GNUC__
#include <windows.h>  // NOLINT
typedef HANDLE pthread_t;
typedef CRITICAL_SECTION pthread_mutex_t;
typedef struct {
  HANDLE waiting_sem_;
  HANDLE received_sem_;
  HANDLE signal_event_;
} pthread_cond_t;
#else
#include <pthread.h> // NOLINT
#endif
#else

and the strtok_r does not seem to work in svc_encodeframe

I needed to have to put some publicdomain source for this.

But possibly something like 

#if defined(__MINGW__) 
#include <pthread.h>
#else
... other ...
#endif

Original issue reported on code.google.com by fithis2...@gmail.com on 1 Jan 2014 at 5:42

GoogleCodeExporter commented 9 years ago
I tested and the correction was

#if defined(__MINGW32__) 
#include <pthread.h>
#else
#ifdef _MSC_VER
#define strdup _strdup
#define strtok_r strtok_s
#endif
#endif

and it compiles cleanly

Original comment by fithis2...@gmail.com on 1 Jan 2014 at 6:05

GoogleCodeExporter commented 9 years ago
Yunqing, can you take a look at this? thanks

Original comment by ya...@google.com on 2 Jan 2014 at 5:30

GoogleCodeExporter commented 9 years ago

Original comment by ya...@google.com on 9 Jan 2014 at 11:19

GoogleCodeExporter commented 9 years ago
> In vp9_thread.h
> 
> shouldn't it read as
> 
> #if defined(_WIN32)
> #ifndef __GNUC__
> #include <windows.h>  // NOLINT
> [...]

You're reporting 2 issues here, so let's focus on the first with pthread in 
vp9_thread.h.
Can you give the mingw-w64 / msys versions you're using? I have no problem 
cross compiling this on linux with: x86_64-w64-mingw32-gcc (GCC) 4.6.3 and 
windows with 4.7.3.

The check is meant to use windows code in i.e., visual studio, and use pthread 
directly with mingw toolchains. Your check is equivalent with my mingw-w64 
toolchains:

$ echo ";" | x86_64-w64-mingw32-gcc -E -dM - |grep -e __MINGW32__ -e __MINGW__ 
-e __GNUC__ -e _WIN32
#define _WIN32 1
#define __WIN32 1
#define __MINGW32__ 1
#define __GNUC__ 4
#define __WIN32__ 1

Is the real problem only strtok_r in the svc code? The check was modified in:
1ed0e1b Move SVC per-frame loop from sample app into libvpx proper

What version are you building with (git describe)?

Original comment by jz...@google.com on 10 Jan 2014 at 3:27

GoogleCodeExporter commented 9 years ago

Original comment by yunqingw...@google.com on 10 Jan 2014 at 5:39

GoogleCodeExporter commented 9 years ago
On Monday I will be able to give you more details. I am sorry for now. The
only detail I can provide is that I use the msys2 from

http://sourceforge.net/projects/msys2/files/Alpha-versions/32-bit/x32-msys2-2013
1022.tar.xz/download

and

for mingw

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/
Personal%20Builds/mingw-builds/4.8.2/threads-posix/sjlj/i686-4.8.2-release-posix
-sjlj-rt_v3-rev1.7z/download

I should try with more recent variants.

Original comment by fithis2...@gmail.com on 11 Jan 2014 at 5:37