P99
p99
p99_hook.h
Go to the documentation of this file.
1
/* This may look like nonsense, but it really is -*- mode: C; coding: utf-8 -*- */
2
/* */
3
/* Except for parts copied from previous work and as explicitly stated below, */
4
/* the authors and copyright holders for this work are as follows: */
5
/* (C) copyright 2013 Jens Gustedt, INRIA, France */
6
/* (C) copyright 2013 Pierre-Nicolas Clauss */
7
/* */
8
/* This file is free software; it is part of the P99 project. */
9
/* */
10
/* Licensed under the Apache License, Version 2.0 (the "License"); */
11
/* you may not use this file except in compliance with the License. */
12
/* You may obtain a copy of the License at */
13
/* */
14
/* http://www.apache.org/licenses/LICENSE-2.0 */
15
/* */
16
/* Unless required by applicable law or agreed to in writing, software */
17
/* distributed under the License is distributed on an "AS IS" BASIS, */
18
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
19
/* See the License for the specific language governing permissions and */
20
/* limitations under the License. */
21
/* */
22
#ifndef P99_HOOK_H_
23
# define P99_HOOK_H_
24
34
#include "
p99_compiler.h
"
35
#include "
p99_if.h
"
36
#include "
p99_list.h
"
37
59
#if p99_has_attribute(constructor)
60
# define P99_AT_LOAD_DECLARE(...) \
61
__attribute__((constructor P99_IF_LE(P99_NARG(__VA_ARGS__), 1)()((P99_SKP(1, __VA_ARGS__))))) \
62
void P99_CHS(0, __VA_ARGS__)(void)
63
# define P99_AT_LOAD_DEFINE P99_AT_LOAD_DECLARE
64
#else
65
# define P99_AT_LOAD_DECLARE(...) \
66
void P99_CHS(0, __VA_ARGS__)(void); \
67
P99_PRAGMA(startup P99_FOR(, P99_NARG(__VA_ARGS__), P00_SER, P00_IDT, __VA_ARGS__)) \
68
P99_MACRO_END(P99_AT_LOAD_DECLARE)
69
# define P99_AT_LOAD_DEFINE(...) void P99_CHS(0, __VA_ARGS__)(void)
70
#endif
71
89
#if p99_has_attribute(destructor)
90
# define P99_AT_UNLOAD_DECLARE(...) \
91
__attribute__((destructor P99_IF_LE(P99_NARG(__VA_ARGS__), 1)()((P99_SKP(1, __VA_ARGS__))))) \
92
void P99_CHS(0, __VA_ARGS__)(void)
93
# define P99_AT_UNLOAD_DEFINE P99_AT_UNLOAD_DECLARE
94
#else
95
# define P99_AT_UNLOAD_DECLARE(...) \
96
void P99_CHS(0, __VA_ARGS__)(void); \
97
P99_PRAGMA(exit P99_FOR(, P99_NARG(__VA_ARGS__), P00_SER, P00_IDT, __VA_ARGS__)) \
98
P99_MACRO_END(P99_AT_UNLOAD_DECLARE)
99
# define P99_AT_UNLOAD_DEFINE(...) void P99_CHS(0, __VA_ARGS__)(void)
100
#endif
101
102
108
#endif
/* !P99_HOOK_H_ */
p99_compiler.h
Group compiler dependencies together in one file.
p99_if.h
preprocessor conditionals to use inside macros
p99_list.h
Basis macros to process the parameter list of a variadic macro.
Generated by
1.8.17