0001-Fix-build-on-32bit-arches-with-64bit-time_t.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. From 8ab672ccc67b64058cffac2cd19a0d3b75d5aa25 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Sat, 30 Nov 2019 11:43:32 -0800
  4. Subject: [PATCH] Fix build on 32bit arches with 64bit time_t
  5. time element is deprecated on new input_event structure in kernel's
  6. input.h [1]
  7. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=152194fe9c3f
  8. Upstream-Status: Submitted [https://github.com/LibVNC/x11vnc/pull/117]
  9. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  10. ---
  11. src/uinput.c | 28 ++++++++++++++++++++++++----
  12. 1 file changed, 24 insertions(+), 4 deletions(-)
  13. diff --git a/src/uinput.c b/src/uinput.c
  14. index 28fbad3..343b7c5 100644
  15. --- a/src/uinput.c
  16. +++ b/src/uinput.c
  17. @@ -54,6 +54,11 @@ so, delete this exception statement from your version.
  18. #include <linux/input.h>
  19. #include <linux/uinput.h>
  20. +#ifndef input_event_sec
  21. +#define input_event_sec time.tv_sec
  22. +#define input_event_usec time.tv_usec
  23. +#endif
  24. +
  25. #if !defined(EV_SYN) || !defined(SYN_REPORT)
  26. #undef UINPUT_OK
  27. #endif
  28. @@ -710,6 +715,7 @@ void parse_uinput_str(char *in) {
  29. static void ptr_move(int dx, int dy) {
  30. #ifdef UINPUT_OK
  31. struct input_event ev;
  32. + struct timeval tval;
  33. int d = direct_rel_fd < 0 ? fd : direct_rel_fd;
  34. if (injectable && strchr(injectable, 'M') == NULL) {
  35. @@ -720,7 +726,9 @@ static void ptr_move(int dx, int dy) {
  36. if (db) fprintf(stderr, "ptr_move(%d, %d) fd=%d\n", dx, dy, d);
  37. - gettimeofday(&ev.time, NULL);
  38. + gettimeofday(&tval, NULL);
  39. + ev.input_event_sec = tval.tv_sec;
  40. + ev.input_event_usec = tval.tv_usec;
  41. ev.type = EV_REL;
  42. ev.code = REL_Y;
  43. ev.value = dy;
  44. @@ -755,6 +763,7 @@ static void apply_tslib(int *x, int *y) {
  45. static void ptr_abs(int x, int y, int p) {
  46. #ifdef UINPUT_OK
  47. struct input_event ev;
  48. + struct timeval tval;
  49. int x0, y0;
  50. int d = direct_abs_fd < 0 ? fd : direct_abs_fd;
  51. @@ -773,7 +782,9 @@ static void ptr_abs(int x, int y, int p) {
  52. if (db) fprintf(stderr, "ptr_abs(%d, %d => %d %d, p=%d) fd=%d\n", x0, y0, x, y, p, d);
  53. - gettimeofday(&ev.time, NULL);
  54. + gettimeofday(&tval, NULL);
  55. + ev.input_event_sec = tval.tv_sec;
  56. + ev.input_event_usec = tval.tv_usec;
  57. ev.type = EV_ABS;
  58. ev.code = ABS_Y;
  59. ev.value = y;
  60. @@ -950,6 +961,7 @@ if (0) {usleep(100*1000) ;}
  61. static void button_click(int down, int btn) {
  62. #ifdef UINPUT_OK
  63. struct input_event ev;
  64. + struct timeval tval;
  65. int d = direct_btn_fd < 0 ? fd : direct_btn_fd;
  66. if (injectable && strchr(injectable, 'B') == NULL) {
  67. @@ -959,7 +971,12 @@ static void button_click(int down, int btn) {
  68. if (db) fprintf(stderr, "button_click: btn %d %s fd=%d\n", btn, down ? "down" : "up", d);
  69. memset(&ev, 0, sizeof(ev));
  70. - gettimeofday(&ev.time, NULL);
  71. + gettimeofday(&tval, NULL);
  72. + gettimeofday(&tval, NULL);
  73. + ev.input_event_sec = tval.tv_sec;
  74. + ev.input_event_usec = tval.tv_usec;
  75. + ev.input_event_sec = tval.tv_sec;
  76. + ev.input_event_usec = tval.tv_usec;
  77. ev.type = EV_KEY;
  78. ev.value = down;
  79. @@ -1230,6 +1247,7 @@ void uinput_pointer_command(int mask, int x, int y, rfbClientPtr client) {
  80. void uinput_key_command(int down, int keysym, rfbClientPtr client) {
  81. #ifdef UINPUT_OK
  82. struct input_event ev;
  83. + struct timeval tval;
  84. int scancode;
  85. allowed_input_t input;
  86. int d = direct_key_fd < 0 ? fd : direct_key_fd;
  87. @@ -1253,7 +1271,9 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) {
  88. if (db) fprintf(stderr, "uinput_key_command: %d -> %d %s fd=%d\n", keysym, scancode, down ? "down" : "up", d);
  89. memset(&ev, 0, sizeof(ev));
  90. - gettimeofday(&ev.time, NULL);
  91. + gettimeofday(&tval, NULL);
  92. + ev.input_event_sec = tval.tv_sec;
  93. + ev.input_event_usec = tval.tv_usec;
  94. ev.type = EV_KEY;
  95. ev.code = (unsigned char) scancode;
  96. ev.value = down;