···241241option(XRT_FEATURE_COLOR_LOG "Enable logging in color on supported platforms" ON)
242242option_with_deps(XRT_FEATURE_COMPOSITOR_MAIN "Build main compositor host functionality" DEPENDS XRT_HAVE_VULKAN "XRT_HAVE_WAYLAND OR XRT_HAVE_XCB OR ANDROID OR WIN32")
243243option_with_deps(XRT_FEATURE_COMPOSITOR_NULL "Build testing null compositor" DEPENDS XRT_HAVE_VULKAN)
244244-option_with_deps(XRT_FEATURE_IPC "Enable the build of the IPC layer" DEPENDS "NOT WIN32")
244244+option(XRT_FEATURE_IPC "Enable the build of the IPC layer" ON)
245245option_with_deps(XRT_FEATURE_OPENXR "Build OpenXR runtime target" DEPENDS "XRT_FEATURE_COMPOSITOR_MAIN OR XRT_FEATURE_COMPOSITOR_NULL")
246246option_with_deps(XRT_FEATURE_RENDERDOC "Enable RenderDoc API" DEPENDS "RT_LIBRARY OR WIN32")
247247option_with_deps(XRT_FEATURE_SERVICE "Enable separate service module for OpenXR runtime" DEPENDS XRT_FEATURE_IPC XRT_FEATURE_OPENXR)
···236236#define XRT_IPC_GOT_IMPL
237237#endif
238238239239+#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN)
240240+ /*!
241241+ * @name Desktop Windows Mainloop Members
242242+ * @{
243243+ */
244244+245245+ //! Named Pipe that we accept connections on.
246246+ HANDLE pipe_handle;
247247+248248+ //! Name of the Pipe that we accept connections on.
249249+ char *pipe_name;
250250+251251+ /*! @} */
252252+253253+#define XRT_IPC_GOT_IMPL
254254+#endif
255255+239256#ifndef XRT_IPC_GOT_IMPL
240257#error "Need port"
241258#endif
···397414 * @{
398415 */
399416/*!
400400- * Start a thread for a client connected at the other end of the file descriptor @p fd.
417417+ * Start a thread for a client connected at the other end of the ipc handle @p ipc_handle.
401418 * @memberof ipc_server
402419 */
403420void
404404-ipc_server_start_client_listener_thread(struct ipc_server *vs, int fd);
421421+ipc_server_start_client_listener_thread(struct ipc_server *vs, xrt_ipc_handle_t ipc_handle);
405422406423/*!
407424 * Perform whatever needs to be done when the mainloop polling encounters a failure.
···1515#include "shared/ipc_protocol.h"
16161717#include <errno.h>
1818+#if !defined(XRT_OS_WINDOWS)
1819#include <sys/socket.h>
1920#include <unistd.h>
2121+#endif
20222123#include <stdio.h>
2224#include <string.h>
···3739#define IPC_WARN(d, ...) U_LOG_IFL_W(d->log_level, __VA_ARGS__)
3840#define IPC_ERROR(d, ...) U_LOG_IFL_E(d->log_level, __VA_ARGS__)
39414242+#if !defined(XRT_OS_WINDOWS)
4043void
4144ipc_message_channel_close(struct ipc_message_channel *imc)
4245{
4343- if (imc->socket_fd < 0) {
4646+ if (imc->ipc_handle < 0) {
4447 return;
4548 }
4646- close(imc->socket_fd);
4747- imc->socket_fd = -1;
4949+ close(imc->ipc_handle);
5050+ imc->ipc_handle = -1;
4851}
49525053xrt_result_t
···6265 msg.msg_iovlen = 1;
6366 msg.msg_flags = 0;
64676565- ssize_t ret = sendmsg(imc->socket_fd, &msg, MSG_NOSIGNAL);
6868+ ssize_t ret = sendmsg(imc->ipc_handle, &msg, MSG_NOSIGNAL);
6669 if (ret < 0) {
6770 int code = errno;
6871 IPC_ERROR(imc, "ERROR: Sending plain message on socket %d failed with error: '%i' '%s'!",
6969- (int)imc->socket_fd, code, strerror(code));
7272+ (int)imc->ipc_handle, code, strerror(code));
7073 return XRT_ERROR_IPC_FAILURE;
7174 }
7275···9093 msg.msg_iovlen = 1;
9194 msg.msg_flags = 0;
92959393- ssize_t len = recvmsg(imc->socket_fd, &msg, MSG_NOSIGNAL);
9696+ ssize_t len = recvmsg(imc->ipc_handle, &msg, MSG_NOSIGNAL);
94979598 if (len < 0) {
9699 int code = errno;
97100 IPC_ERROR(imc, "ERROR: Receiving plain message on socket '%d' failed with error: '%i' '%s'!",
9898- (int)imc->socket_fd, code, strerror(code));
101101+ (int)imc->ipc_handle, code, strerror(code));
99102 return XRT_ERROR_IPC_FAILURE;
100103 }
101104···135138 msg.msg_control = u.buf;
136139 msg.msg_controllen = cmsg_size;
137140138138- ssize_t len = recvmsg(imc->socket_fd, &msg, MSG_NOSIGNAL);
141141+ ssize_t len = recvmsg(imc->ipc_handle, &msg, MSG_NOSIGNAL);
139142 if (len < 0) {
140143 IPC_ERROR(imc, "recvmsg failed with error: '%s'!", strerror(errno));
141144 return XRT_ERROR_IPC_FAILURE;
···187190188191 memcpy(CMSG_DATA(cmsg), handles, fds_size);
189192190190- ssize_t ret = sendmsg(imc->socket_fd, &msg, MSG_NOSIGNAL);
193193+ ssize_t ret = sendmsg(imc->ipc_handle, &msg, MSG_NOSIGNAL);
191194 if (ret < 0) {
192195 IPC_ERROR(imc, "ERROR: sending %d FDs on socket %d failed with error: '%i' '%s'!", (int)handle_count,
193193- imc->socket_fd, errno, strerror(errno));
196196+ imc->ipc_handle, errno, strerror(errno));
194197 for (uint32_t i = 0; i < handle_count; i++) {
195198 IPC_ERROR(imc, "\tfd #%i: %i", i, handles[i]);
196199 }
···199202 return XRT_SUCCESS;
200203}
201204205205+#endif
206206+202207xrt_result_t
203208ipc_receive_handles_shmem(struct ipc_message_channel *imc,
204209 void *out_data,
···244249 }
245250 bool failed = false;
246251 for (uint32_t i = 0; i < handle_count; ++i) {
247247- int err = AHardwareBuffer_recvHandleFromUnixSocket(imc->socket_fd, &(out_handles[i]));
252252+ int err = AHardwareBuffer_recvHandleFromUnixSocket(imc->ipc_handle, &(out_handles[i]));
248253 if (err != 0) {
249254 failed = true;
250255 }
···266271 }
267272 bool failed = false;
268273 for (uint32_t i = 0; i < handle_count; ++i) {
269269- int err = AHardwareBuffer_sendHandleToUnixSocket(handles[i], imc->socket_fd);
274274+ int err = AHardwareBuffer_sendHandleToUnixSocket(handles[i], imc->ipc_handle);
270275 if (err != 0) {
271276 failed = true;
272277 }
···303308 return ipc_send_fds(imc, data, size, handles, handle_count);
304309}
305310311311+#elif defined(XRT_OS_WINDOWS)
306312#else
307313#error "Need port to transport these graphics buffers"
308314#endif
···344350 return ipc_send_fds(imc, data, size, handles, handle_count);
345351}
346352353353+#elif defined(XRT_OS_WINDOWS)
347354#else
348355#error "Need port to transport these graphics buffers"
349356#endif
+52-1
src/xrt/ipc/shared/ipc_utils.h
···2727 */
2828struct ipc_message_channel
2929{
3030- int socket_fd;
3030+ xrt_ipc_handle_t ipc_handle;
3131 enum u_logging_level log_level;
3232};
3333···111111 */
112112xrt_result_t
113113ipc_send_fds(struct ipc_message_channel *imc, const void *data, size_t size, const int *handles, uint32_t handle_count);
114114+#elif defined(XRT_OS_WINDOWS)
115115+/*!
116116+ * Receive a message along with a known number of file HANDLEs over the IPC
117117+ * channel.
118118+ *
119119+ * @param imc Message channel to use
120120+ * @param[out] out_data Pointer to the buffer to fill with data. Must not be
121121+ * null.
122122+ * @param[in] size Maximum size to read, must be greater than 0
123123+ * @param[out] out_handles Array of file HANDLEs to populate. Must not be
124124+ * null.
125125+ * @param[in] handle_count Number of elements to receive into @p out_handles,
126126+ * must be greater than 0 and must match the value provided at the other end.
127127+ *
128128+ * @public @memberof ipc_message_channel
129129+ */
130130+xrt_result_t
131131+ipc_receive_fds(
132132+ struct ipc_message_channel *imc, void *out_data, size_t size, HANDLE *out_handles, uint32_t handle_count);
133133+134134+/*!
135135+ * Send a message along with file HANDLEs over the IPC channel.
136136+ *
137137+ * @param imc Message channel to use
138138+ * @param[in] data Pointer to the data buffer to send. Must not be
139139+ * null: use a filler message if necessary.
140140+ * @param[in] size Size of data pointed-to by @p data, must be greater than 0
141141+ * @param[out] handles Array of file HANDLEs to send. Must not be
142142+ * null.
143143+ * @param[in] handle_count Number of elements in @p handles, must be greater
144144+ * than 0. If this is variable, it must also be separately transmitted ahead of
145145+ * time, because the receiver must have the same value in its receive call.
146146+ *
147147+ * @public @memberof ipc_message_channel
148148+ */
149149+xrt_result_t
150150+ipc_send_fds(
151151+ struct ipc_message_channel *imc, const void *data, size_t size, const HANDLE *handles, uint32_t handle_count);
152152+153153+/*!
154154+ * Helper to convert windows error codes to human readable strings for logging
155155+ * N.B. This routine is not thread safe
156156+ *
157157+ * @param err windows error code
158158+ * @return human readable string corresponding to the error code
159159+ *
160160+ * @public @memberof ipc_message_channel
161161+ */
162162+const char *
163163+ipc_winerror(DWORD err);
164164+114165#endif // XRT_OS_UNIX
115166/*!
116167 * @}