Go to the documentation of this file.
53 # define P00_INIT_NR P99_PASTE3(P00_INIT_3, P00_INIT_2, P00_INIT_1)
55 # define P00_INIT_FUNCTION(NR) P99_IF_EMPTY(NR)(P99_PASTE2(p00_init_function_, P00_INIT_NR))(P99_PASTE2(p00_init_function_, NR))
57 # define P00_HAVE_INIT_FUNCTION(NR) P99_IF_EMPTY(NR)(P99_PASTE2(p00_have_init_function_, P00_INIT_NR))(P99_PASTE2(p00_have_init_function_, NR))
59 # define P00_INIT_FUNC_VAR_S(_0, _1, I) \
60 P99_TENTATIVE_DEC(bool const, P00_HAVE_INIT_FUNCTION(I)); \
61 P99_TENTATIVE_DEC(p99_callback_el const, P00_INIT_FUNCTION(I))
65 # define P00_INIT_TRIGGER_FUNCTION_1(_0, _1, I) \
67 if (P00_HAVE_INIT_FUNCTION(I)) p99_callback_el_call(P00_INIT_FUNCTION(I)); \
70 # define P00_INIT_FUNCTION_(NAME, NR) \
72 P99_TENTATIVE_DEF(bool const, P00_HAVE_INIT_FUNCTION(NR)) = true; \
73 P99_TENTATIVE_DEF(p99_callback_el const, P00_INIT_FUNCTION(NR)) = { .p00_void = { .p00_void_func = NAME, }, }
143 # define P99_INIT_FUNCTION_DECLARE(FUNC, NR)
145 # define P99_INIT_FUNCTION_DECLARE(...) P99_IF_EQ(P99_NARG(__VA_ARGS__), 2)(P00_INIT_FUNCTION_(__VA_ARGS__))(P00_INIT_FUNCTION_(__VA_ARGS__,))
148 # define P00_INIT_VARIABLE(NAME, FUNC, NR) \
149 P99_TENTATIVE_DEF(p99_callback_el const, P00_INIT_FUNCTION(NR)) \
151 .p00_voidptr_func = (FUNC), \
153 .p00_arg = &(NAME), \
179 # define P99_INIT_VARIABLE(NAME, FUNC, NR)
181 # define P99_INIT_VARIABLE(...) P99_IF_EQ(P99_NARG(__VA_ARGS__), 3)(P00_INIT_VARIABLE(__VA_ARGS__))(P00_INIT_VARIABLE(__VA_ARGS__,))
184 # if defined(P00_DOXYGEN)
190 # define P99_INTERCEPT_MAIN
193 # if defined(P99_INTERCEPT_MAIN) || defined(P00_DOXYGEN)
238 # define P99_MAIN_INTERCEPT(NAME) \
239 int NAME(int, char*[]); \
240 P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
241 void P99_PASTE2(p00_init_func_, NAME)(int*, char***); \
243 int main(int p00_argc, char**p00_argv) { \
244 fprintf(stderr, "%s: intercepting " P99_STRINGIFY(NAME) "\n", __func__); \
245 P99_PASTE2(p00_init_func_, NAME)(&p00_argc, &p00_argv); \
246 return NAME(p00_argc, p00_argv); \
248 P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
249 void P99_PASTE2(p00_init_func_, NAME)(int * p00_argc, char***p00_argv)
251 # define P99_INIT_TRIGGER(NAME, ARGC, ARGV) P99_NOP
255 # define P99_MAIN_INTERCEPT(NAME) \
256 P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
257 void P99_PASTE2(p00_init_func_, NAME)(int * p00_argc, char***p00_argv)
259 # define P99_INIT_TRIGGER(NAME, ARGC, ARGV) P99_PASTE2(p00_init_func_, NAME)((ARGC), (ARGV))
263 # if defined(P99_AT_LOAD_DECLARE)
276 void p00_init_func_p99_init_main(
int * p00_argc,
char***p00_argv) {
283 # warning "no native load time launcher found, trying to intercept main"
290 # if defined(P99_INTERCEPT_MAIN)
292 # define main p99_init_main
303 #if P99_PASTE2(P00_INIT_1, 0) == 0
305 # define P00_INIT_1 1
306 #elif P00_INIT_1 == 1
308 # define P00_INIT_1 2
309 #elif P00_INIT_1 == 2
311 # define P00_INIT_1 3
312 #elif P00_INIT_1 == 3
314 # define P00_INIT_1 4
315 #elif P00_INIT_1 == 4
317 # define P00_INIT_1 5
318 #elif P00_INIT_1 == 5
320 # define P00_INIT_1 6
321 #elif P00_INIT_1 == 6
323 # define P00_INIT_1 7
324 #elif P00_INIT_1 == 7
326 # define P00_INIT_1 8
327 #elif P00_INIT_1 == 8
329 # define P00_INIT_1 9
330 #elif P00_INIT_1 == 9
332 # define P00_INIT_1 0
333 # if P99_PASTE2(P00_INIT_2, 0) == 0
335 # define P00_INIT_2 1
336 # elif P00_INIT_2 == 1
338 # define P00_INIT_2 2
339 # elif P00_INIT_2 == 2
341 # define P00_INIT_2 3
342 # elif P00_INIT_2 == 3
344 # define P00_INIT_2 4
345 # elif P00_INIT_2 == 4
347 # define P00_INIT_2 5
348 # elif P00_INIT_2 == 5
350 # define P00_INIT_2 6
351 # elif P00_INIT_2 == 6
353 # define P00_INIT_2 7
354 # elif P00_INIT_2 == 7
356 # define P00_INIT_2 8
357 # elif P00_INIT_2 == 8
359 # define P00_INIT_2 9
360 # elif P00_INIT_2 == 9
362 # define P00_INIT_2 0
363 # if P99_PASTE2(P00_INIT_3, 0) == 0
365 # define P00_INIT_3 1
366 # elif P00_INIT_3 == 1
368 # define P00_INIT_3 2
369 # elif P00_INIT_3 == 2
371 # define P00_INIT_3 3
372 # elif P00_INIT_3 == 3
374 # define P00_INIT_3 4
375 # elif P00_INIT_3 == 4
377 # define P00_INIT_3 5
378 # elif P00_INIT_3 == 5
380 # define P00_INIT_3 6
381 # elif P00_INIT_3 == 6
383 # define P00_INIT_3 7
384 # elif P00_INIT_3 == 7
386 # define P00_INIT_3 8
387 # elif P00_INIT_3 == 8
389 # define P00_INIT_3 9
390 # elif P00_INIT_3 == 9
391 # error "more than 999 init functions, compilation aborted"
396 #if P00_INIT_NR > P99_MAX_NUMBER
397 # error "more init functions than supported through P99_MAX_NUMBER, compilation aborted"
int p99_init_main(int, char *[])
#define P99_MAIN_INTERCEPT(NAME)
Intercept the main function before it is called and run some startup code.
preprocessor conditionals to use inside macros
#define p99_inline
Try to force a function always to be inlined.
#define P99_UNUSED(...)
check if the list of expressions is syntactically valid but don't evaluate it
#define P99_WEAK(...)
Declare a symbol to be weak such that it can be provided several times without error.
#define P99_CONST_FUNCTION
On architectures that support this, assert that a function is "const", i.e only depends on parameters...
#define P99_MAX_NUMBER
The maximal number of arguments the P99 macros can handle.
Compiler specific hook functions to execute at load/unload time.
#define P99_AT_LOAD_DEFINE
#define P99_FOR(NAME, N, OP, FUNC,...)
A preprocessor pseudo iterator.