Make inputflinger_tests compile for musl
inputflinger_tests compile for the host now, so they need to be
compatible with musl libc.
Use LLONG_MIN and LLONG_MAX instead of the nonstandard LONG_LONG_MIN
and LONG_LONG_MAX.
Use input_event_sec and input_event_usec to intialize time fields in
struct input_event, they are not always stored in a struct timespec.
Include linux/ioctl.h to define _IOC_SIZE.
Cast tv_sec and tv_usec to long long, as the type can be any integer
type.
Cast EPOLLIN to compare with epoll_event.events, it is not unsigned
in musl.
Include transitive dependencies of static libraries that are not
needed by the linker when CFI is enabled, but are detected as
errors when CFI is not enabled.
Bug: 190084016
Test: m USE_HOST_MUSL=true inputflinger_tests
Change-Id: I625bb612d5a8816ec5d1ade6d3a887981a549569
diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp
index 956746d..b97c466 100644
--- a/services/inputflinger/reader/EventHub.cpp
+++ b/services/inputflinger/reader/EventHub.cpp
@@ -19,6 +19,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <linux/ioctl.h>
#include <memory.h>
#include <stdint.h>
#include <stdio.h>
@@ -191,8 +192,8 @@
// calls clock_gettime(CLOCK_MONOTONIC) which is implemented as a
// system call that also queries ktime_get_ts().
- const nsecs_t inputEventTime = seconds_to_nanoseconds(event.time.tv_sec) +
- microseconds_to_nanoseconds(event.time.tv_usec);
+ const nsecs_t inputEventTime = seconds_to_nanoseconds(event.input_event_sec) +
+ microseconds_to_nanoseconds(event.input_event_usec);
return inputEventTime;
}
@@ -632,8 +633,8 @@
int32_t sc;
if (hasValidFd() && mapLed(led, &sc) != NAME_NOT_FOUND) {
struct input_event ev;
- ev.time.tv_sec = 0;
- ev.time.tv_usec = 0;
+ ev.input_event_sec = 0;
+ ev.input_event_usec = 0;
ev.type = EV_LED;
ev.code = sc;
ev.value = on ? 1 : 0;
@@ -1462,8 +1463,8 @@
device->ffEffectId = effect.id;
struct input_event ev;
- ev.time.tv_sec = 0;
- ev.time.tv_usec = 0;
+ ev.input_event_sec = 0;
+ ev.input_event_usec = 0;
ev.type = EV_FF;
ev.code = device->ffEffectId;
ev.value = 1;
@@ -1484,8 +1485,8 @@
device->ffEffectPlaying = false;
struct input_event ev;
- ev.time.tv_sec = 0;
- ev.time.tv_usec = 0;
+ ev.input_event_sec = 0;
+ ev.input_event_usec = 0;
ev.type = EV_FF;
ev.code = device->ffEffectId;
ev.value = 0;