improve clang support

master
Rob Sykes 2016-04-12 21:09:01 +01:00
parent b5c95fa305
commit 31fc8a5ae2
8 changed files with 20 additions and 16 deletions

2
NEWS
View File

@ -1,5 +1,5 @@
Version 0.1.3 (2016-mm-dd)
* Better support for ARM+SIMD and cross-compilation.
* Better support for clang, ARM+SIMD, and cross-compilation.
* Other minor fixes/improvements to build/tests/documentation.
Version 0.1.2 (2015-09-05)

View File

@ -50,6 +50,8 @@ include (FindPackageHandleStandardArgs)
set (OpenMP_C_FLAG_CANDIDATES
#Gnu
"-fopenmp"
#Clang
"-fopenmp=libiomp5"
#Microsoft Visual Studio
"/openmp"
#Intel windows

View File

@ -62,6 +62,7 @@ else ()
set (SIMD_C_FLAG_CANDIDATES
# x64
"-Wno-cast-align"
" "
# Microsoft Visual Studio x86
"/arch:SSE /fp:fast -D__SSE__"

View File

@ -101,7 +101,7 @@ double * lsx_make_lpf(
if (h) for (i = 0; i <= m / 2; ++i) {
double z = i - .5 * m, x = z * M_PI, y = z * mult1;
h[i] = x? sin(Fc * x) / x : Fc;
h[i] = x!=0? sin(Fc * x) / x : Fc;
h[i] *= lsx_bessel_I_0(beta * sqrt(1 - y * y)) * mult;
if (m - i != i)
h[m - i] = h[i];
@ -145,7 +145,7 @@ double * lsx_design_lpf(
static double safe_log(double x)
{
assert(x >= 0);
if (x)
if (x!=0)
return log(x);
lsx_debug("log(0)");
return -26;
@ -222,7 +222,7 @@ void lsx_fir_to_phase(double * * h, int * len, int * post_len, double phase)
while (peak && fabs(work[peak-1]) > fabs(work[peak]) && work[peak-1] * work[peak] > 0)
--peak;
if (!phase1)
if (phase1==0)
begin = 0;
else if (phase1 == 1)
begin = peak - *len / 2;

View File

@ -416,7 +416,7 @@ static char const * rate_init(
assert(passband_end + .005 < stopband_begin);
p->factor = factor;
if (bits) while (!n++) { /* Determine stages: */
if (bits!=0) while (!n++) { /* Determine stages: */
int try, L, M, x, maxL = interpolator > 0? 1 : mode? 2048 :
(int)ceil((double)max_coefs_size * 1000. / (U100_l * sizeof(sample_t)));
double d, epsilon = 0, frac;
@ -425,9 +425,9 @@ static char const * rate_init(
preM = upsample || (arbM > 1.5 && arbM < 2);
postM = 1 + (arbM > 1 && preM), arbM /= postM;
preL = 1 + (!preM && arbM < 2) + (upsample && mode), arbM *= preL;
if ((frac = arbM - (int)arbM))
if ((frac = arbM - (int)arbM)!=0)
epsilon = fabs((uint32_t)(frac * MULT32 + .5) / (frac * MULT32) - 1);
for (i = 1, rational = !frac; i <= maxL && !rational; ++i) {
for (i = 1, rational = frac==0; i <= maxL && !rational; ++i) {
d = frac * i, try = (int)(d + .5);
if ((rational = fabs(try / d - 1) <= epsilon)) { /* No long doubles! */
if (try == i)
@ -483,7 +483,7 @@ static char const * rate_init(
log2_min_dft_size, log2_large_dft_size);
}
if (!bits && have_arb_stage) { /* `Quick' cubic arb stage: */
if (bits==0 && have_arb_stage) { /* `Quick' cubic arb stage: */
arb_stage.type = cubic_stage;
arb_stage.fn = cubic_stage_fn;
arb_stage.mult = multiplier, multiplier = 1;
@ -516,7 +516,7 @@ static char const * rate_init(
arbM /= arbL, arbL = 1, rational = false;
phase_bits = (int)ceil(f1->scalar + log(mult)/log(2.));
phases = !rational? (1 << phase_bits) : arbL;
if (!f->interp[0].scalar) {
if (f->interp[0].scalar==0) {
int phases0 = max(phases, 19), n0 = 0;
lsx_design_lpf(Fp, Fs, -Fn, attArb, &n0, phases0, f->beta);
num_coefs = n0 / phases0 + 1, num_coefs += num_coefs & !preM;

View File

@ -275,7 +275,7 @@ soxr_t soxr_create(
soxr_quality_spec_t const * q_spec,
soxr_runtime_spec_t const * runtime_spec)
{
double io_ratio = output_rate? input_rate? input_rate / output_rate : -1 : input_rate? -1 : 0;
double io_ratio = output_rate!=0? input_rate!=0? input_rate / output_rate : -1 : input_rate!=0? -1 : 0;
static const float datatype_full_scale[] = {1, 1, 65536.*32768, 32768};
soxr_t p = 0;
soxr_error_t error = 0;
@ -343,7 +343,7 @@ soxr_t soxr_create(
}
#endif
if (p->num_channels && io_ratio)
if (p->num_channels && io_ratio!=0)
error = soxr_set_io_ratio(p, io_ratio, 0);
}
if (error)

View File

@ -316,7 +316,7 @@ static void vr_init(rate_t * p, double default_io_ratio, int num_stages, double
}
fifo_create(&p->output_fifo, sizeof(float));
p->default_io_ratio = default_io_ratio;
if (!fade_coefs[0]) {
if (fade_coefs[0]==0) {
for (i = 0; i < iAL(fade_coefs); ++i)
fade_coefs[i] = (float)(.5 * (1 + cos(M_PI * i / (AL(fade_coefs) - 1))));
prepare_coefs(poly_fir_coefs_u, POLY_FIR_LEN_U, PHASES0_U, PHASES_U, coefs0_u, mult);
@ -367,7 +367,7 @@ static void vr_set_io_ratio(rate_t * p, double io_ratio, size_t slew_len)
}
}
else {
if (p->default_io_ratio) { /* Then this is the first call to this fn. */
if (p->default_io_ratio!=0) { /* Then this is the first call to this fn. */
int octave = (int)floor(log(io_ratio) / M_LN2);
p->current.stage_num = octave < 0? -1 : min(octave, p->num_stages0-1);
enter_new_stage(p, 0);
@ -375,7 +375,7 @@ static void vr_set_io_ratio(rate_t * p, double io_ratio, size_t slew_len)
else if (p->fade_len)
set_step(&p->fadeout, io_ratio);
set_step(&p->current, io_ratio);
if (p->default_io_ratio) FRAC(p->current.at) = FRAC(p->current.step) >> 1;
if (p->default_io_ratio!=0) FRAC(p->current.at) = FRAC(p->current.step) >> 1;
p->default_io_ratio = 0;
}
}
@ -430,7 +430,7 @@ static bool do_input_stage(rate_t * p, int stage_num, int sign, int min_stage_nu
static int vr_process(rate_t * p, int olen0)
{
assert(p->num_stages > 0);
if (p->default_io_ratio)
if (p->default_io_ratio!=0)
vr_set_io_ratio(p, p->default_io_ratio, 0);
{
float * output = fifo_reserve(&p->output_fifo, olen0);
@ -462,7 +462,7 @@ static int vr_process(rate_t * p, int olen0)
olen = min(olen, (int)(AL(buf) >> 1));
if (p->slew_len)
olen = min(olen, p->slew_len);
else if (p->new_io_ratio) {
else if (p->new_io_ratio!=0) {
set_step(&p->current, p->new_io_ratio);
set_step(&p->fadeout, p->new_io_ratio);
p->fadeout.step_step.all = p->current.step_step.all = 0;

View File

@ -16,6 +16,7 @@ BASE=`basename $0`
TIME=/tmp/$BASE-time-$$
ERR=/tmp/$BASE-err-$$
uname -m |grep -q ^arm && len=60 || len=600
export OMP_NUM_THREADS=2
for rate0 in $rates; do
rate1=44100