[Ffmpeg-devel] Network patch for MingW users

Ryan Martell rdm4
Wed Feb 21 01:17:36 CET 2007


On Feb 19, 2007, at 11:42 PM, Fran?ois Revol wrote:
>>>  #ifdef __MINGW32__
>>>  __declspec(dllimport) void __stdcall Sleep(unsigned long
>>> dwMilliseconds);
>>>  // #  include <windows.h>
>>> +#define GUID microsoft_issue_GUID
>>> +#include <winsock.h>
>>> +#undef GUID
>>>  #  define usleep(t)    Sleep((t) / 1000)
>>> -#  include <fcntl.h>
>>> -#  define lseek(f,p,w) _lseeki64((f), (p), (w))
>>> +#  define sleep(t)     Sleep((t) * 1000)
>>> +#define O_NONBLOCK FIONBIO
>>> +#define fcntl(fd,b,c) { u_long arg=1L; \
>>> +                        ioctlsocket(fd, c, &arg); }
>>
>> I'm not convinced this is a good idea.  Someone might use fcntl() on
>> a
>> real file.
>
> Why not just define a fcntlsocket() that other OSes would just map to
> fcntl like is done for close already ? Much cleaner.
>
>>>      if (port <= 0 || port >= 65536)
>>>          goto fail;
>>>
>>> +#ifdef __MINGW32__
>>> +    init_winsock();
>>> +#endif
>>
>> Aaaaiiiieeee!  NO MORE OF THIS. PLEASE.
>
> Also that's totally definitely non threadsafe.

fcntlsocket() as above..

and

initialize_sockets() and shutdown_sockets(), which do nothing on real  
os's, but does the init_winsock thing on windows?

-Ryan

PS: I volunteer to put the patch together, once everyone comes to a  
consensus on how to do it....





More information about the ffmpeg-devel mailing list