POSIX: add CMPLX(), CMPLXF(), CMPLXL()

appeared in issue 8:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/CMPLX.html

Change-Id: I037e7368611e201df28589172f926e7a9fc52be2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9758
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Jérôme Duval
2025-10-30 07:30:43 +00:00
parent 8c7f77a0b2
commit e0ccf1d924
+11 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2015 Haiku, Inc. All Rights Reserved. * Copyright 2015, 2025 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _COMPLEX_H_ #ifndef _COMPLEX_H_
@@ -15,6 +15,16 @@
#define complex _Complex #define complex _Complex
#define I _Complex_I #define I _Complex_I
#ifdef _Imaginary_I
#define CMPLX(x, y) ((double complex)((double)(x) + _Imaginary_I * (double)(y)))
#define CMPLXF(x, y) ((float complex)((float)(x) + _Imaginary_I * (float)(y)))
#define CMPLXL(x, y) ((long double complex)((long double)(x) + _Imaginary_I * (long double)(y)))
#else
#define CMPLX(x, y) (__builtin_complex((double)(x), (double)(y)))
#define CMPLXF(x, y) (__builtin_complex((float)(x), (float)(y)))
#define CMPLXL(x, y) (__builtin_complex((long double)(x), (long double)(y)))
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif