From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id AED8145B3E for ; Wed, 19 Jul 2023 19:56:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 12F7168C634; Wed, 19 Jul 2023 22:55:51 +0300 (EEST) Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E848968C33E for ; Wed, 19 Jul 2023 22:55:41 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 67F16C021A for ; Wed, 19 Jul 2023 22:55:41 +0300 (EEST) From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jul 2023 22:55:38 +0300 Message-Id: <20230719195540.46961-4-remi@remlab.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <2113654.OBFZWjSADL@basile.remlab.net> References: <2113654.OBFZWjSADL@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] checkasm: make bench clean-up also a function pointer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There are no performance concerns with cleaning up, so might as well indirect it. This incidentally fixes a corner case (and inconsequential) bug whereby the Linux perf descriptor is zero and did not get closed. --- tests/checkasm/checkasm.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 987162e6b5..fad660a924 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -320,9 +320,12 @@ static struct { /* perf */ int nop_time; +#if CONFIG_LINUX_PERF int sysfd; +#endif uint64_t (*start)(void); uint64_t (*stop)(void); + void (*close)(void); int cpu_flag; const char *cpu_flag_name; @@ -683,6 +686,11 @@ static uint64_t checkasm_bench_linux_perf_stop(void) return (read(fd, &t, sizeof(t)) == sizeof (t)) ? t : 0; } +static void checkasm_bench_linux_perf_close(void) +{ + close(state.sysfd); +} + static int bench_init_linux(void) { struct perf_event_attr attr = { @@ -703,6 +711,7 @@ static int bench_init_linux(void) } state.start = checkasm_bench_linux_perf_start; state.stop = checkasm_bench_linux_perf_stop; + state.close = checkasm_bench_linux_perf_close; return 0; } #elif CONFIG_MACOS_KPERF @@ -742,14 +751,6 @@ static int bench_init(void) return 0; } -static void bench_uninit(void) -{ -#if CONFIG_LINUX_PERF - if (state.sysfd > 0) - close(state.sysfd); -#endif -} - static int usage(const char *path) { fprintf(stderr, @@ -816,7 +817,8 @@ int main(int argc, char *argv[]) } destroy_func_tree(state.funcs); - bench_uninit(); + if (state.close != NULL) + state.close(); return ret; } -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".