[Ffmpeg-devel] [PATCH] rename CONFIG_WIN32 to CONFIG_MINGW/__MINGW32__

Diego Biurrun diego
Tue Jul 11 12:13:43 CEST 2006


On Mon, Jul 10, 2006 at 07:39:43PM +0100, M?ns Rullg?rd wrote:
> Diego Biurrun <diego at biurrun.de> writes:
> 
> > We currently have a confusing way to specify MinGW, we call it
> > CONFIG_WIN32 while this name is usually reserved for something that
> > encompasses both MinGW and Cygwin.
> >
> > This patch renames CONFIG_WIN32 to __MINGW__ within the source files and
> > to CONFIG_MINGW within the build system along with cleaning up some of
> > the confusion that this naming scheme seems to have entailed in the
> > past.
> >
> > OK to commit?
> 
> Fine by me in general, assuming the compiler defines __MINGW32__.

We define it in configure.

> Just a couple of minor things:
> 
> > Index: libavutil/common.h
> > ===================================================================
> > --- libavutil/common.h	(revision 5705)
> > +++ libavutil/common.h	(working copy)
> > @@ -292,7 +292,7 @@
> >  #    include <assert.h>
> >
> >  /* dprintf macros */
> > -#    if defined(CONFIG_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
> > +#    if defined(CONFIG_WIN32)
> 
> CONFIG_WIN32 isn't ever defined with your change, right?  I think this
> is a remnant of the days long gone when ffmpeg could be built with
> msvc.  Get rid of the #ifdef entirely.

At the top of libavutil/common.h you will find

  #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
  #    define CONFIG_WIN32
  #endif

  #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(EMULATE_INTTYPES)
  #    define EMULATE_INTTYPES
  #endif

I suppose these are remnants from those long gone days, yes.  I guess
they should be removed, but in a separate commit.

> > -#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
> > +#if defined(_MINGW32__) || defined(CONFIG_OS2) || defined(__CYGWIN__)
> Typo ----------^

Ooops, thanks, fixed locally.

New patch with some more changes in libavutil/common.h attached.  Some
testing on MinGW would be very much welcome as I don't have Windows
anywhere.

Diego
-------------- next part --------------
Index: configure
===================================================================
--- configure	(revision 5708)
+++ configure	(working copy)
@@ -1922,8 +1922,7 @@
 fi
 
 if test "$mingw32" = "yes" ; then
-  echo "#define CONFIG_WIN32 1" >> $TMPH
-  echo "CONFIG_WIN32=yes" >> config.mak
+  echo "CONFIG_MINGW=yes" >> config.mak
   echo "HAVE_W32THREADS=yes" >> config.mak
   echo "#define HAVE_W32THREADS 1" >> $TMPH
   echo "#define HAVE_THREADS 1" >> $TMPH
@@ -1933,8 +1932,7 @@
 fi
 
 if test "$mingwce" = "yes" ; then
-  echo "#define CONFIG_WIN32 1" >> $TMPH
-  echo "CONFIG_WIN32=yes" >> config.mak
+  echo "CONFIG_MINGW=yes" >> config.mak
   echo "#define CONFIG_WINCE 1" >> $TMPH
   echo "CONFIG_WINCE=yes" >> config.mak
   echo "#ifndef __MINGW32__" >> $TMPH
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 5708)
+++ ffmpeg.c	(working copy)
@@ -23,7 +23,7 @@
 #include "dsputil.h"
 #include "opt.h"
 
-#ifndef CONFIG_WIN32
+#ifndef __MINGW32__
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -317,7 +317,7 @@
     int nb_streams;       /* nb streams we are aware of */
 } AVInputFile;
 
-#ifndef CONFIG_WIN32
+#ifndef __MINGW32__
 
 /* init terminal so that we can grab keys */
 static struct termios oldtty;
@@ -1896,7 +1896,7 @@
         }
     }
 
-#ifndef CONFIG_WIN32
+#ifndef __MINGW32__
     if ( !using_stdin && verbose >= 0) {
         fprintf(stderr, "Press [q] to stop encoding\n");
         url_set_interrupt_cb(decode_interrupt_cb);
@@ -3585,7 +3585,7 @@
     do_pass = pass;
 }
 
-#if defined(CONFIG_WIN32) || defined(CONFIG_OS2)
+#if defined(__MINGW32__) || defined(CONFIG_OS2)
 static int64_t getutime(void)
 {
   return av_gettime();
@@ -4299,7 +4299,7 @@
     powerpc_display_perf_report();
 #endif /* POWERPC_PERFORMANCE_REPORT */
 
-#ifndef CONFIG_WIN32
+#ifndef __MINGW32__
     if (received_sigterm) {
         fprintf(stderr,
             "Received signal %d: terminating.\n",
Index: libavutil/common.h
===================================================================
--- libavutil/common.h	(revision 5708)
+++ libavutil/common.h	(working copy)
@@ -103,7 +103,7 @@
     typedef unsigned short uint16_t;
     typedef unsigned int   uint32_t;
 
-#   ifdef CONFIG_WIN32
+#   ifdef __MINGW32__
         typedef signed __int64   int64_t;
         typedef unsigned __int64 uint64_t;
 #   else /* other OS */
@@ -186,7 +186,7 @@
 #    endif
 #endif
 
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
 
 /* windows */
 
@@ -217,7 +217,7 @@
 
 #    endif
 
-/* CONFIG_WIN32 end */
+/* __MINGW32__ end */
 #elif defined (CONFIG_OS2)
 /* OS/2 EMX */
 
@@ -253,7 +253,7 @@
 #        endif
 #    endif /* HAVE_AV_CONFIG_H */
 
-#endif /* !CONFIG_WIN32 && !CONFIG_OS2 */
+#endif /* !__MINGW32__ && !CONFIG_OS2 */
 
 #ifdef HAVE_AV_CONFIG_H
 
@@ -292,7 +292,7 @@
 #    include <assert.h>
 
 /* dprintf macros */
-#    if defined(CONFIG_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+#    if defined(CONFIG_WIN32)
 
 inline void dprintf(const char* fmt,...) {}
 
@@ -304,7 +304,7 @@
 #            define dprintf(fmt,...)
 #        endif
 
-#    endif /* !CONFIG_WIN32 */
+#    endif /* CONFIG_WIN32 */
 #    ifdef CONFIG_WINCE
 #            define abort()
 #    endif
@@ -603,7 +603,7 @@
 /* btw, rintf() is existing on fbsd too -- alex */
 static always_inline long int lrintf(float x)
 {
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
 #  ifdef ARCH_X86
     int32_t i;
     asm volatile(
@@ -617,7 +617,7 @@
 #  endif /* ARCH_X86 */
 #else
     return (int)(rint(x));
-#endif /* CONFIG_WIN32 */
+#endif /* __MINGW32__ */
 }
 #else
 #ifndef _ISOC9X_SOURCE
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c	(revision 5708)
+++ libavcodec/utils.c	(working copy)
@@ -33,7 +33,7 @@
 #include <stdarg.h>
 #include <limits.h>
 #include <float.h>
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
 #include <fcntl.h>
 #endif
 
@@ -1417,7 +1417,7 @@
  * and opened file name in **filename. */
 int av_tempfile(char *prefix, char **filename) {
     int fd=-1;
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
     *filename = tempnam(".", prefix);
 #else
     size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
@@ -1428,7 +1428,7 @@
         av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
         return -1;
     }
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
     fd = open(*filename, _O_RDWR | _O_BINARY | _O_CREAT, 0444);
 #else
     snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
Index: Makefile
===================================================================
--- Makefile	(revision 5708)
+++ Makefile	(working copy)
@@ -124,7 +124,7 @@
 
 # install man from source dir if available
 install-man:
-ifneq ($(CONFIG_WIN32),yes)
+ifneq ($(CONFIG_MINGW),yes)
 	if [ -f doc/ffmpeg.1 ] ; then \
 	    install -d "$(mandir)/man1" ; \
 	    install -m 644 $(MANPAGES) "$(mandir)/man1" ; \
@@ -159,7 +159,7 @@
 	rm -f $(addprefix $(bindir)/, $(ALLPROGS))
 
 uninstall-man:
-ifneq ($(CONFIG_WIN32),yes)
+ifneq ($(CONFIG_MINGW),yes)
 	rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
 endif
 
Index: common.mak
===================================================================
--- common.mak	(revision 5708)
+++ common.mak	(working copy)
@@ -22,7 +22,7 @@
 
 $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
 	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
-ifeq ($(CONFIG_WIN32),yes)
+ifeq ($(CONFIG_MINGW),yes)
 	-lib /machine:i386 /def:$(@:.dll=.def)
 endif
 
@@ -61,7 +61,7 @@
 
 install-lib-shared: $(SLIBNAME)
 	install -d "$(libdir)"
-ifeq ($(CONFIG_WIN32),yes)
+ifeq ($(CONFIG_MINGW),yes)
 	install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
 else
 	install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
@@ -85,7 +85,7 @@
 uninstall: uninstall-libs uninstall-headers
 
 uninstall-libs:
-ifeq ($(CONFIG_WIN32),yes)
+ifeq ($(CONFIG_MINGW),yes)
 	-rm -f $(prefix)/$(SLIBNAME)
 else
 	-rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \
Index: ffplay.c
===================================================================
--- ffplay.c	(revision 5708)
+++ ffplay.c	(working copy)
@@ -25,7 +25,7 @@
 #include <SDL.h>
 #include <SDL_thread.h>
 
-#ifdef CONFIG_WIN32
+#ifdef __MINGW32__
 #undef main /* We don't want SDL to override our main() */
 #endif
 
@@ -2423,7 +2423,7 @@
         video_disable = 1;
     }
     flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
-#if !defined(CONFIG_WIN32) && !defined(CONFIG_DARWIN)
+#if !defined(__MINGW32__) && !defined(CONFIG_DARWIN)
     flags |= SDL_INIT_EVENTTHREAD; /* Not supported on win32 or darwin */
 #endif
     if (SDL_Init (flags)) {
Index: libavformat/os_support.c
===================================================================
--- libavformat/os_support.c	(revision 5708)
+++ libavformat/os_support.c	(working copy)
@@ -20,7 +20,7 @@
 #include "avformat.h"
 #if defined(CONFIG_WINCE)
 /* Skip includes on WinCE. */
-#elif defined(CONFIG_WIN32)
+#elif defined(__MINGW32__)
 #include <sys/types.h>
 #include <sys/timeb.h>
 #elif defined(CONFIG_OS2)
@@ -40,7 +40,7 @@
 {
 #if defined(CONFIG_WINCE)
     return timeGetTime() * int64_t_C(1000);
-#elif defined(CONFIG_WIN32)
+#elif defined(__MINGW32__)
     struct timeb tb;
     _ftime(&tb);
     return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
Index: libavformat/file.c
===================================================================
--- libavformat/file.c	(revision 5708)
+++ libavformat/file.c	(working copy)
@@ -18,14 +18,14 @@
  */
 #include "avformat.h"
 #include <fcntl.h>
-#ifndef CONFIG_WIN32
+#ifndef __MINGW32__
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #else
 #include <io.h>
 #define open(fname,oflag,pmode) _open(fname,oflag,pmode)
-#endif /* CONFIG_WIN32 */
+#endif /* __MINGW32__ */
 
 
 /* standard file protocol */
@@ -44,7 +44,7 @@
     } else {
         access = O_RDONLY;
     }
-#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
+#if defined(__MINGW32__) || defined(CONFIG_OS2) || defined(__CYGWIN__)
     access |= O_BINARY;
 #endif
     fd = open(filename, access, 0666);
@@ -70,7 +70,7 @@
 static offset_t file_seek(URLContext *h, offset_t pos, int whence)
 {
     int fd = (size_t)h->priv_data;
-#if defined(CONFIG_WIN32) && !defined(__CYGWIN__)
+#if defined(__MINGW32__)
     return _lseeki64(fd, pos, whence);
 #else
     return lseek(fd, pos, whence);
@@ -103,7 +103,7 @@
     } else {
         fd = 0;
     }
-#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
+#if defined(__MINGW32__) || defined(CONFIG_OS2) || defined(__CYGWIN__)
     setmode(fd, O_BINARY);
 #endif
     h->priv_data = (void *)(size_t)fd;



More information about the ffmpeg-devel mailing list