X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=e4300719a3b12a83cdb9b2e514572f788a18cb5f;hb=1c231f56482546725c4dbd3303f70300bd3c63e9;hp=9913fcefaeba3ff6a4bfd16aaf0cec0cd2fa5828;hpb=5556b5fe41173107a67dbe875fbd916a46e52a02;p=elogind.git diff --git a/src/shared/util.h b/src/shared/util.h index 9913fcefa..e4300719a 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -58,6 +58,14 @@ # error Unknown uid_t size #endif +#if SIZEOF_GID_T == 4 +# define GID_FMT "%" PRIu32 +#elif SIZEOF_GID_T == 2 +# define GID_FMT "%" PRIu16 +#else +# error Unknown gid_t size +#endif + #include "macro.h" #include "time-util.h" @@ -723,6 +731,15 @@ void* greedy_realloc0(void **p, size_t *allocated, size_t need); #define GREEDY_REALLOC0(array, allocated, need) \ greedy_realloc0((void**) &(array), &(allocated), sizeof((array)[0]) * (need)) +#define GREEDY_REALLOC0_T(array, count, need) \ + ({ \ + size_t _size = (count) * sizeof((array)[0]); \ + void *_ptr = GREEDY_REALLOC0((array), _size, (need)); \ + if (_ptr) \ + (count) = _size / sizeof((array)[0]); \ + _ptr; \ + }) + static inline void _reset_errno_(int *saved_errno) { errno = *saved_errno; } @@ -874,3 +891,5 @@ int fd_warn_permissions(const char *path, int fd); unsigned long personality_from_string(const char *p); const char *personality_to_string(unsigned long); + +uint64_t physical_memory(void);