From 06e6dc3e8003ed29a525f319a4e742a574c77099 Mon Sep 17 00:00:00 2001 From: John Sully Date: Sat, 9 Jun 2007 01:45:28 +0200 Subject: [PATCH 01/14] Johns inital Mixxx commit --- fidlib.c | 32 ++++++++++++++++---------------- fidlib.h | 11 ++++++++++- fidmkf.h | 5 ++++- fidrf_cmdlist.h | 16 ++++++++-------- fidrf_combined.h | 4 ++++ 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/fidlib.c b/fidlib.c index 7f03c7d..7c8d584 100644 --- a/fidlib.c +++ b/fidlib.c @@ -701,7 +701,7 @@ stack_filter(int order, int n_head, int n_val, ...) { // Make as many additional copies as necessary while (order-- > 0) { memcpy(p, q, len); - p= (void*)(len + (char*)p); + p= (FidFilter*)(len + (char*)p); } // List is already terminated due to zeroed allocation @@ -1115,7 +1115,7 @@ des_lpbl(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*) Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1139,7 +1139,7 @@ des_lphm(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*)Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1162,7 +1162,7 @@ des_lphn(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*) Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1185,7 +1185,7 @@ des_lpba(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*) Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1388,7 +1388,7 @@ fid_design(char *spec, double rate, double freq0, double freq1, int f_adj, char if (descp) { char *fmt= filter[sp.fi].txt; int max= strlen(fmt) + 60 + sp.n_arg * 20; - char *desc= Alloc(max); + char *desc= (char*) Alloc(max); char *p= desc; char ch; double *arg= sp.argarr; @@ -1959,14 +1959,14 @@ fid_rewrite_spec(char *spec, double freq0, double freq1, int adj, default: buf[0]= 0; } len= strlen(buf); - rv= Alloc(sp.minlen + len + 1); + rv= (char*) Alloc(sp.minlen + len + 1); memcpy(rv, spec, sp.minlen); strcpy(rv+sp.minlen, buf); *spec1p= rv; } if (spec2p) { - char *rv= Alloc(sp.minlen + 1); + char *rv= (char *)Alloc(sp.minlen + 1); memcpy(rv, spec, sp.minlen); *spec2p= rv; *freq0p= sp.f0; @@ -2015,7 +2015,7 @@ fid_cv_array(double *arr) { dp += len; } - rv= ff= Alloc(FFCSIZE(n_head, n_val)); + rv= ff= (FidFilter*)Alloc(FFCSIZE(n_head, n_val)); // Scan through to fill in FidFilter for (dp= arr; *dp; ) { @@ -2061,7 +2061,7 @@ fid_cat(int freeme, ...) { } va_end(ap); - rv= Alloc(FFCSIZE(0,0) + len); + rv= (FidFilter*)Alloc(FFCSIZE(0,0) + len); dst= (char*)rv; va_start(ap, freeme); @@ -2147,7 +2147,7 @@ fid_parse(double rate, char **pp, FidFilter **ffp) { char buf[128]; char *p= *pp, *rew; #define INIT_LEN 128 - char *rv= Alloc(INIT_LEN); + char *rv= (char*) Alloc(INIT_LEN); char *rvend= rv + INIT_LEN; char *rvp= rv; char *tmp; @@ -2159,9 +2159,9 @@ fid_parse(double rate, char **pp, FidFilter **ffp) { char dmy; #define ERR(ptr, msg) { *pp= ptr; *ffp= 0; return msg; } -#define INCBUF { tmp= realloc(rv, (rvend-rv) * 2); if (!tmp) error("Out of memory"); \ +#define INCBUF { tmp= (char*)realloc(rv, (rvend-rv) * 2); if (!tmp) error("Out of memory"); \ rvend= (rvend-rv) * 2 + tmp; rvp= (rvp-rv) + tmp; \ - curr= (void*)(((char*)curr) - rv + tmp); rv= tmp; } + curr= (FidFilter*)(((char*)curr) - rv + tmp); rv= tmp; } while (1) { rew= p; @@ -2179,9 +2179,9 @@ fid_parse(double rate, char **pp, FidFilter **ffp) { case ']': case '}': // End of filter, return it - tmp= realloc(rv, (rvp-rv) + xtra); + tmp= (char*)realloc(rv, (rvp-rv) + xtra); if (!tmp) error("Out of memory"); - curr= (void*)((rvp-rv) + tmp); + curr= (FidFilter*)((rvp-rv) + tmp); curr->typ= 0; curr->cbm= 0; curr->len= 0; *pp= buf[0] ? (p-1) : p; *ffp= (FidFilter*)tmp; @@ -2248,7 +2248,7 @@ fid_parse(double rate, char **pp, FidFilter **ffp) { } // Must be a list of coefficients - curr= (void*)rvp; + curr= (FidFilter*)rvp; rvp += xtra; while (rvp + sizeof(double) >= rvend) INCBUF; curr->typ= typ; diff --git a/fidlib.h b/fidlib.h index 86da649..31e8136 100644 --- a/fidlib.h +++ b/fidlib.h @@ -1,7 +1,8 @@ // // fidlib include file // - +#ifndef FIDLIB_H +#define FIDLIB_H typedef struct FidFilter FidFilter; struct FidFilter { short typ; // Type of filter element 'I' IIR, 'F' FIR, or 0 for end of list @@ -35,6 +36,9 @@ typedef double (FidFunc)(void*, double); // // Prototypes // +#ifdef MIXXX +extern "C" { +#endif extern void fid_set_error_handler(void(*rout)(char *)); extern char *fid_version(); @@ -66,3 +70,8 @@ extern void fid_run_initbuf(void *run, void *buf); extern void fid_run_zapbuf(void *buf); extern void fid_run_freebuf(void *runbuf); extern void fid_run_free(void *run); + +#ifdef MIXXX +} +#endif +#endif diff --git a/fidmkf.h b/fidmkf.h index 37c7b50..95a003a 100644 --- a/fidmkf.h +++ b/fidmkf.h @@ -128,6 +128,8 @@ // Not A Lawyer". // +#ifndef FIDMK_H +#define FIDMK_H #ifdef HUGE_VAL #define INF HUGE_VAL @@ -729,7 +731,7 @@ z2fidfilter(double gain, int cbm) { ff->len= 0; ff= FFNEXT(ff); - rv= realloc(rv, ((char*)ff)-((char*)rv)); + rv= (FidFilter*) realloc(rv, ((char*)ff)-((char*)rv)); if (!rv) error("Out of memory"); return rv; } @@ -831,3 +833,4 @@ prop_integral(double freq) { } // END // +#endif diff --git a/fidrf_cmdlist.h b/fidrf_cmdlist.h index fbe7883..eb9ffe8 100644 --- a/fidrf_cmdlist.h +++ b/fidrf_cmdlist.h @@ -76,7 +76,7 @@ typedef unsigned char uchar; static double filter_step(void *fbuf, double iir) { double *coef= ((RunBuf*)fbuf)->coef; - uchar *cmd= ((RunBuf*)fbuf)->cmd; + uchar *cmd= (uchar*) ((RunBuf*)fbuf)->cmd; double *buf= &((RunBuf*)fbuf)->buf[0]; uchar ch; double fir= 0; @@ -228,7 +228,7 @@ fid_run_new(FidFilter *filt, double (**funcpp)(void *,double)) { // Allocate worst-case sizes for temporary arrays coef_tmp= ALLOC_ARR(coef_max= filt_cnt + 1, double); - cmd_tmp= ALLOC_ARR(cmd_max= filt_cnt + 4, char); + cmd_tmp= (uchar*)ALLOC_ARR(cmd_max= filt_cnt + 4, char); dp= coef_tmp; cp= cmd_tmp; prev= 0; @@ -386,7 +386,7 @@ fid_run_new(FidFilter *filt, double (**funcpp)(void *,double)) { void * fid_run_newbuf(void *run) { - Run *rr= run; + Run *rr= (Run*)run; RunBuf *rb; int siz; @@ -394,7 +394,7 @@ fid_run_newbuf(void *run) { error("Bad handle passed to fid_run_newbuf()"); siz= rr->buf_size ? rr->buf_size : 1; // Minimum one element to avoid problems - rb= Alloc(sizeof(RunBuf) + siz * sizeof(double)); + rb= (RunBuf*)Alloc(sizeof(RunBuf) + siz * sizeof(double)); rb->coef= rr->coef; rb->cmd= rr->cmd; rb->mov_cnt= (siz-1) * sizeof(double); @@ -409,7 +409,7 @@ fid_run_newbuf(void *run) { int fid_run_bufsize(void *run) { - Run *rr= run; + Run *rr= (Run*) run; int siz; if (rr->magic != 0x64966325) @@ -430,8 +430,8 @@ fid_run_bufsize(void *run) { void fid_run_initbuf(void *run, void *buf) { - Run *rr= run; - RunBuf *rb= buf; + Run *rr= (Run*) run; + RunBuf *rb= (RunBuf*) buf; int siz; if (rr->magic != 0x64966325) @@ -453,7 +453,7 @@ fid_run_initbuf(void *run, void *buf) { void fid_run_zapbuf(void *buf) { - RunBuf *rb= buf; + RunBuf *rb= (RunBuf*) buf; memset(rb->buf, 0, rb->mov_cnt + sizeof(double)); } diff --git a/fidrf_combined.h b/fidrf_combined.h index dc7204b..38996d4 100644 --- a/fidrf_combined.h +++ b/fidrf_combined.h @@ -17,6 +17,9 @@ // that the code is easy to understand. // +#ifndef FIDCOMBINED_H +#define FIDCOMBINED_H + typedef struct Run { int magic; // Magic: 0x64966325 double *fir; // FIR parameters @@ -144,3 +147,4 @@ fid_run_free(void *run) { } // END // +#endif From 2a62f9bf16f0c02d9c4bcbbdf2d541c6ad6b2cfc Mon Sep 17 00:00:00 2001 From: Alex Barker Date: Mon, 25 Jul 2011 03:59:58 +0200 Subject: [PATCH 02/14] Commit Mixxx patches introducing API change to "const char *spec" --- fidlib.c | 20 ++++++++++---------- fidlib.h | 6 +++--- fidmkf.h | 18 ++++++++++++++---- fidrf_cmdlist.h | 10 +++++----- fidrf_combined.h | 1 + 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/fidlib.c b/fidlib.c index 7c8d584..690be05 100644 --- a/fidlib.c +++ b/fidlib.c @@ -1115,7 +1115,7 @@ des_lpbl(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= (FidFilter*) Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*)Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1162,7 +1162,7 @@ des_lphn(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= (FidFilter*) Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*)Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1185,7 +1185,7 @@ des_lpba(double rate, double f0, double f1, int order, int n_arg, double *arg) { double tot, adj; int max= (int)floor(wid); int a; - FidFilter *ff= (FidFilter*) Alloc(FFCSIZE(1, max*2+1)); + FidFilter *ff= (FidFilter*)Alloc(FFCSIZE(1, max*2+1)); ff->typ= 'F'; ff->cbm= 0; ff->len= max*2+1; @@ -1351,7 +1351,7 @@ struct Spec { }; FidFilter * -fid_design(char *spec, double rate, double freq0, double freq1, int f_adj, char **descp) { +fid_design(const char *spec, double rate, double freq0, double freq1, int f_adj, char **descp) { FidFilter *rv; Spec sp; double f0, f1; @@ -1388,7 +1388,7 @@ fid_design(char *spec, double rate, double freq0, double freq1, int f_adj, char if (descp) { char *fmt= filter[sp.fi].txt; int max= strlen(fmt) + 60 + sp.n_arg * 20; - char *desc= (char*) Alloc(max); + char *desc= (char*)Alloc(max); char *p= desc; char ch; double *arg= sp.argarr; @@ -1610,7 +1610,7 @@ expand_spec(char *buf, char *bufend, char *str) { // double -fid_design_coef(double *coef, int n_coef, char *spec, double rate, +fid_design_coef(double *coef, int n_coef, const char *spec, double rate, double freq0, double freq1, int adj) { FidFilter *filt= fid_design(spec, rate, freq0, freq1, adj, 0); FidFilter *ff= filt; @@ -1937,7 +1937,7 @@ parse_spec(Spec *sp) { // void -fid_rewrite_spec(char *spec, double freq0, double freq1, int adj, +fid_rewrite_spec(const char *spec, double freq0, double freq1, int adj, char **spec1p, char **spec2p, double *freq0p, double *freq1p, int *adjp) { Spec sp; @@ -1959,14 +1959,14 @@ fid_rewrite_spec(char *spec, double freq0, double freq1, int adj, default: buf[0]= 0; } len= strlen(buf); - rv= (char*) Alloc(sp.minlen + len + 1); + rv= (char*)Alloc(sp.minlen + len + 1); memcpy(rv, spec, sp.minlen); strcpy(rv+sp.minlen, buf); *spec1p= rv; } if (spec2p) { - char *rv= (char *)Alloc(sp.minlen + 1); + char *rv= (char*)Alloc(sp.minlen + 1); memcpy(rv, spec, sp.minlen); *spec2p= rv; *freq0p= sp.f0; @@ -2147,7 +2147,7 @@ fid_parse(double rate, char **pp, FidFilter **ffp) { char buf[128]; char *p= *pp, *rew; #define INIT_LEN 128 - char *rv= (char*) Alloc(INIT_LEN); + char *rv= (char*)Alloc(INIT_LEN); char *rvend= rv + INIT_LEN; char *rvp= rv; char *tmp; diff --git a/fidlib.h b/fidlib.h index 31e8136..48950e4 100644 --- a/fidlib.h +++ b/fidlib.h @@ -45,14 +45,14 @@ extern char *fid_version(); extern double fid_response_pha(FidFilter *filt, double freq, double *phase); extern double fid_response(FidFilter *filt, double freq); extern int fid_calc_delay(FidFilter *filt); -extern FidFilter *fid_design(char *spec, double rate, double freq0, double freq1, +extern FidFilter *fid_design(const char *spec, double rate, double freq0, double freq1, int f_adj, char **descp); -extern double fid_design_coef(double *coef, int n_coef, char *spec, +extern double fid_design_coef(double *coef, int n_coef, const char *spec, double rate, double freq0, double freq1, int adj); extern void fid_list_filters(FILE *out); extern int fid_list_filters_buf(char *buf, char *bufend); extern FidFilter *fid_flatten(FidFilter *filt); -extern void fid_rewrite_spec(char *spec, double freq0, double freq1, int adj, +extern void fid_rewrite_spec(const char *spec, double freq0, double freq1, int adj, char **spec1p, char **spec2p, double *freq0p, double *freq1p, int *adjp); extern FidFilter *fid_cv_array(double *arr); diff --git a/fidmkf.h b/fidmkf.h index 95a003a..d09aaa4 100644 --- a/fidmkf.h +++ b/fidmkf.h @@ -131,10 +131,19 @@ #ifndef FIDMK_H #define FIDMK_H -#ifdef HUGE_VAL +#ifndef T_MSVC + #ifdef HUGE_VAL + #define INF HUGE_VAL + #else + #define INF (1.0/0.0) + #endif +#endif + +//Hacks for crappy linker error in MSVC... - Albert +#ifdef T_MSVC + #undef HUGE_VAL + #define HUGE_VAL 1.797693134862315E+308 #define INF HUGE_VAL -#else - #define INF (1.0/0.0) #endif #define TWOPI (2*M_PI) @@ -731,7 +740,7 @@ z2fidfilter(double gain, int cbm) { ff->len= 0; ff= FFNEXT(ff); - rv= (FidFilter*) realloc(rv, ((char*)ff)-((char*)rv)); + rv= (FidFilter*)realloc(rv, ((char*)ff)-((char*)rv)); if (!rv) error("Out of memory"); return rv; } @@ -834,3 +843,4 @@ prop_integral(double freq) { // END // #endif + diff --git a/fidrf_cmdlist.h b/fidrf_cmdlist.h index eb9ffe8..7df1171 100644 --- a/fidrf_cmdlist.h +++ b/fidrf_cmdlist.h @@ -76,7 +76,7 @@ typedef unsigned char uchar; static double filter_step(void *fbuf, double iir) { double *coef= ((RunBuf*)fbuf)->coef; - uchar *cmd= (uchar*) ((RunBuf*)fbuf)->cmd; + uchar *cmd= ((RunBuf*)fbuf)->cmd; double *buf= &((RunBuf*)fbuf)->buf[0]; uchar ch; double fir= 0; @@ -409,7 +409,7 @@ fid_run_newbuf(void *run) { int fid_run_bufsize(void *run) { - Run *rr= (Run*) run; + Run *rr= (Run*)run; int siz; if (rr->magic != 0x64966325) @@ -430,8 +430,8 @@ fid_run_bufsize(void *run) { void fid_run_initbuf(void *run, void *buf) { - Run *rr= (Run*) run; - RunBuf *rb= (RunBuf*) buf; + Run *rr= (Run*)run; + RunBuf *rb= (RunBuf*)buf; int siz; if (rr->magic != 0x64966325) @@ -453,7 +453,7 @@ fid_run_initbuf(void *run, void *buf) { void fid_run_zapbuf(void *buf) { - RunBuf *rb= (RunBuf*) buf; + RunBuf *rb= (RunBuf*)buf; memset(rb->buf, 0, rb->mov_cnt + sizeof(double)); } diff --git a/fidrf_combined.h b/fidrf_combined.h index 38996d4..6b5a606 100644 --- a/fidrf_combined.h +++ b/fidrf_combined.h @@ -148,3 +148,4 @@ fid_run_free(void *run) { // END // #endif + From 3e65bf893a475ab74336c78dfa3c815bef5204ee Mon Sep 17 00:00:00 2001 From: Steven Boswell Date: Sat, 29 Mar 2014 14:37:30 -0400 Subject: [PATCH 03/14] Various build system fixes for Windows (and particularly MingW cross-compiling to Windows). --- fidlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fidlib.c b/fidlib.c index 690be05..6193252 100644 --- a/fidlib.c +++ b/fidlib.c @@ -259,7 +259,8 @@ extern FidFilter *mkfilter(char *, ...); // // Macro for local inline routines that shouldn't be visible externally -#ifdef T_MSVC +// See Mixxx Bug #1179683 +#if defined(T_MINGW) || defined(T_MSVC) #define STATIC_INLINE static __inline #else #define STATIC_INLINE static inline From dbd73b86aa3b0133bd439a27390fa1f12cf0b1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 21:35:23 +0200 Subject: [PATCH 04/14] =?UTF-8?q?removed=20"discards=20=E2=80=98const?= =?UTF-8?q?=E2=80=99=20qualifier"=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fidlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fidlib.c b/fidlib.c index 6193252..770aa1a 100644 --- a/fidlib.c +++ b/fidlib.c @@ -1338,7 +1338,7 @@ static FidFilter *auto_adjust_single(Spec *sp, double rate, double f0); static FidFilter *auto_adjust_dual(Spec *sp, double rate, double f0, double f1); struct Spec { #define MAXARG 10 - char *spec; + const char *spec; double in_f0, in_f1; int in_adj; double argarr[MAXARG]; @@ -1826,7 +1826,7 @@ parse_spec(Spec *sp) { for (a= 0; 1; a++) { char *fmt= filter[a].fmt; - char *p= sp->spec; + const char *p= sp->spec; char ch, *q; if (!fmt) return strdupf("Spec-string \"%s\" matches no known format", sp->spec); From dd32dda7c7b282993db0f41b0c96f80212f045c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 21:42:26 +0200 Subject: [PATCH 05/14] replaced #ifdef MIXXX guard with #ifdef __cplusplus --- fidlib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fidlib.h b/fidlib.h index 48950e4..e84130f 100644 --- a/fidlib.h +++ b/fidlib.h @@ -36,7 +36,7 @@ typedef double (FidFunc)(void*, double); // // Prototypes // -#ifdef MIXXX +#ifdef __cplusplus extern "C" { #endif @@ -71,7 +71,7 @@ extern void fid_run_zapbuf(void *buf); extern void fid_run_freebuf(void *runbuf); extern void fid_run_free(void *run); -#ifdef MIXXX +#ifdef __cplusplus } #endif #endif From 3d6905ca6ecbdc174eb2c27d664bde09ce89f66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 21:45:51 +0200 Subject: [PATCH 06/14] Enabled all warnings in debug mode ./mk_firun -d --- mk-firun | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk-firun b/mk-firun index 641839d..ef86b15 100755 --- a/mk-firun +++ b/mk-firun @@ -1,6 +1,6 @@ #!/bin/bash OPT="-O6 -s" -[ "$1" = "-d" ] && OPT="-g" +[ "$1" = "-d" ] && OPT="-g -Wall" -gcc -DT_LINUX $OPT fidlib.c firun.c -lm -o firun \ No newline at end of file +gcc -DT_LINUX $OPT fidlib.c firun.c -lm -o firun From 494524a7c98847558c5b146008c7e60b05d38f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 22:10:31 +0200 Subject: [PATCH 07/14] Fixed warnings --- fidrf_cmdlist.h | 4 ++-- firun.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fidrf_cmdlist.h b/fidrf_cmdlist.h index 7df1171..9389eef 100644 --- a/fidrf_cmdlist.h +++ b/fidrf_cmdlist.h @@ -76,9 +76,9 @@ typedef unsigned char uchar; static double filter_step(void *fbuf, double iir) { double *coef= ((RunBuf*)fbuf)->coef; - uchar *cmd= ((RunBuf*)fbuf)->cmd; + char *cmd= ((RunBuf*)fbuf)->cmd; double *buf= &((RunBuf*)fbuf)->buf[0]; - uchar ch; + char ch; double fir= 0; double tmp= buf[0]; int cnt; diff --git a/firun.c b/firun.c index b17fdda..14bb7b3 100644 --- a/firun.c +++ b/firun.c @@ -55,6 +55,7 @@ NL " -L Ignore following arguments, display list of filter types." #include #include #include +#include #include #include #include @@ -115,10 +116,10 @@ int n_chan; // Number of output channels int n_filt; // Number of filters FidFilter **filt; // Loaded filters -uchar *inbuf; // Input buffer -uchar *inbufend; // End of input buffer allocated space, +1 -uchar *inp; // Input pointer -uchar *inend; // End of currently-loaded data, +1 +char *inbuf; // Input buffer +char *inbufend; // End of input buffer allocated space, +1 +char *inp; // Input pointer +char *inend; // End of currently-loaded data, +1 int ineof; // Hit EOF? // @@ -264,7 +265,7 @@ void refill_input() { if (!inbuf) { int len= 16384; // 100ms of data at 44100Hz 16-bit stereo - inbuf= ALLOC_ARR(len+1, uchar); + inbuf= ALLOC_ARR(len+1, char); inbufend= inbuf+len; *inbufend= 0; // Trailing NUL so that string-reading functions can never overrun inp= inend= inbuf; @@ -315,8 +316,7 @@ input(char **ipp) { inp++; continue; case 'a': { - int cnt; - uchar *tmp; + char *tmp; // Skip WS (maybe lots of it) while (1) { @@ -329,7 +329,7 @@ input(char **ipp) { if (inend - inp < 128 && !ineof) refill_input(); if (inp == inend) goto badeof; - val= strtod(inp, (char**)&tmp); + val= strtod(inp, &tmp); if (inp == tmp) error("Bad floating-point value:\n %.20s", inp); inp= tmp; @@ -578,7 +578,6 @@ main(int ac, char **av) { char *ip= ispec; char *op= ospec; int chan= 0; - int ch; if (inend - inp < 128 && !ineof) refill_input(); From 6f17d2283676d413136165972b6279d66317ee9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 22:16:57 +0200 Subject: [PATCH 08/14] Enabled extra warnings in debug mode --- mk-firun | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mk-firun b/mk-firun index ef86b15..aede515 100755 --- a/mk-firun +++ b/mk-firun @@ -1,6 +1,7 @@ #!/bin/bash OPT="-O6 -s" -[ "$1" = "-d" ] && OPT="-g -Wall" +[ "$1" = "-d" ] && OPT="-g -Wall -Wextra" + gcc -DT_LINUX $OPT fidlib.c firun.c -lm -o firun From d9cbdd065fcbeda49bc93cda8ee8ef953a7600fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 22:26:48 +0200 Subject: [PATCH 09/14] fixed -Wsign-compare warnings --- fidlib.c | 2 +- firun.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fidlib.c b/fidlib.c index 770aa1a..bf5ac4a 100644 --- a/fidlib.c +++ b/fidlib.c @@ -311,7 +311,7 @@ strdupf(char *fmt, ...) { int len; va_start(ap, fmt); len= vsnprintf(buf, sizeof(buf), fmt, ap); - if (len < 0 || len >= sizeof(buf)-1) + if (len < 0 || len >= (int)sizeof(buf)-1) error("strdupf exceeded buffer"); rv= strdup(buf); if (!rv) error("Out of memory"); diff --git a/firun.c b/firun.c index 14bb7b3..b5296f7 100644 --- a/firun.c +++ b/firun.c @@ -367,7 +367,7 @@ input(char **ipp) { val= ((((ch2<<8) + ch1) ^ 32768) - 32768) / 32768.0; break; case 'f': - if (avail < sizeof(float)) goto badeof; + if (avail < (int)sizeof(float)) goto badeof; memcpy((void*)&fv, inp, sizeof(float)); inp += sizeof(float); val= fv; From 0a6b8455e7246c511cd4c500b477314e7f3cb284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 22:55:32 +0200 Subject: [PATCH 10/14] fixed extra warnings for unused parameters --- fidlib.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 1 deletion(-) diff --git a/fidlib.c b/fidlib.c index bf5ac4a..3a67a3d 100644 --- a/fidlib.c +++ b/fidlib.c @@ -695,7 +695,7 @@ stack_filter(int order, int n_head, int n_val, ...) { // Check length len= ((char*)p)-((char*)q); - if (len != FFCSIZE(n_head-1, n_val)) + if (len != (int)FFCSIZE(n_head-1, n_val)) error("Internal error; bad call to stack_filter(); length mismatch (%d,%d)", len, FFCSIZE(n_head-1, n_val)); @@ -825,24 +825,41 @@ do_bandstop(int mz, double f0, double f1) { static FidFilter* des_bpre(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; bandpass_res(f0, arg[0]); return z2fidfilter(1.0, ~0); // FIR constant } static FidFilter* des_bsre(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; bandstop_res(f0, arg[0]); return z2fidfilter(1.0, 0); // FIR not constant, depends on freq } static FidFilter* des_apre(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; allpass_res(f0, arg[0]); return z2fidfilter(1.0, 0); // FIR not constant, depends on freq } static FidFilter* des_pi(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; + (void)arg; prop_integral(prewarp(f0)); s2z_bilinear(); return z2fidfilter(1.0, 0); // FIR not constant, depends on freq @@ -850,6 +867,11 @@ des_pi(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_piz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; + (void)arg; prop_integral(prewarp(f0)); s2z_matchedZ(); return z2fidfilter(1.0, 0); // FIR not constant, depends on freq @@ -857,54 +879,85 @@ des_piz(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_lpbe(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; bessel(order); return do_lowpass(BL, f0); } static FidFilter* des_hpbe(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; bessel(order); return do_highpass(BL, f0); } static FidFilter* des_bpbe(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; bessel(order); return do_bandpass(BL, f0, f1); } static FidFilter* des_bsbe(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; bessel(order); return do_bandstop(BL, f0, f1); } static FidFilter* des_lpbez(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; bessel(order); return do_lowpass(MZ, f0); } static FidFilter* des_hpbez(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; bessel(order); return do_highpass(MZ, f0); } static FidFilter* des_bpbez(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; bessel(order); return do_bandpass(MZ, f0, f1); } static FidFilter* des_bsbez(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; bessel(order); return do_bandstop(MZ, f0, f1); } static FidFilter* // Butterworth-Bessel cross des_lpbube(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double tmp[MAXPZ]; int a; bessel(order); memcpy(tmp, pol, order * sizeof(double)); @@ -916,102 +969,153 @@ des_lpbube(double rate, double f0, double f1, int order, int n_arg, double *arg) static FidFilter* des_lpbu(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; butterworth(order); return do_lowpass(BL, f0); } static FidFilter* des_hpbu(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; butterworth(order); return do_highpass(BL, f0); } static FidFilter* des_bpbu(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; butterworth(order); return do_bandpass(BL, f0, f1); } static FidFilter* des_bsbu(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; butterworth(order); return do_bandstop(BL, f0, f1); } static FidFilter* des_lpbuz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; butterworth(order); return do_lowpass(MZ, f0); } static FidFilter* des_hpbuz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; + (void)arg; butterworth(order); return do_highpass(MZ, f0); } static FidFilter* des_bpbuz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; butterworth(order); return do_bandpass(MZ, f0, f1); } static FidFilter* des_bsbuz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; + (void)arg; butterworth(order); return do_bandstop(MZ, f0, f1); } static FidFilter* des_lpch(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; chebyshev(order, arg[0]); return do_lowpass(BL, f0); } static FidFilter* des_hpch(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; chebyshev(order, arg[0]); return do_highpass(BL, f0); } static FidFilter* des_bpch(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; chebyshev(order, arg[0]); return do_bandpass(BL, f0, f1); } static FidFilter* des_bsch(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; chebyshev(order, arg[0]); return do_bandstop(BL, f0, f1); } static FidFilter* des_lpchz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; chebyshev(order, arg[0]); return do_lowpass(MZ, f0); } static FidFilter* des_hpchz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; chebyshev(order, arg[0]); return do_highpass(MZ, f0); } static FidFilter* des_bpchz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; chebyshev(order, arg[0]); return do_bandpass(MZ, f0, f1); } static FidFilter* des_bschz(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)n_arg; chebyshev(order, arg[0]); return do_bandstop(MZ, f0, f1); } static FidFilter* des_lpbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double alpha= sin(omega) / 2 / arg[0]; @@ -1023,6 +1127,9 @@ des_lpbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_hpbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double alpha= sin(omega) / 2 / arg[0]; @@ -1034,6 +1141,9 @@ des_hpbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_bpbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double alpha= sin(omega) / 2 / arg[0]; @@ -1045,6 +1155,9 @@ des_bpbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_bsbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double alpha= sin(omega) / 2 / arg[0]; @@ -1055,6 +1168,9 @@ des_bsbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_apbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double alpha= sin(omega) / 2 / arg[0]; @@ -1065,6 +1181,9 @@ des_apbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_pkbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double alpha= sin(omega) / 2 / arg[0]; @@ -1076,6 +1195,9 @@ des_pkbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_lsbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double sinv= sin(omega); @@ -1094,6 +1216,9 @@ des_lsbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_hsbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)n_arg; double omega= 2 * M_PI * f0; double cosv= cos(omega); double sinv= sin(omega); @@ -1112,6 +1237,11 @@ des_hsbq(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_lpbl(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; + (void)arg; double wid= 0.4109205/f0; double tot, adj; int max= (int)floor(wid); @@ -1136,6 +1266,11 @@ des_lpbl(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_lphm(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; + (void)arg; double wid= 0.3262096/f0; double tot, adj; int max= (int)floor(wid); @@ -1159,6 +1294,11 @@ des_lphm(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_lphn(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; + (void)arg; double wid= 0.360144/f0; double tot, adj; int max= (int)floor(wid); @@ -1182,6 +1322,11 @@ des_lphn(double rate, double f0, double f1, int order, int n_arg, double *arg) { static FidFilter* des_lpba(double rate, double f0, double f1, int order, int n_arg, double *arg) { + (void)rate; + (void)f1; + (void)order; + (void)n_arg; + (void)arg; double wid= 0.3189435/f0; double tot, adj; int max= (int)floor(wid); From bcd7c527e89e53845d3f2344c1d1cbcd4b8cbfbc Mon Sep 17 00:00:00 2001 From: Alexander Barker Date: Sat, 23 Aug 2014 10:48:36 -0700 Subject: [PATCH 11/14] Added autotools build system and fixed a couple of bugs related to packaging. --- AUTHORS | 8 ++++ COPYING_LIB => COPYING.LESSER | 0 Makefile.am | 25 ++++++++++ fidlib.txt => README | 0 firun.txt => README.firun | 0 bootstrap.sh | 11 +++++ configure.ac | 81 +++++++++++++++++++++++++++++++ fidlib.c | 90 ++++++++++------------------------- fidlib.pc.in | 10 ++++ fidmkf.h | 10 ++-- mk-firun | 7 --- mk-firun-mingw | 7 --- mk-firun-tmp | 6 --- mk-firun-xmingw | 17 ------- 14 files changed, 164 insertions(+), 108 deletions(-) create mode 100644 AUTHORS rename COPYING_LIB => COPYING.LESSER (100%) create mode 100644 Makefile.am rename fidlib.txt => README (100%) rename firun.txt => README.firun (100%) create mode 100755 bootstrap.sh create mode 100644 configure.ac create mode 100644 fidlib.pc.in delete mode 100755 mk-firun delete mode 100755 mk-firun-mingw delete mode 100755 mk-firun-tmp delete mode 100755 mk-firun-xmingw diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..a31ce65 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,8 @@ +Jim Peters + +Daniel Schürmann + Patches contributed from Mixxx project + +Alexander Barker + Autotools build system + Small patches to fix warnings diff --git a/COPYING_LIB b/COPYING.LESSER similarity index 100% rename from COPYING_LIB rename to COPYING.LESSER diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..cdfcb3e --- /dev/null +++ b/Makefile.am @@ -0,0 +1,25 @@ +ACLOCAL_AMFLAGS = -I m4 + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = $(top_builddir)/fidlib.pc + +include_HEADERS = fidlib.h + +bin_PROGRAMS = +lib_LTLIBRARIES = libfidlib.la + + +libfidlib_la_CFLAGS = $(AM_CFLAGS) -Wall -Wextra -I$(top_srcdir) +libfidlib_la_LDFLAGS = $(LTLDFLAGS) $(LDFLAGS) +libfidlib_la_SOURCES = fidlib.c + +if BUILD_TEST +bin_PROGRAMS += firun + +firun_SOURCES = firun.c +firun_LDADD = $(top_builddir)/libfidlib.la +firun_CFLAGS = $(AM_CFLAGS) -Wall $(TEST_CFLAGS) -I$(top_srcdir) +firun_LDFLAGS = $(LTLDFLAGS) $(TEST_LIBS) + +EXTRA_DIST = README.firun +endif diff --git a/fidlib.txt b/README similarity index 100% rename from fidlib.txt rename to README diff --git a/firun.txt b/README.firun similarity index 100% rename from firun.txt rename to README.firun diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..516041a --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ ! -d ./m4 ]; then + mkdir ./m4 +fi + +if [ "$(uname)" == "Darwin" ]; then + include=" -I/opt/local/share/aclocal" +fi + +autoreconf --install --verbose --force $include diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..2a1d856 --- /dev/null +++ b/configure.ac @@ -0,0 +1,81 @@ + +# Define a few constants using m4 macros to prevent multiple definitions. +m4_define([FIDLIB_MAJOR], [0]) +m4_define([FIDLIB_MINOR], [9]) +m4_define([FIDLIB_PATCH], [11]) +m4_define([FIDLIB_RC], []) +m4_define([FIDLIB_BUGS], [jim@uazu.net]) +m4_define([FIDLIB_VERSION_STRING], FIDLIB_MAJOR[.]FIDLIB_MINOR[.]FIDLIB_PATCH[]FIDLIB_RC) + +m4_pattern_allow([AM_PROG_AR]) + +# Library versioning +# These numbers should be tweaked on every release. Read carefully: +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +# http://sourceware.org/autobook/autobook/autobook_91.html +lt_current="0" +lt_revision="2" +lt_age="1" +LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}" + + +# Initialize autoconf. +AC_INIT([fidlib], [FIDLIB_VERSION_STRING], [FIDLIB_BUGS]) + +AC_PREREQ(2.64) + +AC_CONFIG_SRCDIR([fidlib.h]) +AC_CONFIG_FILES([ + fidlib.pc \ + Makefile +]) +#AC_CONFIG_AUX_DIR([config]) +#AC_CONFIG_HEADERS([config.h:config.h.in]) +AC_CONFIG_MACRO_DIR([m4]) + +#AC_CANONICAL_SYSTEM +AC_CANONICAL_HOST +AC_CANONICAL_BUILD +AC_CANONICAL_TARGET + +# Initialize automake. +AM_INIT_AUTOMAKE([foreign subdir-objects]) + +# Checks for language. +AC_LANG([C]) + +# Checks for programs. +AC_PROG_CC([gcc clang]) +AC_PROG_CC_C99 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + +# Checks for header files +AC_C_CONST +AC_HEADER_STDC +AC_CHECK_HEADERS([math.h unistd.h errno.h]) + +# Initialize libtool. +AC_PROG_LIBTOOL + +AC_ARG_ENABLE([test], + AS_HELP_STRING([--enable-test], [Enable test application firun (default: disabled)]), + [enable_test=$enableval], + [enable_test="no"]) + + +AS_IF([test "x$enable_test" = "xyes"], [ + AC_DEFINE([USE_TEST], 1, [Enable Test Application]) +]) + +# Checks for libraries. +LIBS="-lm $LIBS" + +# Requires for pkg-config +AC_SUBST([LIBS]) +AC_SUBST([TEST_LIBS]) + +# Should the unit tests be built? +AM_CONDITIONAL([BUILD_TEST], [test "x$enable_test" = "xyes"]) + +# Generate the "configure" script +AC_OUTPUT diff --git a/fidlib.c b/fidlib.c index 3a67a3d..9c6b819 100644 --- a/fidlib.c +++ b/fidlib.c @@ -24,9 +24,6 @@ // Robert Bristow-Johnson's EQ cookbook formulae: // http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt // - -#define VERSION "0.9.10" - // // Filter specification string // --------------------------- @@ -195,28 +192,6 @@ // depends on the filter type. // -// -// Check that a target macro has been set. This macro selects -// various fixes required on various platforms: -// -// T_LINUX Linux, or probably any UNIX-like platform with GCC -// T_MINGW MinGW -- either building on Win32 or cross-compiling -// T_MSVC Microsoft Visual C -// -// (On MSVC, add "T_MSVC" to the preprocessor definitions in the -// project settings, or add /D "T_MSVC" to the compiler -// command-line.) -// - -#ifndef T_LINUX -#ifndef T_MINGW -#ifndef T_MSVC -#error Please define one of the T_* target macros (e.g. -DT_LINUX); see fidlib.c -#endif -#endif -#endif - - // // Select which method of filter execution is preferred. // RF_CMDLIST is recommended (and is the default). @@ -226,14 +201,8 @@ // RF_JIT -- fastest JIT run-time generated code (no longer supported) // -#ifndef RF_COMBINED -#ifndef RF_CMDLIST -#ifndef RF_JIT - +#if !defined(RF_COMBINED) && !defined(RF_CMDLIST) && !defined(RF_JIT) #define RF_CMDLIST - -#endif -#endif #endif // @@ -259,27 +228,16 @@ extern FidFilter *mkfilter(char *, ...); // // Macro for local inline routines that shouldn't be visible externally +// because Microsoft can't figure out how to support C99. // See Mixxx Bug #1179683 -#if defined(T_MINGW) || defined(T_MSVC) - #define STATIC_INLINE static __inline -#else - #define STATIC_INLINE static inline +#ifdef _MSC_VER +#define XINLINE __inline +#define vsnprintf _vsnprintf +#ifndef snprintf +#define snprintf _snprintf #endif - -// MinGW and MSVC fixes -#if defined(T_MINGW) || defined(T_MSVC) - #ifndef vsnprintf - #define vsnprintf _vsnprintf - #endif - #ifndef snprintf - #define snprintf _snprintf - #endif -// Not sure if we strictly need this still - STATIC_INLINE double - my_asinh(double val) { - return log(val + sqrt(val*val + 1.0)); - } - #define asinh(xx) my_asinh(xx) +#else +#define XINLINE inline #endif @@ -333,7 +291,7 @@ Alloc(int size) { // Complex multiply: aa *= bb; // -STATIC_INLINE void +static XINLINE void cmul(double *aa, double *bb) { double rr= aa[0] * bb[0] - aa[1] * bb[1]; double ii= aa[0] * bb[1] + aa[1] * bb[0]; @@ -345,7 +303,7 @@ cmul(double *aa, double *bb) { // Complex square: aa *= aa; // -STATIC_INLINE void +static XINLINE void csqu(double *aa) { double rr= aa[0] * aa[0] - aa[1] * aa[1]; double ii= 2 * aa[0] * aa[1]; @@ -357,7 +315,7 @@ csqu(double *aa) { // Complex multiply by real: aa *= bb; // -STATIC_INLINE void +static XINLINE void cmulr(double *aa, double fact) { aa[0] *= fact; aa[1] *= fact; @@ -367,7 +325,7 @@ cmulr(double *aa, double fact) { // Complex conjugate: aa= aa* // -STATIC_INLINE void +static XINLINE void cconj(double *aa) { aa[1]= -aa[1]; } @@ -376,7 +334,7 @@ cconj(double *aa) { // Complex divide: aa /= bb; // -STATIC_INLINE void +static XINLINE void cdiv(double *aa, double *bb) { double rr= aa[0] * bb[0] + aa[1] * bb[1]; double ii= -aa[0] * bb[1] + aa[1] * bb[0]; @@ -389,7 +347,7 @@ cdiv(double *aa, double *bb) { // Complex reciprocal: aa= 1/aa // -STATIC_INLINE void +static XINLINE void crecip(double *aa) { double fact= 1.0 / (aa[0] * aa[0] + aa[1] * aa[1]); aa[0] *= fact; @@ -400,7 +358,7 @@ crecip(double *aa) { // Complex assign: aa= bb // -STATIC_INLINE void +static XINLINE void cass(double *aa, double *bb) { memcpy(aa, bb, 2*sizeof(double)); // Assigning doubles is really slow } @@ -409,7 +367,7 @@ cass(double *aa, double *bb) { // Complex assign: aa= (rr + ii*j) // -STATIC_INLINE void +static XINLINE void cassz(double *aa, double rr, double ii) { aa[0]= rr; aa[1]= ii; @@ -419,7 +377,7 @@ cassz(double *aa, double rr, double ii) { // Complex add: aa += bb // -STATIC_INLINE void +static XINLINE void cadd(double *aa, double *bb) { aa[0] += bb[0]; aa[1] += bb[1]; @@ -429,7 +387,7 @@ cadd(double *aa, double *bb) { // Complex add: aa += (rr + ii*j) // -STATIC_INLINE void +static XINLINE void caddz(double *aa, double rr, double ii) { aa[0] += rr; aa[1] += ii; @@ -439,7 +397,7 @@ caddz(double *aa, double rr, double ii) { // Complex subtract: aa -= bb // -STATIC_INLINE void +static XINLINE void csub(double *aa, double *bb) { aa[0] -= bb[0]; aa[1] -= bb[1]; @@ -449,7 +407,7 @@ csub(double *aa, double *bb) { // Complex subtract: aa -= (rr + ii*j) // -STATIC_INLINE void +static XINLINE void csubz(double *aa, double rr, double ii) { aa[0] -= rr; aa[1] -= ii; @@ -459,7 +417,7 @@ csubz(double *aa, double rr, double ii) { // Complex negate: aa= -aa // -STATIC_INLINE void +static XINLINE void cneg(double *aa) { aa[0]= -aa[0]; aa[1]= -aa[1]; @@ -471,7 +429,7 @@ cneg(double *aa) { // Coefficients are real values. // -STATIC_INLINE void +static XINLINE void evaluate(double *rv, double *coef, int n_coef, double *in) { double pz[2]; // Powers of Z @@ -1869,7 +1827,7 @@ fid_list_filters_buf(char *buf, char *bufend) { // Do a convolution of parameters in place // -STATIC_INLINE int +static XINLINE int convolve(double *dst, int n_dst, double *src, int n_src) { int len= n_dst + n_src - 1; int a, b; diff --git a/fidlib.pc.in b/fidlib.pc.in new file mode 100644 index 0000000..044d88c --- /dev/null +++ b/fidlib.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: fidlib +Description: fidlib library +Version: @VERSION@ +Libs: @LIBS@ -L${libdir} -lfidlib +Cflags: -I${includedir} +Requires: @REQUIRE@ \ No newline at end of file diff --git a/fidmkf.h b/fidmkf.h index d09aaa4..d5295db 100644 --- a/fidmkf.h +++ b/fidmkf.h @@ -153,13 +153,13 @@ // Complex square root: aa= aa^0.5 // -STATIC_INLINE double +static XINLINE double my_sqrt(double aa) { return aa <= 0.0 ? 0.0 : sqrt(aa); } // 'csqrt' clashes with builtin in GCC 4, so call it 'c_sqrt' -STATIC_INLINE void +static XINLINE void c_sqrt(double *aa) { double mag= hypot(aa[0], aa[1]); double rr= my_sqrt((mag + aa[0]) * 0.5); @@ -173,7 +173,7 @@ c_sqrt(double *aa) { // Complex imaginary exponent: aa= e^i.theta // -STATIC_INLINE void +static XINLINE void cexpj(double *aa, double theta) { aa[0]= cos(theta); aa[1]= sin(theta); @@ -184,7 +184,7 @@ cexpj(double *aa, double theta) { // // 'cexp' clashes with builtin in GCC 4, so call it 'c_exp' -STATIC_INLINE void +static XINLINE void c_exp(double *aa) { double mag= exp(aa[0]); aa[0]= mag * cos(aa[1]); @@ -222,7 +222,7 @@ static char zertyp[MAXPZ]; // Pre-warp a frequency // -STATIC_INLINE double +static XINLINE double prewarp(double val) { return tan(val * M_PI) / M_PI; } diff --git a/mk-firun b/mk-firun deleted file mode 100755 index aede515..0000000 --- a/mk-firun +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -OPT="-O6 -s" -[ "$1" = "-d" ] && OPT="-g -Wall -Wextra" - - -gcc -DT_LINUX $OPT fidlib.c firun.c -lm -o firun diff --git a/mk-firun-mingw b/mk-firun-mingw deleted file mode 100755 index 22c676a..0000000 --- a/mk-firun-mingw +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -OPT="-O6 -s" -[ "$1" = "-d" ] && OPT="-g" - -gcc -DT_MINGW $OPT fidlib.c firun.c -lm -o firun.exe - diff --git a/mk-firun-tmp b/mk-firun-tmp deleted file mode 100755 index adc785f..0000000 --- a/mk-firun-tmp +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -OPT="-O6 -s" -[ "$1" = "-d" ] && OPT="-g" - -gcc -DT_LINUX $OPT fidlib.c firun-tmp.c -lm -o firun-tmp \ No newline at end of file diff --git a/mk-firun-xmingw b/mk-firun-xmingw deleted file mode 100755 index ed6b01d..0000000 --- a/mk-firun-xmingw +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Cross-compile from Linux to Win32 using mingw32 cross-compiler as -# provided by Debian. Rather hard-coded to my setup here; will need -# adapting anywhere else. - -OPT="-O6 -s" -[ "$1" = "-d" ] && OPT="-g" - -GCC=i586-mingw32msvc-gcc -#INCL="-I /home/jim/win/msys/1.0/mingw/include" -#LIBS="-L/home/jim/win/msys/1.0/mingw/lib -lmingw32" -INCL="-I /usr/i586-mingw32msvc/include" -LIBS="-L/usr/i586-mingw32msvc/lib -lmingw32" - -$GCC -DT_MINGW $OPT $INCL fidlib.c firun.c $LIBS -lm -o firun.exe - From 373c4a8ba1eda8fafebb4e38ffe3a88cd97abceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 15 Aug 2014 23:14:52 +0200 Subject: [PATCH 12/14] removed zero size array --- fidrf_cmdlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fidrf_cmdlist.h b/fidrf_cmdlist.h index 9389eef..b13e184 100644 --- a/fidrf_cmdlist.h +++ b/fidrf_cmdlist.h @@ -28,7 +28,7 @@ typedef struct RunBuf { double *coef; char *cmd; int mov_cnt; // Number of bytes to memmove - double buf[0]; + double *buf; } RunBuf; From 8a315df8527f4c4d0a7f12af74f913eff6cd960f Mon Sep 17 00:00:00 2001 From: Alexander Barker Date: Sat, 23 Aug 2014 12:26:52 -0700 Subject: [PATCH 13/14] Fixed a couple of uninitialized before use warnings. --- fidlib.c | 2 +- fidrf_cmdlist.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fidlib.c b/fidlib.c index 9c6b819..12eab0c 100644 --- a/fidlib.c +++ b/fidlib.c @@ -1721,7 +1721,7 @@ fid_design_coef(double *coef, int n_coef, const char *spec, double rate, int a, len; int cnt= 0; double gain= 1.0; - double *iir, *fir, iir_adj; + double *iir, *fir, iir_adj = 0.0; static double const_one= 1; int n_iir, n_fir; int iir_cbm, fir_cbm; diff --git a/fidrf_cmdlist.h b/fidrf_cmdlist.h index b13e184..fa492db 100644 --- a/fidrf_cmdlist.h +++ b/fidrf_cmdlist.h @@ -237,7 +237,7 @@ fid_run_new(FidFilter *filt, double (**funcpp)(void *,double)) { while (filt->len) { int n_iir, n_fir, cnt; double *iir, *fir; - double adj; + double adj = 0.0; if (filt->typ == 'F' && filt->len == 1) { gain *= filt->val[0]; filt= FFNEXT(filt); From 9f4b962a85a62e5c9b5d4a19bf7177036effda9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 29 Aug 2014 09:46:29 +0200 Subject: [PATCH 14/14] Fixed zero size array issue again. It has now allways one element. --- fidrf_cmdlist.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fidrf_cmdlist.h b/fidrf_cmdlist.h index b13e184..f45ee29 100644 --- a/fidrf_cmdlist.h +++ b/fidrf_cmdlist.h @@ -28,7 +28,7 @@ typedef struct RunBuf { double *coef; char *cmd; int mov_cnt; // Number of bytes to memmove - double *buf; + double buf[1]; // is resized in fid_run_newbuf() } RunBuf; @@ -393,11 +393,11 @@ fid_run_newbuf(void *run) { if (rr->magic != 0x64966325) error("Bad handle passed to fid_run_newbuf()"); - siz= rr->buf_size ? rr->buf_size : 1; // Minimum one element to avoid problems + siz= rr->buf_size > 0 ? rr->buf_size - 1 : 0; // Fist element is part of sizeof(RunBuf) rb= (RunBuf*)Alloc(sizeof(RunBuf) + siz * sizeof(double)); rb->coef= rr->coef; rb->cmd= rr->cmd; - rb->mov_cnt= (siz-1) * sizeof(double); + rb->mov_cnt= siz * sizeof(double); // rb->buf[] already zerod return rb;