From patchwork Mon Jul 1 20:52:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Sherrill X-Patchwork-Id: 93150 Return-Path: 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 ; 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 ; 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 ; 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 To: newlib@sourceware.org Cc: Joel Sherrill 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org --- 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)) +#endif +#endif /* __ISO_C_VISIBLE >= 2011 */ + /* 7.3.5 Trigonometric functions */ /* 7.3.5.1 The cacos functions */ double complex cacos(double complex);