X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=b56ffbde45657c3121c82450c6330c53afde3153;hb=95eb099fa8a90212ed2aef82bad360f147bc19c2;hp=410ce65f14a9d52d20a42bfe701f9f7c1129f6d0;hpb=7d328b544621d4b1bec936dec612947ad8bfb65a;p=elogind.git diff --git a/src/shared/util.h b/src/shared/util.h index 410ce65f1..b56ffbde4 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -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) \