aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/gcov_wrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gcov_wrapper.h')
-rw-r--r--src/include/gcov_wrapper.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/include/gcov_wrapper.h b/src/include/gcov_wrapper.h
new file mode 100644
index 000000000..4aafb8e18
--- /dev/null
+++ b/src/include/gcov_wrapper.h
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 2021 Firejail Authors
3 *
4 * This file is part of firejail project
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#ifndef GCOV_WRAPPER_H
22#define GCOV_WRAPPER_H
23
24#ifdef HAS_GCOV
25#include <gcov.h>
26
27/*
28 * __gcov_flush was removed on gcc 11.1.0 (as it's no longer needed), but it
29 * appears to be the safe/"correct" way to do things on previous versions (as
30 * it ensured proper locking, which is now done elsewhere). Thus, keep using
31 * it in the code and ensure that it exists, in order to support gcc <11.1.0
32 * and gcc >=11.1.0, respectively.
33 */
34#if __GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1)
35static void __gcov_flush(void) {
36 __gcov_dump();
37 __gcov_reset();
38}
39#endif
40#else
41#define __gcov_dump() ((void)0)
42#define __gcov_reset() ((void)0)
43#define __gcov_flush() ((void)0)
44#endif /* HAS_GCOV */
45
46#endif /* GCOV_WRAPPER_H */