chiark / gitweb /
api: replace manual C++ guards by macros
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Nov 2013 15:44:48 +0000 (16:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Nov 2013 15:53:26 +0000 (16:53 +0100)
12 files changed:
src/systemd/_sd-common.h
src/systemd/sd-bus-protocol.h
src/systemd/sd-bus-vtable.h
src/systemd/sd-bus.h
src/systemd/sd-event.h
src/systemd/sd-id128.h
src/systemd/sd-journal.h
src/systemd/sd-login.h
src/systemd/sd-memfd.h
src/systemd/sd-messages.h
src/systemd/sd-rtnl.h
src/systemd/sd-utf8.h

index b861e335442f4b6dea2c033e8eda429619479f6a..b0c48aab9b2e7ff2ba6cd38548cf7abf3d8614b3 100644 (file)
 #  define _sd_packed_ __attribute__((packed))
 #endif
 
 #  define _sd_packed_ __attribute__((packed))
 #endif
 
-#ifndef _sd_stringify
-#  define _sd_xstringify(x) #x
-#  define _sd_stringify(x) _sd_xstringify(x)
+#ifndef _SD_STRINGIFY
+#  define _SD_XSTRINGIFY(x) #x
+#  define _SD_STRINGIFY(x) _SD_XSTRINGIFY(x)
+#endif
+
+#ifndef _SD_BEGIN_DECLARATIONS
+#  ifdef __cplusplus
+#    define _SD_BEGIN_DECLARATIONS                              \
+        extern "C" {                                            \
+        struct __useless_struct_to_allow_trailing_semicolon__
+#  else
+#    define _SD_BEGIN_DECLARATIONS                              \
+        struct __useless_struct_to_allow_trailing_semicolon__
+#  endif
+#endif
+
+#ifndef _SD_END_DECLARATIONS
+#  ifdef __cplusplus
+#    define _SD_END_DECLARATIONS                                \
+        }                                                       \
+        struct __useless_struct_to_allow_trailing_semicolon__
+#  else
+#    define _SD_END_DECLARATIONS                                \
+        struct __useless_struct_to_allow_trailing_semicolon__
+#  endif
 #endif
 
 #endif
 #endif
 
 #endif
index ff2bcc93b8792633764f8addf6bae4f76c87bec7..07fade6039459adce079cff516d46c475115e84c 100644 (file)
@@ -24,9 +24,9 @@
 
 #include <endian.h>
 
 
 #include <endian.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
 
 /* Types of message */
 
 
 /* Types of message */
 
@@ -213,8 +213,6 @@ enum {
 #define SD_BUS_ERROR_INVALID_SIGNATURE          "org.freedesktop.DBus.Error.InvalidSignature"
 #define SD_BUS_ERROR_INCONSISTENT_MESSAGE       "org.freedesktop.DBus.Error.InconsistentMessage"
 
 #define SD_BUS_ERROR_INVALID_SIGNATURE          "org.freedesktop.DBus.Error.InvalidSignature"
 #define SD_BUS_ERROR_INCONSISTENT_MESSAGE       "org.freedesktop.DBus.Error.InconsistentMessage"
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index d1642bae5ec69fae0fc41bb8d74f55c1bf2d71ca..18fc30bd209f8ddd34c3bf799394744c52800724 100644 (file)
@@ -22,9 +22,9 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
 
 typedef struct sd_bus_vtable sd_bus_vtable;
 
 
 typedef struct sd_bus_vtable sd_bus_vtable;
 
@@ -128,8 +128,6 @@ struct sd_bus_vtable {
                 .type = _SD_BUS_VTABLE_END,                             \
         }
 
                 .type = _SD_BUS_VTABLE_END,                             \
         }
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index 48edc59188eecd463fd2ac425f4cd8a8cc433f4b..e6264074e0e301e1e81228231e2b19d45879c044 100644 (file)
@@ -30,9 +30,7 @@
 #include "sd-memfd.h"
 #include "_sd-common.h"
 
 #include "sd-memfd.h"
 #include "_sd-common.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+_SD_BEGIN_DECLARATIONS;
 
 /* Types */
 
 
 /* Types */
 
@@ -269,8 +267,6 @@ int sd_bus_error_has_name(const sd_bus_error *e, const char *name);
                 &(x).bytes[8],  &(x).bytes[9],  &(x).bytes[10], &(x).bytes[11], \
                 &(x).bytes[12], &(x).bytes[13], &(x).bytes[14], &(x).bytes[15]
 
                 &(x).bytes[8],  &(x).bytes[9],  &(x).bytes[10], &(x).bytes[11], \
                 &(x).bytes[12], &(x).bytes[13], &(x).bytes[14], &(x).bytes[15]
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index bc4c01db0b0bcf2d53905c6c0e5243c3f65409c3..8262e139ac77beac61aae0a3e545cd9f7712a97f 100644 (file)
@@ -28,6 +28,8 @@
 #include <inttypes.h>
 #include <signal.h>
 
 #include <inttypes.h>
 #include <signal.h>
 
+#include "_sd-common.h"
+
 /*
   Why is this better than pure epoll?
 
 /*
   Why is this better than pure epoll?
 
@@ -37,9 +39,7 @@
   - Handles signals and child PIDs
 */
 
   - Handles signals and child PIDs
 */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+_SD_BEGIN_DECLARATIONS;
 
 typedef struct sd_event sd_event;
 typedef struct sd_event_source sd_event_source;
 
 typedef struct sd_event sd_event;
 typedef struct sd_event_source sd_event_source;
@@ -115,8 +115,6 @@ int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec);
 int sd_event_source_get_signal(sd_event_source *s);
 int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
 
 int sd_event_source_get_signal(sd_event_source *s);
 int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index 6066f395fac043fb87ed7aebec382e865e998d4e..5bae9655cc1e06a162f5b4f33fc89218bec0b598 100644 (file)
@@ -25,9 +25,9 @@
 #include <inttypes.h>
 #include <string.h>
 
 #include <inttypes.h>
 #include <string.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
 
 /* 128 Bit ID APIs. See sd-id128(3) for more information. */
 
 
 /* 128 Bit ID APIs. See sd-id128(3) for more information. */
 
@@ -102,8 +102,6 @@ static inline int sd_id128_equal(sd_id128_t a, sd_id128_t b) {
 
 #define SD_ID128_NULL ((sd_id128_t) { .qwords = { 0, 0 }})
 
 
 #define SD_ID128_NULL ((sd_id128_t) { .qwords = { 0, 0 }})
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index e319c6e58ccdea83072ffb6533d02dc6c5653170..751e7f9ea7a2cf99b26eb0315eeb0ecd464df887 100644 (file)
 #include "sd-id128.h"
 #include "_sd-common.h"
 
 #include "sd-id128.h"
 #include "_sd-common.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* Journal APIs. See sd-journal(3) for more information. */
 
 /* Journal APIs. See sd-journal(3) for more information. */
 
+_SD_BEGIN_DECLARATIONS;
+
 /* Write to daemon */
 int sd_journal_print(int priority, const char *format, ...) _sd_printf_(2, 3);
 int sd_journal_printv(int priority, const char *format, va_list ap) _sd_printf_(2, 0);
 /* Write to daemon */
 int sd_journal_print(int priority, const char *format, ...) _sd_printf_(2, 3);
 int sd_journal_printv(int priority, const char *format, va_list ap) _sd_printf_(2, 0);
@@ -54,11 +52,11 @@ int sd_journal_perror_with_location(const char *file, const char *line, const ch
 /* implicitly add code location to messages sent, if this is enabled */
 #ifndef SD_JOURNAL_SUPPRESS_LOCATION
 
 /* implicitly add code location to messages sent, if this is enabled */
 #ifndef SD_JOURNAL_SUPPRESS_LOCATION
 
-#define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, __VA_ARGS__)
-#define sd_journal_printv(priority, format, ap) sd_journal_printv_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, format, ap)
-#define sd_journal_send(...) sd_journal_send_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, __VA_ARGS__)
-#define sd_journal_sendv(iovec, n) sd_journal_sendv_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, iovec, n)
-#define sd_journal_perror(message) sd_journal_perror_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _sd_stringify(__LINE__), __func__, message)
+#define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define sd_journal_printv(priority, format, ap) sd_journal_printv_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, format, ap)
+#define sd_journal_send(...) sd_journal_send_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, __VA_ARGS__)
+#define sd_journal_sendv(iovec, n) sd_journal_sendv_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, iovec, n)
+#define sd_journal_perror(message) sd_journal_perror_with_location("CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, message)
 
 #endif
 
 
 #endif
 
@@ -153,8 +151,6 @@ int sd_journal_get_catalog_for_message_id(sd_id128_t id, char **ret);
 #define SD_JOURNAL_FOREACH_UNIQUE(j, data, l)                           \
         for (sd_journal_restart_unique(j); sd_journal_enumerate_unique((j), &(data), &(l)) > 0; )
 
 #define SD_JOURNAL_FOREACH_UNIQUE(j, data, l)                           \
         for (sd_journal_restart_unique(j); sd_journal_enumerate_unique((j), &(data), &(l)) > 0; )
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index 961bd88ec72e3b69e010e668ae69f6070998fa49..a230aff4c53779c8c2990663ef61d8bf3b8d7e68 100644 (file)
@@ -25,9 +25,7 @@
 #include <sys/types.h>
 #include <inttypes.h>
 
 #include <sys/types.h>
 #include <inttypes.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
 
 /*
  * A few points:
 
 /*
  * A few points:
@@ -49,6 +47,8 @@ extern "C" {
  * See sd-login(3) for more information.
  */
 
  * See sd-login(3) for more information.
  */
 
+_SD_BEGIN_DECLARATIONS;
+
 /* Get session from PID. Note that 'shared' processes of a user are
  * not attached to a session, but only attached to a user. This will
  * return an error for system processes and 'shared' processes of a
 /* Get session from PID. Note that 'shared' processes of a user are
  * not attached to a session, but only attached to a user. This will
  * return an error for system processes and 'shared' processes of a
@@ -182,8 +182,6 @@ int sd_login_monitor_get_events(sd_login_monitor *m);
 /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
 int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout_usec);
 
 /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
 int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout_usec);
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index ee140e48d3fa8c31906d985d77324c34a4a76050..f4ef8f102399f555f26b8d51e27ea6a6e865651b 100644 (file)
@@ -26,9 +26,9 @@
 #include <sys/types.h>
 #include <stdio.h>
 
 #include <sys/types.h>
 #include <stdio.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
 
 typedef struct sd_memfd sd_memfd;
 
 
 typedef struct sd_memfd sd_memfd;
 
@@ -51,8 +51,6 @@ int sd_memfd_get_sealed(sd_memfd *m);
 int sd_memfd_get_size(sd_memfd *m, uint64_t *sz);
 int sd_memfd_set_size(sd_memfd *m, uint64_t sz);
 
 int sd_memfd_get_size(sd_memfd *m, uint64_t *sz);
 int sd_memfd_set_size(sd_memfd *m, uint64_t sz);
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index 775aa23c03e4f53320d998b263bc3bb3edee3481..947bd1a9e51906b3aa997bc6356c9eb22b53fe97 100644 (file)
 ***/
 
 #include "sd-id128.h"
 ***/
 
 #include "sd-id128.h"
+#include "_sd-common.h"
 
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+_SD_BEGIN_DECLARATIONS;
 
 /* Hey! If you add a new message here, you *must* also update the
  * message catalog with an appropriate explanation */
 
 /* Hey! If you add a new message here, you *must* also update the
  * message catalog with an appropriate explanation */
@@ -84,8 +83,6 @@ extern "C" {
 
 #define SD_MESSAGE_BOOTCHART        SD_ID128_MAKE(9f,26,aa,56,2c,f4,40,c2,b1,6c,77,3d,04,79,b5,18)
 
 
 #define SD_MESSAGE_BOOTCHART        SD_ID128_MAKE(9f,26,aa,56,2c,f4,40,c2,b1,6c,77,3d,04,79,b5,18)
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index e3ad37c100b28c1c5ef9ba8d2a73a06a395db0fc..223f40307d64bf2917a06cccf5c241ed418e1422 100644 (file)
@@ -24,9 +24,9 @@
 
 #include <inttypes.h>
 
 
 #include <inttypes.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
 
 typedef struct sd_rtnl sd_rtnl;
 typedef struct sd_rtnl_message sd_rtnl_message;
 
 typedef struct sd_rtnl sd_rtnl;
 typedef struct sd_rtnl_message sd_rtnl_message;
@@ -57,8 +57,6 @@ int sd_rtnl_message_get_type(sd_rtnl_message *m, uint16_t *type);
 int sd_rtnl_message_append(sd_rtnl_message *m, unsigned short type, const void *data);
 int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data);
 
 int sd_rtnl_message_append(sd_rtnl_message *m, unsigned short type, const void *data);
 int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data);
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif
index 54ef5fbd89864af0fc907c3ea66a5e63f2258a09..4a43eb7c2cac779813e4ffd740282cbecf14e50b 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "_sd-common.h"
+
+_SD_BEGIN_DECLARATIONS;
 
 const char *sd_utf8_is_valid(const char *s);
 const char *sd_ascii_is_valid(const char *s);
 
 
 const char *sd_utf8_is_valid(const char *s);
 const char *sd_ascii_is_valid(const char *s);
 
-#ifdef __cplusplus
-}
-#endif
+_SD_END_DECLARATIONS;
 
 #endif
 
 #endif