From: ojab <ojab@ojab.ru>
To: musl@lists.openwall.com
Subject: Re: spandsp build, lrint/sqrt/pow issue
Date: Fri, 14 Dec 2012 16:59:57 +0400 [thread overview]
Message-ID: <50CB22CD.1070208@ojab.ru> (raw)
In-Reply-To: <20121214124026.GO23126@port70.net>
On 14.12.2012 16:40, Szabolcs Nagy wrote:
> * ojab <ojab@ojab.ru> [2012-12-14 13:49:57 +0400]:
>> spandsp library (which is used in FreeSWITCH/Asterisk/Yate/many
>> commercial solutions/etc) build fails with (first error):
>>
>>> In file included from awgn.c:59:0:
>>> spandsp/saturated.h: In function 'fsaturate':
>>> spandsp/saturated.h:184:22: warning: cast to pointer from integer of different size
>>> spandsp/saturated.h:184:22: warning: cast to pointer from integer of different size
>>> spandsp/saturated.h:184:5: error: invalid use of void expression
>>
>> line 184 is return statement in
>>> static __inline__ int16_t fsaturate(double damp)
>>> {
>>> if (damp > (double) INT16_MAX)
>>> return INT16_MAX;
>>> if (damp < (double) INT16_MIN)
>>> return INT16_MIN;
>>> return (int16_t) lrint(damp);
>>> }
>
> this is a bug in musl's tgmath.h
> (incorrectly casted the return value to a floating-point type)
>
> thanks for catching it, i pushed a fix to my math repo
> (also attached)
>
>> awgn.i can be found in the attached file. The same errors happens
>> with pow() and sqrt() functions.
>
> i don't see problems with pow or sqrt
>
> they seem to use sqrt(log(something)) which expands to a very
> long expression, but otherwise it should work
>
> actually they shouldn't use tgmath.h at all
> (it could be useful if they used a custom floating-point type that
> is typedefed to float,double or long double in some header, but
> they seem to use plain doubles everywhere)
>
> so you can fix the issue by replacing tgmath.h with math.h in that file
> (and maybe report the issue upstream, tgmath.h is a header
> that is hard to get right, can cause cryptic error messages,
> and is very rarely used, so it should be avoided when possible)
>
Thanks for the quick fix, lrint issue is fixed. Right now build fails
only on sqrt() and pow():
awgn.c: In function 'awgn_init_dbov':
awgn.c:109:14: warning: cast to pointer from integer of different size
awgn.c:109:14: warning: cast to pointer from integer of different size
awgn.c:109:14: warning: cast to pointer from integer of different size
awgn.c:109:5: error: void value not ignored as it ought to be
and line 109:
s->rms = pow(10.0, level/20.0)*32768.0;
Next issue is
awgn.c: In function 'awgn':
awgn.c:165:15: warning: cast to pointer from integer of different size
awgn.c:165:15: warning: cast to pointer from integer of different size
awgn.c:165:9: error: void value not ignored as it ought to be
awgn.c:165:9: warning: type defaults to 'int' in type name
and line 165:
fac = sqrt(-2.0*log(r)/r);
So I suppose the fix is needed (don't know if it should be on musl side
though).
spandsp use tgmath.h only if available, so if I'll remove tgmath.h or
undefine HAVE_TGMATH_H — spandsp builds fine.
//wbr ojab
next prev parent reply other threads:[~2012-12-14 12:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 9:49 ojab
2012-12-14 12:40 ` Szabolcs Nagy
2012-12-14 12:59 ` ojab [this message]
2012-12-14 13:33 ` Szabolcs Nagy
2012-12-14 14:21 ` ojab
2012-12-14 19:47 ` ojab
2012-12-15 0:47 ` Szabolcs Nagy
2012-12-16 10:29 ` ojab
2012-12-16 14:12 ` Szabolcs Nagy
2012-12-18 6:07 ` ojab
2012-12-18 11:45 ` Szabolcs Nagy
2012-12-18 12:31 ` Szabolcs Nagy
2012-12-18 13:50 ` Szabolcs Nagy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50CB22CD.1070208@ojab.ru \
--to=ojab@ojab.ru \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).