From 5abe95c474262dfc0d43cd8fdd5248c9b48a8ecf Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Fri, 4 Nov 2016 16:56:55 +0200 Subject: definitions: add a run-once construct macro. --- include/rin/definitions.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/rin/definitions.h b/include/rin/definitions.h index bc417b5..8364f42 100644 --- a/include/rin/definitions.h +++ b/include/rin/definitions.h @@ -29,4 +29,13 @@ # define WEAK_SYM #endif +#define rin_once(func) \ +do { \ + static unsigned int __rin_firstrun = 1; \ + if (__rin_firstrun) { \ + --__rin_firstrun; \ + func; \ + } \ +} while (0) + #endif /* LIBRIN_DEFINITIONS_INCLUDED */ -- cgit v1.2.3