chiark / gitweb /
headers: check that __INCLUDE_LEVEL__ is defined before using it (#5575)
[elogind.git] / src / systemd / _sd-common.h
1 #ifndef foosdcommonhfoo
2 #define foosdcommonhfoo
3
4 /***
5   This file is part of systemd.
6
7   Copyright 2013 Lennart Poettering
8
9   systemd is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as published by
11   the Free Software Foundation; either version 2.1 of the License, or
12   (at your option) any later version.
13
14   systemd is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public License
20   along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 /* This is a private header; never even think of including this directly! */
24
25 #if defined(__INCLUDE_LEVEL__) && __INCLUDE_LEVEL__ <= 1
26 #  error "Do not include _sd-common.h directly; it is a private header."
27 #endif
28
29 #ifndef _sd_printf_
30 #  if __GNUC__ >= 4
31 #    define _sd_printf_(a,b) __attribute__ ((format (printf, a, b)))
32 #  else
33 #    define _sd_printf_(a,b)
34 #  endif
35 #endif
36
37 #ifndef _sd_sentinel_
38 #  define _sd_sentinel_ __attribute__((sentinel))
39 #endif
40
41 #ifndef _sd_packed_
42 #  define _sd_packed_ __attribute__((packed))
43 #endif
44
45 #ifndef _sd_pure_
46 #  define _sd_pure_ __attribute__((pure))
47 #endif
48
49 #ifndef _SD_STRINGIFY
50 #  define _SD_XSTRINGIFY(x) #x
51 #  define _SD_STRINGIFY(x) _SD_XSTRINGIFY(x)
52 #endif
53
54 #ifndef _SD_BEGIN_DECLARATIONS
55 #  ifdef __cplusplus
56 #    define _SD_BEGIN_DECLARATIONS                              \
57         extern "C" {                                            \
58         struct _sd_useless_struct_to_allow_trailing_semicolon_
59 #  else
60 #    define _SD_BEGIN_DECLARATIONS                              \
61         struct _sd_useless_struct_to_allow_trailing_semicolon_
62 #  endif
63 #endif
64
65 #ifndef _SD_END_DECLARATIONS
66 #  ifdef __cplusplus
67 #    define _SD_END_DECLARATIONS                                \
68         }                                                       \
69         struct _sd_useless_cpp_struct_to_allow_trailing_semicolon_
70 #  else
71 #    define _SD_END_DECLARATIONS                                \
72         struct _sd_useless_struct_to_allow_trailing_semicolon_
73 #  endif
74 #endif
75
76 #define _SD_DEFINE_POINTER_CLEANUP_FUNC(type, func)             \
77         static __inline__ void func##p(type **p) {              \
78                 if (*p)                                         \
79                         func(*p);                               \
80         }                                                       \
81         struct _sd_useless_struct_to_allow_trailing_semicolon_
82
83 #endif