summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2012-11-13 01:31:49 +0100
committerSzabolcs Nagy <nsz@port70.net>2012-11-13 01:31:49 +0100
commitcfbaba79a2dd380e580a247b8fd36af60c878e8f (patch)
treea002987af1ea7652985973f8db98d2d4f8b6064a /include
parente2fe959fe2a450f74271d4d3c4b0d9456f889125 (diff)
downloadmusl-cfbaba79a2dd380e580a247b8fd36af60c878e8f.tar.gz
complex: add C11 CMPLX macros and replace cpack with them
Diffstat (limited to 'include')
-rw-r--r--include/complex.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/complex.h b/include/complex.h
index b4bcb22e..8206e026 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -112,6 +112,15 @@ long double creall(long double complex);
#define cimagf(x) __CIMAG(x, float)
#define cimagl(x) __CIMAG(x, long double)
+#define __CMPLX(x, y, t) \
+ ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
+
+#if __STDC_VERSION__ >= 201112L
+#define CMPLX(x, y) __CMPLX(x, y, double)
+#define CMPLXF(x, y) __CMPLX(x, y, float)
+#define CMPLXL(x, y) __CMPLX(x, y, long double)
+#endif
+
#ifdef __cplusplus
}
#endif