From 14addbab474db9d2394b17cfe34f9e0aa24f234a Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 25 Oct 2015 23:00:06 +1100 Subject: [PATCH] ptrint: ptr2int and int2ptr are constant functions By construction these functions depend only on their arguments, so declare them as CONST_FUNCTION using the helper from ccan/compiler. Signed-off-by: David Gibson --- ccan/ptrint/_info | 1 + ccan/ptrint/ptrint.h | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ccan/ptrint/_info b/ccan/ptrint/_info index 8135d1ee..6300a9bc 100644 --- a/ccan/ptrint/_info +++ b/ccan/ptrint/_info @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) if (strcmp(argv[1], "depends") == 0) { printf("ccan/build_assert\n"); + printf("ccan/compiler\n"); return 0; } if (strcmp(argv[1], "testdepends") == 0) { diff --git a/ccan/ptrint/ptrint.h b/ccan/ptrint/ptrint.h index 992e4b18..d8642e6f 100644 --- a/ccan/ptrint/ptrint.h +++ b/ccan/ptrint/ptrint.h @@ -7,6 +7,7 @@ #include #include +#include /* * This is a deliberately incomplete type, because it should never be @@ -15,7 +16,7 @@ */ typedef struct ptrint ptrint_t; -static inline ptrdiff_t ptr2int(const ptrint_t *p) +CONST_FUNCTION static inline ptrdiff_t ptr2int(const ptrint_t *p) { /* * ptrdiff_t is the right size by definition, but to avoid @@ -26,7 +27,7 @@ static inline ptrdiff_t ptr2int(const ptrint_t *p) return (const char *)p - (const char *)NULL; } -static inline ptrint_t *int2ptr(ptrdiff_t i) +CONST_FUNCTION static inline ptrint_t *int2ptr(ptrdiff_t i) { return (ptrint_t *)((char *)NULL + i); } -- 2.39.2