summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-22 17:49:28 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-22 17:50:50 +0100
commitb9a5f8588facd64fcff0f75fa91e3f80730b93f2 (patch)
treef31b2431533fd90c240f49f6e1801fd3b7adb426 /src/shared
parentaa9bd4992ff0240f6ceecb70ec364d5d9c7574f4 (diff)
import: only define the _to_string() enum mapping function, thus making gcc shut up
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index bfa56335cd..ca0c2e5e3d 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -348,12 +348,14 @@ static inline uint32_t random_u32(void) {
}
/* For basic lookup tables with strictly enumerated entries */
-#define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
+#define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
scope const char *name##_to_string(type i) { \
if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
return NULL; \
return name##_table[i]; \
- } \
+ }
+
+#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
scope type name##_from_string(const char *s) { \
type i; \
if (!s) \
@@ -363,11 +365,17 @@ static inline uint32_t random_u32(void) {
streq(name##_table[i], s)) \
return i; \
return (type) -1; \
- } \
+ }
+
+#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
+ _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
+ _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
struct __useless_struct_to_allow_trailing_semicolon__
-#define DEFINE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,)
-#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,static)
+#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static)
/* For string conversions where numbers are also acceptable */
#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \