Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit af536e1

Browse files
committed
core.stdc.config: Add c_complex(float|double|real) aliases
1 parent 728f1d9 commit af536e1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/core/stdc/config.d

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ version (StdDdoc)
3131
alias ddoc_long = int;
3232
alias ddoc_ulong = uint;
3333
}
34+
struct ddoc_complex(T) {};
3435
}
3536

3637
/***
@@ -86,6 +87,24 @@ version (StdDdoc)
8687
* C++ compiler's `ptrdiff_t` type.
8788
*/
8889
alias cpp_ptrdiff_t = ptrdiff_t;
90+
91+
/***
92+
* Used for a complex floating point type that corresponds in size and ABI to the associated
93+
* C compiler's `_Complex float` type.
94+
*/
95+
alias c_complex_float = ddoc_complex!float;
96+
97+
/***
98+
* Used for a complex floating point type that corresponds in size and ABI to the associated
99+
* C compiler's `_Complex double` type.
100+
*/
101+
alias c_complex_double = ddoc_complex!double;
102+
103+
/***
104+
* Used for a complex floating point type that corresponds in size and ABI to the associated
105+
* C compiler's `_Complex long double` type.
106+
*/
107+
alias c_complex_real = ddoc_complex!real;
89108
}
90109
else
91110
{
@@ -208,4 +227,28 @@ else
208227
alias cpp_size_t = size_t;
209228
alias cpp_ptrdiff_t = ptrdiff_t;
210229
}
230+
231+
// ABI layout of native complex types.
232+
private struct _Complex(T)
233+
{
234+
T re;
235+
T im;
236+
}
237+
238+
version (Posix)
239+
{
240+
align(float.alignof) enum __c_complex_float : _Complex!float;
241+
align(double.alignof) enum __c_complex_double : _Complex!double;
242+
align(real.alignof) enum __c_complex_real : _Complex!real;
243+
}
244+
else
245+
{
246+
align(float.sizeof * 2) enum __c_complex_float : _Complex!float;
247+
align(double.sizeof * 2) enum __c_complex_double : _Complex!double;
248+
align(real.alignof) enum __c_complex_real : _Complex!real;
249+
}
250+
251+
alias c_complex_float = __c_complex_float;
252+
alias c_complex_double = __c_complex_double;
253+
alias c_complex_real = __c_complex_real;
211254
}

0 commit comments

Comments
 (0)