Bug 1834912 - Add iOS-related defines/ifdefs for IPC. r=ipc-reviewers,nika

Differential Revision: https://phabricator.services.mozilla.com/D178999
This commit is contained in:
Mike Hommey 2023-05-25 02:48:33 +00:00
Родитель 80eafa8948
Коммит 38a3d1fae3
5 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -31,7 +31,7 @@ typedef pid_t PlatformThreadId;
# elif defined(OS_BSD)
# include <sys/types.h>
typedef lwpid_t PlatformThreadId;
# elif defined(OS_MACOSX)
# elif defined(OS_MACOSX) || defined(OS_IOS)
# include <mach/mach.h>
typedef mach_port_t PlatformThreadId;
# endif

Просмотреть файл

@ -21,7 +21,11 @@
# define OS_ANDROID 1
# define OS_LINUX 1
#elif defined(__APPLE__)
# define OS_MACOSX 1
# if defined(XP_IOS)
# define OS_IOS 1
# else
# define OS_MACOSX 1
# endif
#elif defined(__linux__)
# define OS_LINUX 1
#elif defined(__DragonFly__)

Просмотреть файл

@ -306,7 +306,7 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
// IPC::Message.
void SetAttachedFileHandles(nsTArray<mozilla::UniqueFileHandle> handles);
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
void set_fd_cookie(uint32_t cookie) { header()->cookie = cookie; }
uint32_t fd_cookie() const { return header()->cookie; }
#endif
@ -325,7 +325,7 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
// IPC. Must only be called when there are no ports on this IPC::Message.
void SetAttachedPorts(nsTArray<mozilla::ipc::ScopedPort> ports);
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
bool WriteMachSendRight(mozilla::UniqueMachSendRight port);
// WARNING: This method is marked as `const` so it can be called when
@ -339,7 +339,7 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
uint32_t num_relayed_attachments() const {
#if defined(OS_WIN)
return num_handles();
#elif defined(OS_MACOSX)
#elif defined(OS_MACOSX) || defined(OS_IOS)
return num_send_rights();
#else
return 0;
@ -356,7 +356,7 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
friend class SyncMessage;
friend class mozilla::ipc::MiniTransceiver;
#if !defined(OS_MACOSX) && !defined(FUZZING_SNAPSHOT)
#if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(FUZZING_SNAPSHOT)
protected:
#endif
@ -365,7 +365,7 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
msgid_t type; // specifies the user-defined message type
HeaderFlags flags; // specifies control flags for the message
uint32_t num_handles; // the number of handles included with this message
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
uint32_t cookie; // cookie to ACK that the descriptors have been read.
uint32_t num_send_rights; // the number of mach send rights included with
// this message
@ -393,7 +393,7 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
// deserializing a message.
mutable nsTArray<mozilla::ipc::ScopedPort> attached_ports_;
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
// The set of mach send rights which are attached to this message.
//
// Mutable, as this array can be mutated during `ConsumeMachSendRight` when

Просмотреть файл

@ -107,7 +107,7 @@ class MOZ_STACK_CLASS MessageWriter final {
message_.WritePort(std::move(port));
}
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
bool WriteMachSendRight(mozilla::UniqueMachSendRight port) {
return message_.WriteMachSendRight(std::move(port));
}
@ -192,7 +192,7 @@ class MOZ_STACK_CLASS MessageReader final {
return message_.ConsumePort(&iter_, port);
}
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
[[nodiscard]] bool ConsumeMachSendRight(mozilla::UniqueMachSendRight* port) {
return message_.ConsumeMachSendRight(&iter_, port);
}
@ -965,7 +965,7 @@ struct ParamTraitsIPC<mozilla::UniqueFileHandle> {
}
};
#if defined(OS_MACOSX)
#if defined(OS_MACOSX) || defined(OS_IOS)
// `UniqueMachSendRight` may be serialized over IPC channels. On the receiving
// side, the UniqueMachSendRight is the local name of the right which was
// transmitted.

Просмотреть файл

@ -19,7 +19,7 @@
#ifdef XP_WIN
# include <cstdint>
#endif
#if defined(XP_MACOSX) && !defined(RUST_BINDGEN)
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
# include <mach/mach.h>
#endif
@ -158,7 +158,7 @@ struct FileHandleDeleter {
MFBT_API void operator()(FileHandleHelper aHelper);
};
#if defined(XP_MACOSX) && !defined(RUST_BINDGEN)
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
struct MachPortHelper {
MOZ_IMPLICIT MachPortHelper(mach_port_t aPort) : mPort(aPort) {}
@ -215,7 +215,7 @@ using UniqueFreePtr = UniquePtr<T, detail::FreePolicy<T>>;
using UniqueFileHandle =
UniquePtr<detail::FileHandleType, detail::FileHandleDeleter>;
#if defined(XP_MACOSX) && !defined(RUST_BINDGEN)
#if defined(XP_DARWIN) && !defined(RUST_BINDGEN)
// A RAII class for a Mach port that names a send right.
using UniqueMachSendRight =
UniquePtr<mach_port_t, detail::MachSendRightDeleter>;