From 7f7f832d091c8b66254ff86cd8e897ef561b173e Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 4 Nov 2012 18:14:07 -0800 Subject: [PATCH] add packaging --- packaging/flac-1.2.1-asm.patch | 73 +++ packaging/flac-1.2.1-bitreader.patch | 558 +++++++++++++++++++++ .../flac-disable-hidden-visibility-for-ppc.patch | 12 + packaging/flac-gcc43-fixes.diff | 10 + packaging/flac-gcc47.patch | 13 + packaging/flac-leaks.patch | 70 +++ packaging/flac-no-xmms.diff | 17 + packaging/flac-ocloexec.patch | 73 +++ packaging/flac-printf-format-fix.diff | 43 ++ packaging/flac-visibility.patch | 348 +++++++++++++ packaging/flac.spec | 120 +++++ 11 files changed, 1337 insertions(+) create mode 100644 packaging/flac-1.2.1-asm.patch create mode 100644 packaging/flac-1.2.1-bitreader.patch create mode 100644 packaging/flac-disable-hidden-visibility-for-ppc.patch create mode 100644 packaging/flac-gcc43-fixes.diff create mode 100644 packaging/flac-gcc47.patch create mode 100644 packaging/flac-leaks.patch create mode 100644 packaging/flac-no-xmms.diff create mode 100644 packaging/flac-ocloexec.patch create mode 100644 packaging/flac-printf-format-fix.diff create mode 100644 packaging/flac-visibility.patch create mode 100644 packaging/flac.spec diff --git a/packaging/flac-1.2.1-asm.patch b/packaging/flac-1.2.1-asm.patch new file mode 100644 index 0000000..932a761 --- /dev/null +++ b/packaging/flac-1.2.1-asm.patch @@ -0,0 +1,73 @@ +diff -up flac-1.2.1/src/libFLAC/stream_decoder.c.asm flac-1.2.1/src/libFLAC/stream_decoder.c +--- flac-1.2.1/src/libFLAC/stream_decoder.c.asm 2007-09-13 17:38:05.000000000 +0200 ++++ flac-1.2.1/src/libFLAC/stream_decoder.c 2008-01-29 10:32:17.000000000 +0100 +@@ -421,7 +421,7 @@ static FLAC__StreamDecoderInitStatus ini + #ifdef FLAC__CPU_IA32 + FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32); + #ifdef FLAC__HAS_NASM +-#if 1 /*@@@@@@ OPT: not clearly faster, needs more testing */ ++#if 0 /*@@@@@@ OPT: not clearly faster, needs more testing */ + if(decoder->private_->cpuinfo.data.ia32.bswap) + decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap; + #endif +diff -up flac-1.2.1/src/libFLAC/ia32/lpc_asm.nasm.asm flac-1.2.1/src/libFLAC/ia32/lpc_asm.nasm +--- flac-1.2.1/src/libFLAC/ia32/lpc_asm.nasm.asm 2007-03-22 05:13:05.000000000 +0100 ++++ flac-1.2.1/src/libFLAC/ia32/lpc_asm.nasm 2008-01-29 10:34:09.000000000 +0100 +@@ -1507,5 +1507,5 @@ cident FLAC__lpc_restore_signal_asm_ia32 + end + + %ifdef OBJ_FORMAT_elf +- section .note.GNU-stack noalloc ++ section .note.GNU-stack progbits noalloc noexec nowrite align=1 + %endif +diff -up flac-1.2.1/src/libFLAC/ia32/Makefile.am.asm flac-1.2.1/src/libFLAC/ia32/Makefile.am +--- flac-1.2.1/src/libFLAC/ia32/Makefile.am.asm 2007-04-04 02:01:13.000000000 +0200 ++++ flac-1.2.1/src/libFLAC/ia32/Makefile.am 2008-03-17 14:04:37.000000000 +0100 +@@ -37,7 +37,6 @@ STRIP_NON_ASM = sh $(top_srcdir)/strip_n + + noinst_LTLIBRARIES = libFLAC-asm.la + libFLAC_asm_la_SOURCES = \ +- bitreader_asm.nasm \ + cpu_asm.nasm \ + fixed_asm.nasm \ + lpc_asm.nasm \ +diff -up flac-1.2.1/src/libFLAC/ia32/bitreader_asm.nasm.asm flac-1.2.1/src/libFLAC/ia32/bitreader_asm.nasm +--- flac-1.2.1/src/libFLAC/ia32/bitreader_asm.nasm.asm 2007-03-30 02:54:53.000000000 +0200 ++++ flac-1.2.1/src/libFLAC/ia32/bitreader_asm.nasm 2008-01-29 10:32:57.000000000 +0100 +@@ -564,5 +564,5 @@ cident FLAC__bitreader_read_rice_signed_ + end + + %ifdef OBJ_FORMAT_elf +- section .note.GNU-stack noalloc ++ section .note.GNU-stack progbits noalloc noexec nowrite align=1 + %endif +diff -up flac-1.2.1/src/libFLAC/ia32/fixed_asm.nasm.asm flac-1.2.1/src/libFLAC/ia32/fixed_asm.nasm +--- flac-1.2.1/src/libFLAC/ia32/fixed_asm.nasm.asm 2007-03-22 05:13:05.000000000 +0100 ++++ flac-1.2.1/src/libFLAC/ia32/fixed_asm.nasm 2008-01-29 10:33:52.000000000 +0100 +@@ -308,5 +308,5 @@ cident FLAC__fixed_compute_best_predicto + end + + %ifdef OBJ_FORMAT_elf +- section .note.GNU-stack noalloc ++ section .note.GNU-stack progbits noalloc noexec nowrite align=1 + %endif +diff -up flac-1.2.1/src/libFLAC/ia32/cpu_asm.nasm.asm flac-1.2.1/src/libFLAC/ia32/cpu_asm.nasm +--- flac-1.2.1/src/libFLAC/ia32/cpu_asm.nasm.asm 2007-03-22 05:13:05.000000000 +0100 ++++ flac-1.2.1/src/libFLAC/ia32/cpu_asm.nasm 2008-01-29 10:33:24.000000000 +0100 +@@ -117,5 +117,5 @@ cident FLAC__cpu_info_extended_amd_asm_i + end + + %ifdef OBJ_FORMAT_elf +- section .note.GNU-stack noalloc ++ section .note.GNU-stack progbits noalloc noexec nowrite align=1 + %endif +diff -up flac-1.2.1/src/libFLAC/ia32/stream_encoder_asm.nasm.asm flac-1.2.1/src/libFLAC/ia32/stream_encoder_asm.nasm +--- flac-1.2.1/src/libFLAC/ia32/stream_encoder_asm.nasm.asm 2007-06-19 22:01:27.000000000 +0200 ++++ flac-1.2.1/src/libFLAC/ia32/stream_encoder_asm.nasm 2008-01-29 10:34:40.000000000 +0100 +@@ -155,5 +155,5 @@ cident precompute_partition_info_sums_32 + end + + %ifdef OBJ_FORMAT_elf +- section .note.GNU-stack noalloc ++ section .note.GNU-stack progbits noalloc noexec nowrite align=1 + %endif diff --git a/packaging/flac-1.2.1-bitreader.patch b/packaging/flac-1.2.1-bitreader.patch new file mode 100644 index 0000000..9d47af3 --- /dev/null +++ b/packaging/flac-1.2.1-bitreader.patch @@ -0,0 +1,558 @@ +Index: src/libFLAC/bitreader.c +=================================================================== +RCS file: /cvsroot/flac/flac/src/libFLAC/bitreader.c,v +retrieving revision 1.15 +diff -u -r1.15 bitreader.c +--- src/libFLAC/bitreader.c 28 Feb 2008 05:34:26 -0000 1.15 ++++ src/libFLAC/bitreader.c 14 Mar 2008 11:07:07 -0000 +@@ -69,13 +69,12 @@ + #endif + /* counts the # of zero MSBs in a word */ + #define COUNT_ZERO_MSBS(word) ( \ +- (word) <= 0xffff ? \ +- ( (word) <= 0xff? byte_to_unary_table[word] + 24 : byte_to_unary_table[(word) >> 8] + 16 ) : \ +- ( (word) <= 0xffffff? byte_to_unary_table[word >> 16] + 8 : byte_to_unary_table[(word) >> 24] ) \ ++ word > 0xffffff ? byte_to_unary_table[(word) >> 24] : \ ++ !word ? 32 : \ ++ word > 0xffff ? byte_to_unary_table[word >> 16] + 8 : \ ++ word > 0xff ? byte_to_unary_table[(word) >> 8] + 16 : \ ++ byte_to_unary_table[word] + 24 \ + ) +-/* this alternate might be slightly faster on some systems/compilers: */ +-#define COUNT_ZERO_MSBS2(word) ( (word) <= 0xff ? byte_to_unary_table[word] + 24 : ((word) <= 0xffff ? byte_to_unary_table[(word) >> 8] + 16 : ((word) <= 0xffffff ? byte_to_unary_table[(word) >> 16] + 8 : byte_to_unary_table[(word) >> 24])) ) +- + + /* + * This should be at least twice as large as the largest number of words +Index: src/libFLAC/bitreader.c +=================================================================== +RCS file: /cvsroot/flac/flac/src/libFLAC/bitreader.c,v +retrieving revision 1.15 +diff -u -r1.15 bitreader.c +--- src/libFLAC/bitreader.c 28 Feb 2008 05:34:26 -0000 1.15 ++++ src/libFLAC/bitreader.c 14 Mar 2008 13:19:46 -0000 +@@ -149,6 +148,7 @@ + FLAC__CPUInfo cpu_info; + }; + ++#if FLAC__BYTES_PER_WORD == 4 && FLAC__CPU_IA32 + #ifdef _MSC_VER + /* OPT: an MSVC built-in would be better */ + static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x) +@@ -173,6 +173,15 @@ + done1: + } + } ++#elif __GNUC__ ++static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len) ++{ ++ FLAC__uint32 *end; ++ ++ for(end = start + len; start < end; start++) ++ asm ("bswap %0" : "=r"(*start) : "0"(*start)); ++} ++#endif + #endif + + static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, brword word) +@@ -263,7 +272,7 @@ + #if WORDS_BIGENDIAN + #else + end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD; +-# if defined(_MSC_VER) && (FLAC__BYTES_PER_WORD == 4) ++# if FLAC__CPU_IA32 && (__GNUC__ || defined(_MSC_VER)) && FLAC__BYTES_PER_WORD == 4 + if(br->cpu_info.type == FLAC__CPUINFO_TYPE_IA32 && br->cpu_info.data.ia32.bswap) { + start = br->words; + local_swap32_block_(br->buffer + start, end - start); +Index: src/libFLAC/bitreader.c +=================================================================== +RCS file: /cvsroot/flac/flac/src/libFLAC/bitreader.c,v +retrieving revision 1.15 +diff -u -r1.15 bitreader.c +--- src/libFLAC/bitreader.c 28 Feb 2008 05:34:26 -0000 1.15 ++++ src/libFLAC/bitreader.c 17 Mar 2008 15:42:57 -0000 +@@ -803,379 +812,144 @@ + } + + /* this is by far the most heavily used reader call. it ain't pretty but it's fast */ +-/* a lot of the logic is copied, then adapted, from FLAC__bitreader_read_unary_unsigned() and FLAC__bitreader_read_raw_uint32() */ + FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter) +-/* OPT: possibly faster version for use with MSVC */ +-#ifdef _MSC_VER + { +- unsigned i; +- unsigned uval = 0; +- unsigned bits; /* the # of binary LSBs left to read to finish a rice codeword */ +- + /* try and get br->consumed_words and br->consumed_bits into register; + * must remember to flush them back to *br before calling other +- * bitwriter functions that use them, and before returning */ +- register unsigned cwords; +- register unsigned cbits; ++ * bitreader functions that use them, and before returning */ ++ unsigned cwords, words, lsbs, msbs, x, y; ++ unsigned ucbits; /* keep track of the number of unconsumed bits in word */ ++ brword b; ++ int *val, *end; + + FLAC__ASSERT(0 != br); + FLAC__ASSERT(0 != br->buffer); + /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ + FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); + FLAC__ASSERT(parameter < 32); +- /* the above two asserts also guarantee that the binary part never straddles more that 2 words, so we don't have to loop to read it */ +- +- if(nvals == 0) +- return true; +- +- cbits = br->consumed_bits; +- cwords = br->consumed_words; ++ /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */ + +- while(1) { ++ val = vals; ++ end = vals + nvals; + +- /* read unary part */ +- while(1) { +- while(cwords < br->words) { /* if we've not consumed up to a partial tail word... */ +- brword b = br->buffer[cwords] << cbits; +- if(b) { +-#if 0 /* slower, probably due to bad register allocation... */ && defined FLAC__CPU_IA32 && !defined FLAC__NO_ASM && FLAC__BITS_PER_WORD == 32 +- __asm { +- bsr eax, b +- not eax +- and eax, 31 +- mov i, eax +- } +-#else +- i = COUNT_ZERO_MSBS(b); +-#endif +- uval += i; +- bits = parameter; +- i++; +- cbits += i; +- if(cbits == FLAC__BITS_PER_WORD) { +- crc16_update_word_(br, br->buffer[cwords]); +- cwords++; +- cbits = 0; +- } +- goto break1; +- } +- else { +- uval += FLAC__BITS_PER_WORD - cbits; +- crc16_update_word_(br, br->buffer[cwords]); +- cwords++; +- cbits = 0; +- /* didn't find stop bit yet, have to keep going... */ +- } +- } +- /* at this point we've eaten up all the whole words; have to try +- * reading through any tail bytes before calling the read callback. +- * this is a repeat of the above logic adjusted for the fact we +- * don't have a whole word. note though if the client is feeding +- * us data a byte at a time (unlikely), br->consumed_bits may not +- * be zero. +- */ +- if(br->bytes) { +- const unsigned end = br->bytes * 8; +- brword b = (br->buffer[cwords] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << cbits; +- if(b) { +- i = COUNT_ZERO_MSBS(b); +- uval += i; +- bits = parameter; +- i++; +- cbits += i; +- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD); +- goto break1; +- } +- else { +- uval += end - cbits; +- cbits += end; +- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD); +- /* didn't find stop bit yet, have to keep going... */ +- } +- } +- /* flush registers and read; bitreader_read_from_client_() does +- * not touch br->consumed_bits at all but we still need to set +- * it in case it fails and we have to return false. +- */ +- br->consumed_bits = cbits; +- br->consumed_words = cwords; +- if(!bitreader_read_from_client_(br)) ++ if(parameter == 0) { ++ while(val < end) { ++ /* read the unary MSBs and end bit */ ++ if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; +- cwords = br->consumed_words; +- } +-break1: +- /* read binary part */ +- FLAC__ASSERT(cwords <= br->words); +- +- if(bits) { +- while((br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits < bits) { +- /* flush registers and read; bitreader_read_from_client_() does +- * not touch br->consumed_bits at all but we still need to set +- * it in case it fails and we have to return false. +- */ +- br->consumed_bits = cbits; +- br->consumed_words = cwords; +- if(!bitreader_read_from_client_(br)) +- return false; +- cwords = br->consumed_words; +- } +- if(cwords < br->words) { /* if we've not consumed up to a partial tail word... */ +- if(cbits) { +- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ +- const unsigned n = FLAC__BITS_PER_WORD - cbits; +- const brword word = br->buffer[cwords]; +- if(bits < n) { +- uval <<= bits; +- uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-bits); +- cbits += bits; +- goto break2; +- } +- uval <<= n; +- uval |= word & (FLAC__WORD_ALL_ONES >> cbits); +- bits -= n; +- crc16_update_word_(br, word); +- cwords++; +- cbits = 0; +- if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */ +- uval <<= bits; +- uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits)); +- cbits = bits; +- } +- goto break2; +- } +- else { +- FLAC__ASSERT(bits < FLAC__BITS_PER_WORD); +- uval <<= bits; +- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits); +- cbits = bits; +- goto break2; +- } +- } +- else { +- /* in this case we're starting our read at a partial tail word; +- * the reader has guaranteed that we have at least 'bits' bits +- * available to read, which makes this case simpler. +- */ +- uval <<= bits; +- if(cbits) { +- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ +- FLAC__ASSERT(cbits + bits <= br->bytes*8); +- uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-bits); +- cbits += bits; +- goto break2; +- } +- else { +- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits); +- cbits += bits; +- goto break2; +- } +- } +- } +-break2: +- /* compose the value */ +- *vals = (int)(uval >> 1 ^ -(int)(uval & 1)); + +- /* are we done? */ +- --nvals; +- if(nvals == 0) { +- br->consumed_bits = cbits; +- br->consumed_words = cwords; +- return true; ++ *val++ = (int)(msbs >> 1) ^ -(int)(msbs & 1); + } + +- uval = 0; +- ++vals; +- ++ return true; + } +-} +-#else +-{ +- unsigned i; +- unsigned uval = 0; + +- /* try and get br->consumed_words and br->consumed_bits into register; +- * must remember to flush them back to *br before calling other +- * bitwriter functions that use them, and before returning */ +- register unsigned cwords; +- register unsigned cbits; +- unsigned ucbits; /* keep track of the number of unconsumed bits in the buffer */ ++ FLAC__ASSERT(parameter > 0); + +- FLAC__ASSERT(0 != br); +- FLAC__ASSERT(0 != br->buffer); +- /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ +- FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); +- FLAC__ASSERT(parameter < 32); +- /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */ ++ cwords = br->consumed_words; ++ words = br->words; + +- if(nvals == 0) +- return true; ++ /* if we've not consumed up to a partial tail word... */ ++ if(cwords >= words) { ++ x = 0; ++ goto process_tail; ++ } ++ ++ ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; ++ b = br->buffer[cwords] << br->consumed_bits; /* keep unconsumed bits aligned to left */ ++ ++ while(val < end) { ++ /* read the unary MSBs and end bit */ ++ x = y = COUNT_ZERO_MSBS(b); ++ if(x == FLAC__BITS_PER_WORD) { ++ x = ucbits; ++ do { ++ /* didn't find stop bit yet, have to keep going... */ ++ crc16_update_word_(br, br->buffer[cwords++]); ++ if (cwords >= words) ++ goto incomplete_msbs; ++ b = br->buffer[cwords]; ++ y = COUNT_ZERO_MSBS(b); ++ x += y; ++ } while(y == FLAC__BITS_PER_WORD); ++ } ++ b <<= y; ++ b <<= 1; /* account for stop bit */ ++ ucbits = (ucbits - x - 1) % FLAC__BITS_PER_WORD; ++ msbs = x; ++ ++ /* read the binary LSBs */ ++ x = b >> (FLAC__BITS_PER_WORD - parameter); ++ if(parameter <= ucbits) { ++ ucbits -= parameter; ++ b <<= parameter; ++ } else { ++ /* there are still bits left to read, they will all be in the next word */ ++ crc16_update_word_(br, br->buffer[cwords++]); ++ if (cwords >= words) ++ goto incomplete_lsbs; ++ b = br->buffer[cwords]; ++ ucbits += FLAC__BITS_PER_WORD - parameter; ++ x |= b >> ucbits; ++ b <<= FLAC__BITS_PER_WORD - ucbits; ++ } ++ lsbs = x; + +- cbits = br->consumed_bits; +- cwords = br->consumed_words; +- ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits; ++ /* compose the value */ ++ x = (msbs << parameter) | lsbs; ++ *val++ = (int)(x >> 1) ^ -(int)(x & 1); + +- while(1) { ++ continue; + +- /* read unary part */ +- while(1) { +- while(cwords < br->words) { /* if we've not consumed up to a partial tail word... */ +- brword b = br->buffer[cwords] << cbits; +- if(b) { +-#if 0 /* is not discernably faster... */ && defined FLAC__CPU_IA32 && !defined FLAC__NO_ASM && FLAC__BITS_PER_WORD == 32 && defined __GNUC__ +- asm volatile ( +- "bsrl %1, %0;" +- "notl %0;" +- "andl $31, %0;" +- : "=r"(i) +- : "r"(b) +- ); +-#else +- i = COUNT_ZERO_MSBS(b); +-#endif +- uval += i; +- cbits += i; +- cbits++; /* skip over stop bit */ +- if(cbits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(cbits == FLAC__BITS_PER_WORD) */ +- crc16_update_word_(br, br->buffer[cwords]); +- cwords++; +- cbits = 0; +- } +- goto break1; +- } +- else { +- uval += FLAC__BITS_PER_WORD - cbits; +- crc16_update_word_(br, br->buffer[cwords]); +- cwords++; +- cbits = 0; +- /* didn't find stop bit yet, have to keep going... */ +- } +- } +- /* at this point we've eaten up all the whole words; have to try +- * reading through any tail bytes before calling the read callback. +- * this is a repeat of the above logic adjusted for the fact we +- * don't have a whole word. note though if the client is feeding +- * us data a byte at a time (unlikely), br->consumed_bits may not +- * be zero. +- */ +- if(br->bytes) { +- const unsigned end = br->bytes * 8; +- brword b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end)) << cbits; +- if(b) { +- i = COUNT_ZERO_MSBS(b); +- uval += i; +- cbits += i; +- cbits++; /* skip over stop bit */ +- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD); +- goto break1; +- } +- else { +- uval += end - cbits; +- cbits += end; +- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD); +- /* didn't find stop bit yet, have to keep going... */ +- } ++ /* at this point we've eaten up all the whole words */ ++process_tail: ++ do { ++ if(0) { ++incomplete_msbs: ++ br->consumed_bits = 0; ++ br->consumed_words = cwords; + } +- /* flush registers and read; bitreader_read_from_client_() does +- * not touch br->consumed_bits at all but we still need to set +- * it in case it fails and we have to return false. +- */ +- br->consumed_bits = cbits; +- br->consumed_words = cwords; +- if(!bitreader_read_from_client_(br)) ++ ++ /* read the unary MSBs and end bit */ ++ if(!FLAC__bitreader_read_unary_unsigned(br, &msbs)) + return false; +- cwords = br->consumed_words; +- ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits + uval; +- /* + uval to offset our count by the # of unary bits already +- * consumed before the read, because we will add these back +- * in all at once at break1 +- */ +- } +-break1: +- ucbits -= uval; +- ucbits--; /* account for stop bit */ +- +- /* read binary part */ +- FLAC__ASSERT(cwords <= br->words); +- +- if(parameter) { +- while(ucbits < parameter) { +- /* flush registers and read; bitreader_read_from_client_() does +- * not touch br->consumed_bits at all but we still need to set +- * it in case it fails and we have to return false. +- */ +- br->consumed_bits = cbits; ++ msbs += x; ++ x = ucbits = 0; ++ ++ if(0) { ++incomplete_lsbs: ++ br->consumed_bits = 0; + br->consumed_words = cwords; +- if(!bitreader_read_from_client_(br)) +- return false; +- cwords = br->consumed_words; +- ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits; +- } +- if(cwords < br->words) { /* if we've not consumed up to a partial tail word... */ +- if(cbits) { +- /* this also works when consumed_bits==0, it's just slower than necessary for that case */ +- const unsigned n = FLAC__BITS_PER_WORD - cbits; +- const brword word = br->buffer[cwords]; +- if(parameter < n) { +- uval <<= parameter; +- uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-parameter); +- cbits += parameter; +- } +- else { +- uval <<= n; +- uval |= word & (FLAC__WORD_ALL_ONES >> cbits); +- crc16_update_word_(br, word); +- cwords++; +- cbits = parameter - n; +- if(cbits) { /* parameter > n, i.e. if there are still bits left to read, there have to be less than 32 so they will all be in the next word */ +- uval <<= cbits; +- uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits)); +- } +- } +- } +- else { +- cbits = parameter; +- uval <<= parameter; +- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits); +- } + } +- else { +- /* in this case we're starting our read at a partial tail word; +- * the reader has guaranteed that we have at least 'parameter' +- * bits available to read, which makes this case simpler. +- */ +- uval <<= parameter; +- if(cbits) { +- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ +- FLAC__ASSERT(cbits + parameter <= br->bytes*8); +- uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-parameter); +- cbits += parameter; +- } +- else { +- cbits = parameter; +- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits); +- } +- } +- } + +- ucbits -= parameter; +- +- /* compose the value */ +- *vals = (int)(uval >> 1 ^ -(int)(uval & 1)); ++ /* read the binary LSBs */ ++ if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter - ucbits)) ++ return false; ++ lsbs = x | lsbs; + +- /* are we done? */ +- --nvals; +- if(nvals == 0) { +- br->consumed_bits = cbits; +- br->consumed_words = cwords; +- return true; +- } ++ /* compose the value */ ++ x = (msbs << parameter) | lsbs; ++ *val++ = (int)(x >> 1) ^ -(int)(x & 1); ++ x = 0; + +- uval = 0; +- ++vals; ++ cwords = br->consumed_words; ++ words = br->words; ++ ucbits = FLAC__BITS_PER_WORD - br->consumed_bits; ++ b = br->buffer[cwords] << br->consumed_bits; ++ } while(cwords >= words && val < end); ++ } + ++ if(ucbits == 0 && cwords < words) { ++ /* don't leave the head word with no unconsumed bits */ ++ crc16_update_word_(br, br->buffer[cwords++]); ++ ucbits = FLAC__BITS_PER_WORD; + } ++ ++ br->consumed_bits = FLAC__BITS_PER_WORD - ucbits; ++ br->consumed_words = cwords; ++ ++ return true; + } +-#endif + + #if 0 /* UNUSED */ + FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter) diff --git a/packaging/flac-disable-hidden-visibility-for-ppc.patch b/packaging/flac-disable-hidden-visibility-for-ppc.patch new file mode 100644 index 0000000..597e235 --- /dev/null +++ b/packaging/flac-disable-hidden-visibility-for-ppc.patch @@ -0,0 +1,12 @@ +Index: flac-1.2.1/src/libFLAC/Makefile.am +=================================================================== +--- flac-1.2.1.orig/src/libFLAC/Makefile.am ++++ flac-1.2.1/src/libFLAC/Makefile.am +@@ -68,7 +68,6 @@ endif + endif + endif + endif +-libFLAC_la_CFLAGS = -fvisibility=hidden + libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ + + SUBDIRS = $(ARCH_SUBDIRS) include . diff --git a/packaging/flac-gcc43-fixes.diff b/packaging/flac-gcc43-fixes.diff new file mode 100644 index 0000000..8d41490 --- /dev/null +++ b/packaging/flac-gcc43-fixes.diff @@ -0,0 +1,10 @@ +--- examples/cpp/encode/file/main.cpp-dist 2007-10-22 15:14:12.000000000 +0200 ++++ examples/cpp/encode/file/main.cpp 2007-10-22 15:14:41.000000000 +0200 +@@ -30,6 +30,7 @@ + + #include + #include ++#include + #include "FLAC++/metadata.h" + #include "FLAC++/encoder.h" + diff --git a/packaging/flac-gcc47.patch b/packaging/flac-gcc47.patch new file mode 100644 index 0000000..2fd37a6 --- /dev/null +++ b/packaging/flac-gcc47.patch @@ -0,0 +1,13 @@ +Index: flac-1.2.1/src/metaflac/options.c +=================================================================== +--- flac-1.2.1.orig/src/metaflac/options.c ++++ flac-1.2.1/src/metaflac/options.c +@@ -1041,7 +1041,7 @@ FLAC__bool parse_block_type(const char * + out->entries[entry].filter_application_by_id = (0 != r); + if(0 != r) { + if(strlen(r) == 4) { +- strcpy(out->entries[entry].application_id, r); ++ memcpy(out->entries[entry].application_id, r, 4); + } + else if(strlen(r) == 10 && strncmp(r, "0x", 2) == 0 && strspn(r+2, "0123456789ABCDEFabcdef") == 8) { + FLAC__uint32 x = strtoul(r+2, 0, 16); diff --git a/packaging/flac-leaks.patch b/packaging/flac-leaks.patch new file mode 100644 index 0000000..f0b43e4 --- /dev/null +++ b/packaging/flac-leaks.patch @@ -0,0 +1,70 @@ +--- src/libFLAC/metadata_iterators.c.orig ++++ src/libFLAC/metadata_iterators.c +@@ -1217,6 +1217,7 @@ static FLAC__bool chain_read_cb_(FLAC__M + } + + if(!read_metadata_block_header_cb_(handle, read_cb, &is_last, &type, &length)) { ++ node_delete_(node); + chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; + return false; + } +@@ -1412,11 +1413,13 @@ static FLAC__bool chain_rewrite_file_(FL + if(!open_tempfile_(chain->filename, tempfile_path_prefix, &tempfile, &tempfilename, &status)) { + chain->status = get_equivalent_status_(status); + cleanup_tempfile_(&tempfile, &tempfilename); ++ fclose(f); + return false; + } + if(!copy_n_bytes_from_file_(f, tempfile, chain->first_offset, &status)) { + chain->status = get_equivalent_status_(status); + cleanup_tempfile_(&tempfile, &tempfilename); ++ fclose(f); + return false; + } + +@@ -1424,10 +1427,14 @@ static FLAC__bool chain_rewrite_file_(FL + for(node = chain->head; node; node = node->next) { + if(!write_metadata_block_header_(tempfile, &status, node->data)) { + chain->status = get_equivalent_status_(status); ++ cleanup_tempfile_(&tempfile, &tempfilename); ++ fclose(f); + return false; + } + if(!write_metadata_block_data_(tempfile, &status, node->data)) { + chain->status = get_equivalent_status_(status); ++ cleanup_tempfile_(&tempfile, &tempfilename); ++ fclose(f); + return false; + } + } +@@ -1437,10 +1444,12 @@ static FLAC__bool chain_rewrite_file_(FL + if(0 != fseeko(f, chain->last_offset, SEEK_SET)) { + cleanup_tempfile_(&tempfile, &tempfilename); + chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; ++ fclose(f); + return false; + } + if(!copy_remaining_bytes_from_file_(f, tempfile, &status)) { + cleanup_tempfile_(&tempfile, &tempfilename); ++ fclose(f); + chain->status = get_equivalent_status_(status); + return false; + } +--- src/libFLAC/stream_encoder.c.orig ++++ src/libFLAC/stream_encoder.c +@@ -1004,10 +1004,12 @@ static FLAC__StreamEncoderInitStatus ini + /* + * Now set up a stream decoder for verification + */ +- encoder->private_->verify.decoder = FLAC__stream_decoder_new(); + if(0 == encoder->private_->verify.decoder) { +- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; +- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; ++ encoder->private_->verify.decoder = FLAC__stream_decoder_new(); ++ if(0 == encoder->private_->verify.decoder) { ++ encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; ++ return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR; ++ } + } + + if(FLAC__stream_decoder_init_stream(encoder->private_->verify.decoder, verify_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, verify_write_callback_, verify_metadata_callback_, verify_error_callback_, /*client_data=*/encoder) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { diff --git a/packaging/flac-no-xmms.diff b/packaging/flac-no-xmms.diff new file mode 100644 index 0000000..f80d680 --- /dev/null +++ b/packaging/flac-no-xmms.diff @@ -0,0 +1,17 @@ +Index: configure.in +=================================================================== +--- configure.in.orig ++++ configure.in +@@ -225,9 +225,9 @@ AC_HELP_STRING([--disable-xmms-plugin], + no) enable_xmms_plugin=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-xmms-plugin) ;; + esac],[enable_xmms_plugin=true]) +-if test "x$enable_xmms_plugin" != xfalse ; then +- AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built])) +-fi ++dnl if test "x$enable_xmms_plugin" != xfalse ; then ++dnl AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - XMMS support will not be built])) ++dnl fi + AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR") + + dnl build FLAC++ or not diff --git a/packaging/flac-ocloexec.patch b/packaging/flac-ocloexec.patch new file mode 100644 index 0000000..151df99 --- /dev/null +++ b/packaging/flac-ocloexec.patch @@ -0,0 +1,73 @@ +--- src/libFLAC/metadata_iterators.c.orig ++++ src/libFLAC/metadata_iterators.c +@@ -438,10 +438,10 @@ static FLAC__bool simple_iterator_prime_ + + FLAC__ASSERT(0 != iterator); + +- if(read_only || 0 == (iterator->file = fopen(iterator->filename, "r+b"))) { ++ if(read_only || 0 == (iterator->file = fopen(iterator->filename, "r+be"))) { + iterator->is_writable = false; + if(read_only || errno == EACCES) { +- if(0 == (iterator->file = fopen(iterator->filename, "rb"))) { ++ if(0 == (iterator->file = fopen(iterator->filename, "rbe"))) { + iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE; + return false; + } +@@ -1380,7 +1380,7 @@ static FLAC__bool chain_rewrite_metadata + + FLAC__ASSERT(0 != chain->filename); + +- if(0 == (file = fopen(chain->filename, "r+b"))) { ++ if(0 == (file = fopen(chain->filename, "r+be"))) { + chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; + return false; + } +@@ -1405,7 +1405,7 @@ static FLAC__bool chain_rewrite_file_(FL + FLAC__ASSERT(0 != chain->head); + + /* copy the file prefix (data up to first metadata block */ +- if(0 == (f = fopen(chain->filename, "rb"))) { ++ if(0 == (f = fopen(chain->filename, "rbe"))) { + chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; + return false; + } +@@ -1542,7 +1542,7 @@ static FLAC__bool chain_read_(FLAC__Meta + + chain->is_ogg = is_ogg; + +- if(0 == (file = fopen(filename, "rb"))) { ++ if(0 == (file = fopen(filename, "rbe"))) { + chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE; + return false; + } +@@ -3240,7 +3240,7 @@ FLAC__bool open_tempfile_(const char *fi + strcat(*tempfilename, tempfile_suffix); + } + +- if(0 == (*tempfile = fopen(*tempfilename, "w+b"))) { ++ if(0 == (*tempfile = fopen(*tempfilename, "w+be"))) { + *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE; + return false; + } +--- src/libFLAC/stream_decoder.c.orig ++++ src/libFLAC/stream_decoder.c +@@ -628,7 +628,7 @@ static FLAC__StreamDecoderInitStatus ini + if(0 == write_callback || 0 == error_callback) + return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; + +- file = filename? fopen(filename, "rb") : stdin; ++ file = filename? fopen(filename, "rbe") : stdin; + + if(0 == file) + return FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE; +--- src/libFLAC/stream_encoder.c.orig ++++ src/libFLAC/stream_encoder.c +@@ -1283,7 +1283,7 @@ static FLAC__StreamEncoderInitStatus ini + if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) + return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED; + +- file = filename? fopen(filename, "w+b") : stdout; ++ file = filename? fopen(filename, "w+be") : stdout; + + if(file == 0) { + encoder->protected_->state = FLAC__STREAM_ENCODER_IO_ERROR; diff --git a/packaging/flac-printf-format-fix.diff b/packaging/flac-printf-format-fix.diff new file mode 100644 index 0000000..2296cdb --- /dev/null +++ b/packaging/flac-printf-format-fix.diff @@ -0,0 +1,43 @@ +--- src/test_grabbag/cuesheet/main.c-dist 2007-04-10 19:14:42.000000000 +0200 ++++ src/test_grabbag/cuesheet/main.c 2007-04-10 19:15:33.000000000 +0200 +@@ -115,12 +115,12 @@ int main(int argc, char *argv[]) + const char *usage = "usage: test_cuesheet cuesheet_file lead_out_offset [ cdda ]\n"; + + if(argc > 1 && 0 == strcmp(argv[1], "-h")) { +- printf(usage); ++ fputs(usage, stdout); + return 0; + } + + if(argc < 3 || argc > 4) { +- fprintf(stderr, usage); ++ fputs(usage, stderr); + return 255; + } + +@@ -129,7 +129,7 @@ int main(int argc, char *argv[]) + if(0 == strcmp(argv[3], "cdda")) + is_cdda = true; + else { +- fprintf(stderr, usage); ++ fputs(usage, stderr); + return 255; + } + } +--- src/test_grabbag/picture/main.c-dist 2007-04-10 19:15:47.000000000 +0200 ++++ src/test_grabbag/picture/main.c 2007-04-10 19:16:02.000000000 +0200 +@@ -211,12 +211,12 @@ int main(int argc, char *argv[]) + const char *usage = "usage: test_pictures path_prefix\n"; + + if(argc > 1 && 0 == strcmp(argv[1], "-h")) { +- printf(usage); ++ fputs(usage, stdout); + return 0; + } + + if(argc != 2) { +- fprintf(stderr, usage); ++ fputs(usage, stderr); + return 255; + } + diff --git a/packaging/flac-visibility.patch b/packaging/flac-visibility.patch new file mode 100644 index 0000000..ac60385 --- /dev/null +++ b/packaging/flac-visibility.patch @@ -0,0 +1,348 @@ +Index: include/FLAC/export.h +=================================================================== +--- include/FLAC/export.h.orig ++++ include/FLAC/export.h +@@ -56,7 +56,7 @@ + */ + + #if defined(FLAC__NO_DLL) || !defined(_MSC_VER) +-#define FLAC_API ++#define FLAC_API __attribute__ ((visibility ("default"))) + + #else + +Index: include/FLAC++/export.h +=================================================================== +--- include/FLAC++/export.h.orig ++++ include/FLAC++/export.h +@@ -56,7 +56,7 @@ + */ + + #if defined(FLAC__NO_DLL) || !defined(_MSC_VER) +-#define FLACPP_API ++#define FLACPP_API __attribute__ ((visibility ("default"))) + + #else + +Index: src/libFLAC/Makefile.am +=================================================================== +--- src/libFLAC/Makefile.am.orig ++++ src/libFLAC/Makefile.am +@@ -68,7 +68,7 @@ endif + endif + endif + endif +- ++libFLAC_la_CFLAGS = -fvisibility=hidden + libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ + + SUBDIRS = $(ARCH_SUBDIRS) include . +@@ -96,7 +96,7 @@ extra_ogg_sources = \ + ogg_mapping.c + endif + # see 'http://www.gnu.org/software/libtool/manual.html#Libtool-versioning' for numbering convention +-libFLAC_la_LDFLAGS = -version-info 10:0:2 -lm $(LOCAL_EXTRA_LDFLAGS) ++libFLAC_la_LDFLAGS = -Wl,-Bsymbolic-functions -no-undefined -version-info 10:0:2 -lm $(LOCAL_EXTRA_LDFLAGS) + libFLAC_la_SOURCES = \ + bitmath.c \ + bitreader.c \ +Index: src/libFLAC++/Makefile.am +=================================================================== +--- src/libFLAC++/Makefile.am.orig ++++ src/libFLAC++/Makefile.am +@@ -45,8 +45,9 @@ EXTRA_DIST = \ + libFLAC++_static.vcproj \ + libFLAC++.m4 + ++libFLAC___la_CXXFLAGS= -fvisibility=hidden -fvisibility-inlines-hidden + # see 'http://www.gnu.org/software/libtool/manual.html#Libtool-versioning' for numbering convention +-libFLAC___la_LDFLAGS = -version-info 8:0:2 ++libFLAC___la_LDFLAGS = -Wl,-Bsymbolic-functions -no-undefined -version-info 8:0:2 + libFLAC___la_LIBADD = ../libFLAC/libFLAC.la + + libFLAC___la_SOURCES = \ +Index: configure.in +=================================================================== +--- configure.in.orig ++++ configure.in +@@ -18,7 +18,8 @@ + # NOTE that for many of the AM_CONDITIONALs we use the prefix FLaC__ + # instead of FLAC__ since autoconf triggers off 'AC_' in strings + +-AC_INIT(src/flac/main.c) ++AC_INIT ++AC_CONFIG_SRCDIR([src/flac/main.c]) + AM_INIT_AUTOMAKE(flac, 1.2.1) + + # Don't automagically regenerate autoconf/automake generated files unless +@@ -28,23 +29,24 @@ AM_MAINTAINER_MODE + # We need two libtools, one that builds both shared and static, and + # one that builds only static. This is because the resulting libtool + # does not allow us to choose which to build at runtime. +-AM_PROG_LIBTOOL +-sed -e 's/^build_old_libs=yes/build_old_libs=no/' libtool > libtool-disable-static +-chmod +x libtool-disable-static ++#AM_PROG_LIBTOOL ++#sed -e 's/^build_old_libs=yes/build_old_libs=no/' libtool > libtool-disable-static ++#chmod +x libtool-disable-static + + AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") + + AM_PROG_AS ++AC_PROG_CC_STDC + AC_PROG_CXX + AC_PROG_MAKE_SET +- ++AC_USE_SYSTEM_EXTENSIONS + AC_SYS_LARGEFILE + AC_FUNC_FSEEKO +- ++LT_INIT([pic-only disable-static]) + AC_CHECK_SIZEOF(void*,0) + + #@@@ new name is AC_CONFIG_HEADERS +-AM_CONFIG_HEADER(config.h) ++AC_CONFIG_HEADERS([config.h]) + + AC_C_BIGENDIAN + +@@ -110,7 +112,7 @@ AC_DEFINE(FLAC__ALIGN_MALLOC_DATA) + AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries]) + fi + +-AC_ARG_ENABLE(asm-optimizations, AC_HELP_STRING([--disable-asm-optimizations], [Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes) ++AC_ARG_ENABLE(asm-optimizations, AS_HELP_STRING([--disable-asm-optimizations],[Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes) + AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno) + if test "x$asm_opt" = xno ; then + AC_DEFINE(FLAC__NO_ASM) +@@ -118,7 +120,7 @@ AH_TEMPLATE(FLAC__NO_ASM, [define to dis + fi + + AC_ARG_ENABLE(debug, +-AC_HELP_STRING([--enable-debug], [Turn on debugging]), ++AS_HELP_STRING([--enable-debug],[Turn on debugging]), + [case "${enableval}" in + yes) debug=true ;; + no) debug=false ;; +@@ -127,7 +129,7 @@ esac],[debug=false]) + AM_CONDITIONAL(DEBUG, test "x$debug" = xtrue) + + AC_ARG_ENABLE(sse, +-AC_HELP_STRING([--enable-sse], [Enable SSE support by asserting that the OS supports SSE instructions]), ++AS_HELP_STRING([--enable-sse],[Enable SSE support by asserting that the OS supports SSE instructions]), + [case "${enableval}" in + yes) sse_os=true ;; + no) sse_os=false ;; +@@ -140,7 +142,7 @@ AH_TEMPLATE(FLAC__SSE_OS, [define if you + fi + + AC_ARG_ENABLE(3dnow, +-AC_HELP_STRING([--disable-3dnow], [Disable 3DNOW! optimizations]), ++AS_HELP_STRING([--disable-3dnow],[Disable 3DNOW! optimizations]), + [case "${enableval}" in + yes) use_3dnow=true ;; + no) use_3dnow=false ;; +@@ -153,7 +155,7 @@ AH_TEMPLATE(FLAC__USE_3DNOW, [define to + fi + + AC_ARG_ENABLE(altivec, +-AC_HELP_STRING([--disable-altivec], [Disable Altivec optimizations]), ++AS_HELP_STRING([--disable-altivec],[Disable Altivec optimizations]), + [case "${enableval}" in + yes) use_altivec=true ;; + no) use_altivec=false ;; +@@ -166,14 +168,14 @@ AH_TEMPLATE(FLAC__USE_ALTIVEC, [define t + fi + + AC_ARG_ENABLE(thorough-tests, +-AC_HELP_STRING([--disable-thorough-tests], [Disable thorough (long) testing, do only basic tests]), ++AS_HELP_STRING([--disable-thorough-tests],[Disable thorough (long) testing, do only basic tests]), + [case "${enableval}" in + yes) thorough_tests=true ;; + no) thorough_tests=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-thorough-tests) ;; + esac],[thorough_tests=true]) + AC_ARG_ENABLE(exhaustive-tests, +-AC_HELP_STRING([--enable-exhaustive-tests], [Enable exhaustive testing (VERY long)]), ++AS_HELP_STRING([--enable-exhaustive-tests],[Enable exhaustive testing (VERY long)]), + [case "${enableval}" in + yes) exhaustive_tests=true ;; + no) exhaustive_tests=false ;; +@@ -189,7 +191,7 @@ fi + AC_SUBST(FLAC__TEST_LEVEL) + + AC_ARG_ENABLE(valgrind-testing, +-AC_HELP_STRING([--enable-valgrind-testing], [Run all tests inside Valgrind]), ++AS_HELP_STRING([--enable-valgrind-testing],[Run all tests inside Valgrind]), + [case "${enableval}" in + yes) FLAC__TEST_WITH_VALGRIND=yes ;; + no) FLAC__TEST_WITH_VALGRIND=no ;; +@@ -198,7 +200,7 @@ esac],[FLAC__TEST_WITH_VALGRIND=no]) + AC_SUBST(FLAC__TEST_WITH_VALGRIND) + + AC_ARG_ENABLE(doxygen-docs, +-AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen]), ++AS_HELP_STRING([--disable-doxygen-docs],[Disable API documentation building via Doxygen]), + [case "${enableval}" in + yes) enable_doxygen_docs=true ;; + no) enable_doxygen_docs=false ;; +@@ -210,7 +212,7 @@ fi + AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN") + + AC_ARG_ENABLE(local-xmms-plugin, +-AC_HELP_STRING([--enable-local-xmms-plugin], [Install XMMS plugin to ~/.xmms/Plugins instead of system location]), ++AS_HELP_STRING([--enable-local-xmms-plugin],[Install XMMS plugin to ~/.xmms/Plugins instead of system location]), + [case "${enableval}" in + yes) install_xmms_plugin_locally=true ;; + no) install_xmms_plugin_locally=false ;; +@@ -219,7 +221,7 @@ esac],[install_xmms_plugin_locally=false + AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test "x$install_xmms_plugin_locally" = xtrue) + + AC_ARG_ENABLE(xmms-plugin, +-AC_HELP_STRING([--disable-xmms-plugin], [Do not build XMMS plugin]), ++AS_HELP_STRING([--disable-xmms-plugin],[Do not build XMMS plugin]), + [case "${enableval}" in + yes) enable_xmms_plugin=true ;; + no) enable_xmms_plugin=false ;; +@@ -232,7 +234,7 @@ AM_CONDITIONAL(FLaC__HAS_XMMS, test -n " + + dnl build FLAC++ or not + AC_ARG_ENABLE([cpplibs], +-AC_HELP_STRING([--disable-cpplibs], [Do not build libFLAC++]), ++AS_HELP_STRING([--disable-cpplibs],[Do not build libFLAC++]), + [case "${enableval}" in + yes) disable_cpplibs=false ;; + no) disable_cpplibs=true ;; +@@ -242,7 +244,7 @@ AM_CONDITIONAL(FLaC__WITH_CPPLIBS, [test + + dnl check for ogg library + AC_ARG_ENABLE([ogg], +- AC_HELP_STRING([--disable-ogg], [Disable ogg support (default: test for libogg)]), ++ AS_HELP_STRING([--disable-ogg],[Disable ogg support (default: test for libogg)]), + [ want_ogg=$enableval ], [ want_ogg=yes ] ) + + if test "x$want_ogg" != "xno"; then +@@ -300,8 +302,8 @@ if test "x$debug" = xtrue; then + else + CPPFLAGS="-DNDEBUG $CPPFLAGS" + if test "x$GCC" = xyes; then +- CPPFLAGS="-DFLaC__INLINE=__inline__ $CPPFLAGS" +- CFLAGS="-O3 -funroll-loops -finline-functions -Wall -W -Winline $CFLAGS" ++ CPPFLAGS="-DFLaC__INLINE=__always_inline $CPPFLAGS" ++ CFLAGS="$CFLAGS" + fi + fi + +Index: Makefile.am +=================================================================== +--- Makefile.am.orig ++++ Makefile.am +@@ -30,7 +30,7 @@ + + AUTOMAKE_OPTIONS = foreign 1.7 + +-SUBDIRS = doc include m4 man src examples test build obj ++SUBDIRS = doc include m4 man src examples build obj + + DISTCLEANFILES = libtool-disable-static + +Index: src/Makefile.am +=================================================================== +--- src/Makefile.am.orig ++++ src/Makefile.am +@@ -20,7 +20,7 @@ XMMS_DIRS = plugin_common plugin_xmms + endif + + if FLaC__WITH_CPPLIBS +-CPPLIBS_DIRS = libFLAC++ test_libFLAC++ ++CPPLIBS_DIRS = libFLAC++ + endif + + SUBDIRS = \ +@@ -31,11 +31,6 @@ SUBDIRS = \ + monkeys_audio_utilities \ + $(XMMS_DIRS) \ + plugin_winamp2 \ +- test_grabbag \ +- test_libs_common \ +- test_libFLAC \ +- test_seeking \ +- test_streams \ + $(CPPLIBS_DIRS) + + EXTRA_DIST = \ +Index: include/share/alloc.h +=================================================================== +--- include/share/alloc.h.orig ++++ include/share/alloc.h +@@ -48,10 +48,14 @@ + #define FLaC__INLINE + #endif + ++#define FLAC_ATTR_MALLOC __attribute__((__malloc__)) ++#define FLAC_ATTR_ALLOC_SIZE(n) __attribute__((alloc_size(n))) ++#define FLAC_ATTR_ALLOC_SIZE2(x,y) __attribute__((alloc_size(x,y))) ++ + /* avoid malloc()ing 0 bytes, see: + * https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003 + */ +-static FLaC__INLINE void *safe_malloc_(size_t size) ++static FLAC_ATTR_MALLOC FLAC_ATTR_ALLOC_SIZE(1) FLaC__INLINE void *safe_malloc_(size_t size) + { + /* malloc(0) is undefined; FLAC src convention is to always allocate */ + if(!size) +@@ -59,7 +63,7 @@ static FLaC__INLINE void *safe_malloc_(s + return malloc(size); + } + +-static FLaC__INLINE void *safe_calloc_(size_t nmemb, size_t size) ++static FLAC_ATTR_MALLOC FLAC_ATTR_ALLOC_SIZE2(1,2) FLaC__INLINE void *safe_calloc_(size_t nmemb, size_t size) + { + if(!nmemb || !size) + return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */ +Index: src/libFLAC/include/private/bitreader.h +=================================================================== +--- src/libFLAC/include/private/bitreader.h.orig ++++ src/libFLAC/include/private/bitreader.h +@@ -80,11 +80,11 @@ FLAC__bool FLAC__bitreader_skip_byte_blo + FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals); /* WATCHOUT: does not CRC the read data! */ + FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val); + FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter); +-FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter); ++FLAC__bool __attribute__((__hot__)) FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter); + #ifndef FLAC__NO_ASM + # ifdef FLAC__CPU_IA32 + # ifdef FLAC__HAS_NASM +-FLAC__bool FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter); ++FLAC__bool __attribute__((__hot__)) FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter); + # endif + # endif + #endif +Index: src/libFLAC/include/private/lpc.h +=================================================================== +--- src/libFLAC/include/private/lpc.h.orig ++++ src/libFLAC/include/private/lpc.h +@@ -165,17 +165,17 @@ void FLAC__lpc_compute_residual_from_qlp + * IN data[-order,-1] previously-reconstructed historical samples + * OUT data[0,data_len-1] original signal + */ +-void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +-void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); ++void __attribute__((__hot__)) FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); ++void __attribute__((__hot__)) FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + #ifndef FLAC__NO_ASM + # ifdef FLAC__CPU_IA32 + # ifdef FLAC__HAS_NASM +-void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +-void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); ++void __attribute__((__hot__)) FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); ++void __attribute__((__hot__)) FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + # endif /* FLAC__HAS_NASM */ + # elif defined FLAC__CPU_PPC +-void FLAC__lpc_restore_signal_asm_ppc_altivec_16(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +-void FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); ++void __attribute__((__hot__)) FLAC__lpc_restore_signal_asm_ppc_altivec_16(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); ++void __attribute__((__hot__)) FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + # endif/* FLAC__CPU_IA32 || FLAC__CPU_PPC */ + #endif /* FLAC__NO_ASM */ + diff --git a/packaging/flac.spec b/packaging/flac.spec new file mode 100644 index 0000000..18d18cb --- /dev/null +++ b/packaging/flac.spec @@ -0,0 +1,120 @@ +Name: flac +BuildRequires: gcc-c++ +BuildRequires: gettext-tools +BuildRequires: libogg-devel +BuildRequires: libtool +BuildRequires: pkg-config +%ifarch %{ix86} +BuildRequires: nasm +%endif +Version: 1.2.1 +Release: 0 +License: BSD-3-Clause +Summary: Free Lossless Audio Codec +Url: http://flac.sourceforge.net/ +Group: Productivity/Multimedia/Sound/Utilities +Source: %{name}-%{version}.tar.bz2 +Patch0: flac-no-xmms.diff +Patch1: flac-printf-format-fix.diff +Patch2: flac-gcc43-fixes.diff +Patch3: flac-1.2.1-asm.patch +Patch4: flac-1.2.1-bitreader.patch +Patch5: flac-ocloexec.patch +Patch6: flac-visibility.patch +Patch7: flac-leaks.patch +Patch8: flac-disable-hidden-visibility-for-ppc.patch +Patch9: flac-gcc47.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +FLAC is an open source lossless audio codec developed by Josh Coalson. + +%package -n libflac +Summary: Free Lossless Audio Codec Library +Group: System/Libraries + +%description -n libflac +This package contains the library for FLAC (Free Lossless Audio Codec) +developed by Josh Coalson. + +%package -n libflac++ +Summary: Free Lossless Audio Codec Library +Group: System/Libraries + +%description -n libflac++ +This package contains the C++ library for FLAC (Free Lossless Audio +Codec) developed by Josh Coalson. + +%package devel +Summary: FLAC Library Development Package +Group: Development/Libraries/C and C++ +Requires: glibc-devel +Requires: libflac = %{version} +Requires: libflac = %{version} +Requires: libstdc++-devel + +%description devel +This package contains the files needed to compile programs that use the +FLAC library. + +%prep +%setup -q +%patch0 +%patch1 +%patch2 +%patch3 -p1 +%patch4 +%patch5 +%patch6 +%patch7 +%patch9 -p1 + +%build +autoreconf --force --install +%define warn_flags -O3 -W -Wall -Wstrict-prototypes -Wformat-security +export CFLAGS="%{optflags} %{warn_flags}" +export CXXFLAGS="$CFLAGS" +%configure --disable-thorough-tests --disable-exhaustive-tests\ + --disable-xmms-plugin \ + --disable-static \ + --disable-rpath \ + --with-pic \ + --enable-sse + +make %{?_smp_mflags} + +%install +%make_install +# documents +mkdir -p %{buildroot}%{_docdir} +mv %{buildroot}%{_datadir}/doc/%{name}-%{version} %{buildroot}%{_docdir}/%{name} +cp -a AUTHORS README COPYING.* %{buildroot}%{_docdir}/%{name} + +%post -n libflac -p /sbin/ldconfig + +%postun -n libflac -p /sbin/ldconfig + +%post -n libflac++ -p /sbin/ldconfig + +%postun -n libflac++ -p /sbin/ldconfig + +%files +%defattr(-, root, root) +%doc %{_docdir}/%{name} +%{_bindir}/* +%{_mandir}/man*/* + +%files -n libflac +%defattr(-, root, root) +%{_libdir}/libFLAC.so.8* + +%files -n libflac++ +%defattr(-, root, root) +%{_libdir}/libFLAC++.so.6* + +%files devel +%defattr(-, root, root) +%{_libdir}/lib*.so +%{_includedir}/* +%{_libdir}/pkgconfig/*.pc +%{_datadir}/aclocal/*.m4 -- 2.7.4