fcint: add casts to allow building with stricter compilers
When targeting CHERI, casts between pointers and integers must use (u)intptr_t. uintptr_t values contains pointer bounds (and additional metadata), whereas other integer types do not. This change also adds a cast to FcOffsetToPtr() to silence a compiler warning that triggers if the compiler cannot statically infer which side of an arithmetic operation is the pointer operand and which one is the offset/mask.
This commit is contained in:
parent
3a7ad1b49f
commit
ab4761ff87
|
@ -152,16 +152,16 @@ FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
|
|||
#define FcIsEncodedOffset(p) ((((intptr_t) (p)) & 1) != 0)
|
||||
|
||||
/* Encode offset in a pointer of type t */
|
||||
#define FcOffsetEncode(o,t) ((t *) ((o) | 1))
|
||||
#define FcOffsetEncode(o,t) ((t *) (intptr_t) ((o) | 1))
|
||||
|
||||
/* Decode a pointer into an offset */
|
||||
#define FcOffsetDecode(p) (((intptr_t) (p)) & ~1)
|
||||
|
||||
/* Compute pointer offset */
|
||||
#define FcPtrToOffset(b,p) ((intptr_t) (p) - (intptr_t) (b))
|
||||
#define FcPtrToOffset(b,p) ((ptrdiff_t) ((intptr_t) (p) - (intptr_t) (b)))
|
||||
|
||||
/* Given base address, offset and type, return a pointer */
|
||||
#define FcOffsetToPtr(b,o,t) ((t *) ((intptr_t) (b) + (o)))
|
||||
#define FcOffsetToPtr(b,o,t) ((t *) ((intptr_t) (b) + (ptrdiff_t) (o)))
|
||||
|
||||
/* Given base address, encoded offset and type, return a pointer */
|
||||
#define FcEncodedOffsetToPtr(b,p,t) FcOffsetToPtr(b,FcOffsetDecode(p),t)
|
||||
|
|
Loading…
Reference in New Issue