From 28c118c3c1032076bc987b8123d1c91f513f67e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 28 Sep 2017 09:47:57 +0200 Subject: [PATCH] Some C89_BUILD fixes for libFLAC --- deps/libFLAC/bitreader.c | 10 ++--- deps/libFLAC/cpu.c | 56 +++++++++++++------------- deps/libFLAC/include/private/bitmath.h | 18 +++++---- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/deps/libFLAC/bitreader.c b/deps/libFLAC/bitreader.c index b7607af178..fc6e89f671 100644 --- a/deps/libFLAC/bitreader.c +++ b/deps/libFLAC/bitreader.c @@ -114,7 +114,7 @@ struct FLAC__BitReader { void *client_data; }; -static inline void crc16_update_word_(FLAC__BitReader *br, brword word) +static INLINE void crc16_update_word_(FLAC__BitReader *br, brword word) { register unsigned crc = br->read_crc16; #if FLAC__BYTES_PER_WORD == 4 @@ -347,17 +347,17 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br) return br->read_crc16; } -inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br) +INLINE FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br) { return ((br->consumed_bits & 7) == 0); } -inline unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) +INLINE unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) { return 8 - (br->consumed_bits & 7); } -inline unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) +INLINE unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) { return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits; } @@ -476,7 +476,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *va return true; } -inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val) +INLINE FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val) { FLAC__uint32 x8, x32 = 0; diff --git a/deps/libFLAC/cpu.c b/deps/libFLAC/cpu.c index da76d87d19..3f0a2346db 100644 --- a/deps/libFLAC/cpu.c +++ b/deps/libFLAC/cpu.c @@ -49,11 +49,6 @@ #ifdef DEBUG #include - -#define dfprintf fprintf -#else -/* This is bad practice, it should be a static void empty function */ -#define dfprintf(file, format, ...) #endif @@ -138,21 +133,23 @@ ia32_cpu_info (FLAC__CPUInfo *info) info->ia32.avx2 = (flags_ebx & FLAC__CPUINFO_IA32_CPUID_AVX2 ) ? true : false; } - dfprintf(stderr, "CPU info (IA-32):\n"); - dfprintf(stderr, " CMOV ....... %c\n", info->ia32.cmov ? 'Y' : 'n'); - dfprintf(stderr, " MMX ........ %c\n", info->ia32.mmx ? 'Y' : 'n'); - dfprintf(stderr, " SSE ........ %c\n", info->ia32.sse ? 'Y' : 'n'); - dfprintf(stderr, " SSE2 ....... %c\n", info->ia32.sse2 ? 'Y' : 'n'); - dfprintf(stderr, " SSE3 ....... %c\n", info->ia32.sse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSSE3 ...... %c\n", info->ia32.ssse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSE41 ...... %c\n", info->ia32.sse41 ? 'Y' : 'n'); - dfprintf(stderr, " SSE42 ...... %c\n", info->ia32.sse42 ? 'Y' : 'n'); +#if 0 + fprintf(stderr, "CPU info (IA-32):\n"); + fprintf(stderr, " CMOV ....... %c\n", info->ia32.cmov ? 'Y' : 'n'); + fprintf(stderr, " MMX ........ %c\n", info->ia32.mmx ? 'Y' : 'n'); + fprintf(stderr, " SSE ........ %c\n", info->ia32.sse ? 'Y' : 'n'); + fprintf(stderr, " SSE2 ....... %c\n", info->ia32.sse2 ? 'Y' : 'n'); + fprintf(stderr, " SSE3 ....... %c\n", info->ia32.sse3 ? 'Y' : 'n'); + fprintf(stderr, " SSSE3 ...... %c\n", info->ia32.ssse3 ? 'Y' : 'n'); + fprintf(stderr, " SSE41 ...... %c\n", info->ia32.sse41 ? 'Y' : 'n'); + fprintf(stderr, " SSE42 ...... %c\n", info->ia32.sse42 ? 'Y' : 'n'); if (FLAC__HAS_X86INTRIN && FLAC__AVX_SUPPORTED) { - dfprintf(stderr, " AVX ........ %c\n", info->ia32.avx ? 'Y' : 'n'); - dfprintf(stderr, " FMA ........ %c\n", info->ia32.fma ? 'Y' : 'n'); - dfprintf(stderr, " AVX2 ....... %c\n", info->ia32.avx2 ? 'Y' : 'n'); + fprintf(stderr, " AVX ........ %c\n", info->ia32.avx ? 'Y' : 'n'); + fprintf(stderr, " FMA ........ %c\n", info->ia32.fma ? 'Y' : 'n'); + fprintf(stderr, " AVX2 ....... %c\n", info->ia32.avx2 ? 'Y' : 'n'); } +#endif /* * now have to check for OS support of AVX instructions @@ -164,9 +161,10 @@ ia32_cpu_info (FLAC__CPUInfo *info) info->ia32.fma = false; } - if (FLAC__HAS_X86INTRIN && FLAC__AVX_SUPPORTED) { - dfprintf(stderr, " AVX OS sup . %c\n", info->ia32.avx ? 'Y' : 'n'); - } +#if 0 + if (FLAC__HAS_X86INTRIN && FLAC__AVX_SUPPORTED) + fprintf(stderr, " AVX OS sup . %c\n", info->ia32.avx ? 'Y' : 'n'); +#endif #else info->use_asm = false; #endif @@ -199,16 +197,16 @@ x86_64_cpu_info (FLAC__CPUInfo *info) info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_IA32_CPUID_AVX2 ) ? true : false; } - dfprintf(stderr, "CPU info (x86-64):\n"); - dfprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n'); - dfprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n'); - dfprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n'); + fprintf(stderr, "CPU info (x86-64):\n"); + fprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n'); + fprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n'); + fprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n'); + fprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n'); if (FLAC__AVX_SUPPORTED) { - dfprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n'); - dfprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n'); - dfprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n'); + fprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n'); + fprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n'); + fprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n'); } /* @@ -222,7 +220,7 @@ x86_64_cpu_info (FLAC__CPUInfo *info) } if (FLAC__AVX_SUPPORTED) { - dfprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n'); + fprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n'); } #else /* Silence compiler warnings. */ diff --git a/deps/libFLAC/include/private/bitmath.h b/deps/libFLAC/include/private/bitmath.h index 9c75f85bf4..2c8ecf53b9 100644 --- a/deps/libFLAC/include/private/bitmath.h +++ b/deps/libFLAC/include/private/bitmath.h @@ -33,6 +33,8 @@ #ifndef FLAC__PRIVATE__BITMATH_H #define FLAC__PRIVATE__BITMATH_H +#include + #include "FLAC/ordinals.h" #include "FLAC/assert.h" @@ -43,7 +45,7 @@ #endif /* Will never be emitted for MSVC, GCC, Intel compilers */ -static inline unsigned int FLAC__clz_soft_uint32(FLAC__uint32 word) +static INLINE unsigned int FLAC__clz_soft_uint32(FLAC__uint32 word) { static const unsigned char byte_to_unary_table[] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, @@ -70,7 +72,7 @@ static inline unsigned int FLAC__clz_soft_uint32(FLAC__uint32 word) byte_to_unary_table[word] + 24; } -static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v) +static INLINE unsigned int FLAC__clz_uint32(FLAC__uint32 v) { /* Never used with input 0 */ FLAC__ASSERT(v > 0); @@ -92,13 +94,13 @@ static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v) } /* Used when 64-bit bsr/clz is unavailable; can use 32-bit bsr/clz when possible */ -static inline unsigned int FLAC__clz_soft_uint64(FLAC__uint64 word) +static INLINE unsigned int FLAC__clz_soft_uint64(FLAC__uint64 word) { return (FLAC__uint32)(word>>32) ? FLAC__clz_uint32((FLAC__uint32)(word>>32)) : FLAC__clz_uint32((FLAC__uint32)word) + 32; } -static inline unsigned int FLAC__clz_uint64(FLAC__uint64 v) +static INLINE unsigned int FLAC__clz_uint64(FLAC__uint64 v) { /* Never used with input 0 */ FLAC__ASSERT(v > 0); @@ -116,14 +118,14 @@ static inline unsigned int FLAC__clz_uint64(FLAC__uint64 v) } /* These two functions work with input 0 */ -static inline unsigned int FLAC__clz2_uint32(FLAC__uint32 v) +static INLINE unsigned int FLAC__clz2_uint32(FLAC__uint32 v) { if (!v) return 32; return FLAC__clz_uint32(v); } -static inline unsigned int FLAC__clz2_uint64(FLAC__uint64 v) +static INLINE unsigned int FLAC__clz2_uint64(FLAC__uint64 v) { if (!v) return 64; @@ -153,7 +155,7 @@ static inline unsigned int FLAC__clz2_uint64(FLAC__uint64 v) * ilog2(18) = 4 */ -static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v) +static INLINE unsigned FLAC__bitmath_ilog2(FLAC__uint32 v) { FLAC__ASSERT(v > 0); #if defined(__INTEL_COMPILER) @@ -169,7 +171,7 @@ static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v) #endif } -static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) +static INLINE unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) { FLAC__ASSERT(v > 0); #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))