[FFmpeg-devel] [PATCH] UDP fixes join multicast group on Darwin arch

Sébastien Zwickert szwickert
Wed Apr 22 17:44:56 CEST 2009

On Apr 22, 2009, at 4:47 PM, Diego Biurrun wrote:

> On Tue, Apr 21, 2009 at 12:55:37PM +0200, S?bastien Zwickert wrote:
>> On Apr 20, 2009, at 6:11 PM, Diego Biurrun wrote:
>>> On Fri, Apr 17, 2009 at 04:25:42PM +0200, S?bastien Zwickert wrote:
>>>> I found that udp_join_multicast_group() in libavformat/udp.c is
>>>> broken because IP_ADD_MEMBERSHIP and ip_mreq struct aren't defined
>>>> on Darwin Kernel Version 9.6.0 architecture.
>>>> I've read this archive
>>>> http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2008-August/051136.html
>>>> and i've added the _DARWIN_C_SOURCE definition at the top of the
>>>> udp.c file.
>>> The problem is that this struct and definition are only defined when
>>> _POSIX_C_SOURCE is not defined.  But we compile with _POSIX_C_SOURCE
>>> set, so it fails.
>> Almost right, this struct is only defined when _POSIX_C_SOURCE is not
>> defined OR when _DARWIN_C_SOURCE is defined.
>> This struct is defined on Apple system in <netinet/in.h> under this
>> condition :
>> #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
> On my Mac OS X 10.4 it is under
> #ifndef _POSIX_C_SOURCE

I'm running Mac OS 10.5 (darwin kernel 9.6.0).

>>> I'm not sure if this is a bug in the Apple system headers or if we
>>> should disable _POSIX_C_SOURCE on Darwin (probably not) or if we
>>> should avoid that struct and that definition...
>> Maybe, disable _POSIX_C_SOURCE is an appropriate solution on Darwin
>> because in this case the system headers will act as if we had have
>> defined _DARWIN_C_SOURCE, which causes the library and kernel calls  
>> to
>> conform to _POSIX_C_SOURCE with non-POSIX extensions. Defining
>> _POSIX_C_SOURCE excludes all non-POSIX extentions on Darwin.
>> The link below is the Apple's document (man compat) about the
>> compatibility settings:
>> http://developer.apple.com/documentation/Darwin/Reference/Manpages/man5/compat.5.html
>> Another document explaining Apple's unix conoformance:
>> http://developer.apple.com/ReleaseNotes/Darwin/RN-Unix03Conformance/index.html
> man compat only speaks of _APPLE_C_SOURCE on my system.

hmm, it appears that _APPLE_C_SOURCE has been renamed to  
_DARWIN_C_SOURCE and this is the default behavior from darwin 9.
On darwin 8 the default behavior is defined to _NONSTD_SOURCE that  
causes library and kernel calls to behave as closely to Mac OS X  
10.3's  (darwin 7) library and kernel calls as possible.

Sebastien Zwickert.

More information about the ffmpeg-devel mailing list