mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
Merge branch 'wip/smcv/issue114' into 'master'
Conditionalize uses of C99 restrict keyword Closes #114 See merge request GNOME/sysprof!88
This commit is contained in:
@ -91,9 +91,11 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define SYSPROF_BEGIN_DECLS extern "C" {
|
#define SYSPROF_BEGIN_DECLS extern "C" {
|
||||||
#define SYSPROF_END_DECLS }
|
#define SYSPROF_END_DECLS }
|
||||||
|
#define SYSPROF_RESTRICT /* nothing */
|
||||||
#else
|
#else
|
||||||
#define SYSPROF_BEGIN_DECLS
|
#define SYSPROF_BEGIN_DECLS
|
||||||
#define SYSPROF_END_DECLS
|
#define SYSPROF_END_DECLS
|
||||||
|
#define SYSPROF_RESTRICT restrict
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (__GNUC__)
|
#if defined (__GNUC__)
|
||||||
|
|||||||
@ -21,6 +21,7 @@ libsysprof_capture_testsuite = {
|
|||||||
'rewrite-pid' : {'skip': true},
|
'rewrite-pid' : {'skip': true},
|
||||||
'test-capture' : {},
|
'test-capture' : {},
|
||||||
'test-capture-cursor' : {},
|
'test-capture-cursor' : {},
|
||||||
|
'test-cplusplus' : {'cpp': true},
|
||||||
'test-mapped-ring-buffer' : {},
|
'test-mapped-ring-buffer' : {},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,10 +31,18 @@ libsysprof_capture_testsuite_deps = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
foreach test, params: libsysprof_capture_testsuite
|
foreach test, params: libsysprof_capture_testsuite
|
||||||
test_exe = executable(test, '@0@.c'.format(test),
|
if params.get('cpp', false)
|
||||||
c_args: libsysprof_capture_testsuite_c_args,
|
test_exe = executable(test, '@0@.cpp'.format(test),
|
||||||
dependencies: libsysprof_capture_testsuite_deps,
|
cpp_args: libsysprof_capture_testsuite_c_args,
|
||||||
)
|
dependencies: libsysprof_capture_testsuite_deps,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
test_exe = executable(test, '@0@.c'.format(test),
|
||||||
|
c_args: libsysprof_capture_testsuite_c_args,
|
||||||
|
dependencies: libsysprof_capture_testsuite_deps,
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
if not params.get('skip', false)
|
if not params.get('skip', false)
|
||||||
test(test, test_exe, env: libsysprof_capture_test_env)
|
test(test, test_exe, env: libsysprof_capture_test_env)
|
||||||
endif
|
endif
|
||||||
|
|||||||
24
src/libsysprof-capture/tests/test-cplusplus.cpp
Normal file
24
src/libsysprof-capture/tests/test-cplusplus.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Simon McVittie
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sysprof-capture.h>
|
||||||
|
|
||||||
|
#undef _NDEBUG
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define UNUSED __attribute__((__unused__))
|
||||||
|
#else
|
||||||
|
#define UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main (UNUSED int argc,
|
||||||
|
UNUSED char *argv[])
|
||||||
|
{
|
||||||
|
assert (sysprof_getpagesize () > 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
void sysprof_document_ctrset_get_raw_value (SysprofDocumentCtrset *self,
|
void sysprof_document_ctrset_get_raw_value (SysprofDocumentCtrset *self,
|
||||||
guint nth,
|
guint nth,
|
||||||
guint *id,
|
guint *id,
|
||||||
guint8 value[restrict 8]);
|
guint8 value[SYSPROF_RESTRICT 8]);
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentCtrset, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentCtrset, g_object_unref)
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ sysprof_time_span_relative_to (SysprofTimeSpan time_span,
|
|||||||
static inline void
|
static inline void
|
||||||
sysprof_time_span_normalize (SysprofTimeSpan time_span,
|
sysprof_time_span_normalize (SysprofTimeSpan time_span,
|
||||||
SysprofTimeSpan allowed,
|
SysprofTimeSpan allowed,
|
||||||
float values[restrict 2])
|
float values[SYSPROF_RESTRICT 2])
|
||||||
{
|
{
|
||||||
double duration = allowed.end_nsec - allowed.begin_nsec;
|
double duration = allowed.end_nsec - allowed.begin_nsec;
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ libsysprof_testsuite = {
|
|||||||
'test-allocs-by-func' : {'skip': true},
|
'test-allocs-by-func' : {'skip': true},
|
||||||
'test-callgraph' : {'skip': true},
|
'test-callgraph' : {'skip': true},
|
||||||
'test-capture-model' : {'skip': true},
|
'test-capture-model' : {'skip': true},
|
||||||
|
'test-cplusplus' : {'cpp': true},
|
||||||
'test-elf-loader' : {'skip': true},
|
'test-elf-loader' : {'skip': true},
|
||||||
'test-leak-detector' : {'skip': true},
|
'test-leak-detector' : {'skip': true},
|
||||||
'test-list-counters' : {'skip': true},
|
'test-list-counters' : {'skip': true},
|
||||||
@ -41,10 +42,18 @@ libsysprof_testsuite_deps = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
foreach test, params: libsysprof_testsuite
|
foreach test, params: libsysprof_testsuite
|
||||||
test_exe = executable(test, '@0@.c'.format(test),
|
if params.get('cpp', false)
|
||||||
c_args: libsysprof_testsuite_c_args,
|
test_exe = executable(test, '@0@.cpp'.format(test),
|
||||||
dependencies: libsysprof_testsuite_deps,
|
cpp_args: libsysprof_testsuite_c_args,
|
||||||
)
|
dependencies: libsysprof_testsuite_deps,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
test_exe = executable(test, '@0@.c'.format(test),
|
||||||
|
c_args: libsysprof_testsuite_c_args,
|
||||||
|
dependencies: libsysprof_testsuite_deps,
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
if not params.get('skip', false)
|
if not params.get('skip', false)
|
||||||
test(test, test_exe, env: libsysprof_test_env)
|
test(test, test_exe, env: libsysprof_test_env)
|
||||||
endif
|
endif
|
||||||
|
|||||||
17
src/libsysprof/tests/test-cplusplus.cpp
Normal file
17
src/libsysprof/tests/test-cplusplus.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Simon McVittie
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sysprof.h>
|
||||||
|
|
||||||
|
#undef _NDEBUG
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (G_GNUC_UNUSED int argc,
|
||||||
|
G_GNUC_UNUSED char *argv[])
|
||||||
|
{
|
||||||
|
assert (sysprof_callgraph_flags_get_type () != 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user