projects
/
libm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8f02fce
)
tgmath.h: better comments
author
nsz
<nsz@port70.net>
Sat, 10 Mar 2012 19:19:06 +0000
(20:19 +0100)
committer
nsz
<nsz@port70.net>
Sat, 10 Mar 2012 19:19:06 +0000
(20:19 +0100)
include/tgmath.h
patch
|
blob
|
history
diff --git
a/include/tgmath.h
b/include/tgmath.h
index
9034ef7
..
840a8d2
100644
(file)
--- a/
include/tgmath.h
+++ b/
include/tgmath.h
@@
-2,12
+2,12
@@
#define _TGMATH_H
/*
#define _TGMATH_H
/*
-the return types are only
set correctly whit
gcc (__GNUC__)
+the return types are only
correctly with
gcc (__GNUC__)
otherwise they are long double or long double complex
the long double version of a function is never chosen when
sizeof(double) == sizeof(long double)
otherwise they are long double or long double complex
the long double version of a function is never chosen when
sizeof(double) == sizeof(long double)
-(but the return type is set correctly)
+(but the return type is set correctly
with gcc
)
*/
#include <math.h>
*/
#include <math.h>
@@
-24,12
+24,14
@@
sizeof(double) == sizeof(long double)
#define __DBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(double complex))
#define __LDBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(long double complex) && sizeof(long double) != sizeof(double))
#define __DBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(double complex))
#define __LDBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(long double complex) && sizeof(long double) != sizeof(double))
+/* return type */
+
#ifdef __GNUC__
#ifdef __GNUC__
-/*
arg type if it's floating-point else double (using ?: with null pointers
) */
+/*
cast to double when x is integral, otherwise use typeof(x
) */
#define __RETCAST(x) (__typeof__(*( \
0 ? (__typeof__(0 ? (double *)0 : (void *)__IS_FP(x)))0 : \
(__typeof__(0 ? (__typeof__(x) *)0 : (void *)!__IS_FP(x)))0 )))
#define __RETCAST(x) (__typeof__(*( \
0 ? (__typeof__(0 ? (double *)0 : (void *)__IS_FP(x)))0 : \
(__typeof__(0 ? (__typeof__(x) *)0 : (void *)!__IS_FP(x)))0 )))
-/*
two
args case, consider complex types (for cpow) */
+/*
2
args case, consider complex types (for cpow) */
#define __RETCAST_2(x, y) (__typeof__(*( \
0 ? (__typeof__(0 ? (double *)0 : \
(void *)!((!__IS_FP(x) || !__IS_FP(y)) && __FLT((x)+(y)+1.0f))))0 : \
#define __RETCAST_2(x, y) (__typeof__(*( \
0 ? (__typeof__(0 ? (double *)0 : \
(void *)!((!__IS_FP(x) || !__IS_FP(y)) && __FLT((x)+(y)+1.0f))))0 : \
@@
-37,7
+39,7
@@
sizeof(double) == sizeof(long double)
(void *)!((!__IS_FP(x) || !__IS_FP(y)) && __FLTCX((x)+(y)))))0 : \
(__typeof__(0 ? (__typeof__((x)+(y)) *)0 : \
(void *)((!__IS_FP(x) || !__IS_FP(y)) && (__FLT((x)+(y)+1.0f) || __FLTCX((x)+(y))))))0 )))
(void *)!((!__IS_FP(x) || !__IS_FP(y)) && __FLTCX((x)+(y)))))0 : \
(__typeof__(0 ? (__typeof__((x)+(y)) *)0 : \
(void *)((!__IS_FP(x) || !__IS_FP(y)) && (__FLT((x)+(y)+1.0f) || __FLTCX((x)+(y))))))0 )))
-/*
three
args case, don't consider complex types (fma only) */
+/*
3
args case, don't consider complex types (fma only) */
#define __RETCAST_3(x, y, z) (__typeof__(*( \
0 ? (__typeof__(0 ? (double *)0 : \
(void *)!((!__IS_FP(x) || !__IS_FP(y) || !__IS_FP(z)) && __FLT((x)+(y)+(z)+1.0f))))0 : \
#define __RETCAST_3(x, y, z) (__typeof__(*( \
0 ? (__typeof__(0 ? (double *)0 : \
(void *)!((!__IS_FP(x) || !__IS_FP(y) || !__IS_FP(z)) && __FLT((x)+(y)+(z)+1.0f))))0 : \
@@
-55,6
+57,8
@@
sizeof(double) == sizeof(long double)
#define __RETCAST_3(x, y, z)
#endif
#define __RETCAST_3(x, y, z)
#endif
+/* function selection */
+
#define __tg_real(fun, x) (__RETCAST(x)( \
__FLT(x) ? fun ## f (x) : \
__LDBL(x) ? fun ## l (x) : \
#define __tg_real(fun, x) (__RETCAST(x)( \
__FLT(x) ? fun ## f (x) : \
__LDBL(x) ? fun ## l (x) : \