X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fmacro.h;h=daa42c4c68101ce5e70fb773a7fafd5937c417e8;hp=6a5742824479165f846e2df2f32c69d935998d9d;hb=8cb4ab0058e51f1fba93683d145ef95f97c2fa86;hpb=309a29dfd24f4175de334ca1593e3fe2436ab082 diff --git a/src/shared/macro.h b/src/shared/macro.h index 6a5742824..daa42c4c6 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -275,6 +275,14 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { #define PTR_TO_SIZE(p) ((size_t) ((uintptr_t) (p))) #define SIZE_TO_PTR(u) ((void *) ((uintptr_t) (u))) +/* The following macros add 1 when converting things, since UID 0 is a + * valid UID, while the pointer NULL is special */ +#define PTR_TO_UID(p) ((uid_t) (((uintptr_t) (p))-1)) +#define UID_TO_PTR(u) ((void*) (((uintptr_t) (u))+1)) + +#define PTR_TO_GID(p) ((gid_t) (((uintptr_t) (p))-1)) +#define GID_TO_PTR(u) ((void*) (((uintptr_t) (u))+1)) + #define memzero(x,l) (memset((x), 0, (l))) #define zero(x) (memzero(&(x), sizeof(x)))