diff options
| author | Khem Raj <raj.khem@gmail.com> | 2019-11-23 18:45:32 -0800 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@bitmath.se> | 2020-01-26 15:00:32 +0100 |
| commit | 598e561881c687cea072375637aa08ac9230fabe (patch) | |
| tree | d8e334f081ab2cd907bb408343c1a9709154f344 | |
| parent | 5a260fa95a5e7cebdd8f9da947c8d8eb244efae0 (diff) | |
adjust for 64bit time_t for 32bit architectures
libc that has support for 32 bit applications to use 64 bit
time_t supplies __USE_TIME_BITS64 define [1]
[1] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@bitmath.se>
| -rw-r--r-- | src/core.c | 8 | ||||
| -rw-r--r-- | test/mtdev-test.c | 10 |
2 files changed, 15 insertions, 3 deletions
| @@ -31,6 +31,11 @@ | |||
| 31 | #include "evbuf.h" | 31 | #include "evbuf.h" |
| 32 | #include "match.h" | 32 | #include "match.h" |
| 33 | 33 | ||
| 34 | #ifndef input_event_sec | ||
| 35 | #define input_event_sec time.tv_sec | ||
| 36 | #define input_event_usec time.tv_usec | ||
| 37 | #endif | ||
| 38 | |||
| 34 | static inline int istouch(const struct mtdev_slot *data, | 39 | static inline int istouch(const struct mtdev_slot *data, |
| 35 | const struct mtdev *dev) | 40 | const struct mtdev *dev) |
| 36 | { | 41 | { |
| @@ -251,7 +256,8 @@ static void push_slot_changes(struct mtdev_state *state, | |||
| 251 | count++; | 256 | count++; |
| 252 | if (!count) | 257 | if (!count) |
| 253 | return; | 258 | return; |
| 254 | ev.time = syn->time; | 259 | ev.input_event_sec = syn->input_event_sec; |
| 260 | ev.input_event_usec = syn->input_event_usec; | ||
| 255 | ev.type = EV_ABS; | 261 | ev.type = EV_ABS; |
| 256 | ev.code = ABS_MT_SLOT; | 262 | ev.code = ABS_MT_SLOT; |
| 257 | ev.value = slot; | 263 | ev.value = slot; |
diff --git a/test/mtdev-test.c b/test/mtdev-test.c index 1b3e4f2..773f86a 100644 --- a/test/mtdev-test.c +++ b/test/mtdev-test.c | |||
| @@ -30,9 +30,15 @@ | |||
| 30 | #include <stdio.h> | 30 | #include <stdio.h> |
| 31 | #include <unistd.h> | 31 | #include <unistd.h> |
| 32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
| 33 | #include <stdint.h> | ||
| 34 | |||
| 35 | #ifndef input_event_sec | ||
| 36 | #define input_event_sec time.tv_sec | ||
| 37 | #define input_event_usec time.tv_usec | ||
| 38 | #endif | ||
| 33 | 39 | ||
| 34 | /* year-proof millisecond event time */ | 40 | /* year-proof millisecond event time */ |
| 35 | typedef __u64 mstime_t; | 41 | typedef uint64_t mstime_t; |
| 36 | 42 | ||
| 37 | static int use_event(const struct input_event *ev) | 43 | static int use_event(const struct input_event *ev) |
| 38 | { | 44 | { |
| @@ -47,7 +53,7 @@ static void print_event(const struct input_event *ev) | |||
| 47 | { | 53 | { |
| 48 | static const mstime_t ms = 1000; | 54 | static const mstime_t ms = 1000; |
| 49 | static int slot; | 55 | static int slot; |
| 50 | mstime_t evtime = ev->time.tv_usec / ms + ev->time.tv_sec * ms; | 56 | mstime_t evtime = ev->input_event_usec / ms + ev->input_event_sec * ms; |
| 51 | if (ev->type == EV_ABS && ev->code == ABS_MT_SLOT) | 57 | if (ev->type == EV_ABS && ev->code == ABS_MT_SLOT) |
| 52 | slot = ev->value; | 58 | slot = ev->value; |
| 53 | fprintf(stderr, "%012llx %02d %01d %04x %d\n", | 59 | fprintf(stderr, "%012llx %02d %01d %04x %d\n", |
