1From 84d40417fcf58ed123cd0040e5e5678ec12e68b2 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 28 May 2022 15:50:50 -0700
4Subject: [PATCH] Deal with 64bit time_t default on 32bit architectures
5
6Deal with Y2K38 concerns related to Linux input events on more recent
7kernels and libcs on 32-bit systems
8
9Original-Author: Khem Raj <raj.khem@gmail.com>
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12Signed-off-by: Pablo Saavedra <psaavedra@igalia.com>
13
14Upstream-Status: Submitted [https://github.com/pyinput/python-uinput/pull/2]
15
16---
17 libsuinput/src/suinput.c | 11 ++++++++++-
18 1 file changed, 10 insertions(+), 1 deletion(-)
19
20diff --git a/libsuinput/src/suinput.c b/libsuinput/src/suinput.c
21index 8d5fb71..13ff16a 100644
22--- a/libsuinput/src/suinput.c
23+++ b/libsuinput/src/suinput.c
24@@ -45,11 +45,20 @@ int suinput_emit(int uinput_fd, uint16_t ev_type, uint16_t ev_code,
25         struct input_event event;
26
27         memset(&event, 0, sizeof(event));
28-        gettimeofday(&event.time, 0);
29         event.type = ev_type;
30         event.code = ev_code;
31         event.value = ev_value;
32
33+/* attempt to deal with 64-bit time keeping on recent 32-bit systems */
34+#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64))
35+	gettimeofday(&event.time, 0);
36+#else
37+        struct timeval now;
38+        memset(&now, 0, sizeof(now));
39+        gettimeofday(&now, 0);
40+        event.input_event_sec  = now.tv_sec;
41+        event.input_event_usec = now.tv_usec;
42+#endif
43         return suinput_write_event(uinput_fd, &event);
44 }
45
46--
472.34.1
48
49