diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-06 02:39:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-08 14:55:22 +0100 |
commit | 5f86c1f4c43ee9caa120d130e9b89d3fd25124c0 (patch) | |
tree | 34908816bfd429ba578f99626eb2deabc1ed631a /src/systemd/sd-bus.h | |
parent | 8b5e2af10830d55b2032e6c79d0cd1f959bb5b7f (diff) |
sd-bus: rework ELF error mapping table magic
The ELF magic cannot work for consumers of our shard library, since they
are in a different module. Hence make all the ELF magic private, and
instead introduce a public function to register additional static
mapping table.
Diffstat (limited to 'src/systemd/sd-bus.h')
-rw-r--r-- | src/systemd/sd-bus.h | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 3ad3db54e..f5fd37a66 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -46,6 +46,11 @@ typedef struct { int _need_free; } sd_bus_error; +typedef struct { + const char* name; + int code; +} sd_bus_error_map; + /* Flags */ enum { @@ -356,32 +361,9 @@ int sd_bus_creds_get_description(sd_bus_creds *c, const char **name); /* Error structures */ -struct sd_bus_name_error_mapping { - const char* name; - int code; -}; -typedef struct sd_bus_name_error_mapping sd_bus_name_error_mapping; - #define SD_BUS_ERROR_MAKE_CONST(name, message) ((const sd_bus_error) {(name), (message), 0}) #define SD_BUS_ERROR_NULL SD_BUS_ERROR_MAKE_CONST(NULL, NULL) -#ifndef SD_BUS_ERROR_MAPPING -# define _SD_BUS_ERROR_XCONCAT(x, y) x ## y -# define _SD_BUS_ERROR_CONCAT(x, y) _SD_BUS_ERROR_XCONCAT(x, y) -# define SD_BUS_ERROR_MAPPING(name) \ - __attribute((__section__("sd_bus_errnomap"))) \ - __attribute((__used__)) \ - const sd_bus_name_error_mapping _SD_BUS_ERROR_CONCAT(_sd_bus_errno_mapping_, name)[] -# define SD_BUS_ERROR_MAPPING_USE(name) \ - extern \ - const sd_bus_name_error_mapping _SD_BUS_ERROR_CONCAT(_sd_bus_errno_mapping_, name)[]; \ - __attribute((__used__)) \ - static const sd_bus_name_error_mapping* \ - _SD_BUS_ERROR_CONCAT(sd_bus_name_error_mapping_ref, __COUNTER__) \ - = _SD_BUS_ERROR_CONCAT(_sd_bus_errno_mapping_, name); -#endif - - void sd_bus_error_free(sd_bus_error *e); int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message); int sd_bus_error_setf(sd_bus_error *e, const char *name, const char *format, ...) _sd_printf_(3, 4); @@ -393,6 +375,19 @@ int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e); int sd_bus_error_is_set(const sd_bus_error *e); int sd_bus_error_has_name(const sd_bus_error *e, const char *name); +#define SD_BUS_ERROR_MAP(_name, _code) \ + { \ + .name = _name, \ + .code = _code, \ + } +#define SD_BUS_ERROR_MAP_END \ + { \ + .name = NULL, \ + .code = - 'x', \ + } + +int sd_bus_error_add_map(const sd_bus_error_map *map); + /* Auxiliary macros */ #define SD_BUS_MESSAGE_APPEND_ID128(x) 16, \ |