From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2469 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: spandsp build, lrint/sqrt/pow issue Date: Fri, 14 Dec 2012 13:40:26 +0100 Message-ID: <20121214124026.GO23126@port70.net> References: <50CAF645.9000804@ojab.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="p4qYPpj5QlsIQJ0K" X-Trace: ger.gmane.org 1355488839 22897 80.91.229.3 (14 Dec 2012 12:40:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Dec 2012 12:40:39 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2470-gllmg-musl=m.gmane.org@lists.openwall.com Fri Dec 14 13:40:52 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TjUZQ-00080R-6i for gllmg-musl@plane.gmane.org; Fri, 14 Dec 2012 13:40:52 +0100 Original-Received: (qmail 4015 invoked by uid 550); 14 Dec 2012 12:40:38 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 4007 invoked from network); 14 Dec 2012 12:40:38 -0000 Content-Disposition: inline In-Reply-To: <50CAF645.9000804@ojab.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2469 Archived-At: --p4qYPpj5QlsIQJ0K Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * ojab [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) --p4qYPpj5QlsIQJ0K Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="tg.diff" diff --git a/include/tgmath.h b/include/tgmath.h index 5b65e21..832b052 100644 --- a/include/tgmath.h +++ b/include/tgmath.h @@ -59,10 +59,12 @@ sizeof(double) == sizeof(long double) /* function selection */ -#define __tg_real(fun, x) (__RETCAST(x)( \ +#define __tg_real_nocast(fun, x) ( \ __FLT(x) ? fun ## f (x) : \ __LDBL(x) ? fun ## l (x) : \ - fun(x) )) + fun(x) ) + +#define __tg_real(fun, x) (__RETCAST(x)__tg_real_nocast(fun, x)) #define __tg_real_2_1(fun, x, y) (__RETCAST(x)( \ __FLT(x) ? fun ## f (x, y) : \ @@ -217,18 +219,18 @@ sizeof(double) == sizeof(long double) #define fmod(x,y) __tg_real_2(fmod, (x), (y)) #define frexp(x,y) __tg_real_2_1(frexp, (x), (y)) #define hypot(x,y) __tg_real_2(hypot, (x), (y)) -#define ilogb(x) __tg_real(ilogb, (x)) +#define ilogb(x) __tg_real_nocast(ilogb, (x)) #define ldexp(x,y) __tg_real_2_1(ldexp, (x), (y)) #define lgamma(x) __tg_real(lgamma, (x)) -#define llrint(x) __tg_real(llrint, (x)) -#define llround(x) __tg_real(llround, (x)) +#define llrint(x) __tg_real_nocast(llrint, (x)) +#define llround(x) __tg_real_nocast(llround, (x)) #define log(x) __tg_real_complex(log, (x)) #define log10(x) __tg_real(log10, (x)) #define log1p(x) __tg_real(log1p, (x)) #define log2(x) __tg_real(log2, (x)) #define logb(x) __tg_real(logb, (x)) -#define lrint(x) __tg_real(lrint, (x)) -#define lround(x) __tg_real(lround, (x)) +#define lrint(x) __tg_real_nocast(lrint, (x)) +#define lround(x) __tg_real_nocast(lround, (x)) #define nearbyint(x) __tg_real(nearbyint, (x)) #define nextafter(x,y) __tg_real_2(nextafter, (x), (y)) #define nexttoward(x,y) __tg_real_2(nexttoward, (x), (y)) --p4qYPpj5QlsIQJ0K--