Message ID | 20240701205240.16456-1-joel@rtems.org |
---|---|
State | New |
Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6EDA63882042 for <patchwork@sourceware.org>; Mon, 1 Jul 2024 20:53:01 +0000 (GMT) X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) by sourceware.org (Postfix) with ESMTPS id A6F93385C6C1 for <newlib@sourceware.org>; Mon, 1 Jul 2024 20:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6F93385C6C1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A6F93385C6C1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.219.180 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719867166; cv=none; b=t2oYfTCJZVfdaoLjzcJSZSV1slAexlRcuI0V2zAOFGa6QgBqgfCEIpxrEfXbzjFcaXWZlVF3nNkdgbSn03DJHG5Deem1GNb0PfBYiJMj4L01FLrIHT+ieuVZn8VkSi0dsKeflVp3kVAaChSdP8aXqEF9ZswrMB/ze6uvtKBrdA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719867166; c=relaxed/simple; bh=NkfYY2JzzW/ZYJ4JW5awRyb8iJbWvMQFxVtciFWwLOg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=PzXkzNeUZugnagXMqr4Hvn6eDCRNPvUhKqnygCyivc086JdXdbM5IP9KpX/weexm6+HqKLRb6MmDtB4mM0nGjZgreKwHJsuD9l8Bm05yKCeq4g+TGaGOisQa0VvsGgAgQOc57WvbcgdTD5+BjfRn1XZmteOO5rZKM012CV1VIEU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e02b79c6f21so3648447276.2 for <newlib@sourceware.org>; Mon, 01 Jul 2024 13:52:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719867164; x=1720471964; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eG6X4M4fB/cuyeh6lcav5G2/acEulAnsGF6VhgVNXGw=; b=CZdkpmz3Ag+7ZesNu69tzfxL+ScRmmLECnfrToA0Ccv0SiFvwLDUOubM/WYcI1RhGU yljRYGUqK5I+VIHwyBinsoWYy+yt2DbFA17GNRS9XdD329wIeTF0n28L5ysrglqLweLS EKqxnzw5LcV0fTi8sT17fSLBwbhUMmY0/Tf/KU0uudf2rnfRpo3pHmZiTJwzOSa3bCZU pe+jYpCPGgnO/iUqfaX9yAt2KbFGi5/mv6Oe0IS0LWVgpcSwGm/hxzGCN2jcSZSwp+GY 7D26eaua0DLDUoShqgX/62WUuQfuC3woAioR6qAnrUaj/GZoNJnGNR3JCIAhfnGwWgcO L3gQ== X-Gm-Message-State: AOJu0Yxmmfu0ou7N6mRRivsxuZvOIOVZOBHFG6ZkeOprPqYjcyx2HbnP unFzLwyavp8Aglf6ULUb/va52XFouv+RBdhkaLoX6X3lEcAyuG544YYNhYBg X-Google-Smtp-Source: AGHT+IGq2PqKLABIrK2wQOPmNiBlFGPgJfGhjqKq6/QQi2zSowCfZ5VmH9K3vxZeG36LKtYZM9rpmA== X-Received: by 2002:a5b:a91:0:b0:de6:3d8:3deb with SMTP id 3f1490d57ef6-e036eb61985mr6798649276.21.1719867163673; Mon, 01 Jul 2024 13:52:43 -0700 (PDT) Received: from devel.oarcorp.com (d27-96-189-151.evv.wideopenwest.com. [96.27.151.189]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e0353d591cbsm1479545276.10.2024.07.01.13.52.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2024 13:52:43 -0700 (PDT) From: Joel Sherrill <joel@rtems.org> To: newlib@sourceware.org Cc: Joel Sherrill <joel@rtems.org> Subject: [PATCH] libc/include/complex.h: Add CMPLX, CMPLXF, and CMPLXL Date: Mon, 1 Jul 2024 15:52:40 -0500 Message-Id: <20240701205240.16456-1-joel@rtems.org> X-Mailer: git-send-email 2.24.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3039.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
Series |
libc/include/complex.h: Add CMPLX, CMPLXF, and CMPLXL
|
|
Commit Message
Joel Sherrill
July 1, 2024, 8:52 p.m. UTC
--- newlib/libc/include/complex.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Comments
On Mon, Jul 1, 2024 at 1:53 PM Joel Sherrill <joel@rtems.org> wrote: > > --- > newlib/libc/include/complex.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h > index ad3028e4c..dbabdf67a 100644 > --- a/newlib/libc/include/complex.h > +++ b/newlib/libc/include/complex.h > @@ -16,6 +16,19 @@ > > __BEGIN_DECLS > > +/* Implementation from FreeBSD */ > +#if __ISO_C_VISIBLE >= 2011 > +#ifdef __clang__ > +#define CMPLX(x, y) ((double complex){ x, y }) > +#define CMPLXF(x, y) ((float complex){ x, y }) > +#define CMPLXL(x, y) ((long double complex){ x, y }) > +#elif __GNUC_PREREQ__(4, 7) > +#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)) I only know this because I have been working with complex in the last few weeks but __builtin_complex does not work with GCC's C++ front-end (but it is not documented). I don't know if you care about using this part of the header with C++ but I am just putting it out there. Thanks, Andrew Pinski > +#endif > +#endif /* __ISO_C_VISIBLE >= 2011 */ > + > /* 7.3.5 Trigonometric functions */ > /* 7.3.5.1 The cacos functions */ > double complex cacos(double complex); > -- > 2.24.4 >
On Mon, Jul 1, 2024 at 3:58 PM Andrew Pinski <pinskia@gmail.com> wrote: > On Mon, Jul 1, 2024 at 1:53 PM Joel Sherrill <joel@rtems.org> wrote: > > > > --- > > newlib/libc/include/complex.h | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/newlib/libc/include/complex.h > b/newlib/libc/include/complex.h > > index ad3028e4c..dbabdf67a 100644 > > --- a/newlib/libc/include/complex.h > > +++ b/newlib/libc/include/complex.h > > @@ -16,6 +16,19 @@ > > > > __BEGIN_DECLS > > > > +/* Implementation from FreeBSD */ > > +#if __ISO_C_VISIBLE >= 2011 > > +#ifdef __clang__ > > +#define CMPLX(x, y) ((double complex){ x, y }) > > +#define CMPLXF(x, y) ((float complex){ x, y }) > > +#define CMPLXL(x, y) ((long double complex){ x, y }) > > +#elif __GNUC_PREREQ__(4, 7) > > +#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)) > > I only know this because I have been working with complex in the last > few weeks but __builtin_complex does not work with GCC's C++ front-end > (but it is not documented). > I don't know if you care about using this part of the header with C++ > but I am just putting it out there. Will C++ see this since it is in __ISO_C_VISIBLE >= 2011? Do you consider that an issue with GCC? I don't see these in a C++ standard. Technically that means they shouldn't be visible. And I am open to changing this if you think that there is an issue. > > Thanks, > Andrew Pinski > > > +#endif > > +#endif /* __ISO_C_VISIBLE >= 2011 */ > > + > > /* 7.3.5 Trigonometric functions */ > > /* 7.3.5.1 The cacos functions */ > > double complex cacos(double complex); > > -- > > 2.24.4 > > >
On Mon, Jul 1, 2024 at 2:51 PM Joel Sherrill <joel@rtems.org> wrote: > > > > On Mon, Jul 1, 2024 at 3:58 PM Andrew Pinski <pinskia@gmail.com> wrote: >> >> On Mon, Jul 1, 2024 at 1:53 PM Joel Sherrill <joel@rtems.org> wrote: >> > >> > --- >> > newlib/libc/include/complex.h | 13 +++++++++++++ >> > 1 file changed, 13 insertions(+) >> > >> > diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h >> > index ad3028e4c..dbabdf67a 100644 >> > --- a/newlib/libc/include/complex.h >> > +++ b/newlib/libc/include/complex.h >> > @@ -16,6 +16,19 @@ >> > >> > __BEGIN_DECLS >> > >> > +/* Implementation from FreeBSD */ >> > +#if __ISO_C_VISIBLE >= 2011 >> > +#ifdef __clang__ >> > +#define CMPLX(x, y) ((double complex){ x, y }) >> > +#define CMPLXF(x, y) ((float complex){ x, y }) >> > +#define CMPLXL(x, y) ((long double complex){ x, y }) >> > +#elif __GNUC_PREREQ__(4, 7) >> > +#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)) >> >> I only know this because I have been working with complex in the last >> few weeks but __builtin_complex does not work with GCC's C++ front-end >> (but it is not documented). >> I don't know if you care about using this part of the header with C++ >> but I am just putting it out there. > > > Will C++ see this since it is in __ISO_C_VISIBLE >= 2011? I am not sure. I was more just warning about __builtin_complex rather than anything else. > > Do you consider that an issue with GCC? I don't see these in a C++ standard. > Technically that means they shouldn't be visible. I did file https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107279 for __builtin_complex support in the C++ front-end (a few years back because I was working on the documentation at that point). Thanks, Andrew > > And I am open to changing this if you think that there is an issue. >> >> >> Thanks, >> Andrew Pinski >> >> > +#endif >> > +#endif /* __ISO_C_VISIBLE >= 2011 */ >> > + >> > /* 7.3.5 Trigonometric functions */ >> > /* 7.3.5.1 The cacos functions */ >> > double complex cacos(double complex); >> > -- >> > 2.24.4 >> >
On Mon, Jul 1, 2024 at 4:57 PM Andrew Pinski <pinskia@gmail.com> wrote: > On Mon, Jul 1, 2024 at 2:51 PM Joel Sherrill <joel@rtems.org> wrote: > > > > > > > > On Mon, Jul 1, 2024 at 3:58 PM Andrew Pinski <pinskia@gmail.com> wrote: > >> > >> On Mon, Jul 1, 2024 at 1:53 PM Joel Sherrill <joel@rtems.org> wrote: > >> > > >> > --- > >> > newlib/libc/include/complex.h | 13 +++++++++++++ > >> > 1 file changed, 13 insertions(+) > >> > > >> > diff --git a/newlib/libc/include/complex.h > b/newlib/libc/include/complex.h > >> > index ad3028e4c..dbabdf67a 100644 > >> > --- a/newlib/libc/include/complex.h > >> > +++ b/newlib/libc/include/complex.h > >> > @@ -16,6 +16,19 @@ > >> > > >> > __BEGIN_DECLS > >> > > >> > +/* Implementation from FreeBSD */ > >> > +#if __ISO_C_VISIBLE >= 2011 > >> > +#ifdef __clang__ > >> > +#define CMPLX(x, y) ((double complex){ x, y }) > >> > +#define CMPLXF(x, y) ((float complex){ x, y }) > >> > +#define CMPLXL(x, y) ((long double complex){ x, y }) > >> > +#elif __GNUC_PREREQ__(4, 7) > >> > +#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)) > >> > >> I only know this because I have been working with complex in the last > >> few weeks but __builtin_complex does not work with GCC's C++ front-end > >> (but it is not documented). > >> I don't know if you care about using this part of the header with C++ > >> but I am just putting it out there. > > > > > > Will C++ see this since it is in __ISO_C_VISIBLE >= 2011? > > I am not sure. I was more just warning about __builtin_complex rather > than anything else. > OK. I was just picking low hanging fruit as I was updating my Standards API spreadsheet to include POSIX-2024 and see what RTEMS already supports. Do you have an issue with this going in? If you don't, Jeff or Corinna still need to bless it. don't see these in a C++ standard. > > Technically that means they shouldn't be visible. > > I did file https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107279 for > __builtin_complex support in the C++ front-end (a few years back > because I was working on the documen > > > Do you consider that an issue with GCC? Itation at that point). > Maybe someone will implement it. It is open source. :) --joel > > Thanks, > Andrew > > > > > And I am open to changing this if you think that there is an issue. > >> > >> > >> Thanks, > >> Andrew Pinski > >> > >> > +#endif > >> > +#endif /* __ISO_C_VISIBLE >= 2011 */ > >> > + > >> > /* 7.3.5 Trigonometric functions */ > >> > /* 7.3.5.1 The cacos functions */ > >> > double complex cacos(double complex); > >> > -- > >> > 2.24.4 > >> > >
On Jul 1 17:30, Joel Sherrill wrote: > On Mon, Jul 1, 2024 at 4:57 PM Andrew Pinski <pinskia@gmail.com> wrote: > > > On Mon, Jul 1, 2024 at 2:51 PM Joel Sherrill <joel@rtems.org> wrote: > > > > > > > > > > > > On Mon, Jul 1, 2024 at 3:58 PM Andrew Pinski <pinskia@gmail.com> wrote: > > >> > > >> On Mon, Jul 1, 2024 at 1:53 PM Joel Sherrill <joel@rtems.org> wrote: > > >> > > > >> > --- > > >> > newlib/libc/include/complex.h | 13 +++++++++++++ > > >> > 1 file changed, 13 insertions(+) > > >> > > > >> > diff --git a/newlib/libc/include/complex.h > > b/newlib/libc/include/complex.h > > >> > index ad3028e4c..dbabdf67a 100644 > > >> > --- a/newlib/libc/include/complex.h > > >> > +++ b/newlib/libc/include/complex.h > > >> > @@ -16,6 +16,19 @@ > > >> > > > >> > __BEGIN_DECLS > > >> > > > >> > +/* Implementation from FreeBSD */ > > >> > +#if __ISO_C_VISIBLE >= 2011 > > >> > +#ifdef __clang__ > > >> > +#define CMPLX(x, y) ((double complex){ x, y }) > > >> > +#define CMPLXF(x, y) ((float complex){ x, y }) > > >> > +#define CMPLXL(x, y) ((long double complex){ x, y }) > > >> > +#elif __GNUC_PREREQ__(4, 7) > > >> > +#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)) > > >> > > >> I only know this because I have been working with complex in the last > > >> few weeks but __builtin_complex does not work with GCC's C++ front-end > > >> (but it is not documented). > > >> I don't know if you care about using this part of the header with C++ > > >> but I am just putting it out there. > > > > > > > > > Will C++ see this since it is in __ISO_C_VISIBLE >= 2011? > > > > I am not sure. I was more just warning about __builtin_complex rather > > than anything else. > > > > OK. I was just picking low hanging fruit as I was updating my Standards API > spreadsheet to include POSIX-2024 and see what RTEMS already supports. > > Do you have an issue with this going in? If you don't, Jeff or Corinna > still need to bless it. GLibC uses the exact same feature test macros, so, LGTM, please push. Andrew, if you have another change which you think is required for newlib, just send a followup patch for discussion. Thanks, Corinna
Merged. Thanks. On Wed, Jul 3, 2024 at 6:17 AM Corinna Vinschen <vinschen@redhat.com> wrote: > On Jul 1 17:30, Joel Sherrill wrote: > > On Mon, Jul 1, 2024 at 4:57 PM Andrew Pinski <pinskia@gmail.com> wrote: > > > > > On Mon, Jul 1, 2024 at 2:51 PM Joel Sherrill <joel@rtems.org> wrote: > > > > > > > > > > > > > > > > On Mon, Jul 1, 2024 at 3:58 PM Andrew Pinski <pinskia@gmail.com> > wrote: > > > >> > > > >> On Mon, Jul 1, 2024 at 1:53 PM Joel Sherrill <joel@rtems.org> > wrote: > > > >> > > > > >> > --- > > > >> > newlib/libc/include/complex.h | 13 +++++++++++++ > > > >> > 1 file changed, 13 insertions(+) > > > >> > > > > >> > diff --git a/newlib/libc/include/complex.h > > > b/newlib/libc/include/complex.h > > > >> > index ad3028e4c..dbabdf67a 100644 > > > >> > --- a/newlib/libc/include/complex.h > > > >> > +++ b/newlib/libc/include/complex.h > > > >> > @@ -16,6 +16,19 @@ > > > >> > > > > >> > __BEGIN_DECLS > > > >> > > > > >> > +/* Implementation from FreeBSD */ > > > >> > +#if __ISO_C_VISIBLE >= 2011 > > > >> > +#ifdef __clang__ > > > >> > +#define CMPLX(x, y) ((double complex){ x, y }) > > > >> > +#define CMPLXF(x, y) ((float complex){ x, y }) > > > >> > +#define CMPLXL(x, y) ((long double complex){ x, y }) > > > >> > +#elif __GNUC_PREREQ__(4, 7) > > > >> > +#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)) > > > >> > > > >> I only know this because I have been working with complex in the > last > > > >> few weeks but __builtin_complex does not work with GCC's C++ > front-end > > > >> (but it is not documented). > > > >> I don't know if you care about using this part of the header with > C++ > > > >> but I am just putting it out there. > > > > > > > > > > > > Will C++ see this since it is in __ISO_C_VISIBLE >= 2011? > > > > > > I am not sure. I was more just warning about __builtin_complex rather > > > than anything else. > > > > > > > OK. I was just picking low hanging fruit as I was updating my Standards > API > > spreadsheet to include POSIX-2024 and see what RTEMS already supports. > > > > Do you have an issue with this going in? If you don't, Jeff or Corinna > > still need to bless it. > > GLibC uses the exact same feature test macros, so, LGTM, please push. > > Andrew, if you have another change which you think is required for > newlib, just send a followup patch for discussion. > > > Thanks, > Corinna > >
diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h index ad3028e4c..dbabdf67a 100644 --- a/newlib/libc/include/complex.h +++ b/newlib/libc/include/complex.h @@ -16,6 +16,19 @@ __BEGIN_DECLS +/* Implementation from FreeBSD */ +#if __ISO_C_VISIBLE >= 2011 +#ifdef __clang__ +#define CMPLX(x, y) ((double complex){ x, y }) +#define CMPLXF(x, y) ((float complex){ x, y }) +#define CMPLXL(x, y) ((long double complex){ x, y }) +#elif __GNUC_PREREQ__(4, 7) +#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 +#endif /* __ISO_C_VISIBLE >= 2011 */ + /* 7.3.5 Trigonometric functions */ /* 7.3.5.1 The cacos functions */ double complex cacos(double complex);