From eb5a95bfc9b2c9072fc959ff8525ed65b09b2232 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 15 Feb 2021 13:34:01 +0200 Subject: [PATCH] libweston: move TYPEVERIFY macro into shared This will be useful in the test harness macros. Signed-off-by: Pekka Paalanen --- libweston/timeline.h | 7 ++----- shared/helpers.h | 8 ++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libweston/timeline.h b/libweston/timeline.h index aaed7431..23c06bb2 100644 --- a/libweston/timeline.h +++ b/libweston/timeline.h @@ -33,6 +33,8 @@ #include #include +#include "shared/helpers.h" + enum timeline_type { TLT_END = 0, TLT_OUTPUT, @@ -67,11 +69,6 @@ struct weston_timeline_subscription_object { struct wl_listener destroy_listener; }; -#define TYPEVERIFY(type, arg) ({ \ - typeof(arg) tmp___ = (arg); \ - (void)((type)0 == tmp___); \ - tmp___; }) - /** * Should be used as the last argument when using TL_POINT macro * diff --git a/shared/helpers.h b/shared/helpers.h index adb68893..44f2f764 100644 --- a/shared/helpers.h +++ b/shared/helpers.h @@ -134,6 +134,14 @@ extern "C" { # endif #endif +/** Ensure argument is of given type */ +#ifndef TYPEVERIFY +#define TYPEVERIFY(type, arg) ({ \ + typeof(arg) tmp___ = (arg); \ + (void)((type)0 == tmp___); \ + tmp___; }) +#endif + #ifdef __cplusplus } #endif