]> git.proxmox.com Git - wasi-libc.git/commitdiff
Use the compiler's real/imag operators instead of union type punning.
authorDan Gohman <sunfish@mozilla.com>
Mon, 29 Apr 2019 12:59:36 +0000 (05:59 -0700)
committerDan Gohman <sunfish@mozilla.com>
Thu, 9 May 2019 16:15:30 +0000 (09:15 -0700)
This removes the last use of union type punning from WASI libc's
public header files.

expected/wasm32-wasi/predefined-macros.txt
libc-top-half/musl/include/complex.h

index cb65a74deb634c1ca270ea8727ec41ba131e302f..ef6de5c29d09404857faa156f8d1b0e9ebef61fe 100644 (file)
 #define __CHAR16_TYPE__ unsigned short
 #define __CHAR32_TYPE__ unsigned int
 #define __CHAR_BIT__ 8
-#define __CIMAG(x,t) (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
 #define __compiler_ATOMIC_BOOL_LOCK_FREE 2
 #define __compiler_ATOMIC_CHAR16_T_LOCK_FREE 2
 #define __compiler_ATOMIC_CHAR32_T_LOCK_FREE 2
 #define cbrt(x) __tg_real(cbrt, (x))
 #define ceil(x) __tg_real(ceil, (x))
 #define cimag(x) __tg_complex_retreal(cimag, (x))
-#define cimagf(x) __CIMAG(x, float)
-#define cimagl(x) __CIMAG(x, long double)
 #define clrbit(x,i) __bitop(x,i,&=~)
 #define compl ~
 #define complex _Complex
 #define cosh(x) __tg_real_complex(cosh, (x))
 #define cproj(x) __tg_complex(cproj, (x))
 #define creal(x) __tg_complex_retreal(creal, (x))
-#define crealf(x) ((float)(x))
-#define creall(x) ((long double)(x))
 #define creat64 creat
 #define d_fileno d_ino
 #define direct dirent
index 008b3c7e3b7d6190cb864892aa7b2bad3f1aa2cf..daa7f85e8f8633eec686b1dfecf2a28825cf851a 100644 (file)
@@ -101,6 +101,7 @@ double creal(double complex);
 float crealf(float complex);
 long double creall(long double complex);
 
+#ifdef __wasilibc_unmodified_upstream /* Use the compiler's real/imag operators rather than union type punning */
 #ifndef __cplusplus
 #define __CIMAG(x, t) \
        (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
@@ -113,6 +114,7 @@ long double creall(long double complex);
 #define cimagf(x) __CIMAG(x, float)
 #define cimagl(x) __CIMAG(x, long double)
 #endif
+#endif
 
 #if __STDC_VERSION__ >= 201112L
 #if defined(_Imaginary_I)