Martin Storsjö <[email protected]> writes:

> On Sun, 15 Jul 2012, Måns Rullgård wrote:
>
>> Martin Storsjö <[email protected]> writes:
>>
>>> This was unnoticed on linux, since stdlib.h apparently includes
>>> files declaring the pthread_mutex_t and pthread_cond_t types.
>>
>> That seems unlikely.
>
> On Ubuntu 12.04 (glibc 2.15) at least, a file containing only
>
> #include <stdlib.h>
> struct foo { pthread_mutex_t foo; };
>
> compiles just fine.

That is contrary to the standard:

  Inclusion of the <stdlib.h> header may also make visible all symbols
  from <stddef.h>, <limits.h>, <math.h>, and <sys/wait.h>.

None of these headers, or stdlib.h, are allowed to define any pthread_*
names.

>>> ---
>>>  libavcodec/vp8.c |    6 ------
>>>  libavcodec/vp8.h |    5 +++++
>>>  2 files changed, 5 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
>>> index ee954fc..e39fc0b 100644
>>> --- a/libavcodec/vp8.c
>>> +++ b/libavcodec/vp8.c
>>> @@ -31,12 +31,6 @@
>>>  #include "rectangle.h"
>>>  #include "thread.h"
>>>
>>> -#if HAVE_PTHREADS
>>> -#include <pthread.h>
>>> -#elif HAVE_W32THREADS
>>> -#include "w32pthreads.h"
>>> -#endif
>>> -
>>>  #if ARCH_ARM
>>>  #   include "arm/vp8.h"
>>>  #endif
>>> diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h
>>> index 1355da4..458a11a 100644
>>> --- a/libavcodec/vp8.h
>>> +++ b/libavcodec/vp8.h
>>> @@ -30,6 +30,11 @@
>>>  #include "vp56data.h"
>>>  #include "vp8dsp.h"
>>>  #include "h264pred.h"
>>> +#if HAVE_PTHREADS
>>> +#include <pthread.h>
>>> +#elif HAVE_W32THREADS
>>> +#include "w32pthreads.h"
>>> +#endif
>>
>> This ifdeffery is in the wrong place.  It should be abstracted somewhere
>> else.
>
> Yes, and w32pthreads.h could use being converted into a proper .c
> file. It has function pointers to vista-only functions for cond vars
> and an init function, that are loaded only from ff_thread_init in
> pthread.c. The function pointers are static, so each file that
> currently includes w32pthreads.h get a separate instance of the
> pointers variables, and only the one included in pthread.c actually
> initializes the pointers - all others will use the pre-vista fallback.

So can someone please fix this before the situation becomes out of hand?

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to