chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: improve signal_to_string, signal_from_string
[elogind.git]
/
src
/
util.h
diff --git
a/src/util.h
b/src/util.h
index 3e1f46d82697d7aea47eb377924074bf0d03a1f3..e254bc7884b284b9289c1ec423dd16349f4a1f55 100644
(file)
--- a/
src/util.h
+++ b/
src/util.h
@@
-288,13
+288,13
@@
int make_null_stdio(void);
unsigned long long random_ull(void);
unsigned long long random_ull(void);
-#define
DEFINE_STRING_TABLE_LOOKUP(name,type)
\
-
const char *name##_to_string(type i) {
\
+#define
__DEFINE_STRING_TABLE_LOOKUP(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]; \
} \
if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
return NULL; \
return name##_table[i]; \
} \
-
type name##_from_string(const char *s) {
\
+
scope type name##_from_string(const char *s) {
\
type i; \
unsigned u = 0; \
assert(s); \
type i; \
unsigned u = 0; \
assert(s); \
@@
-309,6
+309,8
@@
unsigned long long random_ull(void);
} \
struct __useless_struct_to_allow_trailing_semicolon__
} \
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)
int fd_nonblock(int fd, bool nonblock);
int fd_cloexec(int fd, bool cloexec);
int fd_nonblock(int fd, bool nonblock);
int fd_cloexec(int fd, bool cloexec);