glib-aux/tests: add NMTST_COPY() helper

This commit is contained in:
Thomas Haller 2021-09-07 19:12:52 +02:00
parent d422434945
commit 0f5ed15008
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1458,6 +1458,19 @@ next:;
/*****************************************************************************/
/* uses an expression statement to copy and return @arg. The use is for functions
* like nmtst_inet4_from_string(), which return a static (thread-local) variable.
* If you use such a statement twice, the result will be overwritten. The macro
* prevents that. */
#define NMTST_COPY(arg) \
({ \
typeof(arg) _arg = (arg); \
\
_arg; \
})
/*****************************************************************************/
#define __define_nmtst_static(NUM, SIZE) \
static inline const char *nmtst_static_##SIZE##_##NUM(const char *str) \
{ \