[FFmpeg-devel] setmode(fd, flag)

Ramiro Polla ramiro.polla
Fri Dec 19 01:34:46 CET 2008


Hi,

On Thu, Dec 18, 2008 at 8:17 PM, M?ns Rullg?rd <mans at mansr.com> wrote:
> "Ramiro Polla" <ramiro.polla at gmail.com> writes:
>> On Tue, Dec 16, 2008 at 3:48 PM, M?ns Rullg?rd <mans at mansr.com> wrote:
>>> Fran?ois Revol wrote:
>>>>> Yes. But it is defined in BeOS (IIRC) and setmode does something
>>>>> completely different. So the code, as is, is not good.
>>>>
>>>> BSD has its own setmode(), see
>>>> http://www.manpagez.com/man/3/setmode/
>>>>
>>>> It's been discussed already several times here.
>>>>
>>>>> It seems (from msdn [0]) that _setmode is preferred.
>>>>
>>>> Then check for it in configure...
>>>> but make sure it doesn't colide with a weak symbol fallback
>>>> elsewhere...
>>>
>>> Since a variety of setmode() functions seem to exist on different
>>> systems, I suggest manually enabling its use in the OS-specific part
>>> of configure on the relevant systems.
>>
>> Like $attached?
>>
>> Index: configure
>> ===================================================================
>> --- configure (revision 16223)
>> +++ configure (working copy)
>> @@ -824,6 +824,7 @@
>>      $THREADS_LIST
>>      altivec_h
>>      arpa_inet_h
>> +    binary_files
>>      bswap
>>      closesocket
>>      cmov
>> @@ -1462,6 +1463,7 @@
>>          SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
>>          objformat="win32"
>>          enable dos_paths
>> +        enable binary_files
>>          check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
>>              die "ERROR: MinGW runtime version must be >= 3.15."
>>          enabled_any avisynth vfwcap_demuxer &&
>> @@ -1485,6 +1487,7 @@
>>          SHFLAGS='-shared -Wl,--enable-auto-image-base'
>>          objformat="win32"
>>          enable dos_paths
>> +        enable binary_files
>>          ;;
>>      *-dos|freedos|opendos)
>>          disable ffplay ffserver vhook
>> @@ -1493,6 +1496,7 @@
>>          EXESUF=".exe"
>>          objformat="win32"
>>          enable dos_paths
>> +        enable binary_files
>>          ;;
>>      linux)
>>          enable dv1394
>> @@ -1525,6 +1529,7 @@
>>          SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
>>          disable vhook
>>          enable dos_paths
>> +        enable binary_files
>>          ;;
>>      interix)
>>          disable vhook
>
> I has something like HAVE_MS_SETMODE in mind.

I searched for setmode()'s origin, but couldn't find anything saying
it was specific to Microsoft. I couldn't find much information about
it either. MSDN says it's POSIX, although it most certainly isn't (and
I didn't find a way to report it).

If noone comes with a better suggestion in a few days, I propose
HAVE_DOS_SETMODE.

> A system could well
> distinguish binary files from some other kind, yet lack this
> particular setmode() function.
>
>> Index: libavformat/file.c
>> ===================================================================
>> --- libavformat/file.c        (revision 16223)
>> +++ libavformat/file.c        (working copy)
>> @@ -44,7 +44,7 @@
>>      } else {
>>          access = O_RDONLY;
>>      }
>> -#ifdef O_BINARY
>> +#ifdef HAVE_BINARY_FILES
>>      access |= O_BINARY;
>>  #endif
>>      fd = open(filename, access, 0666);
>
> This can stay.  If someone ever finds a system where O_BINARY exists
> but does something else, we'll deal with it then.

Right.

[...]

Ramiro Polla




More information about the ffmpeg-devel mailing list