meson: explicitly include coverage tweaks when built w/ --coverage
To make sure we don't miss any _exit() calls let's move the
coverage-related tweaks into a separate header file and include it
explicitly on the compiler command line using -include when a coverage
build is requested.
Follow-up to c6552ad381.
This commit is contained in:
committed by
Yu Watanabe
parent
492f9e74ff
commit
7e43be7d0e
@@ -0,0 +1,19 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
/* When built with --coverage (gcov) we need to explicitly call __gcov_dump()
|
||||
* in places where we use _exit(), since _exit() skips at-exit hooks resulting
|
||||
* in lost coverage.
|
||||
*
|
||||
* To make sure we don't miss any _exit() calls, this header file is included
|
||||
* explicitly on the compiler command line via the -include directive (only
|
||||
* when built with -Db_coverage=true)
|
||||
* */
|
||||
extern void _exit(int);
|
||||
extern void __gcov_dump(void);
|
||||
|
||||
static inline void _coverage__exit(int status) {
|
||||
__gcov_dump();
|
||||
_exit(status);
|
||||
}
|
||||
#define _exit(x) _coverage__exit(x)
|
||||
@@ -29,19 +29,6 @@
|
||||
#define _alignptr_ __attribute__((__aligned__(sizeof(void*))))
|
||||
#define _warn_unused_result_ __attribute__((__warn_unused_result__))
|
||||
|
||||
#if defined(BUILT_WITH_COVERAGE) && BUILT_WITH_COVERAGE
|
||||
/* We need to explicitly call __gcov_dump() in places where we use _exit(), since
|
||||
* _exit() skips at-exit hooks resulting in lost coverage */
|
||||
# include <unistd.h>
|
||||
extern void __gcov_dump(void);
|
||||
|
||||
_noreturn_ static inline void _coverage__exit(int status) {
|
||||
__gcov_dump();
|
||||
_exit(status);
|
||||
}
|
||||
# define _exit(x) _coverage__exit(x)
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_FEATURE_MEMORY_SANITIZER)
|
||||
# if defined(__has_feature)
|
||||
# if __has_feature(memory_sanitizer)
|
||||
|
||||
Reference in New Issue
Block a user