libweston: move TYPEVERIFY macro into shared

This will be useful in the test harness macros.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2021-02-15 13:34:01 +02:00 committed by Pekka Paalanen
parent 69039ceb43
commit eb5a95bfc9
2 changed files with 10 additions and 5 deletions

View file

@ -33,6 +33,8 @@
#include <libweston/weston-log.h> #include <libweston/weston-log.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include "shared/helpers.h"
enum timeline_type { enum timeline_type {
TLT_END = 0, TLT_END = 0,
TLT_OUTPUT, TLT_OUTPUT,
@ -67,11 +69,6 @@ struct weston_timeline_subscription_object {
struct wl_listener destroy_listener; 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 * Should be used as the last argument when using TL_POINT macro
* *

View file

@ -134,6 +134,14 @@ extern "C" {
# endif # endif
#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 #ifdef __cplusplus
} }
#endif #endif