0002-Fix-build-with-64-bits-time_t.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. From 839e51aa452345b440f8d2d0df84ab58bdedfcd1 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sat, 14 Nov 2020 21:54:17 +0100
  4. Subject: [PATCH] Fix build with 64 bits time_t
  5. time element is deprecated on new input_event structure in kernel's
  6. input.h [1]
  7. This will avoid the following build failure:
  8. hw/input/virtio-input-host.c: In function 'virtio_input_host_handle_status':
  9. hw/input/virtio-input-host.c:198:28: error: 'struct input_event' has no member named 'time'
  10. 198 | if (gettimeofday(&evdev.time, NULL)) {
  11. | ^
  12. Fixes:
  13. - http://autobuild.buildroot.org/results/a538167e288c14208d557cd45446df86d3d599d5
  14. - http://autobuild.buildroot.org/results/efd4474fb4b6c0ce0ab3838ce130429c51e43bbb
  15. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f
  16. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  17. ---
  18. contrib/vhost-user-input/main.c | 10 +++++++++-
  19. hw/input/virtio-input-host.c | 10 +++++++++-
  20. 2 files changed, 18 insertions(+), 2 deletions(-)
  21. diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c
  22. index 6020c6f33a..e688c3e0a9 100644
  23. --- a/contrib/vhost-user-input/main.c
  24. +++ b/contrib/vhost-user-input/main.c
  25. @@ -17,6 +17,11 @@
  26. #include "standard-headers/linux/virtio_input.h"
  27. #include "qapi/error.h"
  28. +#ifndef input_event_sec
  29. +#define input_event_sec time.tv_sec
  30. +#define input_event_usec time.tv_usec
  31. +#endif
  32. +
  33. enum {
  34. VHOST_USER_INPUT_MAX_QUEUES = 2,
  35. };
  36. @@ -115,13 +120,16 @@ vi_evdev_watch(VuDev *dev, int condition, void *data)
  37. static void vi_handle_status(VuInput *vi, virtio_input_event *event)
  38. {
  39. struct input_event evdev;
  40. + struct timeval tval;
  41. int rc;
  42. - if (gettimeofday(&evdev.time, NULL)) {
  43. + if (gettimeofday(&tval, NULL)) {
  44. perror("vi_handle_status: gettimeofday");
  45. return;
  46. }
  47. + evdev.input_event_sec = tval.tv_sec;
  48. + evdev.input_event_usec = tval.tv_usec;
  49. evdev.type = le16toh(event->type);
  50. evdev.code = le16toh(event->code);
  51. evdev.value = le32toh(event->value);
  52. diff --git a/hw/input/virtio-input-host.c b/hw/input/virtio-input-host.c
  53. index 85daf73f1a..2e261737e1 100644
  54. --- a/hw/input/virtio-input-host.c
  55. +++ b/hw/input/virtio-input-host.c
  56. @@ -16,6 +16,11 @@
  57. #include <sys/ioctl.h>
  58. #include "standard-headers/linux/input.h"
  59. +#ifndef input_event_sec
  60. +#define input_event_sec time.tv_sec
  61. +#define input_event_usec time.tv_usec
  62. +#endif
  63. +
  64. /* ----------------------------------------------------------------- */
  65. static struct virtio_input_config virtio_input_host_config[] = {
  66. @@ -193,13 +198,16 @@ static void virtio_input_host_handle_status(VirtIOInput *vinput,
  67. {
  68. VirtIOInputHost *vih = VIRTIO_INPUT_HOST(vinput);
  69. struct input_event evdev;
  70. + struct timeval tval;
  71. int rc;
  72. - if (gettimeofday(&evdev.time, NULL)) {
  73. + if (gettimeofday(&tval, NULL)) {
  74. perror("virtio_input_host_handle_status: gettimeofday");
  75. return;
  76. }
  77. + evdev.input_event_sec = tval.tv_sec;
  78. + evdev.input_event_usec = tval.tv_usec;
  79. evdev.type = le16_to_cpu(event->type);
  80. evdev.code = le16_to_cpu(event->code);
  81. evdev.value = le32_to_cpu(event->value);
  82. --
  83. 2.29.2