diff options
author | Kay Sievers <kay@vrfy.org> | 2013-05-14 16:13:52 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2013-05-14 16:13:52 +0200 |
commit | a3dc35472f3a48ea8445ad7a943e2ff253170417 (patch) | |
tree | a1ae9f8b5c579eaebf2487987b2d8e7bf29aa777 /src | |
parent | 7e853a9b9a858edbc24e6c85d134478cec840173 (diff) |
bus: add and use UINT64_TO_PTR()
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-bus/bus-kernel.c | 6 | ||||
-rw-r--r-- | src/shared/macro.h | 26 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index e329b14be8..071f2b9708 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -436,7 +436,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess if (d->vec.size < sizeof(struct bus_header)) return -EBADMSG; - h = (struct bus_header*)(uintptr_t) d->vec.address; + h = (struct bus_header*)UINT64_TO_PTR(d->vec.address); } n_payload++; @@ -486,9 +486,9 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess if (d->type == KDBUS_MSG_PAYLOAD_VEC) { range_contains(idx, d->vec.size, ALIGN8(sizeof(struct bus_header)), BUS_MESSAGE_FIELDS_SIZE(m), - (void *)(uintptr_t) d->vec.address, &m->fields); + UINT64_TO_PTR(d->vec.address), &m->fields); range_contains(idx, d->vec.size, ALIGN8(sizeof(struct bus_header)) + ALIGN8(BUS_MESSAGE_FIELDS_SIZE(m)), - BUS_MESSAGE_BODY_SIZE(m), (void *)(uintptr_t) d->vec.address, &m->body); + BUS_MESSAGE_BODY_SIZE(m), UINT64_TO_PTR(d->vec.address), &m->body); idx += d->vec.size; diff --git a/src/shared/macro.h b/src/shared/macro.h index 0874102ece..2f151bcc8c 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -159,23 +159,25 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { } while (false) #endif +#define PTR_TO_INT(p) ((int) ((intptr_t) (p))) +#define INT_TO_PTR(u) ((void *) ((intptr_t) (u))) #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) -#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u))) - -#define PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p))) -#define UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u))) +#define UINT_TO_PTR(u) ((void *) ((uintptr_t) (u))) +#define PTR_TO_LONG(p) ((long) ((intptr_t) (p))) +#define LONG_TO_PTR(u) ((void *) ((intptr_t) (u))) #define PTR_TO_ULONG(p) ((unsigned long) ((uintptr_t) (p))) -#define ULONG_TO_PTR(u) ((void*) ((uintptr_t) (u))) +#define ULONG_TO_PTR(u) ((void *) ((uintptr_t) (u))) -#define PTR_TO_INT(p) ((int) ((intptr_t) (p))) -#define INT_TO_PTR(u) ((void*) ((intptr_t) (u))) - -#define TO_INT32(p) ((int32_t) ((intptr_t) (p))) -#define INT32_TO_PTR(u) ((void*) ((intptr_t) (u))) +#define PTR_TO_INT32(p) ((int32_t) ((intptr_t) (p))) +#define INT32_TO_PTR(u) ((void *) ((intptr_t) (u))) +#define PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p))) +#define UINT32_TO_PTR(u) ((void *) ((uintptr_t) (u))) -#define PTR_TO_LONG(p) ((long) ((intptr_t) (p))) -#define LONG_TO_PTR(u) ((void*) ((intptr_t) (u))) +#define PTR_TO_INT64(p) ((int64_t) ((intptr_t) (p))) +#define INT64_TO_PTR(u) ((void *) ((intptr_t) (u))) +#define PTR_TO_UINT64(p) ((uint64_t) ((uintptr_t) (p))) +#define UINT64_TO_PTR(u) ((void *) ((uintptr_t) (u))) #define memzero(x,l) (memset((x), 0, (l))) #define zero(x) (memzero(&(x), sizeof(x))) |