From 36f4988ecc2fe494aa0bc17548593aa4e3e483d1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 24 Feb 2024 11:38:47 +0000 Subject: [PATCH] Conditionalize uses of C99 restrict keyword This is part of C99, but not part of Standard C++, so it can't be used unconditionally if the sysprof headers might get included into C++ code. Resolves: https://gitlab.gnome.org/GNOME/sysprof/-/issues/114 Signed-off-by: Simon McVittie --- src/libsysprof-capture/sysprof-macros.h | 2 ++ src/libsysprof/sysprof-document-ctrset.h | 2 +- src/libsysprof/sysprof-time-span.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libsysprof-capture/sysprof-macros.h b/src/libsysprof-capture/sysprof-macros.h index 9292f924..1bc92afc 100644 --- a/src/libsysprof-capture/sysprof-macros.h +++ b/src/libsysprof-capture/sysprof-macros.h @@ -91,9 +91,11 @@ #ifdef __cplusplus #define SYSPROF_BEGIN_DECLS extern "C" { #define SYSPROF_END_DECLS } +#define SYSPROF_RESTRICT /* nothing */ #else #define SYSPROF_BEGIN_DECLS #define SYSPROF_END_DECLS +#define SYSPROF_RESTRICT restrict #endif #if defined (__GNUC__) diff --git a/src/libsysprof/sysprof-document-ctrset.h b/src/libsysprof/sysprof-document-ctrset.h index 3bc6cc32..3806245e 100644 --- a/src/libsysprof/sysprof-document-ctrset.h +++ b/src/libsysprof/sysprof-document-ctrset.h @@ -42,7 +42,7 @@ SYSPROF_AVAILABLE_IN_ALL void sysprof_document_ctrset_get_raw_value (SysprofDocumentCtrset *self, guint nth, guint *id, - guint8 value[restrict 8]); + guint8 value[SYSPROF_RESTRICT 8]); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentCtrset, g_object_unref) diff --git a/src/libsysprof/sysprof-time-span.h b/src/libsysprof/sysprof-time-span.h index a85595a8..b550ac04 100644 --- a/src/libsysprof/sysprof-time-span.h +++ b/src/libsysprof/sysprof-time-span.h @@ -60,7 +60,7 @@ sysprof_time_span_relative_to (SysprofTimeSpan time_span, static inline void sysprof_time_span_normalize (SysprofTimeSpan time_span, SysprofTimeSpan allowed, - float values[restrict 2]) + float values[SYSPROF_RESTRICT 2]) { double duration = allowed.end_nsec - allowed.begin_nsec;