spa: system: make spa_poll_event compatible with epoll_events

spa_poll_event should have exactly same layout as epoll_events to be
compatible across platforms. The structure is packed only on x86-64.

Fix packing and replace the data member with similar union as
epoll_data, to fix compatibility on 32-bit etc.
This commit is contained in:
Pauli Virtanen 2026-04-06 10:24:34 +03:00 committed by Wim Taymans
parent 6b0248d68c
commit ad0bab69a1
2 changed files with 11 additions and 2 deletions

View file

@ -59,8 +59,15 @@ struct spa_system { struct spa_interface iface; };
struct spa_poll_event {
uint32_t events;
void *data;
} __attribute__ ((packed));
union {
void *data;
uint64_t data_u64;
};
#ifdef __x86_64__
} __attribute__((packed));
#else
};
#endif
struct spa_system_methods {
#define SPA_VERSION_SYSTEM_METHODS 1

View file

@ -31,6 +31,8 @@ SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.system");
#endif
SPA_STATIC_ASSERT(sizeof(struct spa_poll_event) == sizeof(struct epoll_event));
SPA_STATIC_ASSERT(offsetof(struct spa_poll_event, events) == offsetof(struct epoll_event, events));
SPA_STATIC_ASSERT(offsetof(struct spa_poll_event, data) == offsetof(struct epoll_event, data.ptr));
struct impl {
struct spa_handle handle;