From d9c3226ef2db2a2a9e63e93f79a6dacc65a9691f Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Tue, 8 Oct 2024 00:29:47 +0530 Subject: [PATCH 01/27] init --- .../include/llvm-libc-macros/complex-macros.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 libc/include/llvm-libc-macros/complex-macros.h diff --git a/libc/include/llvm-libc-macros/complex-macros.h b/libc/include/llvm-libc-macros/complex-macros.h new file mode 100644 index 0000000000000..175ada6594e3b --- /dev/null +++ b/libc/include/llvm-libc-macros/complex-macros.h @@ -0,0 +1,21 @@ +//===-- Definition of macros to be used with complex functions ------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __LLVM_LIBC_MACROS_COMPLEX_MACROS_H +#define __LLVM_LIBC_MACROS_COMPLEX_MACROS_H + +#ifndef __STDC_NO_COMPLEX__ + +#define __STDC_VERSION_COMPLEX_H__ 202311L + +#define complex _Complex +#define _Complex_I 1.0fi + +#endif + +#endif // __LLVM_LIBC_MACROS_COMPLEX_MACROS_H From 135b2ebc781d4c2ad613c51e0c17486732ef7681 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Wed, 9 Oct 2024 16:01:02 +0530 Subject: [PATCH 02/27] Libc: Complex init --- libc/docs/complex.rst | 65 +++++++++++++++++++ libc/include/CMakeLists.txt | 10 +++ libc/include/complex.h.def | 17 +++++ libc/include/llvm-libc-macros/CMakeLists.txt | 6 ++ .../include/llvm-libc-macros/complex-macros.h | 11 +++- 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 libc/docs/complex.rst create mode 100644 libc/include/complex.h.def diff --git a/libc/docs/complex.rst b/libc/docs/complex.rst new file mode 100644 index 0000000000000..f56910067ef9a --- /dev/null +++ b/libc/docs/complex.rst @@ -0,0 +1,65 @@ +.. include:: check.rst + +========= +complex.h +========= + +Macros +====== + ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| | (float) | (double) | (long double) | C23 Definition Section | C23 Error Handling Section | ++===========+==================+=================+========================+========================+============================+ +| CMPLX | | | | 7.3.9.3 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ + +Functions +========= + ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| | (float) | (double) | (long double) | C23 Definition Section | C23 Error Handling Section | ++===========+==================+=================+========================+========================+============================+ +| cacos | | | | 7.3.5.1 | G.6.2.1 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| casin | | | | 7.3.5.2 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| catan | | | | 7.3.5.3 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| ccos | | | | 7.3.5.4 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| csin | | | | 7.3.5.5 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| ctan | | | | 7.3.5.6 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| cacosh | | | | 7.3.6.1 | G.6.3.1 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| casinh | | | | 7.3.6.2 | G.6.3.2 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| catanh | | | | 7.3.6.3 | G.6.3.3 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| ccosh | | | | 7.3.6.4 | G.6.3.4 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| csinh | | | | 7.3.6.5 | G.6.3.5 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| ctanh | | | | 7.3.6.6 | G.6.3.6 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| cexp | | | | 7.3.7.1 | G.6.4.1 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| clog | | | | 7.3.7.2 | G.6.4.2 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| cabs | | | | 7.3.8.1 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| cpow | | | | 7.3.8.2 | G.6.5.1 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| csqrt | | | | 7.3.8.3 | G.6.5.2 | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| carg | | | | 7.3.9.1 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| cimag | | | | 7.3.9.2 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| conj | | | | 7.3.9.4 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| cproj | | | | 7.3.9.5 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ +| creal | | | | 7.3.9.6 | N/A | ++-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 1f3cb59f69e96..5deb5258d532f 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -202,6 +202,16 @@ add_header_macro( .llvm-libc-macros.assert_macros ) +add_header_macro( + complex + ../libc/newhdrgen/yaml/complex.yaml + complex.h.def + complex.h + DEPENDS + .llvm_libc_common_h + .llvm-libc-macros.complex_macros +) + add_header_macro( setjmp ../libc/newhdrgen/yaml/setjmp.yaml diff --git a/libc/include/complex.h.def b/libc/include/complex.h.def new file mode 100644 index 0000000000000..65f5765573e84 --- /dev/null +++ b/libc/include/complex.h.def @@ -0,0 +1,17 @@ +//===-- C standard library header complex.h -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_COMPLEX_H +#define LLVM_LIBC_COMPLEX_H + +#include "__llvm-libc-common.h" +#include "llvm-libc-macros/complex-macros.h" + +%%public_api() + +#endif // LLVM_LIBC_COMPLEX_H diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt index 2ba437c8437f2..75194923a452f 100644 --- a/libc/include/llvm-libc-macros/CMakeLists.txt +++ b/libc/include/llvm-libc-macros/CMakeLists.txt @@ -61,6 +61,12 @@ add_macro_header( fcntl-macros.h ) +add_macro_header( + complex_macros + HDR + complex-macros.h +) + add_macro_header( features_macros HDR diff --git a/libc/include/llvm-libc-macros/complex-macros.h b/libc/include/llvm-libc-macros/complex-macros.h index 175ada6594e3b..3c239a04f8a6a 100644 --- a/libc/include/llvm-libc-macros/complex-macros.h +++ b/libc/include/llvm-libc-macros/complex-macros.h @@ -14,7 +14,16 @@ #define __STDC_VERSION_COMPLEX_H__ 202311L #define complex _Complex -#define _Complex_I 1.0fi +#define _Complex_I (float _Complex)1.0fi + +#ifdef _Imaginary +#define imaginary _Imaginary +#define _Imaginary_I (float _Imaginary)1.0i + +#define I _Imaginary_I +#else +#define I _Complex_I +#endif #endif From 4fc0e05d871ecf2021e299fe9bfbef153067832f Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Wed, 9 Oct 2024 16:36:49 +0530 Subject: [PATCH 03/27] add _Imaginary type --- libc/include/CMakeLists.txt | 1 + libc/include/llvm-libc-types/CMakeLists.txt | 1 + libc/include/llvm-libc-types/_Imaginary.h | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 libc/include/llvm-libc-types/_Imaginary.h diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 5deb5258d532f..9a07445ec8b5b 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -210,6 +210,7 @@ add_header_macro( DEPENDS .llvm_libc_common_h .llvm-libc-macros.complex_macros + .llvm-libc-types._Imaginary ) add_header_macro( diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index a4cf4631c8470..f0dadc99099c7 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -17,6 +17,7 @@ add_header(__qsortrcompare_t HDR __qsortrcompare_t.h) add_header(__sighandler_t HDR __sighandler_t.h) add_header(__thread_type HDR __thread_type.h) add_header(blkcnt_t HDR blkcnt_t.h) +add_header(_Imaginary HDR _Imaginary.h) add_header(blksize_t HDR blksize_t.h) add_header(cc_t HDR cc_t.h) add_header(clock_t HDR clock_t.h) diff --git a/libc/include/llvm-libc-types/_Imaginary.h b/libc/include/llvm-libc-types/_Imaginary.h new file mode 100644 index 0000000000000..ad51bc1d37b56 --- /dev/null +++ b/libc/include/llvm-libc-types/_Imaginary.h @@ -0,0 +1,14 @@ +//===-- Definition of _Imaginary type -------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_TYPES__Imaginary_H +#define LLVM_LIBC_TYPES__Imaginary_H + +typedef /* TODO */ _Imaginary; + +#endif // LLVM_LIBC_TYPES__Imaginary_H From e4e2bb4673cc935ff1136026d1f792be391bef5c Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Wed, 9 Oct 2024 16:42:20 +0530 Subject: [PATCH 04/27] fix doc --- libc/docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/libc/docs/index.rst b/libc/docs/index.rst index d089a800ab90a..6f759aa215b62 100644 --- a/libc/docs/index.rst +++ b/libc/docs/index.rst @@ -73,6 +73,7 @@ stages there is no ABI stability in any form. libc_search c23 ctype + complex signal threads setjmp From 9021b17d020817bd09af78fc8bf31b4233016f17 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Thu, 10 Oct 2024 00:03:01 +0530 Subject: [PATCH 05/27] Add F16 and F128 --- libc/docs/complex.rst | 104 +++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/libc/docs/complex.rst b/libc/docs/complex.rst index f56910067ef9a..09fbdd7c6179e 100644 --- a/libc/docs/complex.rst +++ b/libc/docs/complex.rst @@ -7,59 +7,59 @@ complex.h Macros ====== -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| | (float) | (double) | (long double) | C23 Definition Section | C23 Error Handling Section | -+===========+==================+=================+========================+========================+============================+ -| CMPLX | | | | 7.3.9.3 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| | (float) | (double) | (long double) | (float16) | (float128) | C23 Definition Section | C23 Error Handling Section | ++===========+==================+=================+========================+======================+========================+========================+============================+ +| CMPLX | | | | | | 7.3.9.3 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ Functions ========= -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| | (float) | (double) | (long double) | C23 Definition Section | C23 Error Handling Section | -+===========+==================+=================+========================+========================+============================+ -| cacos | | | | 7.3.5.1 | G.6.2.1 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| casin | | | | 7.3.5.2 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| catan | | | | 7.3.5.3 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| ccos | | | | 7.3.5.4 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| csin | | | | 7.3.5.5 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| ctan | | | | 7.3.5.6 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| cacosh | | | | 7.3.6.1 | G.6.3.1 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| casinh | | | | 7.3.6.2 | G.6.3.2 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| catanh | | | | 7.3.6.3 | G.6.3.3 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| ccosh | | | | 7.3.6.4 | G.6.3.4 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| csinh | | | | 7.3.6.5 | G.6.3.5 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| ctanh | | | | 7.3.6.6 | G.6.3.6 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| cexp | | | | 7.3.7.1 | G.6.4.1 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| clog | | | | 7.3.7.2 | G.6.4.2 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| cabs | | | | 7.3.8.1 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| cpow | | | | 7.3.8.2 | G.6.5.1 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| csqrt | | | | 7.3.8.3 | G.6.5.2 | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| carg | | | | 7.3.9.1 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| cimag | | | | 7.3.9.2 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| conj | | | | 7.3.9.4 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| cproj | | | | 7.3.9.5 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ -| creal | | | | 7.3.9.6 | N/A | -+-----------+------------------+-----------------+------------------------+------------------------+----------------------------+ ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| | (float) | (double) | (long double) | (float16) | (float128) | C23 Definition Section | C23 Error Handling Section | ++===========+==================+=================+========================+======================+========================+========================+============================+ +| cacos | | | | | | 7.3.5.1 | G.6.2.1 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| casin | | | | | | 7.3.5.2 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| catan | | | | | | 7.3.5.3 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| ccos | | | | | | 7.3.5.4 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| csin | | | | | | 7.3.5.5 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| ctan | | | | | | 7.3.5.6 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| cacosh | | | | | | 7.3.6.1 | G.6.3.1 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| casinh | | | | | | 7.3.6.2 | G.6.3.2 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| catanh | | | | | | 7.3.6.3 | G.6.3.3 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| ccosh | | | | | | 7.3.6.4 | G.6.3.4 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| csinh | | | | | | 7.3.6.5 | G.6.3.5 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| ctanh | | | | | | 7.3.6.6 | G.6.3.6 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| cexp | | | | | | 7.3.7.1 | G.6.4.1 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| clog | | | | | | 7.3.7.2 | G.6.4.2 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| cabs | | | | | | 7.3.8.1 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| cpow | | | | | | 7.3.8.2 | G.6.5.1 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| csqrt | | | | | | 7.3.8.3 | G.6.5.2 | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| carg | | | | | | 7.3.9.1 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| cimag | | | | | | 7.3.9.2 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| conj | | | | | | 7.3.9.4 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| cproj | | | | | | 7.3.9.5 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ +| creal | | | | | | 7.3.9.6 | N/A | ++-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ From 3bac6b3c07522964c744184457f0e4b4ec11db50 Mon Sep 17 00:00:00 2001 From: Shourya Goel Date: Thu, 10 Oct 2024 20:03:57 +0530 Subject: [PATCH 06/27] Update complex-macros.h --- libc/include/llvm-libc-macros/complex-macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/include/llvm-libc-macros/complex-macros.h b/libc/include/llvm-libc-macros/complex-macros.h index 3c239a04f8a6a..962054aeb197e 100644 --- a/libc/include/llvm-libc-macros/complex-macros.h +++ b/libc/include/llvm-libc-macros/complex-macros.h @@ -14,11 +14,11 @@ #define __STDC_VERSION_COMPLEX_H__ 202311L #define complex _Complex -#define _Complex_I (float _Complex)1.0fi +#define _Complex_I ((float _Complex)1.0fi) #ifdef _Imaginary #define imaginary _Imaginary -#define _Imaginary_I (float _Imaginary)1.0i +#define _Imaginary_I ((float _Imaginary)1.0i) #define I _Imaginary_I #else From 33c4e0206d64788873157438742de125a5db2bd1 Mon Sep 17 00:00:00 2001 From: Shourya Goel Date: Thu, 10 Oct 2024 20:25:57 +0530 Subject: [PATCH 07/27] Update _Imaginary.h --- libc/include/llvm-libc-types/_Imaginary.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc/include/llvm-libc-types/_Imaginary.h b/libc/include/llvm-libc-types/_Imaginary.h index ad51bc1d37b56..0b2c17f79d2e6 100644 --- a/libc/include/llvm-libc-types/_Imaginary.h +++ b/libc/include/llvm-libc-types/_Imaginary.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TYPES__Imaginary_H #define LLVM_LIBC_TYPES__Imaginary_H -typedef /* TODO */ _Imaginary; +// TODO: Define the _Imaginary type once clang or gcc supports it. +// typedef _Imaginary; #endif // LLVM_LIBC_TYPES__Imaginary_H From 1ceaffb53ee2fc891f6f12538cc5708979e40717 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Thu, 10 Oct 2024 20:28:33 +0530 Subject: [PATCH 08/27] remove _Imaginary --- libc/include/CMakeLists.txt | 1 - libc/include/llvm-libc-types/_Imaginary.h | 15 --------------- 2 files changed, 16 deletions(-) delete mode 100644 libc/include/llvm-libc-types/_Imaginary.h diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 9a07445ec8b5b..5deb5258d532f 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -210,7 +210,6 @@ add_header_macro( DEPENDS .llvm_libc_common_h .llvm-libc-macros.complex_macros - .llvm-libc-types._Imaginary ) add_header_macro( diff --git a/libc/include/llvm-libc-types/_Imaginary.h b/libc/include/llvm-libc-types/_Imaginary.h deleted file mode 100644 index 0b2c17f79d2e6..0000000000000 --- a/libc/include/llvm-libc-types/_Imaginary.h +++ /dev/null @@ -1,15 +0,0 @@ -//===-- Definition of _Imaginary type -------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_TYPES__Imaginary_H -#define LLVM_LIBC_TYPES__Imaginary_H - -// TODO: Define the _Imaginary type once clang or gcc supports it. -// typedef _Imaginary; - -#endif // LLVM_LIBC_TYPES__Imaginary_H From f5027c2454efea17fd1da76e28badc79e40fef6c Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Thu, 10 Oct 2024 22:26:18 +0530 Subject: [PATCH 09/27] Add tests --- .../include/llvm-libc-macros/complex-macros.h | 10 ++------- libc/test/UnitTest/LibcTest.cpp | 4 ++++ libc/test/include/CMakeLists.txt | 10 +++++++++ libc/test/include/complex_test.cpp | 22 +++++++++++++++++++ 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 libc/test/include/complex_test.cpp diff --git a/libc/include/llvm-libc-macros/complex-macros.h b/libc/include/llvm-libc-macros/complex-macros.h index 962054aeb197e..b2833bf09d3ed 100644 --- a/libc/include/llvm-libc-macros/complex-macros.h +++ b/libc/include/llvm-libc-macros/complex-macros.h @@ -15,15 +15,9 @@ #define complex _Complex #define _Complex_I ((float _Complex)1.0fi) - -#ifdef _Imaginary -#define imaginary _Imaginary -#define _Imaginary_I ((float _Imaginary)1.0i) - -#define I _Imaginary_I -#else #define I _Complex_I -#endif + +// TODO: Add imaginary macros once GCC or Clang support them. #endif diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp index ad5722f99a436..8bbe1fe0abed7 100644 --- a/libc/test/UnitTest/LibcTest.cpp +++ b/libc/test/UnitTest/LibcTest.cpp @@ -232,6 +232,10 @@ TEST_SPECIALIZATION(unsigned long long); TEST_SPECIALIZATION(bool); +TEST_SPECIALIZATION(float _Complex); +TEST_SPECIALIZATION(double _Complex); +TEST_SPECIALIZATION(long double _Complex); + // We cannot just use a single UInt128 specialization as that resolves to only // one type, UInt<128> or __uint128_t. We want both overloads as we want to #ifdef LIBC_TYPES_HAS_INT128 diff --git a/libc/test/include/CMakeLists.txt b/libc/test/include/CMakeLists.txt index dd8f21bdd07ae..05646a3c8c28c 100644 --- a/libc/test/include/CMakeLists.txt +++ b/libc/test/include/CMakeLists.txt @@ -11,6 +11,16 @@ add_libc_test( libc.include.llvm-libc-macros.assert_macros ) +add_libc_test( + complex_test + SUITE + libc_include_tests + SRCS + complex_test.cpp + DEPENDS + libc.include.llvm-libc-macros.complex_macros +) + add_libc_test( sys_queue_test SUITE diff --git a/libc/test/include/complex_test.cpp b/libc/test/include/complex_test.cpp new file mode 100644 index 0000000000000..ec4547a66c031 --- /dev/null +++ b/libc/test/include/complex_test.cpp @@ -0,0 +1,22 @@ +//===-- Unittests for complex ---------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "include/llvm-libc-macros/complex-macros.h" +#include "test/UnitTest/Test.h" + +TEST(LlvmLibcComplexTest, VersionMacro) { + EXPECT_EQ(__STDC_VERSION_COMPLEX_H__, 202311L); +} + +TEST(LlvmLibcComplexTest, IMacro) { + EXPECT_EQ(I, 1.0fi); +} + +TEST(LlvmLibcComplexTest, _Complex_IMacro) { + EXPECT_EQ(_Complex_I, 1.0fi); +} From 7967075ccc1efd5d30a03e3ae2761501ed767f65 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Thu, 10 Oct 2024 23:28:10 +0530 Subject: [PATCH 10/27] Add FpBits --- libc/test/include/complex_test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libc/test/include/complex_test.cpp b/libc/test/include/complex_test.cpp index ec4547a66c031..6933a19ff6f23 100644 --- a/libc/test/include/complex_test.cpp +++ b/libc/test/include/complex_test.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "include/llvm-libc-macros/complex-macros.h" +#include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" TEST(LlvmLibcComplexTest, VersionMacro) { @@ -14,9 +15,9 @@ TEST(LlvmLibcComplexTest, VersionMacro) { } TEST(LlvmLibcComplexTest, IMacro) { - EXPECT_EQ(I, 1.0fi); + EXPECT_FP_EQ(I, 1.0fi); } TEST(LlvmLibcComplexTest, _Complex_IMacro) { - EXPECT_EQ(_Complex_I, 1.0fi); + EXPECT_FP_EQ(_Complex_I, 1.0fi); } From 9c61d3acc422d6519ed6086382278334f0e1a24a Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Thu, 10 Oct 2024 23:29:06 +0530 Subject: [PATCH 11/27] fmt --- libc/test/include/complex_test.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libc/test/include/complex_test.cpp b/libc/test/include/complex_test.cpp index 6933a19ff6f23..906ac53eb70a1 100644 --- a/libc/test/include/complex_test.cpp +++ b/libc/test/include/complex_test.cpp @@ -14,10 +14,6 @@ TEST(LlvmLibcComplexTest, VersionMacro) { EXPECT_EQ(__STDC_VERSION_COMPLEX_H__, 202311L); } -TEST(LlvmLibcComplexTest, IMacro) { - EXPECT_FP_EQ(I, 1.0fi); -} +TEST(LlvmLibcComplexTest, IMacro) { EXPECT_FP_EQ(I, 1.0fi); } -TEST(LlvmLibcComplexTest, _Complex_IMacro) { - EXPECT_FP_EQ(_Complex_I, 1.0fi); -} +TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_FP_EQ(_Complex_I, 1.0fi); } From f19dcbce2a70a78c2a71244b39939e103dadba88 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 10:22:09 +0530 Subject: [PATCH 12/27] Added iscomplex type --- .../modules/LLVMLibCCompileOptionRules.cmake | 4 ++ .../include/llvm-libc-macros/complex-macros.h | 2 +- libc/src/__support/CPP/type_traits.h | 1 + .../__support/CPP/type_traits/is_complex.h | 39 +++++++++++++++++++ libc/src/__support/FPUtil/FPBits.h | 2 +- libc/test/UnitTest/FPMatcher.h | 4 +- libc/test/UnitTest/LibcTest.cpp | 4 -- libc/test/include/complex_test.cpp | 4 +- 8 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 libc/src/__support/CPP/type_traits/is_complex.h diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 8643c9bb48ad4..6af6faba27eb7 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -152,6 +152,8 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") + list(APPEND compile_options "-Wno-c99-extensions") + list(APPEND compile_options "-Wno-pedantic") list(APPEND compile_options "-Wimplicit-fallthrough") list(APPEND compile_options "-Wwrite-strings") list(APPEND compile_options "-Wextra-semi") @@ -227,6 +229,8 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wimplicit-fallthrough") # list(APPEND compile_options "-Wwrite-strings") # list(APPEND compile_options "-Wextra-semi") + list(APPEND compile_options "-Wno-c99-extensions") + list(APPEND compile_options "-Wno-pedantic") # if(NOT CMAKE_COMPILER_IS_GNUCXX) # list(APPEND compile_options "-Wnewline-eof") # list(APPEND compile_options "-Wnonportable-system-include-path") diff --git a/libc/include/llvm-libc-macros/complex-macros.h b/libc/include/llvm-libc-macros/complex-macros.h index b2833bf09d3ed..a4ad53b2f2b2e 100644 --- a/libc/include/llvm-libc-macros/complex-macros.h +++ b/libc/include/llvm-libc-macros/complex-macros.h @@ -14,7 +14,7 @@ #define __STDC_VERSION_COMPLEX_H__ 202311L #define complex _Complex -#define _Complex_I ((float _Complex)1.0fi) +#define _Complex_I ((_Complex float)1.0fi) #define I _Complex_I // TODO: Add imaginary macros once GCC or Clang support them. diff --git a/libc/src/__support/CPP/type_traits.h b/libc/src/__support/CPP/type_traits.h index d50b6612656db..fe8003a5c4b49 100644 --- a/libc/src/__support/CPP/type_traits.h +++ b/libc/src/__support/CPP/type_traits.h @@ -32,6 +32,7 @@ #include "src/__support/CPP/type_traits/is_enum.h" #include "src/__support/CPP/type_traits/is_fixed_point.h" #include "src/__support/CPP/type_traits/is_floating_point.h" +#include "src/__support/CPP/type_traits/is_complex.h" #include "src/__support/CPP/type_traits/is_function.h" #include "src/__support/CPP/type_traits/is_integral.h" #include "src/__support/CPP/type_traits/is_lvalue_reference.h" diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h new file mode 100644 index 0000000000000..04a24e14bce45 --- /dev/null +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -0,0 +1,39 @@ +//===-- is_complex type_traits ---------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H +#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H + +#include "src/__support/CPP/type_traits/is_same.h" +#include "src/__support/CPP/type_traits/remove_cv.h" +#include "src/__support/macros/attributes.h" +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 + +namespace LIBC_NAMESPACE_DECL { +namespace cpp { + +// is_complex +template struct is_complex { +private: + template + LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { + return (... || is_same_v, Args>); + } + +public: + LIBC_INLINE_VAR static constexpr bool value = + __is_unqualified_any_of(); +}; +template +LIBC_INLINE_VAR constexpr bool is_complex_v = + is_complex::value; + +} // namespace cpp +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h index 5d1f633bb56ee..99510f64c014f 100644 --- a/libc/src/__support/FPUtil/FPBits.h +++ b/libc/src/__support/FPUtil/FPBits.h @@ -799,7 +799,7 @@ template LIBC_INLINE static constexpr FPType get_fp_type() { // It derives its functionality to FPRepImpl above. template struct FPBits final : public internal::FPRepImpl(), FPBits> { - static_assert(cpp::is_floating_point_v, + static_assert(cpp::is_floating_point_v || cpp::is_complex_v, "FPBits instantiated with invalid type."); using UP = internal::FPRepImpl(), FPBits>; using StorageType = typename UP::StorageType; diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index 3cf0b04952ec0..a266b63795b4e 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -27,8 +27,8 @@ namespace LIBC_NAMESPACE_DECL { namespace testing { template class FPMatcher : public Matcher { - static_assert(cpp::is_floating_point_v, - "FPMatcher can only be used with floating point values."); + static_assert(cpp::is_floating_point_v || cpp::is_complex_v, + "FPMatcher can only be used with floating point or complex floating point values."); static_assert(Condition == TestCond::EQ || Condition == TestCond::NE, "Unsupported FPMatcher test condition."); diff --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp index 8bbe1fe0abed7..ad5722f99a436 100644 --- a/libc/test/UnitTest/LibcTest.cpp +++ b/libc/test/UnitTest/LibcTest.cpp @@ -232,10 +232,6 @@ TEST_SPECIALIZATION(unsigned long long); TEST_SPECIALIZATION(bool); -TEST_SPECIALIZATION(float _Complex); -TEST_SPECIALIZATION(double _Complex); -TEST_SPECIALIZATION(long double _Complex); - // We cannot just use a single UInt128 specialization as that resolves to only // one type, UInt<128> or __uint128_t. We want both overloads as we want to #ifdef LIBC_TYPES_HAS_INT128 diff --git a/libc/test/include/complex_test.cpp b/libc/test/include/complex_test.cpp index 906ac53eb70a1..9c13ad06d1193 100644 --- a/libc/test/include/complex_test.cpp +++ b/libc/test/include/complex_test.cpp @@ -14,6 +14,6 @@ TEST(LlvmLibcComplexTest, VersionMacro) { EXPECT_EQ(__STDC_VERSION_COMPLEX_H__, 202311L); } -TEST(LlvmLibcComplexTest, IMacro) { EXPECT_FP_EQ(I, 1.0fi); } +TEST(LlvmLibcComplexTest, IMacro) { EXPECT_FP_EQ(1.0fi, I); } -TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_FP_EQ(_Complex_I, 1.0fi); } +TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_FP_EQ(1.0fi, _Complex_I); } From 4433861e51c1ad9b3b563483656ac77ba310e107 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 12:52:39 +0530 Subject: [PATCH 13/27] Added CFPMatcher --- libc/test/UnitTest/FPMatcher.h | 79 +++++++++++++++++++++++++++++- libc/test/include/complex_test.cpp | 4 +- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index a266b63795b4e..d711e5a76e328 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -27,8 +27,8 @@ namespace LIBC_NAMESPACE_DECL { namespace testing { template class FPMatcher : public Matcher { - static_assert(cpp::is_floating_point_v || cpp::is_complex_v, - "FPMatcher can only be used with floating point or complex floating point values."); + static_assert(cpp::is_floating_point_v, + "FPMatcher can only be used with floating point values."); static_assert(Condition == TestCond::EQ || Condition == TestCond::NE, "Unsupported FPMatcher test condition."); @@ -60,10 +60,81 @@ template class FPMatcher : public Matcher { } }; +template class CFPMatcher : public Matcher { + static_assert(cpp::is_complex_v, + "CFPMatcher can only be used with complex floating point values."); + static_assert(Condition == TestCond::EQ || Condition == TestCond::NE, + "Unsupported CFPMatcher test condition."); + + T expected; + T actual; + +public: + CFPMatcher(T expectedValue) : expected(expectedValue) {} + + template + bool matchComplex() { + CFT* actualCmplxPtr = reinterpret_cast(&actual); + CFT* expectedCmplxPtr = reinterpret_cast(&expected); + CFT actualReal = actualCmplxPtr[0]; + CFT actualImag = actualCmplxPtr[1]; + CFT expectedReal = expectedCmplxPtr[0]; + CFT expectedImag = expectedCmplxPtr[1]; + fputil::FPBits actualRealBits(actualReal), expectedRealBits(expectedReal); + fputil::FPBits actualImagBits(actualImag), expectedImagBits(expectedImag); + if (Condition == TestCond::EQ) + return ((actualRealBits.is_nan() && expectedRealBits.is_nan()) || + (actualRealBits.uintval() == expectedRealBits.uintval())) && + ((actualImagBits.is_nan() && expectedImagBits.is_nan()) || + (actualImagBits.uintval() == expectedImagBits.uintval())); + + // If condition == TestCond::NE. + if (actualRealBits.is_nan() && expectedRealBits.is_nan()) + return !expectedRealBits.is_nan() && !expectedImagBits.is_nan(); + if (actualRealBits.is_nan()) + return !expectedRealBits.is_nan(); + if (actualImagBits.is_nan()) + return !expectedImagBits.is_nan(); + return (expectedRealBits.is_nan() || actualRealBits.uintval() != expectedRealBits.uintval()) && + (expectedImagBits.is_nan() || actualImagBits.uintval() != expectedImagBits.uintval()); + } + + template + void explainErrorComplex() { + CFT* actualCmplxPtr = reinterpret_cast(&actual); + CFT* expectedCmplxPtr = reinterpret_cast(&expected); + CFT actualReal = actualCmplxPtr[0]; + CFT actualImag = actualCmplxPtr[1]; + CFT expectedReal = expectedCmplxPtr[0]; + CFT expectedImag = expectedCmplxPtr[1]; + tlog << "Expected complex floating point value: " + << str(fputil::FPBits(expectedReal)) + " + " + str(fputil::FPBits(expectedImag)) + "i" << '\n'; + tlog << "Actual complex floating point value: " + << str(fputil::FPBits(actualReal)) + " + " + str(fputil::FPBits(actualImag)) + "i" << '\n'; + } + + bool match(T actualValue) { + actual = actualValue; + if (sizeof(T) == 2 * sizeof(float)) return matchComplex(); + else if (sizeof(T) == 2 * sizeof(double)) return matchComplex(); + else if (sizeof(T) == 2 * sizeof(long double)) return matchComplex(); + } + + void explainError() override { + if (sizeof(T) == 2 * sizeof(float)) explainErrorComplex(); + else if (sizeof(T) == 2 * sizeof(double)) explainErrorComplex(); + else if (sizeof(T) == 2 * sizeof(long double)) explainErrorComplex(); + } +}; + template FPMatcher getMatcher(T expectedValue) { return FPMatcher(expectedValue); } +template CFPMatcher getMatcherComplex(T expectedValue) { + return CFPMatcher(expectedValue); +} + template struct FPTest : public Test { using FPBits = LIBC_NAMESPACE::fputil::FPBits; using StorageType = typename FPBits::StorageType; @@ -125,6 +196,10 @@ template struct FPTest : public Test { EXPECT_THAT(actual, LIBC_NAMESPACE::testing::getMatcher< \ LIBC_NAMESPACE::testing::TestCond::EQ>(expected)) +#define EXPECT_CFP_EQ(expected, actual) \ + EXPECT_THAT(actual, LIBC_NAMESPACE::testing::getMatcherComplex< \ + LIBC_NAMESPACE::testing::TestCond::EQ>(expected)) + #define TEST_FP_EQ(expected, actual) \ LIBC_NAMESPACE::testing::getMatcher( \ expected) \ diff --git a/libc/test/include/complex_test.cpp b/libc/test/include/complex_test.cpp index 9c13ad06d1193..f6bfe997d98dd 100644 --- a/libc/test/include/complex_test.cpp +++ b/libc/test/include/complex_test.cpp @@ -14,6 +14,6 @@ TEST(LlvmLibcComplexTest, VersionMacro) { EXPECT_EQ(__STDC_VERSION_COMPLEX_H__, 202311L); } -TEST(LlvmLibcComplexTest, IMacro) { EXPECT_FP_EQ(1.0fi, I); } +TEST(LlvmLibcComplexTest, IMacro) { EXPECT_CFP_EQ(1.0fi, I); } -TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_FP_EQ(1.0fi, _Complex_I); } +TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_CFP_EQ(1.0fi, _Complex_I); } From af6ce5e0a8d45997fd2eda105ee3fbff43e39b8b Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 12:53:27 +0530 Subject: [PATCH 14/27] fmt --- libc/src/__support/CPP/type_traits.h | 2 +- .../__support/CPP/type_traits/is_complex.h | 6 +- libc/test/UnitTest/FPMatcher.h | 64 +++++++++++-------- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/libc/src/__support/CPP/type_traits.h b/libc/src/__support/CPP/type_traits.h index fe8003a5c4b49..cef4e5d1f0b13 100644 --- a/libc/src/__support/CPP/type_traits.h +++ b/libc/src/__support/CPP/type_traits.h @@ -25,6 +25,7 @@ #include "src/__support/CPP/type_traits/is_array.h" #include "src/__support/CPP/type_traits/is_base_of.h" #include "src/__support/CPP/type_traits/is_class.h" +#include "src/__support/CPP/type_traits/is_complex.h" #include "src/__support/CPP/type_traits/is_const.h" #include "src/__support/CPP/type_traits/is_constant_evaluated.h" #include "src/__support/CPP/type_traits/is_convertible.h" @@ -32,7 +33,6 @@ #include "src/__support/CPP/type_traits/is_enum.h" #include "src/__support/CPP/type_traits/is_fixed_point.h" #include "src/__support/CPP/type_traits/is_floating_point.h" -#include "src/__support/CPP/type_traits/is_complex.h" #include "src/__support/CPP/type_traits/is_function.h" #include "src/__support/CPP/type_traits/is_integral.h" #include "src/__support/CPP/type_traits/is_lvalue_reference.h" diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 04a24e14bce45..4ae17d38d8a40 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -27,11 +27,11 @@ template struct is_complex { public: LIBC_INLINE_VAR static constexpr bool value = - __is_unqualified_any_of(); + __is_unqualified_any_of(); }; template -LIBC_INLINE_VAR constexpr bool is_complex_v = - is_complex::value; +LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex::value; } // namespace cpp } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index d711e5a76e328..8c9978ded2318 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -61,8 +61,9 @@ template class FPMatcher : public Matcher { }; template class CFPMatcher : public Matcher { - static_assert(cpp::is_complex_v, - "CFPMatcher can only be used with complex floating point values."); + static_assert( + cpp::is_complex_v, + "CFPMatcher can only be used with complex floating point values."); static_assert(Condition == TestCond::EQ || Condition == TestCond::NE, "Unsupported CFPMatcher test condition."); @@ -72,22 +73,23 @@ template class CFPMatcher : public Matcher { public: CFPMatcher(T expectedValue) : expected(expectedValue) {} - template - bool matchComplex() { - CFT* actualCmplxPtr = reinterpret_cast(&actual); - CFT* expectedCmplxPtr = reinterpret_cast(&expected); + template bool matchComplex() { + CFT *actualCmplxPtr = reinterpret_cast(&actual); + CFT *expectedCmplxPtr = reinterpret_cast(&expected); CFT actualReal = actualCmplxPtr[0]; CFT actualImag = actualCmplxPtr[1]; CFT expectedReal = expectedCmplxPtr[0]; CFT expectedImag = expectedCmplxPtr[1]; - fputil::FPBits actualRealBits(actualReal), expectedRealBits(expectedReal); - fputil::FPBits actualImagBits(actualImag), expectedImagBits(expectedImag); + fputil::FPBits actualRealBits(actualReal), + expectedRealBits(expectedReal); + fputil::FPBits actualImagBits(actualImag), + expectedImagBits(expectedImag); if (Condition == TestCond::EQ) return ((actualRealBits.is_nan() && expectedRealBits.is_nan()) || - (actualRealBits.uintval() == expectedRealBits.uintval())) && + (actualRealBits.uintval() == expectedRealBits.uintval())) && ((actualImagBits.is_nan() && expectedImagBits.is_nan()) || (actualImagBits.uintval() == expectedImagBits.uintval())); - + // If condition == TestCond::NE. if (actualRealBits.is_nan() && expectedRealBits.is_nan()) return !expectedRealBits.is_nan() && !expectedImagBits.is_nan(); @@ -95,35 +97,46 @@ template class CFPMatcher : public Matcher { return !expectedRealBits.is_nan(); if (actualImagBits.is_nan()) return !expectedImagBits.is_nan(); - return (expectedRealBits.is_nan() || actualRealBits.uintval() != expectedRealBits.uintval()) && - (expectedImagBits.is_nan() || actualImagBits.uintval() != expectedImagBits.uintval()); + return (expectedRealBits.is_nan() || + actualRealBits.uintval() != expectedRealBits.uintval()) && + (expectedImagBits.is_nan() || + actualImagBits.uintval() != expectedImagBits.uintval()); } - template - void explainErrorComplex() { - CFT* actualCmplxPtr = reinterpret_cast(&actual); - CFT* expectedCmplxPtr = reinterpret_cast(&expected); + template void explainErrorComplex() { + CFT *actualCmplxPtr = reinterpret_cast(&actual); + CFT *expectedCmplxPtr = reinterpret_cast(&expected); CFT actualReal = actualCmplxPtr[0]; CFT actualImag = actualCmplxPtr[1]; CFT expectedReal = expectedCmplxPtr[0]; CFT expectedImag = expectedCmplxPtr[1]; tlog << "Expected complex floating point value: " - << str(fputil::FPBits(expectedReal)) + " + " + str(fputil::FPBits(expectedImag)) + "i" << '\n'; + << str(fputil::FPBits(expectedReal)) + " + " + + str(fputil::FPBits(expectedImag)) + "i" + << '\n'; tlog << "Actual complex floating point value: " - << str(fputil::FPBits(actualReal)) + " + " + str(fputil::FPBits(actualImag)) + "i" << '\n'; + << str(fputil::FPBits(actualReal)) + " + " + + str(fputil::FPBits(actualImag)) + "i" + << '\n'; } bool match(T actualValue) { actual = actualValue; - if (sizeof(T) == 2 * sizeof(float)) return matchComplex(); - else if (sizeof(T) == 2 * sizeof(double)) return matchComplex(); - else if (sizeof(T) == 2 * sizeof(long double)) return matchComplex(); + if (sizeof(T) == 2 * sizeof(float)) + return matchComplex(); + else if (sizeof(T) == 2 * sizeof(double)) + return matchComplex(); + else if (sizeof(T) == 2 * sizeof(long double)) + return matchComplex(); } void explainError() override { - if (sizeof(T) == 2 * sizeof(float)) explainErrorComplex(); - else if (sizeof(T) == 2 * sizeof(double)) explainErrorComplex(); - else if (sizeof(T) == 2 * sizeof(long double)) explainErrorComplex(); + if (sizeof(T) == 2 * sizeof(float)) + explainErrorComplex(); + else if (sizeof(T) == 2 * sizeof(double)) + explainErrorComplex(); + else if (sizeof(T) == 2 * sizeof(long double)) + explainErrorComplex(); } }; @@ -131,7 +144,8 @@ template FPMatcher getMatcher(T expectedValue) { return FPMatcher(expectedValue); } -template CFPMatcher getMatcherComplex(T expectedValue) { +template +CFPMatcher getMatcherComplex(T expectedValue) { return CFPMatcher(expectedValue); } From 94f8130eb51659a7b94da78d221e086a6fcd5b56 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 12:55:37 +0530 Subject: [PATCH 15/27] nit --- libc/include/llvm-libc-types/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index f0dadc99099c7..a4cf4631c8470 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -17,7 +17,6 @@ add_header(__qsortrcompare_t HDR __qsortrcompare_t.h) add_header(__sighandler_t HDR __sighandler_t.h) add_header(__thread_type HDR __thread_type.h) add_header(blkcnt_t HDR blkcnt_t.h) -add_header(_Imaginary HDR _Imaginary.h) add_header(blksize_t HDR blksize_t.h) add_header(cc_t HDR cc_t.h) add_header(clock_t HDR clock_t.h) From 4f8fe9adcf0b1d48b2f33482f324bd5a77a09563 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 12:59:05 +0530 Subject: [PATCH 16/27] nit --- libc/include/llvm-libc-macros/complex-macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/include/llvm-libc-macros/complex-macros.h b/libc/include/llvm-libc-macros/complex-macros.h index a4ad53b2f2b2e..427c68d289e0b 100644 --- a/libc/include/llvm-libc-macros/complex-macros.h +++ b/libc/include/llvm-libc-macros/complex-macros.h @@ -17,7 +17,7 @@ #define _Complex_I ((_Complex float)1.0fi) #define I _Complex_I -// TODO: Add imaginary macros once GCC or Clang support them. +// TODO: Add imaginary macros once GCC or Clang support _Imaginary builtin-type. #endif From 720f95e5b1df1f42828187c787f9d6211389ec07 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 13:01:21 +0530 Subject: [PATCH 17/27] nit --- libc/src/__support/FPUtil/FPBits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h index 99510f64c014f..5d1f633bb56ee 100644 --- a/libc/src/__support/FPUtil/FPBits.h +++ b/libc/src/__support/FPUtil/FPBits.h @@ -799,7 +799,7 @@ template LIBC_INLINE static constexpr FPType get_fp_type() { // It derives its functionality to FPRepImpl above. template struct FPBits final : public internal::FPRepImpl(), FPBits> { - static_assert(cpp::is_floating_point_v || cpp::is_complex_v, + static_assert(cpp::is_floating_point_v, "FPBits instantiated with invalid type."); using UP = internal::FPRepImpl(), FPBits>; using StorageType = typename UP::StorageType; From e94699379dc7d27a6fabef730f017f8ac927cabd Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 13:18:50 +0530 Subject: [PATCH 18/27] Cmake nit --- libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 6af6faba27eb7..636233326253e 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -153,7 +153,6 @@ function(_get_common_compile_options output_var flags) list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") list(APPEND compile_options "-Wno-c99-extensions") - list(APPEND compile_options "-Wno-pedantic") list(APPEND compile_options "-Wimplicit-fallthrough") list(APPEND compile_options "-Wwrite-strings") list(APPEND compile_options "-Wextra-semi") @@ -230,7 +229,6 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wwrite-strings") # list(APPEND compile_options "-Wextra-semi") list(APPEND compile_options "-Wno-c99-extensions") - list(APPEND compile_options "-Wno-pedantic") # if(NOT CMAKE_COMPILER_IS_GNUCXX) # list(APPEND compile_options "-Wnewline-eof") # list(APPEND compile_options "-Wnonportable-system-include-path") From 6af7faf29b50d80bb512ef9f142abe32d3384b9e Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 14:25:50 +0530 Subject: [PATCH 19/27] Add FP16 and FP128 --- libc/src/__support/CPP/type_traits/is_complex.h | 11 ++++++++++- libc/test/UnitTest/FPMatcher.h | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 4ae17d38d8a40..5cdf9e29064f0 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -28,7 +28,16 @@ template struct is_complex { public: LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of(); + _Complex long double +#ifdef LIBC_TYPES_HAS_FLOAT16 + , + _Complex _Float16 +#endif +#ifdef LIBC_TYPES_HAS_FLOAT128 + , + _Complex __float128 +#endif + >(); }; template LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex::value; diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index 8c9978ded2318..d61232a6cbcdf 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -128,6 +128,14 @@ template class CFPMatcher : public Matcher { return matchComplex(); else if (sizeof(T) == 2 * sizeof(long double)) return matchComplex(); +#ifdef LIBC_TYPES_HAS_FLOAT16 + else if (sizeof(T) == 2 * sizeof(float16)) + return matchComplex(); +#endif +#ifdef LIBC_TYPES_HAS_FLOAT128 + else if (sizeof(T) == 2 * sizeof(float128)) + return matchComplex(); +#endif } void explainError() override { @@ -137,6 +145,14 @@ template class CFPMatcher : public Matcher { explainErrorComplex(); else if (sizeof(T) == 2 * sizeof(long double)) explainErrorComplex(); +#ifdef LIBC_TYPES_HAS_FLOAT16 + else if (sizeof(T) == 2 * sizeof(float16)) + explainErrorComplex(); +#endif +#ifdef LIBC_TYPES_HAS_FLOAT128 + else if (sizeof(T) == 2 * sizeof(float128)) + explainErrorComplex(); +#endif } }; From 729aea1549bb8f1f781893e2a8b032ff807ae43b Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 14:28:24 +0530 Subject: [PATCH 20/27] nit --- libc/src/__support/CPP/type_traits/is_complex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 5cdf9e29064f0..8e47b18aae76c 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -1,4 +1,4 @@ -//===-- is_complex type_traits ---------------------------*- C++ -*-===// +//===-- is_complex type_traits ----------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. From 0c7457cac600380e2312f5b5be251fc1e8f662ad Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 15:35:44 +0530 Subject: [PATCH 21/27] Fixed bug for long double and FP128 --- .../__support/CPP/type_traits/is_complex.h | 2 ++ libc/test/UnitTest/FPMatcher.h | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 8e47b18aae76c..90e45384473c3 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -41,6 +41,8 @@ template struct is_complex { }; template LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex::value; +template +LIBC_INLINE_VAR constexpr bool is_complex_type_same() {return is_same_v, T2>;} } // namespace cpp } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index d61232a6cbcdf..99d8ab133badf 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -122,36 +122,34 @@ template class CFPMatcher : public Matcher { bool match(T actualValue) { actual = actualValue; - if (sizeof(T) == 2 * sizeof(float)) + if (cpp::is_complex_type_same()) return matchComplex(); - else if (sizeof(T) == 2 * sizeof(double)) + else if (cpp::is_complex_type_same()) return matchComplex(); - else if (sizeof(T) == 2 * sizeof(long double)) + else if (cpp::is_complex_type_same()) return matchComplex(); #ifdef LIBC_TYPES_HAS_FLOAT16 - else if (sizeof(T) == 2 * sizeof(float16)) + else if (cpp::is_complex_type_same()) return matchComplex(); #endif #ifdef LIBC_TYPES_HAS_FLOAT128 - else if (sizeof(T) == 2 * sizeof(float128)) - return matchComplex(); + return matchComplex(); #endif } void explainError() override { - if (sizeof(T) == 2 * sizeof(float)) - explainErrorComplex(); - else if (sizeof(T) == 2 * sizeof(double)) - explainErrorComplex(); - else if (sizeof(T) == 2 * sizeof(long double)) - explainErrorComplex(); + if (cpp::is_complex_type_same()) + return explainErrorComplex(); + else if (cpp::is_complex_type_same()) + return explainErrorComplex(); + else if (cpp::is_complex_type_same()) + return explainErrorComplex(); #ifdef LIBC_TYPES_HAS_FLOAT16 - else if (sizeof(T) == 2 * sizeof(float16)) - explainErrorComplex(); + else if (cpp::is_complex_type_same()) + return explainErrorComplex(); #endif #ifdef LIBC_TYPES_HAS_FLOAT128 - else if (sizeof(T) == 2 * sizeof(float128)) - explainErrorComplex(); + return explainErrorComplex(); #endif } }; From 4078236af225b530782bccadb155225c2cf16059 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 15:35:57 +0530 Subject: [PATCH 22/27] fmt --- libc/src/__support/CPP/type_traits/is_complex.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 90e45384473c3..3cad2070df26d 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -42,7 +42,9 @@ template struct is_complex { template LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex::value; template -LIBC_INLINE_VAR constexpr bool is_complex_type_same() {return is_same_v, T2>;} +LIBC_INLINE_VAR constexpr bool is_complex_type_same() { + return is_same_v, T2>; +} } // namespace cpp } // namespace LIBC_NAMESPACE_DECL From e769743cefc3625191c1ec7d80261c7a8fd6608f Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sat, 12 Oct 2024 19:22:53 +0530 Subject: [PATCH 23/27] remove F16 and F128 --- libc/src/__support/CPP/type_traits/is_complex.h | 11 +---------- libc/test/UnitTest/FPMatcher.h | 14 -------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 3cad2070df26d..9f6def0d76a55 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -28,16 +28,7 @@ template struct is_complex { public: LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of(); + _Complex long double>(); }; template LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex::value; diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index 99d8ab133badf..5220b1245bf3a 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -128,13 +128,6 @@ template class CFPMatcher : public Matcher { return matchComplex(); else if (cpp::is_complex_type_same()) return matchComplex(); -#ifdef LIBC_TYPES_HAS_FLOAT16 - else if (cpp::is_complex_type_same()) - return matchComplex(); -#endif -#ifdef LIBC_TYPES_HAS_FLOAT128 - return matchComplex(); -#endif } void explainError() override { @@ -144,13 +137,6 @@ template class CFPMatcher : public Matcher { return explainErrorComplex(); else if (cpp::is_complex_type_same()) return explainErrorComplex(); -#ifdef LIBC_TYPES_HAS_FLOAT16 - else if (cpp::is_complex_type_same()) - return explainErrorComplex(); -#endif -#ifdef LIBC_TYPES_HAS_FLOAT128 - return explainErrorComplex(); -#endif } }; From 1b94e495e645695758c88286082942ab17475e4d Mon Sep 17 00:00:00 2001 From: Shourya Goel Date: Sun, 13 Oct 2024 14:18:06 +0530 Subject: [PATCH 24/27] Update is_complex.h --- libc/src/__support/CPP/type_traits/is_complex.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index 9f6def0d76a55..ee35268cd188e 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -12,7 +12,6 @@ #include "src/__support/CPP/type_traits/remove_cv.h" #include "src/__support/macros/attributes.h" #include "src/__support/macros/config.h" -#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 namespace LIBC_NAMESPACE_DECL { namespace cpp { From 05c18fb865ac1914cf27cbb2e2bc69c22cd14163 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Sun, 13 Oct 2024 14:24:13 +0530 Subject: [PATCH 25/27] removed unnecessary imports --- libc/src/__support/CPP/type_traits/is_complex.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc/src/__support/CPP/type_traits/is_complex.h b/libc/src/__support/CPP/type_traits/is_complex.h index ee35268cd188e..4f5ee9abdb33a 100644 --- a/libc/src/__support/CPP/type_traits/is_complex.h +++ b/libc/src/__support/CPP/type_traits/is_complex.h @@ -10,8 +10,6 @@ #include "src/__support/CPP/type_traits/is_same.h" #include "src/__support/CPP/type_traits/remove_cv.h" -#include "src/__support/macros/attributes.h" -#include "src/__support/macros/config.h" namespace LIBC_NAMESPACE_DECL { namespace cpp { From 764f7cd58f55d01ed278bdaf97f48b9ee17f352d Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Mon, 14 Oct 2024 19:57:22 +0530 Subject: [PATCH 26/27] nit --- libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index 636233326253e..f43da0dc4f78c 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -152,6 +152,7 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") + # silencing this warning because _Complex is part of C99. list(APPEND compile_options "-Wno-c99-extensions") list(APPEND compile_options "-Wimplicit-fallthrough") list(APPEND compile_options "-Wwrite-strings") @@ -228,6 +229,7 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wimplicit-fallthrough") # list(APPEND compile_options "-Wwrite-strings") # list(APPEND compile_options "-Wextra-semi") + # silencing this warning because _Complex is part of C99. list(APPEND compile_options "-Wno-c99-extensions") # if(NOT CMAKE_COMPILER_IS_GNUCXX) # list(APPEND compile_options "-Wnewline-eof") From db9737ba944f26427d7345bed4179de986b99aa4 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Mon, 14 Oct 2024 20:40:16 +0530 Subject: [PATCH 27/27] nit --- libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake index f43da0dc4f78c..7af67e629471c 100644 --- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake +++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake @@ -152,7 +152,7 @@ function(_get_common_compile_options output_var flags) endif() list(APPEND compile_options "-Wconversion") list(APPEND compile_options "-Wno-sign-conversion") - # silencing this warning because _Complex is part of C99. + # Silence this warning because _Complex is a part of C99. list(APPEND compile_options "-Wno-c99-extensions") list(APPEND compile_options "-Wimplicit-fallthrough") list(APPEND compile_options "-Wwrite-strings") @@ -229,7 +229,7 @@ function(_get_common_test_compile_options output_var c_test flags) # list(APPEND compile_options "-Wimplicit-fallthrough") # list(APPEND compile_options "-Wwrite-strings") # list(APPEND compile_options "-Wextra-semi") - # silencing this warning because _Complex is part of C99. + # Silence this warning because _Complex is a part of C99. list(APPEND compile_options "-Wno-c99-extensions") # if(NOT CMAKE_COMPILER_IS_GNUCXX) # list(APPEND compile_options "-Wnewline-eof")