Skip to content

Commit

Permalink
Bug 1834912 - Add iOS-related defines/ifdefs for IPC. r=ipc-reviewers…
Browse files Browse the repository at this point in the history
…,nika

Differential Revision: https://phabricator.services.mozilla.com/D178999
  • Loading branch information
glandium committed May 25, 2023
1 parent 80eafa8 commit 38a3d1f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ipc/chromium/src/base/platform_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion ipc/chromium/src/build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
12 changes: 6 additions & 6 deletions ipc/chromium/src/chrome/common/ipc_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ipc/chromium/src/chrome/common/ipc_message_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions mfbt/UniquePtrExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {}

Expand Down Expand Up @@ -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>;
Expand Down

0 comments on commit 38a3d1f

Please sign in to comment.