Add file include/share/compat.h and start moving CPP hackery into it.

This commit is contained in:
Erik de Castro Lopo
2012-02-04 16:13:37 +11:00
parent 494919106a
commit 59afe36f71
19 changed files with 85 additions and 128 deletions

View File

@@ -28,11 +28,9 @@
# include <config.h> # include <config.h>
#endif #endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "share/compat.h"
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);

View File

@@ -28,12 +28,10 @@
# include <config.h> # include <config.h>
#endif #endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "share/compat.h"
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "FLAC/stream_encoder.h" #include "FLAC/stream_encoder.h"

61
include/share/compat.h Normal file
View File

@@ -0,0 +1,61 @@
/* libFLAC - Free Lossless Audio Codec library
* Copyright (C) 2012 Xiph.org Foundation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Xiph.org Foundation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* This is the prefered location of all CPP hackery to make $random_compiler
* work like something approaching a C99 (or maybe more accurately GNU99)
* compiler.
*
* It is assumed that this header will be included after "config.h".
*/
#if defined _WIN32 && !defined __CYGWIN__
/* where MSVC puts unlink() */
# include <io.h>
#else
# include <unistd.h>
#endif
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif

View File

@@ -20,23 +20,6 @@
# include <config.h> # include <config.h>
#endif #endif
#if defined _WIN32 && !defined __CYGWIN__
/* where MSVC puts unlink() */
# include <io.h>
#else
# include <unistd.h>
#endif
#if defined _MSC_VER || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include <errno.h> #include <errno.h>
#include <math.h> /* for floor() */ #include <math.h> /* for floor() */
#include <stdio.h> /* for FILE etc. */ #include <stdio.h> /* for FILE etc. */
@@ -44,6 +27,7 @@
#include "FLAC/all.h" #include "FLAC/all.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/replaygain_synthesis.h" #include "share/replaygain_synthesis.h"
#include "share/compat.h"
#include "decode.h" #include "decode.h"
typedef struct { typedef struct {

View File

@@ -20,23 +20,6 @@
# include <config.h> # include <config.h>
#endif #endif
#if defined _WIN32 && !defined __CYGWIN__
/* where MSVC puts unlink() */
# include <io.h>
#else
# include <unistd.h>
#endif
#if defined _MSC_VER || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include <errno.h> #include <errno.h>
#include <limits.h> /* for LONG_MAX */ #include <limits.h> /* for LONG_MAX */
#include <math.h> /* for floor() */ #include <math.h> /* for floor() */
@@ -46,6 +29,7 @@
#include "FLAC/all.h" #include "FLAC/all.h"
#include "share/alloc.h" #include "share/alloc.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h"
#include "encode.h" #include "encode.h"
#ifdef min #ifdef min

View File

@@ -20,23 +20,13 @@
# include <config.h> # include <config.h>
#endif #endif
#if defined _MSC_VER || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include <stdio.h> /* for FILE etc. */ #include <stdio.h> /* for FILE etc. */
#include <stdlib.h> /* for calloc() etc. */ #include <stdlib.h> /* for calloc() etc. */
#include <string.h> /* for memcmp() etc. */ #include <string.h> /* for memcmp() etc. */
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "share/alloc.h" #include "share/alloc.h"
#include "share/compat.h"
#include "foreign_metadata.h" #include "foreign_metadata.h"
#ifdef min #ifdef min

View File

@@ -23,17 +23,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if defined _MSC_VER || defined __MINGW32__ #include "share/compat.h"
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include "foreign_metadata.h" #include "foreign_metadata.h"
static FLAC__uint32 unpack32be_(const FLAC__byte *b) static FLAC__uint32 unpack32be_(const FLAC__byte *b)

View File

@@ -46,14 +46,6 @@
#endif #endif
#include <io.h> /* for chmod() */ #include <io.h> /* for chmod() */
#include <sys/types.h> /* for off_t */ #include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#else #else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */ #include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */ #include <utime.h> /* for utime() */
@@ -66,6 +58,7 @@
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
#include "share/alloc.h" #include "share/alloc.h"
#include "share/compat.h"
#ifdef max #ifdef max
#undef max #undef max

View File

@@ -46,19 +46,10 @@
#include <stdlib.h> /* for malloc() */ #include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcpy() */ #include <string.h> /* for memcpy() */
#include <sys/types.h> /* for off_t */ #include <sys/types.h> /* for off_t */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
#include "share/alloc.h" #include "share/alloc.h"
#include "share/compat.h"
#include "protected/stream_encoder.h" #include "protected/stream_encoder.h"
#include "private/bitwriter.h" #include "private/bitwriter.h"
#include "private/bitmath.h" #include "private/bitmath.h"

View File

@@ -27,9 +27,7 @@
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "share/alloc.h" #include "share/alloc.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#if HAVE_INTTYPES_H #include "share/compat.h"
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -21,15 +21,13 @@
#endif #endif
#include <errno.h> #include <errno.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> /* for snprintf() */ #include <stdio.h> /* for snprintf() */
#include <string.h> #include <string.h>
#include "options.h" #include "options.h"
#include "utils.h" #include "utils.h"
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h"
#include "operations_shorthand.h" #include "operations_shorthand.h"
static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link); static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link);

View File

@@ -24,9 +24,7 @@
#include "utils.h" #include "utils.h"
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#if HAVE_INTTYPES_H #include "share/compat.h"
#include <inttypes.h>
#endif
#include <string.h> #include <string.h>
#include "operations_shorthand.h" #include "operations_shorthand.h"

View File

@@ -21,10 +21,8 @@
#endif #endif
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h"
#include "FLAC/assert.h" #include "FLAC/assert.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -24,20 +24,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if defined _MSC_VER || defined __MINGW32__
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include "decoders.h" #include "decoders.h"
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h"
#include "test_libs_common/file_utils_flac.h" #include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h" #include "test_libs_common/metadata_utils.h"

View File

@@ -21,9 +21,6 @@
#endif #endif
#include <errno.h> #include <errno.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -31,6 +28,7 @@
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/stream_encoder.h" #include "FLAC/stream_encoder.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h"
#include "test_libs_common/file_utils_flac.h" #include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h" #include "test_libs_common/metadata_utils.h"

View File

@@ -26,14 +26,6 @@
#if defined _MSC_VER || defined __MINGW32__ #if defined _MSC_VER || defined __MINGW32__
#include <sys/utime.h> /* for utime() */ #include <sys/utime.h> /* for utime() */
#include <io.h> /* for chmod() */ #include <io.h> /* for chmod() */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#else #else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */ #include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */ #include <utime.h> /* for utime() */
@@ -44,6 +36,7 @@
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "share/grabbag.h" #include "share/grabbag.h"
#include "share/compat.h"
#include "test_libs_common/file_utils_flac.h" #include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h" #include "test_libs_common/metadata_utils.h"
#include "metadata.h" #include "metadata.h"

View File

@@ -23,10 +23,8 @@
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "test_libs_common/metadata_utils.h" #include "test_libs_common/metadata_utils.h"
#include "share/compat.h"
#include "metadata.h" #include "metadata.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* for malloc() */ #include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcmp() */ #include <string.h> /* for memcmp() */

View File

@@ -26,9 +26,7 @@
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "test_libs_common/metadata_utils.h" #include "test_libs_common/metadata_utils.h"
#if HAVE_INTTYPES_H #include "share/compat.h"
#include <inttypes.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* for malloc() */ #include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcmp() */ #include <string.h> /* for memcmp() */

View File

@@ -20,9 +20,6 @@
# include <config.h> # include <config.h>
#endif #endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -36,6 +33,7 @@
#include "FLAC/assert.h" #include "FLAC/assert.h"
#include "FLAC/metadata.h" #include "FLAC/metadata.h"
#include "FLAC/stream_decoder.h" #include "FLAC/stream_decoder.h"
#include "share/compat.h"
typedef struct { typedef struct {
FLAC__int32 **pcm; FLAC__int32 **pcm;