commit patch for compiling on mingw32
authorJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 13 Nov 2001 21:37:04 +0000 (21:37 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 13 Nov 2001 21:37:04 +0000 (21:37 +0000)
build/config.mk
include/FLAC/ordinals.h.in
src/flac/decode.c
src/flac/encode.c
src/flac/file.c
src/flac/main.c
src/libFLAC/fixed.c
src/libFLAC/lpc.c
src/libFLAC/seekable_stream_decoder.c
src/test_streams/main.c

index c593148..e861fe5 100644 (file)
@@ -25,10 +25,10 @@ ORDINALS_H = ../../include/FLAC/ordinals.h
 
 $(ORDINALS_H): $(ORDINALS_H).in
        sed \
-               -e 's/@FLaC__SIZE16@/short/g' \
-               -e 's/@FLaC__SIZE32@/int/g' \
-               -e 's/@FLaC__SIZE64@/long long/g' \
-               -e 's/@FLaC__USIZE16@/unsigned short/g' \
-               -e 's/@FLaC__USIZE32@/unsigned int/g' \
-               -e 's/@FLaC__USIZE64@/unsigned long long/g' \
+               -e "s/@FLaC__SIZE16@/short/g" \
+               -e "s/@FLaC__SIZE32@/int/g" \
+               -e "s/@FLaC__SIZE64@/long long/g" \
+               -e "s/@FLaC__USIZE16@/unsigned short/g" \
+               -e "s/@FLaC__USIZE32@/unsigned int/g" \
+               -e "s/@FLaC__USIZE64@/unsigned long long/g" \
                $< > $@
index 7b00d00..85c8dff 100644 (file)
@@ -34,7 +34,7 @@ typedef int FLAC__bool;
 typedef signed char FLAC__int8;
 typedef unsigned char FLAC__uint8;
 
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
 typedef __int16 FLAC__int16;
 typedef __int32 FLAC__int32;
 typedef __int64 FLAC__int64;
index 0b5eaeb..507105b 100644 (file)
@@ -784,7 +784,7 @@ void error_callback(const void *decoder, FLAC__StreamDecoderErrorStatus status,
 void print_stats(const stream_info_struct *stream_info)
 {
        if(stream_info->verbose) {
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
                /* with VC++ you have to spoon feed it the casting */
                const double progress = (double)(FLAC__int64)stream_info->samples_processed / (double)(FLAC__int64)stream_info->total_samples * 100.0;
 #else
index 643fb08..a83f36d 100644 (file)
@@ -1245,7 +1245,7 @@ void verify_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecod
 
 void print_stats(const encoder_wrapper_struct *encoder_wrapper)
 {
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
        /* with VC++ you have to spoon feed it the casting */
        const double progress = (double)(FLAC__int64)encoder_wrapper->samples_written / (double)(FLAC__int64)encoder_wrapper->total_samples_to_encode;
        const double ratio = (double)(FLAC__int64)encoder_wrapper->bytes_written / ((double)(FLAC__int64)encoder_wrapper->unencoded_size * progress);
index 366ad94..fa6a9e4 100644 (file)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
 #include <sys/utime.h> /* for utime() */
 #include <io.h> /* for chmod() */
 #else
@@ -38,7 +38,7 @@ void flac__file_copy_metadata(const char *srcpath, const char *destpath)
                srctime.modtime = srcstat.st_mtime;
                (void)chmod(destpath, srcstat.st_mode);
                (void)utime(destpath, &srctime);
-#ifndef _MSC_VER
+#if !defined _MSC_VER && !defined __MINGW32__
                (void)chown(destpath, srcstat.st_uid, -1);
                (void)chown(destpath, -1, srcstat.st_gid);
 #endif
index 642cb27..f335200 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifndef _MSC_VER
+#if !defined _MSC_VER && !defined __MINGW32__
 /* unlink is in stdio.h in VC++ */
 #include <unistd.h> /* for unlink() */
 #else
index b7ac892..afa045f 100644 (file)
@@ -110,7 +110,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig
        /* Estimate the expected number of bits per residual signal sample. */
        /* 'total_error*' is linearly related to the variance of the residual */
        /* signal, so we use it directly to compute E(|x|) */
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
        /* with VC++ you have to spoon feed it the casting */
        residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_0 / (double) data_len) / M_LN2 : 0.0);
        residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_1 / (double) data_len) / M_LN2 : 0.0);
index 06f5e80..af8b874 100644 (file)
@@ -217,7 +217,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 data[],
                        sum += qlp_coeff[j] * (*(--history));
 #ifdef FLAC__OVERFLOW_DETECT
                        sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
-#ifdef _MSC_VER /* don't know how to do 64-bit literals in VC++ */
+#if defined _MSC_VER || defined __MINGW32__ /* don't know how to do 64-bit literals in VC++ */
                        if(sumo < 0) sumo = -sumo;
                        if(sumo > 2147483647)
 #else
@@ -268,7 +268,7 @@ void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, c
                        sum += qlp_coeff[j] * (*(--history));
 #ifdef FLAC__OVERFLOW_DETECT
                        sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
-#ifdef _MSC_VER /* don't know how to do 64-bit literals in VC++ */
+#if defined _MSC_VER || defined __MINGW32__ /* don't know how to do 64-bit literals in VC++ */
                        if(sumo < 0) sumo = -sumo;
                        if(sumo > 2147483647)
 #else
index 31b02f0..dfb5200 100644 (file)
@@ -636,7 +636,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
                        const FLAC__uint64 target_offset = target_sample - decoder->private_->seek_table->points[lower_seek_point].sample_number;
                        const FLAC__uint64 range_samples = decoder->private_->seek_table->points[upper_seek_point].sample_number - decoder->private_->seek_table->points[lower_seek_point].sample_number;
                        const FLAC__uint64 range_bytes = upper_bound - lower_bound;
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
                        /* with VC++ you have to spoon feed it the casting */
                        pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)(FLAC__int64)target_offset / (double)(FLAC__int64)range_samples * (double)(FLAC__int64)(range_bytes-1)) - approx_bytes_per_frame;
 #else
@@ -646,7 +646,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
        }
        if(pos < 0) {
                /* We need to use the metadata and the filelength to estimate the position of the frame with the correct sample */
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
                /* with VC++ you have to spoon feed it the casting */
                pos = (FLAC__int64)first_frame_offset + (FLAC__int64)((double)(FLAC__int64)target_sample / (double)(FLAC__int64)decoder->private_->stream_info.total_samples * (double)(FLAC__int64)(stream_length-first_frame_offset-1)) - approx_bytes_per_frame;
 #else
index 56690f0..dee0d53 100644 (file)
@@ -19,7 +19,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifndef _MSC_VER
+#if !defined _MSC_VER && !defined __MINGW32__
 #include <sys/time.h>
 #endif
 #include "FLAC/assert.h"
@@ -392,7 +392,7 @@ static FLAC__bool generate_noise(const char *fn, unsigned bytes)
 {
        FILE *f;
        unsigned b;
-#ifndef _MSC_VER
+#if !defined _MSC_VER && !defined __MINGW32__
        struct timeval tv;
 
        if(gettimeofday(&tv, 0) < 0) {
@@ -408,7 +408,7 @@ static FLAC__bool generate_noise(const char *fn, unsigned bytes)
                return false;
 
        for(b = 0; b < bytes; b++) {
-#ifndef _MSC_VER
+#if !defined _MSC_VER && !defined __MINGW32__
                FLAC__byte x = (FLAC__byte)(((unsigned)random()) & 0xff);
 #else
                FLAC__byte x = (FLAC__byte)((((unsigned)generate_noise) >> 8) ^ (b * 17)); /* fake it */