From ea38f4d89c9698895b1cf53a5946429dc1d8bbaa Mon Sep 17 00:00:00 2001 From: Sergey Cherkashin <4erkashin@list.ru> Date: Tue, 3 Oct 2017 15:26:34 +0300 Subject: math: add exception handling functionality According to standards SVID and SYSV. Modified lgamma calling in case when 'signgam' variable should not be used. Signed-off-by: Waldemar Brodkorb --- include/math.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/math.h b/include/math.h index 25454764a..70f04f230 100644 --- a/include/math.h +++ b/include/math.h @@ -192,6 +192,30 @@ extern long double __REDIRECT_NTH (nexttowardl, (long double __x, long double __ #if defined __USE_MISC || defined __USE_XOPEN /* This variable is used by `gamma' and `lgamma'. */ extern int signgam; +#else +/* This is used when standart of libm + * should prevent lgamma(x) of modifying signgam variable. + */ +# define lgammaf(arg) \ +({ \ +int local_signgam = 0; \ +float result = lgammaf_r((float)arg, &local_signgam); \ +result; \ +}) + +# define lgamma(arg) \ +({ \ +int local_signgam = 0; \ +double result = lgamma_r(arg, &local_signgam); \ +result; \ +}) + +# define lgammal(arg) \ +({ \ +int local_signgam = 0; \ +long double result = lgammal_r(arg, &local_signgam); \ +result; \ +}) #endif @@ -361,7 +385,7 @@ struct exception # ifdef __cplusplus extern int matherr (struct __exception *__exc) throw (); # else -extern int matherr (struct exception *__exc); +extern int __attribute__ ((weak)) matherr (struct exception *__exc); # endif # define X_TLOSS 1.41484755040568800000e+16 -- cgit v1.2.3