X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/70ad1dc8a19d6edd9b97aa81f32cfd65758ae97d..refs/heads/master:/libdarwin/h/mach_utils.h?ds=inline diff --git a/libdarwin/h/mach_utils.h b/libdarwin/h/mach_utils.h index 13ad410..8b95751 100644 --- a/libdarwin/h/mach_utils.h +++ b/libdarwin/h/mach_utils.h @@ -40,6 +40,10 @@ #include #include +#if DARWIN_TAPI +#include "tapi.h" +#endif + /*! * @define OS_MIG_SUBSYSTEM_MAXSIZE * A macro that evaluates to the maximum size of a request or reply message in @@ -63,6 +67,42 @@ __BEGIN_DECLS; +/*! + * @function os_vm_address_from_ptr + * Converts the given pointer to a vm_address_t. + * + * @param p + * The pointer to convert. + * + * @result + * The pointer as a vm_address_t. + */ +DARWIN_API_AVAILABLE_20190830 +OS_ALWAYS_INLINE OS_WARN_RESULT +static inline vm_address_t +os_vm_address_from_ptr(const void *p) +{ + return (vm_address_t)(uintptr_t)p; +} + +/*! + * @function os_mach_vm_address_from_ptr + * Converts the given pointer to a mach_vm_address_t. + * + * @param p + * The pointer to convert. + * + * @result + * The pointer as a mach_vm_address_t. + */ +DARWIN_API_AVAILABLE_20190830 +OS_ALWAYS_INLINE OS_WARN_RESULT +static inline mach_vm_address_t +os_mach_vm_address_from_ptr(const void *p) +{ + return (mach_vm_address_t)(uintptr_t)p; +} + /*! * @function os_mach_msg_get_trailer * Obtains the trailer for the received Mach message. @@ -155,7 +195,7 @@ os_mach_msg_get_context_trailer(const mach_msg_header_t *hdr); * required. */ DARWIN_API_AVAILABLE_20170407 -OS_EXPORT OS_WARN_RESULT OS_MALLOC OS_NONNULL1 +OS_EXPORT OS_COLD OS_WARN_RESULT OS_MALLOC OS_NONNULL1 char * os_mach_msg_copy_description(const mach_msg_header_t *msg); @@ -176,7 +216,7 @@ os_mach_msg_copy_description(const mach_msg_header_t *msg); * required. */ DARWIN_API_AVAILABLE_20170407 -OS_EXPORT OS_WARN_RESULT OS_MALLOC OS_NONNULL1 +OS_EXPORT OS_COLD OS_WARN_RESULT OS_MALLOC OS_NONNULL1 char * os_mach_msg_trailer_copy_description(const mach_msg_trailer_t *tlr); @@ -196,7 +236,7 @@ os_mach_msg_trailer_copy_description(const mach_msg_trailer_t *tlr); * required. */ DARWIN_API_AVAILABLE_20170407 -OS_EXPORT OS_WARN_RESULT OS_MALLOC +OS_EXPORT OS_COLD OS_WARN_RESULT OS_MALLOC char * os_mach_port_copy_description(mach_port_t port);