The open source OpenXR runtime

ipc: static assertions for structur sizes

Assertions will need to be manually updated, but will catch cases when
size is different across architectures.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2396>

authored by

Patrick Nicolas and committed by
Marge Bot
25bd1abc cb5f527c

+34
+34
src/xrt/ipc/shared/ipc_protocol.h
··· 25 25 #include "xrt/xrt_tracking.h" 26 26 #include "xrt/xrt_config_build.h" 27 27 28 + #include <assert.h> 28 29 #include <sys/types.h> 29 30 30 31 ··· 73 74 struct xrt_pose offset; 74 75 }; 75 76 77 + static_assert(sizeof(struct ipc_shared_tracking_origin) == 288, 78 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 79 + 76 80 /*! 77 81 * A binding in the shared memory area. 78 82 * ··· 93 97 uint32_t first_output_index; 94 98 }; 95 99 100 + static_assert(sizeof(struct ipc_shared_binding_profile) == 20, 101 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 102 + 96 103 /*! 97 104 * A device in the shared memory area. 98 105 * ··· 140 147 bool battery_status_supported; 141 148 }; 142 149 150 + static_assert(sizeof(struct ipc_shared_device) == 560, 151 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 152 + 143 153 /*! 144 154 * Data for a single composition layer. 145 155 * ··· 166 176 struct xrt_layer_data data; 167 177 }; 168 178 179 + static_assert(sizeof(struct ipc_layer_entry) == 392, 180 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 181 + 169 182 /*! 170 183 * Render state for a single client, including all layers. 171 184 * ··· 177 190 uint32_t layer_count; 178 191 struct ipc_layer_entry layers[IPC_MAX_LAYERS]; 179 192 }; 193 + 194 + static_assert(sizeof(struct ipc_layer_slot) == IPC_MAX_LAYERS * sizeof(struct ipc_layer_entry) + 32, 195 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 180 196 181 197 /*! 182 198 * A big struct that contains all data that is shared to a client, no pointers ··· 282 298 uint64_t startup_timestamp; 283 299 }; 284 300 301 + static_assert(sizeof(struct ipc_shared_memory) == 6497680, 302 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 303 + 285 304 /*! 286 305 * Initial info from a client when it connects. 287 306 */ ··· 290 309 pid_t pid; 291 310 struct xrt_application_info info; 292 311 }; 312 + 313 + static_assert(sizeof(struct ipc_client_description) == 140, 314 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 293 315 294 316 struct ipc_client_list 295 317 { ··· 297 319 uint32_t id_count; 298 320 }; 299 321 322 + static_assert(sizeof(struct ipc_client_list) == 36, 323 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 324 + 300 325 /*! 301 326 * State for a connected application. 302 327 * ··· 318 343 struct xrt_application_info info; 319 344 }; 320 345 346 + static_assert(sizeof(struct ipc_app_state) == 156, 347 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 348 + 321 349 322 350 /*! 323 351 * Arguments for creating swapchains from native images. ··· 327 355 uint32_t sizes[XRT_MAX_SWAPCHAIN_IMAGES]; 328 356 }; 329 357 358 + static_assert(sizeof(struct ipc_arg_swapchain_from_native) == 32, 359 + "invalid structure size, maybe different 32/64 bits sizes or padding"); 360 + 330 361 /*! 331 362 * Arguments for xrt_device::get_view_poses with two views. 332 363 */ ··· 336 367 struct xrt_pose poses[XRT_MAX_VIEWS]; 337 368 struct xrt_space_relation head_relation; 338 369 }; 370 + 371 + static_assert(sizeof(struct ipc_info_get_view_poses_2) == 144, 372 + "invalid structure size, maybe different 32/64 bits sizes or padding");