Use cgettop where appropriate.
diff --git a/sdk/include/cheri.hh b/sdk/include/cheri.hh index 02e4fae..26f5496 100644 --- a/sdk/include/cheri.hh +++ b/sdk/include/cheri.hh
@@ -521,9 +521,14 @@ */ operator ptrdiff_t() const { +#if __has_builtin(__builtin_cheri_top_get) + return __builtin_cheri_top_get(ptr()) - + __builtin_cheri_address_get(ptr()); +#else return __builtin_cheri_length_get(ptr()) - (__builtin_cheri_address_get(ptr()) - __builtin_cheri_base_get(ptr())); +#endif } /** @@ -789,11 +794,9 @@ /** * Return the bounds as an integer. */ - [[nodiscard]] ptrdiff_t bounds() const + [[nodiscard]] __always_inline ptrdiff_t bounds() const { - return __builtin_cheri_length_get(ptr) - - (__builtin_cheri_address_get(ptr()) - - __builtin_cheri_base_get(ptr())); + return top() - address(); } /** @@ -915,7 +918,11 @@ */ [[nodiscard]] ptraddr_t top() const { +#if __has_builtin(__builtin_cheri_top_get) + return __builtin_cheri_top_get(ptr); +#else return base() + length(); +#endif } /**