From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97665 invoked by alias); 27 Sep 2016 04:48:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 97524 invoked by uid 89); 27 Sep 2016 04:48:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=H*RU:10.0.90.82, Hx-spam-relays-external:CMOut01, H*r:CMOut01, H*RU:CMOut01 X-HELO: gproxy4-pub.mail.unifiedlayer.com Received: from gproxy4-pub.mail.unifiedlayer.com (HELO gproxy4-pub.mail.unifiedlayer.com) (69.89.23.142) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Tue, 27 Sep 2016 04:48:02 +0000 Received: (qmail 10137 invoked by uid 0); 27 Sep 2016 04:48:01 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy4.mail.unifiedlayer.com with SMTP; 27 Sep 2016 04:48:01 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id oUnw1t00m2f2jeq01UnzXH; Mon, 26 Sep 2016 22:47:59 -0600 X-Authority-Analysis: v=2.1 cv=OPq0g0qB c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=GW1xBdLrtEIA:10 a=zstS-IiYAAAA:8 a=qUXFsv20AAAA:8 a=qP7Aq_7qRByOJlosDe4A:9 a=r7gNwwvMS7Ivrw7E:21 a=Rkn0clDWT2CNkvnJ:21 a=4G6NA9xxw8l3yy4pmD5M:22 a=9MODbo6-FXLeArg8YEg9:22 Received: from 71-218-192-86.hlrn.qwest.net ([71.218.192.86]:56110 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bojhM-0006Nj-RT; Mon, 26 Sep 2016 22:08:52 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 01/22] Change selttest.c to use use std::vector Date: Tue, 27 Sep 2016 04:48:00 -0000 Message-Id: <1474949330-4307-2-git-send-email-tom@tromey.com> In-Reply-To: <1474949330-4307-1-git-send-email-tom@tromey.com> References: <1474949330-4307-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bojhM-0006Nj-RT X-Source-Sender: 71-218-192-86.hlrn.qwest.net (bapiya.Home) [71.218.192.86]:56110 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2016-09/txt/msg00349.txt.bz2 This patch changes selftest.c to use std::vector rather than VEC. I think this is a small net plus. Because we're using C++03, we unfortunately don't all the possible benefits here; namely, iterating over a vector is still a pain. For reference, in C++11 the loop would be just: for (auto f : tests) ... 2016-09-26 Tom Tromey * selftest.c: Include , not "vec.h". (self_test_function_ptr): Remove. (tests): Now a std::vector. (register_self_test, run_self_tests): Update. --- gdb/ChangeLog | 7 +++++++ gdb/selftest.c | 22 +++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a9ef3ee..2f28e54 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2016-09-26 Tom Tromey + + * selftest.c: Include , not "vec.h". + (self_test_function_ptr): Remove. + (tests): Now a std::vector. + (register_self_test, run_self_tests): Update. + 2016-09-23 Jon Turney * windows-nat.c (windows_delete_thread): Adjusting call to diff --git a/gdb/selftest.c b/gdb/selftest.c index c63c06d..bbd37b5 100644 --- a/gdb/selftest.c +++ b/gdb/selftest.c @@ -18,22 +18,18 @@ #include "defs.h" #include "selftest.h" -#include "vec.h" - -typedef self_test_function *self_test_function_ptr; - -DEF_VEC_P (self_test_function_ptr); +#include /* All the tests that have been registered. */ -static VEC (self_test_function_ptr) *tests; +static std::vector tests; /* See selftest.h. */ void register_self_test (self_test_function *function) { - VEC_safe_push (self_test_function_ptr, tests, function); + tests.push_back (function); } /* See selftest.h. */ @@ -41,17 +37,17 @@ register_self_test (self_test_function *function) void run_self_tests (void) { - int i; - self_test_function_ptr func; int failed = 0; - for (i = 0; VEC_iterate (self_test_function_ptr, tests, i, func); ++i) + for (std::vector::iterator iter = tests.begin (); + iter != tests.end (); + ++iter) { QUIT; TRY { - (*func) (); + (*iter) (); } CATCH (ex, RETURN_MASK_ERROR) { @@ -62,6 +58,6 @@ run_self_tests (void) END_CATCH } - printf_filtered (_("Ran %u unit tests, %d failed\n"), - VEC_length (self_test_function_ptr, tests), failed); + printf_filtered (_("Ran %lu unit tests, %d failed\n"), + tests.size (), failed); } -- 2.7.4