Skip to content

Commit 5ccebd3

Browse files
committed
Implement the cimag/creal functions for all types consistently.
1 parent b77dcff commit 5ccebd3

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
166166
%/fminf.c %/fmaxf.c \
167167
%/fmin.c %/fmax.c, \
168168
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/math/*.c)) \
169-
$(filter-out %/crealf.c %/creal.c \
170-
%/cimagf.c %/cimag.c, \
169+
$(filter-out %/crealf.c %/creal.c %creall.c \
170+
%/cimagf.c %/cimag.c %cimagl.c, \
171171
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/complex/*.c)) \
172172
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/crypt/*.c)
173173
MUSL_PRINTSCAN_SOURCES = \

expected/wasm32-wasi/predefined-macros.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,8 @@
31203120
#define cbrt(x) __tg_real(cbrt, (x))
31213121
#define ceil(x) __tg_real(ceil, (x))
31223122
#define cimag(x) __tg_complex_retreal(cimag, (x))
3123+
#define cimagf(x) (__builtin_cimagf(x))
3124+
#define cimagl(x) (__builtin_cimagl(x))
31233125
#define clrbit(x,i) __bitop(x,i,&=~)
31243126
#define compl ~
31253127
#define complex _Complex
@@ -3129,6 +3131,8 @@
31293131
#define cosh(x) __tg_real_complex(cosh, (x))
31303132
#define cproj(x) __tg_complex(cproj, (x))
31313133
#define creal(x) __tg_complex_retreal(creal, (x))
3134+
#define crealf(x) (__builtin_crealf(x))
3135+
#define creall(x) (__builtin_creall(x))
31323136
#define creat64 creat
31333137
#define d_fileno d_ino
31343138
#define direct dirent

libc-bottom-half/sources/complex-builtins.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44

55
#include <complex.h>
66

7-
float crealf(float _Complex x) {
8-
return __real__ x;
7+
float (crealf)(float _Complex x) {
8+
return __builtin_crealf(x);
99
}
1010

11-
double creal(double _Complex x) {
12-
return __real__ x;
11+
double (creal)(double _Complex x) {
12+
return __builtin_creal(x);
1313
}
1414

15-
float cimagf(float _Complex x) {
16-
return __imag__ x;
15+
long double (creall)(long double _Complex x) {
16+
return __builtin_creall(x);
1717
}
1818

19-
double cimag(double _Complex x) {
20-
return __imag__ x;
19+
float (cimagf)(float _Complex x) {
20+
return __builtin_cimagf(x);
21+
}
22+
23+
double (cimag)(double _Complex x) {
24+
return __builtin_cimag(x);
25+
}
26+
27+
long double (cimagl)(long double _Complex x) {
28+
return __builtin_cimagl(x);
2129
}

0 commit comments

Comments
 (0)