chiark / gitweb /
bus-proxy: close each connection fd only once
[elogind.git] / src / shared / util.h
index 410ce65f14a9d52d20a42bfe701f9f7c1129f6d0..b56ffbde45657c3121c82450c6330c53afde3153 100644 (file)
@@ -872,16 +872,6 @@ static inline unsigned log2u(unsigned x) {
         return sizeof(unsigned) * 8 - __builtin_clz(x) - 1;
 }
 
-static inline unsigned log2u64(uint64_t x) {
-        assert(x > 0);
-
-#if __SIZEOF_LONG_LONG__ == 8
-        return 64 - __builtin_clzll(x) - 1;
-#else
-#error "Wut?"
-#endif
-}
-
 static inline unsigned log2u_round_up(unsigned x) {
         assert(x > 0);
 
@@ -931,19 +921,19 @@ int unlink_noerrno(const char *path);
                 (void*)memset(_new_, 0, _size_);                        \
         })
 
-#define strappenda(a, ...)                                       \
-        ({                                                       \
-                int _len = strlen(a);                            \
-                unsigned _i;                                     \
-                char *_d_, *_p_;                                 \
-                const char *_appendees_[] = { __VA_ARGS__ };     \
-                for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
-                        _len += strlen(_appendees_[_i]);         \
-                _d_ = alloca(_len + 1);                          \
-                _p_ = stpcpy(_d_, a);                            \
-                for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
-                        _p_ = stpcpy(_p_, _appendees_[_i]);      \
-                _d_;                                             \
+#define strjoina(a, ...)                                                \
+        ({                                                              \
+                const char *_appendees_[] = { a, __VA_ARGS__ };         \
+                char *_d_, *_p_;                                        \
+                int _len_ = 0;                                          \
+                unsigned _i_;                                           \
+                for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
+                        _len_ += strlen(_appendees_[_i_]);              \
+                _p_ = _d_ = alloca(_len_ + 1);                          \
+                for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
+                        _p_ = stpcpy(_p_, _appendees_[_i_]);            \
+                *_p_ = 0;                                               \
+                _d_;                                                    \
         })
 
 #define procfs_file_alloca(pid, field)                                  \