summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@nil.im>2020-09-26 19:13:14 +0000
committerJonathan Schleifer <js@nil.im>2020-09-26 19:13:14 +0000
commit5f496c3a49bfd504644d20a62126376e0c58ad60 (patch)
tree7f6211523a7ac53871baccb7ca176a7e39550b8e
parent68689769e88b363b13dd23d0c68b53a3dd3fb88c (diff)
runtime: Document functions for tagged pointerstagged-pointers
FossilOrigin-Name: 55001dba247b77096a086302fdb039e6ac2d4c3bb61d9dd77134fdb918591981
-rw-r--r--src/runtime/ObjFWRT.h44
-rw-r--r--src/runtime/private.h8
2 files changed, 44 insertions, 8 deletions
diff --git a/src/runtime/ObjFWRT.h b/src/runtime/ObjFWRT.h
index 33ff2cc6..9b211846 100644
--- a/src/runtime/ObjFWRT.h
+++ b/src/runtime/ObjFWRT.h
@@ -244,10 +244,54 @@ extern void *_Nullable objc_destructInstance(id _Nullable object);
extern void *_Null_unspecified objc_autoreleasePoolPush(void);
extern void objc_autoreleasePoolPop(void *_Null_unspecified pool);
extern id _Nullable _objc_rootAutorelease(id _Nullable object);
+
+/*!
+ * @brief Sets the tagged pointer secret.
+ *
+ * @param secret A secret, random value that will be used to XOR all tagged
+ * pointers with
+ */
extern void objc_setTaggedPointerSecret(uintptr_t secret);
+
+/*!
+ * @brief Registers a class for tagged pointers.
+ *
+ * @param class The class to register for tagged pointers
+ * @return The tagged pointer ID for the registered class
+ */
extern int objc_registerTaggedPointerClass(Class _Nonnull class);
+
+/*!
+ * @brief Returns whether the specified object is a tagged pointer.
+ *
+ * @param object The object to inspect
+ * @return Whether the specified object is a tagged pointer
+ */
+static inline bool
+object_isTaggedPointer(id _Nullable object)
+{
+ uintptr_t pointer = (uintptr_t)object;
+
+ return pointer & 1;
+}
+
extern Class _Nullable object_getTaggedPointerClass(id _Nonnull object);
+
+/*!
+ * @brief Returns the value of the specified tagged pointer.
+ *
+ * @param object The object whose tagged pointer value should be returned
+ * @return The tagged pointer value of the object
+ */
extern uintptr_t object_getTaggedPointerValue(id _Nonnull object);
+
+/*!
+ * @brief Creates a new tagged pointer.
+ *
+ * @param class The tag ID for the tagged pointer class to use
+ * @param value The value the tagged pointer should have
+ * @return A tagged pointer, or `nil` if it could not be created
+ */
extern id _Nullable objc_createTaggedPointer(int class, uintptr_t value);
/*
diff --git a/src/runtime/private.h b/src/runtime/private.h
index efbbde18..c8677729 100644
--- a/src/runtime/private.h
+++ b/src/runtime/private.h
@@ -336,14 +336,6 @@ objc_dtable_get(const struct objc_dtable *_Nonnull dtable, uint32_t idx)
#endif
}
-static inline bool
-object_isTaggedPointer(id _Nullable object)
-{
- uintptr_t pointer = (uintptr_t)object;
-
- return pointer & 1;
-}
-
#if defined(OF_ELF)
# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \
defined(OF_ARM64) || defined(OF_ARM) || \