diff options
author | 2023-05-09 22:45:35 -0700 | |
---|---|---|
committer | 2023-05-10 10:57:45 -0700 | |
commit | 983cae052ad7d807387b2a0634c272edc449f0f1 (patch) | |
tree | a1c4df1f5c3a1ca7036d11ab638fa4dcc14b9f7b | |
parent | 8b0d097a741b2c47dcd445e1af63a2e49ec37994 (diff) |
Fix VirtualInputDevice build for musl libc
The struct input_event timespec types come from the kernel headers,
which can vary in their exact definition based on which libc they
came from. Use decltype to cast to the exact definition of the
fields.
Bug: 271946580
Test: m USE_HOST_MUSL=true host-native
Change-Id: Iddcc6ea7c1e5d70edf8c159ddaff585eb38ef7fa
-rw-r--r-- | libs/input/VirtualInputDevice.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libs/input/VirtualInputDevice.cpp b/libs/input/VirtualInputDevice.cpp index af9ce3a38f..9a459b135c 100644 --- a/libs/input/VirtualInputDevice.cpp +++ b/libs/input/VirtualInputDevice.cpp @@ -49,11 +49,10 @@ bool VirtualInputDevice::writeInputEvent(uint16_t type, uint16_t code, int32_t v std::chrono::seconds seconds = std::chrono::duration_cast<std::chrono::seconds>(eventTime); std::chrono::microseconds microseconds = std::chrono::duration_cast<std::chrono::microseconds>(eventTime - seconds); - struct input_event ev = {.type = type, - .code = code, - .value = value, - .input_event_sec = static_cast<time_t>(seconds.count()), - .input_event_usec = static_cast<suseconds_t>(microseconds.count())}; + struct input_event ev = {.type = type, .code = code, .value = value}; + ev.input_event_sec = static_cast<decltype(ev.input_event_sec)>(seconds.count()); + ev.input_event_usec = static_cast<decltype(ev.input_event_usec)>(microseconds.count()); + return TEMP_FAILURE_RETRY(write(mFd, &ev, sizeof(struct input_event))) == sizeof(ev); } |