From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id r+1NEThOWWomTg0AWB0awg (envelope-from ) for ; Thu, 16 Jul 2026 17:33:44 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TU/vhqP8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 350541E09E; Thu, 16 Jul 2026 17:33:44 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 101CC1E033 for ; Thu, 16 Jul 2026 17:33:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 360564BA23CB for ; Thu, 16 Jul 2026 21:33:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 360564BA23CB Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TU/vhqP8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 59D3E4BA543C for ; Thu, 16 Jul 2026 21:33:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59D3E4BA543C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 59D3E4BA543C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784237598; cv=none; b=MdmMkxIWfYPVIIJPygmXgvgH1EwtsWGjiBET95gjCHZSYb8w8TkgvjfrUGAN/i81NRM6D73bGenXrb1hTw1cDJlKdadhOM/RFE9znmGPp1lEGU6rI3GPtwZvrGVLIsrbhozDxnGRjFjYafTRfYhhvashqi1B6ANUgf1/9lBLqy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784237598; c=relaxed/simple; bh=zunvfuunGOI3Z0gVwhc1OJY1N0WR6tjwbw6YIk4g2/o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HfMJI6uoouKRNpFjw7cZJmNpmYx1KR/CqA0izZKxTJqUTRszC3tqJgRDnbyWIp9MFUP8y/FVsNSFjqgeUCfzYjH2bI3C7cW863eVnk7rwE1dP1Ja6uoTWJ39nf4zYJzoEvAFRuJQoIC9aIyZ/8E2DtcNpQZKtLRsU2aUOmEpEHI= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TU/vhqP8 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59D3E4BA543C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784237598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QqUPQVqhMtZq+wUQqGf6v+xnvmZb248c0cm6FegLtuU=; b=TU/vhqP8cp4cV/Prpyd3irBpgHvYnU8KnA/IIIPoQwmr/XrH+3FTYyGoigUJdfWIvOpNKO xG3tT95WG3yx/jmsRro/w2ArRl9170kyOd+sJ7ILFSw3DMMTb02eqEVBcmOE/g/4+CNEUf sB2bVDbtFfNG5O8poqc5dHWDfEocrQ0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-2XCRGjESNXaj9mGR0lOgJg-1; Thu, 16 Jul 2026 17:33:16 -0400 X-MC-Unique: 2XCRGjESNXaj9mGR0lOgJg-1 X-Mimecast-MFC-AGG-ID: 2XCRGjESNXaj9mGR0lOgJg_1784237595 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49544a639e9so4701085e9.1 for ; Thu, 16 Jul 2026 14:33:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784237595; x=1784842395; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QqUPQVqhMtZq+wUQqGf6v+xnvmZb248c0cm6FegLtuU=; b=FXYocVPbcHjpwLtyRE4jCbMFvySPYza1sT4m1/T7S+vYqR54QPCxrMd/3MBST6U/AY 4/HBpTZN36cJQHK2ZbK+umx/gB8JJZ2Ig/5uyEDoT7s21wAuWJ3EN9IGHAOf3cITSyGN PxBSq2g1/fuUGvHJ8m6hf0W9zDNxLyEM063F2gjLhREsQz6CwXCcr5uHirp2Q3KlTXth ZDyIT9+aiAsD88bVH8LSngask/axaDOQor3ggf6wzSZm1BSDPPDueUphnnN+1vykSgP7 3xvKbGH6/dC022I1j8h7PJAwzvuOrVhNOoah0HXCs2qkXOuek7nMjdZzEtlByH5QArHA BsHw== X-Forwarded-Encrypted: i=1; AHgh+RrfufMNwnViWoiK9h8/ozxjEWRU60EZ1EkhinNzEInoNxqndK56mHOTAwGNSQka9WUYa3eRD7ZafI8SDA==@sourceware.org X-Gm-Message-State: AOJu0Yz48h5jDprr1wlQGNwsxEVRbpzYbI8sTzvVOavagTKHairogOj3 ORRa1smIX/im13n8PPkiRLsxgPZoXqoquq00D3HVonp01SFxIBdbr6WhHmXXB1hJrj+3qK8E7NU MZvVWt7qxFnNgP7u5TpJW1QrHix9tU1aTWgmUz7hhTjZbNEhuYGJd65y6qh2052u2+oSJWPQ= X-Gm-Gg: AfdE7ck1Pfvq9ZYNyIEhIDig8068CprresbxtoQwwc+91P9BJLTQ6rf6VMsW2ddlgOD V1N/cSRdj5HDQTd3OOrt4Yqi4ZZJd5dmsDgQza4244iDixPtEArpGB38qHW0MUaCw4b06bL8ymZ lbnUg/k/uzdC+bumBM12CyL4QCiMm34a4BmacjzWNpvbVfN5sG4G10ksvRK46urLBZJfWx0rh5v 3mLtoJuX8S3xhs5qE0nsChUGnCi5irQlPnQKHEDj0IeT6l6kY0VKa3B/0DKp1bLUUTugatMK9H7 ZM10puvyq127fNh0HxiEOTZSM9CGYU/R6XNYzvDnSGp/pOqL9Hx74fA/gzjziUfIMB0nHS1b X-Received: by 2002:a05:600c:6792:b0:495:3f28:3f19 with SMTP id 5b1f17b1804b1-495407316c4mr71988155e9.37.1784237595375; Thu, 16 Jul 2026 14:33:15 -0700 (PDT) X-Received: by 2002:a05:600c:6792:b0:495:3f28:3f19 with SMTP id 5b1f17b1804b1-495407316c4mr71987945e9.37.1784237594799; Thu, 16 Jul 2026 14:33:14 -0700 (PDT) Received: from localhost ([31.111.209.233]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49549fef323sm361135e9.2.2026.07.16.14.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 14:33:14 -0700 (PDT) From: Andrew Burgess To: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH 3/4] gdb.base/callfuncs.c: factor out float/double functions In-Reply-To: <20260714220631.1499846-4-pedro@palves.net> References: <20260714220631.1499846-1-pedro@palves.net> <20260714220631.1499846-4-pedro@palves.net> Date: Thu, 16 Jul 2026 22:33:13 +0100 Message-ID: <87tspyd3hi.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: G7Y3dSnh_lG0ez7z-Hs7DCLAfZziuKuNF_oH6IU71cY_1784237595 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Pedro Alves writes: > Other than float vs double, t_float_values2 and t_double_values are > identical. Same for t_float_many_args and t_double_many_args. > > Adding 'long double' variants would mean even more duplication. > > Factor each "values" and "many_args" pair into a macro that generates > the function from the type, so that adding a new type is just one > line. LGTM. Approved-By: Andrew Burgess Thanks, Andrew > > Tested on x86_64-unknown-linux-gnu. > > Change-Id: I43013f4db9ccf1e5d8ac17dc5b557bd44500b9f4 > --- > gdb/testsuite/gdb.base/callfuncs.c | 138 +++++++++++++---------------- > 1 file changed, 60 insertions(+), 78 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c > index 1d35272a50e..0e6d9dcdd71 100644 > --- a/gdb/testsuite/gdb.base/callfuncs.c > +++ b/gdb/testsuite/gdb.base/callfuncs.c > @@ -345,96 +345,78 @@ float float_arg1, float_arg2; > && (float_arg2 - float_val2) > -DELTA); > } > > -int > +/* The parameter list of a t_TYPE_values function. Split out into > + prototyped vs non-prototyped variants because a macro body cannot > + contain #ifdef. */ > + > #ifdef NO_PROTOTYPES > -/* In this case we are just duplicating t_float_values, but that is the > - easiest way to deal with either ANSI or non-ANSI. */ > -t_float_values2 (float_arg1, float_arg2) > - float float_arg1, float_arg2; > +# define T_VALUES_PARAMS(TYPE) \ > + (arg1, arg2) \ > + TYPE arg1, arg2; > #else > -t_float_values2 (float float_arg1, float float_arg2) > +# define T_VALUES_PARAMS(TYPE) \ > + (TYPE arg1, TYPE arg2) > #endif > -{ > - return ((float_arg1 - float_val1) < DELTA > - && (float_arg1 - float_val1) > -DELTA > - && (float_arg2 - float_val2) < DELTA > - && (float_arg2 - float_val2) > -DELTA); > -} > > -/* This function has many arguments to force some of them to be passed via > - the stack instead of registers, to test that GDB can construct correctly > - the parameter save area. Note that Linux/ppc32 has 8 float registers to use > - for float parameter passing and Linux/ppc64 has 13, so the number of > - arguments has to be at least 14 to contemplate these platforms. */ > +/* Define a function NAME comparing its two TYPE arguments against the > + TYPE_val1 and TYPE_val2 globals. */ > > -float > -#ifdef NO_PROTOTYPES > -t_float_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, > - f14, f15) > - float f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; > -#else > -t_float_many_args (float f1, float f2, float f3, float f4, float f5, float f6, > - float f7, float f8, float f9, float f10, float f11, > - float f12, float f13, float f14, float f15) > -#endif > -{ > - float sum_args; > - float sum_values; > - > - sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 > - + f13 + f14 + f15; > - sum_values = float_val1 + float_val2 + float_val3 + float_val4 + float_val5 > - + float_val6 + float_val7 + float_val8 + float_val9 > - + float_val10 + float_val11 + float_val12 + float_val13 > - + float_val14 + float_val15; > - > - return ((sum_args - sum_values) < DELTA > - && (sum_args - sum_values) > -DELTA); > +#define DEFINE_T_FLOAT_VALUES(TYPE, NAME) \ > +int \ > +NAME T_VALUES_PARAMS (TYPE) \ > +{ \ > + return ((arg1 - TYPE##_val1) < DELTA \ > + && (arg1 - TYPE##_val1) > -DELTA \ > + && (arg2 - TYPE##_val2) < DELTA \ > + && (arg2 - TYPE##_val2) > -DELTA); \ > } > > -#ifdef PROTOTYPES > -int t_double_values (double double_arg1, double double_arg2) > -#else > -int t_double_values (double_arg1, double_arg2) > -double double_arg1, double_arg2; > -#endif > -{ > - return ((double_arg1 - double_val1) < DELTA > - && (double_arg1 - double_val1) > -DELTA > - && (double_arg2 - double_val2) < DELTA > - && (double_arg2 - double_val2) > -DELTA); > -} > +DEFINE_T_FLOAT_VALUES (float, t_float_values2) > +DEFINE_T_FLOAT_VALUES (double, t_double_values) > > -/* This function has many arguments to force some of them to be passed via > - the stack instead of registers, to test that GDB can construct correctly > - the parameter save area. Note that Linux/ppc32 has 8 float registers to use > - for float parameter passing and Linux/ppc64 has 13, so the number of > - arguments has to be at least 14 to contemplate these platforms. */ > +/* The parameter list of a t_TYPE_many_args function. Split out into > + prototyped vs non-prototyped variants because a macro body cannot > + contain #ifdef. */ > > -double > #ifdef NO_PROTOTYPES > -t_double_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, > - f14, f15) > - double f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; > +# define T_MANY_ARGS_PARAMS(TYPE) \ > + (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15) \ > + TYPE f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15; > #else > -t_double_many_args (double f1, double f2, double f3, double f4, double f5, > - double f6, double f7, double f8, double f9, double f10, > - double f11, double f12, double f13, double f14, double f15) > +# define T_MANY_ARGS_PARAMS(TYPE) \ > + (TYPE f1, TYPE f2, TYPE f3, TYPE f4, TYPE f5, TYPE f6, TYPE f7, \ > + TYPE f8, TYPE f9, TYPE f10, TYPE f11, TYPE f12, TYPE f13, TYPE f14, \ > + TYPE f15) > #endif > -{ > - double sum_args; > - double sum_values; > - > - sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 > - + f13 + f14 + f15; > - sum_values = double_val1 + double_val2 + double_val3 + double_val4 > - + double_val5 + double_val6 + double_val7 + double_val8 > - + double_val9 + double_val10 + double_val11 + double_val12 > - + double_val13 + double_val14 + double_val15; > - > - return ((sum_args - sum_values) < DELTA > - && (sum_args - sum_values) > -DELTA); > -} > + > +/* Define a function NAME returning TYPE with many arguments, to force > + some of them to be passed via the stack instead of registers, to > + test that GDB can construct the parameter save area correctly. > + Note that Linux/ppc32 has 8 float registers to use for float > + parameter passing and Linux/ppc64 has 13, so the number of > + arguments has to be at least 14 to contemplate these platforms. */ > + > +#define DEFINE_T_MANY_ARGS(TYPE, NAME) \ > +TYPE \ > +NAME T_MANY_ARGS_PARAMS (TYPE) \ > +{ \ > + TYPE sum_args; \ > + TYPE sum_values; \ > + \ > + sum_args = (f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 \ > + + f12 + f13 + f14 + f15); \ > + sum_values = (TYPE##_val1 + TYPE##_val2 + TYPE##_val3 \ > + + TYPE##_val4 + TYPE##_val5 + TYPE##_val6 \ > + + TYPE##_val7 + TYPE##_val8 + TYPE##_val9 \ > + + TYPE##_val10 + TYPE##_val11 + TYPE##_val12 \ > + + TYPE##_val13 + TYPE##_val14 + TYPE##_val15); \ > + \ > + return ((sum_args - sum_values) < DELTA \ > + && (sum_args - sum_values) > -DELTA); \ > +} > + > +DEFINE_T_MANY_ARGS (float, t_float_many_args) > +DEFINE_T_MANY_ARGS (double, t_double_many_args) > > /* Various functions for _Complex types. */ > > -- > 2.54.0