shithub: sox

Download patch

ref: 879b0c2409f166d355175809a1c9f9c48f4e7b55
parent: d0647a4f8650f92057274f2412bb8aa79f71a242
author: Doug Cook <idigdoug@users.sourceforge.net>
date: Thu Dec 22 18:54:28 EST 2011

Use (standardized) PRIuPTR instead of FMT_size_t.

--- a/src/delay.c
+++ b/src/delay.c
@@ -82,7 +82,7 @@
     lsx_parsesamples(effp->in_signal.rate, p->argv[effp->flow], &p->buffer_size, 't');
   lsx_parsesamples(effp->in_signal.rate, p->max_arg, &max_delay, 't');
   if (effp->flow == 0)
-    lsx_debug("extending audio by %" FMT_size_t " samples", max_delay);
+    lsx_debug("extending audio by %" PRIuPTR " samples", max_delay);
   p->buffer_index = p->delay = p->pre_pad = 0;
   p->pad = max_delay - p->buffer_size;
   p->buffer = lsx_malloc(p->buffer_size * sizeof(*p->buffer));
--- a/src/sox.h
+++ b/src/sox.h
@@ -34,6 +34,7 @@
 #else
 #error Unable to determine an appropriate definition for sox_int8_t.
 #endif
+lsx_static_assert(sizeof(sox_int8_t)==1, sox_int8_size);
 
 #if UCHAR_MAX==0xff
 typedef unsigned char sox_uint8_t;
@@ -42,6 +43,7 @@
 #else
 #error Unable to determine an appropriate definition for sox_uint8_t.
 #endif
+lsx_static_assert(sizeof(sox_uint8_t)==1, sox_uint8_size);
 
 #if SHRT_MAX==32767 && SHRT_MIN==(-32768)
 typedef short sox_int16_t;
@@ -50,6 +52,7 @@
 #else
 #error Unable to determine an appropriate definition for sox_int16_t.
 #endif
+lsx_static_assert(sizeof(sox_int16_t)==2, sox_int16_size);
 
 #if USHRT_MAX==0xffff
 typedef unsigned short sox_uint16_t;
@@ -58,6 +61,7 @@
 #else
 #error Unable to determine an appropriate definition for sox_uint16_t.
 #endif
+lsx_static_assert(sizeof(sox_uint16_t)==2, sox_uint16_size);
 
 #if INT_MAX==2147483647 && INT_MIN==(-2147483647-1)
 typedef int sox_int32_t;
@@ -66,6 +70,7 @@
 #else
 #error Unable to determine an appropriate definition for sox_int32_t.
 #endif
+lsx_static_assert(sizeof(sox_int32_t)==4, sox_int32_size);
 
 #if UINT_MAX==0xffffffff
 typedef unsigned int sox_uint32_t;
@@ -74,28 +79,25 @@
 #else
 #error Unable to determine an appropriate definition for sox_uint32_t.
 #endif
+lsx_static_assert(sizeof(sox_uint32_t)==4, sox_uint32_size);
 
 #if LONG_MAX==9223372036854775807 && LONG_MIN==(-9223372036854775807-1)
 typedef long sox_int64_t;
-#elif defined(LLONG_MAX) && defined(LLONG_MIN) && LLONG_MAX==9223372036854775807 && LLONG_MIN==(-9223372036854775807-1)
-typedef long long sox_int64_t;
 #elif defined(_MSC_VER)
 typedef __int64 sox_int64_t;
 #else
 typedef long long sox_int64_t;
-lsx_static_assert(sizeof(sox_int64_t)==8, sox_int64_size);
 #endif
+lsx_static_assert(sizeof(sox_int64_t)==8, sox_int64_size);
 
 #if ULONG_MAX==0xffffffffffffffff
 typedef unsigned long sox_uint64_t;
-#elif ULLONG_MAX==0xffffffffffffffff
-typedef unsigned long long sox_uint64_t;
 #elif defined(_MSC_VER)
 typedef unsigned __int64 sox_uint64_t;
 #else
 typedef unsigned long long sox_uint64_t;
-lsx_static_assert(sizeof(sox_uint64_t)==8, sox_uint64_size);
 #endif
+lsx_static_assert(sizeof(sox_uint64_t)==8, sox_uint64_size);
 
 typedef sox_int32_t sox_int24_t;   /* sox_int24_t == sox_int32_t (beware of the extra byte) */
 typedef sox_uint32_t sox_uint24_t; /* sox_uint24_t == sox_uint32_t (beware of the extra byte) */
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -54,14 +54,6 @@
 assert_static(sizeof(off_t) == _FILE_OFFSET_BITS >> 3, OFF_T_BUILD_PROBLEM);
 #endif
 
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define FMT_size_t "Iu"
-#elif defined __GNUC__
-#define FMT_size_t "zu"
-#else
-#define FMT_size_t "lu"
-#endif
-
 FILE * lsx_tmpfile(void);
 
 void lsx_debug_more_impl(char const * fmt, ...) LSX_PRINTF12;
--- a/src/util.h
+++ b/src/util.h
@@ -51,8 +51,10 @@
 /* Define the format specifier to use for int64_t values.
  * Example: printf("You may have already won $ %" PRId64 " !!!", n64); */
 #ifndef PRId64 /* Maybe <inttypes.h> already defined this. */
-#ifdef _MSC_VER /* Older versions of MSC don't recognize %lld. */
+#if defined(_MSC_VER) || defined(__MINGW32__) /* Older versions of msvcrt.dll don't recognize %lld. */
 #define PRId64 "I64d"
+#elif LONG_MAX==9223372036854775807
+#define PRId64 "ld"
 #else
 #define PRId64 "lld"
 #endif
@@ -60,12 +62,24 @@
 
 /* Define the format specifier to use for uint64_t values. */
 #ifndef PRIu64 /* Maybe <inttypes.h> already defined this. */
-#ifdef _MSC_VER /* Older versions of MSC don't recognize %llu. */
+#if defined(_MSC_VER) || defined(__MINGW32__) /* Older versions of msvcrt.dll don't recognize %llu. */
 #define PRIu64 "I64u"
+#elif ULONG_MAX==0xffffffffffffffff
+#define PRIu64 "lu"
 #else
 #define PRIu64 "llu"
 #endif
 #endif /* PRIu64 */
+
+/* Define the format specifier to use for size_t values.
+ * Example: printf("Sizeof(x) = %" PRIuPTR " bytes", sizeof(x)); */
+#ifndef PRIuPTR /* Maybe <inttypes.h> already defined this. */
+#if defined(_MSC_VER) || defined(__MINGW32__) /* Older versions of msvcrt.dll don't recognize %zu. */
+#define PRIuPTR "Iu"
+#else
+#define PRIuPTR "zu"
+#endif
+#endif /* PRIuPTR */
 
 #ifdef __GNUC__
 #define NORET __attribute__((noreturn))