summaryrefslogtreecommitdiff
path: root/clients/linux
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-07-04 23:30:48 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-07-04 23:30:48 +0300
commit07a7d361fd1a56784f531cdb5b5dbeff0dad4237 (patch)
tree19011aaa6475f2b62bcd7eecb72f8469858c1215 /clients/linux
parent528c882e97fea16d56e22e19b76fbf5e45895967 (diff)
clients: Make host word size tunable compile-time
By default we assume 64bit host, compile with -DHOST_32BIT if your server runs on 32bit machine. Other kind of setups are not supported, but may work.
Diffstat (limited to 'clients/linux')
-rw-r--r--clients/linux/linux-uinput.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/clients/linux/linux-uinput.c b/clients/linux/linux-uinput.c
index 0b6e901..10151e9 100644
--- a/clients/linux/linux-uinput.c
+++ b/clients/linux/linux-uinput.c
@@ -17,24 +17,21 @@ struct core {
int input;
};
-// we assume 64bit host, see packet.h for rant
-
-#if UINTPTR_MAX != 0xffffffffffffffff
-#define NOT_64BIT
-
-struct timeval_64 {
+struct timeval_host {
+#ifdef HOST_32BIT
+ uint32_t tv_sec, tv_usec;
+#else
uint64_t tv_sec, tv_usec;
+#endif
};
-struct input_event_64 {
- struct timeval_64 time;
+struct input_event_host {
+ struct timeval_host time;
uint16_t type;
uint16_t code;
int32_t value;
};
-#endif
-
static int
_ioctl(const int fd, const unsigned long request, void *arg)
{
@@ -234,11 +231,7 @@ info(void)
warnx("version %s", UINPUTD_VERSION);
warnx("remote ip: %s", (remote ? remote : "none"));
warnx("sizeof(struct packet) is %zu bytes", sizeof(struct packet));
-#ifdef NOT_64BIT
- warnx("sizeof(struct input_event) is %zu bytes", sizeof(struct input_event_64));
-#else
- warnx("sizeof(struct input_event) is %zu bytes", sizeof(struct input_event));
-#endif
+ warnx("sizeof(struct input_event) is %zu bytes", sizeof(struct input_event_host));
warnx("sizeof(struct uinput_user_dev) is %zu bytes", sizeof(struct uinput_user_dev));
}
@@ -277,18 +270,14 @@ main(int argc, const char *argv[])
{
struct input_event event;
while (read(core.input, &event, sizeof(event)) == sizeof(event)) {
-#ifdef NOT_64BIT
- struct input_event_64 ev = {
+ struct input_event_host event_host = {
.time.tv_sec = event.time.tv_sec,
.time.tv_usec = event.time.tv_usec,
.type = event.type,
.code = event.code,
.value = event.value,
};
- uinputd_write(sizeof(ev), &ev);
-#else
- uinputd_write(sizeof(event), &event);
-#endif
+ uinputd_write(sizeof(event_host), &event_host);
}
err(EXIT_FAILURE, "read");
}