From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gVFXLA+zVmpEfwgAWB0awg (envelope-from ) for ; Tue, 14 Jul 2026 18:07:11 -0400 Received: by simark.ca (Postfix, from userid 112) id B1FD71E033; Tue, 14 Jul 2026 18:07:11 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 2932D1E033 for ; Tue, 14 Jul 2026 18:07:11 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BBE404BA2E25 for ; Tue, 14 Jul 2026 22:07:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBE404BA2E25 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by sourceware.org (Postfix) with ESMTPS id F12934BA7988 for ; Tue, 14 Jul 2026 22:06:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F12934BA7988 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F12934BA7988 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784066807; cv=none; b=KKJvcHF4AHTAdJc9Q8K0pKk8W5DntC1XlSiPewv/6m586aw9uOGWw6M6xPszksUd5zGnw9s9XcQFneJ1lQ7STr6C1ULpvM+hL4J6F9vEnBclqQHOzGNvgi1iKtWS/YbEdeMoTiE4wxf7HYGLMm8zw4c6nhCoMc0hKj0TNpvRNqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784066807; c=relaxed/simple; bh=AurM2PveQxqxbehYJ1yYSS8V3KTYs/q41ybS01deGwY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=oeFwIaKxqIfPvJtzcUI3h0sZwFW4PkafI8c6t2cJXQWD9SkIuvEkECyHqq7sXi6SjirOJLzypkde4Fr7dXQh4K5uzYF12pBdy2VxBucHlWCqalhc9FwqGRN3GWjnSRmxaYeEJvZ8wUu9xP6/n1uq44rT++gp6vrorAIkqUNpsrY= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F12934BA7988 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-493f6de72faso7940055e9.0 for ; Tue, 14 Jul 2026 15:06:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784066806; x=1784671606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=HPhKpPjcO4+dfTjd7SNwDjzD4i3fk1FF+aFlPWOgBCo=; b=jCxGchc9dKRSwDh+PrFKQvaQldRWPkAxRuGJ+tst4OwVq+txgXoCQ/TEqyDAq+b8x2 b0h0q3duat6NacGC89DvA48n3MEk/7yuXsz3Zdz6xq68eyjgL8dvpinCOFwAZRZZMF5H 7KLT5hwNpH2Dxz2JABNCBhXRUY8vnw0nNMwbgHIXlQyKqqW9eBJ1RpTnm4UwxrWw7vyt qADPzbjZout9zHBpirWdWv/rr/395inwDPQsMaKGK94lI4qkEbKZkpUQ/5vF1eHyxdBj FFk9TP7khA+pyqzZynhahLMKsYxFiK06bmLhWsmLX23jg0Nsalvi8zYSc+p3vmz2o5GI VlBA== X-Gm-Message-State: AOJu0YyqhxP0ragJJC3kREicyLZRq94MqEgyV71DcIIJ6j2YDgXJMNft pH5F90wmwQcd++HPTweE36/Mb32DLBsQgZA6Hxt8C0Pqpv4rZmmKjc17vAqCDVhE X-Gm-Gg: AfdE7ckeEbbfx91bonCWF+pTrtfz3k5Of7GlYfOk89PZWcRBDST+tyjrhpue6rOS1IE a/jcMzU+tBzVDJ4PWxKSMoGg4+Cmby3Zw1G0iPGrKyaeW/JDUIoPiTJ7livE8AGgBGkywBRS7PG Bq6oJBtk6JRxEbNgzN+SKc8J+Efaymqaourhu/0haKSzLATvs1CcHzQhA00bo0ps56fBrZqJPJi FdaYFWtbq0cWnPrcFHdlb4rdgo1in4xsH84sS9RAYaZSot5aK3w8r843juzTGArosv1efuNwBPE IofJmrCrP+hUJmJo6yA72X+B/dU59em3CCuGXFxlsXu3gf2HdEa2T8NXpts+rnRPZKC8lZ9ODf4 iKYIbS8SYpSso4e2YK1aTsUzT5EMU4RFSGryCIE5bxJJD8PibdcyXbTQ6eK6/aDHf+0S5lY565t t3i4Ew3yqcQRY= X-Received: by 2002:a05:600c:3b0e:b0:493:f806:fc4d with SMTP id 5b1f17b1804b1-493f88268e9mr141468185e9.0.1784066805611; Tue, 14 Jul 2026 15:06:45 -0700 (PDT) Received: from localhost ([2001:8a0:fae3:3700:4d25:7ae8:520f:e7a8]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4950871e830sm105667055e9.2.2026.07.14.15.06.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jul 2026 15:06:45 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 3/4] gdb.base/callfuncs.c: factor out float/double functions Date: Tue, 14 Jul 2026 23:06:30 +0100 Message-ID: <20260714220631.1499846-4-pedro@palves.net> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260714220631.1499846-1-pedro@palves.net> References: <20260714220631.1499846-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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. 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