chiark / gitweb /
util: define union dirent_storage and make use of it everywhere
[elogind.git] / src / shared / util.h
index 2429339f5bba3c3a46a1e521d902e3ceb1fc0a17..e5728bd87e275eee904a5d021a105f0211ad8765 100644 (file)
@@ -35,6 +35,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <sys/resource.h>
+#include <stddef.h>
 
 #include "macro.h"
 
@@ -46,6 +47,12 @@ typedef struct dual_timestamp {
         usec_t monotonic;
 } dual_timestamp;
 
+union dirent_storage {
+        struct dirent de;
+        uint8_t storage[offsetof(struct dirent, d_name) +
+                        ((NAME_MAX + 1 + sizeof(long)) & ~(sizeof(long) - 1))];
+};
+
 #define MSEC_PER_SEC  1000ULL
 #define USEC_PER_SEC  1000000ULL
 #define USEC_PER_MSEC 1000ULL