diff --git a/doc/ipc-design.md b/doc/ipc-design.md index 2e011ec2c..68bf27f9c 100644 --- a/doc/ipc-design.md +++ b/doc/ipc-design.md @@ -228,3 +228,12 @@ for details. [SCM_RIGHTS]: https://man7.org/linux/man-pages/man3/cmsg.3.html [win32handles]: https://lackingrhoticity.blogspot.com/2015/05/passing-fds-handles-between-processes.html [WinSCM_RIGHTS]: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/#unsupportedunavailable + +## 32 bits client support on 64 bits server + +On 64 bits system, the server process will typically be a 64 bits executable, +clients may be 32 or 64 bits. As IPC either through socket or shared memory will +share C struct directly, we must pay attention to memory layout. + +All data types must be fixed size and alignments must be based on the 64 bits +targets. On Linux this mostly means `alignas(8)` must be used for (u)int64_t. diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index e9900507e..24d2f7ba8 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -409,6 +409,8 @@ struct xrt_layer_data * * The layer may be displayed after this point, but must never be * displayed before. + * + * alignas for 32 bit client support, */ alignas(8) int64_t timestamp; @@ -478,6 +480,7 @@ struct xrt_layer_data */ struct xrt_layer_frame_data { + //! alignas for 32 bit client support, see @ref ipc-design alignas(8) int64_t frame_id; int64_t display_time_ns; enum xrt_blend_mode env_blend_mode; @@ -931,6 +934,7 @@ struct xrt_swapchain_create_properties struct xrt_session_info { bool is_overlay; + //! alignas for 32 bit client support, see @ref ipc-design alignas(8) uint64_t flags; uint32_t z_order; }; @@ -945,7 +949,10 @@ struct xrt_compositor_info //! Number of formats, never changes. uint32_t format_count; - //! Supported formats, never changes. + /*! + * Supported formats, never changes. + * alignas for 32 bit client support, see @ref ipc-design + */ alignas(8) int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS]; //! Max texture size that GPU supports (size of a single dimension), zero means any size. diff --git a/src/xrt/include/xrt/xrt_device.h b/src/xrt/include/xrt/xrt_device.h index c0450efa1..dd17b1724 100644 --- a/src/xrt/include/xrt/xrt_device.h +++ b/src/xrt/include/xrt/xrt_device.h @@ -164,6 +164,7 @@ struct xrt_input //! Is this input active. bool active; + //! alignas for 32 bit client support, see @ref ipc-design alignas(8) int64_t timestamp; enum xrt_input_name name; diff --git a/src/xrt/include/xrt/xrt_system.h b/src/xrt/include/xrt/xrt_system.h index 356fa462f..995f71bc3 100644 --- a/src/xrt/include/xrt/xrt_system.h +++ b/src/xrt/include/xrt/xrt_system.h @@ -169,6 +169,8 @@ struct xrt_system_roles * All valid values are greater then zero; this is to * make init easier where any cache can start at zero and be guaranteed * to be replaced with a new @ref xrt_system_roles. + * + * alignas for 32 bit client support, see @ref ipc-design */ alignas(8) uint64_t generation_id;