inttypes emulation cleanup patch by ("Chris Flerackers" <cflerackers at androme dot...
authorChris Flerackers <cflerackers@androme.be>
Fri, 9 Jan 2004 18:00:31 +0000 (18:00 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 9 Jan 2004 18:00:31 +0000 (18:00 +0000)
Originally committed as revision 2681 to svn://svn.ffmpeg.org/ffmpeg/trunk

configure
libavcodec/common.h

index b99534a..d1c306c 100755 (executable)
--- a/configure
+++ b/configure
@@ -148,6 +148,7 @@ debug="yes"
 extralibs="-lm"
 simpleidct="yes"
 bigendian="no"
+inttypes="yes"
 emu_fast_int="no"
 vhook="default"
 dlfcn="no"
@@ -634,6 +635,17 @@ fi
 fi
 
 # ---
+# *inttypes.h* test
+cat > $TMPC << EOF
+#include <inttypes.h>
+int main(int argc, char ** argv){
+    return 0;
+}
+EOF
+
+$cc -o $TMPE $TMPC 2>/dev/null || inttypes="no"
+
+# ---
 # *int_fast* test
 cat > $TMPC << EOF
 #include <inttypes.h>
@@ -870,6 +882,7 @@ echo "C compiler       $cc"
 echo "make             $make"
 echo "CPU              $cpu ($tune)"
 echo "Big Endian       $bigendian"
+echo "inttypes.h       $inttypes"
 echo "broken inttypes.h $emu_fast_int"
 if test $cpu = "x86"; then
 echo "MMX enabled      $mmx"
@@ -972,6 +985,9 @@ if test "$bigendian" = "yes" ; then
   echo "WORDS_BIGENDIAN=yes" >> config.mak
   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
 fi
+if test "$inttypes" = "yes" ; then
+  echo "#define HAVE_INTTYPES_H 1" >> $TMPH
+fi
 if test "$emu_fast_int" = "yes" ; then
   echo "#define EMULATE_FAST_INT 1" >> $TMPH
 fi
index 385372f..ee5a4cb 100644 (file)
@@ -82,6 +82,25 @@ extern const struct AVOption avoptions_workaround_bug[11];
 #    define always_inline inline
 #endif
 
+#ifdef HAVE_INTTYPES_H
+#   include <inttypes.h>
+#else
+    typedef signed char  int8_t;
+    typedef signed short int16_t;
+    typedef signed int   int32_t;
+    typedef unsigned char  uint8_t;
+    typedef unsigned short uint16_t;
+    typedef unsigned int   uint32_t;
+
+#   ifdef CONFIG_WIN32
+        typedef signed __int64   int64_t;
+        typedef unsigned __int64 uint64_t;
+#   else /* other OS */
+        typedef signed long long   int64_t;
+        typedef unsigned long long uint64_t;
+#   endif /* other OS */
+#endif /* HAVE_INTTYPES_H */
+
 #ifdef EMULATE_FAST_INT
 /* note that we don't emulate 64bit ints */
 typedef signed char int_fast8_t;
@@ -102,15 +121,6 @@ static inline float floorf(float f) {
 
 /* windows */
 
-typedef unsigned short uint16_t;
-typedef signed short int16_t;
-typedef unsigned char uint8_t;
-typedef unsigned int uint32_t;
-typedef unsigned __int64 uint64_t;
-typedef signed char int8_t;
-typedef signed int int32_t;
-typedef signed __int64 int64_t;
-
 #    ifndef __MINGW32__
 #        define int64_t_C(c)     (c ## i64)
 #        define uint64_t_C(c)    (c ## i64)
@@ -137,8 +147,6 @@ typedef signed __int64 int64_t;
 #elif defined (CONFIG_OS2)
 /* OS/2 EMX */
 
-#include <inttypes.h>
-
 #ifndef int64_t_C
 #define int64_t_C(c)     (c ## LL)
 #define uint64_t_C(c)    (c ## ULL)
@@ -159,8 +167,6 @@ typedef signed __int64 int64_t;
 
 /* unix */
 
-#include <inttypes.h>
-
 #ifndef int64_t_C
 #define int64_t_C(c)     (c ## LL)
 #define uint64_t_C(c)    (c ## ULL)