aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/gcov_wrapper.h
blob: f714a9b20caf2ccfc88c9d3b35f47e40b97c719a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (C) 2022 Firejail Authors
 *
 * This file is part of firejail project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef GCOV_WRAPPER_H
#define GCOV_WRAPPER_H

#ifdef HAVE_GCOV
#include <gcov.h>

/*
 * __gcov_flush was removed on gcc 11.1.0 (as it's no longer needed), but it
 * appears to be the safe/"correct" way to do things on previous versions (as
 * it ensured proper locking, which is now done elsewhere).  Thus, keep using
 * it in the code and ensure that it exists, in order to support gcc <11.1.0
 * and gcc >=11.1.0, respectively.
 */
#if __GNUC__ > 11 || (__GNUC__ == 11 && __GNUC_MINOR__ >= 1)
static void __gcov_flush(void) {
       __gcov_dump();
       __gcov_reset();
}
#endif
#else
#define __gcov_dump() ((void)0)
#define __gcov_reset() ((void)0)
#define __gcov_flush() ((void)0)
#endif /* HAVE_GCOV */

#endif /* GCOV_WRAPPER_H */