]> granicus.if.org Git - strace/commitdiff
evdev: fix build with old kernel headers
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 21 Feb 2015 23:50:33 +0000 (02:50 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 22 Feb 2015 02:29:55 +0000 (02:29 +0000)
* configure.ac: Check whether struct input_absinfo.resolution is defined
in <linux/input.h>.
* evdev.c (SYN_MAX): Add fallback definition.
(abs_ioctl): Wrap use of struct input_absinfo.resolution in #ifdef check.
(keycode_V2_ioctl, mtslots_ioctl, repeat_ioctl): Wrap in #ifdef checks.
(evdev_read_ioctl): Wrap in #ifdef checks the code that uses EV_SW,
EVIOCGREP, EVIOCGKEYCODE_V2, EVIOCGMTSLOTS, EVIOCGPROP, and EVIOCGSW.
(evdev_write_ioctl): Wrap in #ifdef checks the code that uses EVIOCSREP,
EVIOCSKEYCODE_V2, EVIOCSCLOCKID, and EVIOCREVOKE.

configure.ac
evdev.c

index 228ca5f8fd4ef1eb7296fe16e6060dd98a4bdfaf..b21941ea3dd6564dffce7007f55012988865b4af 100644 (file)
@@ -249,7 +249,6 @@ AC_CHECK_HEADERS(m4_normalize([
        linux/falloc.h
        linux/filter.h
        linux/hiddev.h
-       linux/input.h
        linux/mmtimer.h
        linux/perf_event.h
        linux/seccomp.h
@@ -308,6 +307,10 @@ AC_CHECK_HEADERS([libaio.h], [
        AC_CHECK_DECLS([IO_CMD_PWRITE, IO_CMD_PWRITEV],,, [#include <libaio.h>])
 ])
 
+AC_CHECK_HEADERS([linux/input.h], [
+       AC_CHECK_MEMBERS([struct input_absinfo.resolution],,, [#include <linux/input.h>])
+])
+
 AC_CHECK_DECLS([sys_errlist])
 AC_CHECK_DECLS(m4_normalize([
        PTRACE_PEEKUSER,
diff --git a/evdev.c b/evdev.c
index 0faa487bdbbfbfa92cd1e6a67245720b458118aa..e26896fa846fc93499efcad2de4f2f92084792f5 100644 (file)
--- a/evdev.c
+++ b/evdev.c
 #include "xlat/evdev_switch.h"
 #include "xlat/evdev_sync.h"
 
+#ifndef SYN_MAX
+# define SYN_MAX 0xf
+#endif
+
 static void
 decode_envelope(struct ff_envelope *envelope)
 {
@@ -139,8 +143,10 @@ abs_ioctl(struct tcb *tcp, long arg)
        if (!abbrev(tcp)) {
                tprintf(", maximum=%" PRIu32 ", fuzz=%" PRIu32,
                        absinfo.maximum, absinfo.fuzz);
-               tprintf(", flat=%" PRIu32 ", resolution=%" PRIu32,
-                       absinfo.flat, absinfo.resolution);
+               tprintf(", flat=%" PRIu32, absinfo.flat);
+#ifdef HAVE_STRUCT_INPUT_ABSINFO_RESOLUTION
+               tprintf(", resolution=%" PRIu32, absinfo.resolution);
+#endif
                tprints("}");
        } else {
                tprints(", ...}");
@@ -167,6 +173,7 @@ keycode_ioctl(struct tcb *tcp, long arg)
        return 1;
 }
 
+#ifdef EVIOCGKEYCODE_V2
 static int
 keycode_V2_ioctl(struct tcb *tcp, long arg)
 {
@@ -195,6 +202,7 @@ keycode_V2_ioctl(struct tcb *tcp, long arg)
        }
        return 1;
 }
+#endif /* EVIOCGKEYCODE_V2 */
 
 static int
 getid_ioctl(struct tcb *tcp, long arg)
@@ -257,6 +265,7 @@ decode_bitset(struct tcb *tcp, long arg, const struct xlat decode_nr[],
        return 1;
 }
 
+#ifdef EVIOCGMTSLOTS
 static int
 mtslots_ioctl(struct tcb *tcp, const unsigned int code, long arg)
 {
@@ -281,7 +290,9 @@ mtslots_ioctl(struct tcb *tcp, const unsigned int code, long arg)
        tprints("]}");
        return 1;
 }
+#endif /* EVIOCGMTSLOTS */
 
+#ifdef EVIOCGREP
 static int
 repeat_ioctl(struct tcb *tcp, long arg)
 {
@@ -293,6 +304,7 @@ repeat_ioctl(struct tcb *tcp, long arg)
        tprintf(", [%" PRIu32 " %" PRIu32 "]", val[0], val[1]);
        return 1;
 }
+#endif /* EVIOCGREP */
 
 static int
 evdev_read_ioctl(struct tcb *tcp, const unsigned int code, long arg)
@@ -320,9 +332,11 @@ evdev_read_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                        case EV_MSC:
                                return decode_bitset(tcp, arg,
                                                evdev_misc, MSC_MAX, "MSC_???");
+#ifdef EV_SW
                        case EV_SW:
                                return decode_bitset(tcp, arg,
                                                evdev_switch, SW_MAX, "SW_???");
+#endif
                        case EV_LED:
                                return decode_bitset(tcp, arg,
                                                evdev_leds, LED_MAX, "LED_???");
@@ -360,32 +374,42 @@ evdev_read_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                        return 1;
                case EVIOCGID:
                        return getid_ioctl(tcp, arg);
+#ifdef EVIOCGREP
                case EVIOCGREP:
                        return repeat_ioctl(tcp, arg);;
+#endif
                case EVIOCGKEYCODE:
                        return keycode_ioctl(tcp, arg);
+#ifdef EVIOCGKEYCODE_V2
                case EVIOCGKEYCODE_V2:
                        return keycode_V2_ioctl(tcp, arg);
+#endif
        }
 
        switch (_IOC_NR(code)) {
+#ifdef EVIOCGMTSLOTS
                case _IOC_NR(EVIOCGMTSLOTS(0)):
                        return mtslots_ioctl(tcp, code, arg);
+#endif
                case _IOC_NR(EVIOCGNAME(0)):
                case _IOC_NR(EVIOCGPHYS(0)):
                case _IOC_NR(EVIOCGUNIQ(0)):
                        tprints(", ");
                        printstr(tcp, arg, tcp->u_rval - 1);
                        return 1;
+#ifdef EVIOCGPROP
                case _IOC_NR(EVIOCGPROP(0)):
                        return decode_bitset(tcp, arg,
                                        evdev_prop, INPUT_PROP_MAX, "PROP_???");
+#endif
                case _IOC_NR(EVIOCGSND(0)):
                        return decode_bitset(tcp, arg,
                                        evdev_snd, SND_MAX, "SND_???");
+#ifdef EVIOCGSW
                case _IOC_NR(EVIOCGSW(0)):
                        return decode_bitset(tcp, arg,
                                        evdev_switch, SW_MAX, "SW_???");
+#endif
                case _IOC_NR(EVIOCGKEY(0)):
                        return decode_bitset(tcp, arg,
                                        evdev_keycode, KEY_MAX, "KEY_???");
@@ -407,18 +431,26 @@ evdev_write_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                return abs_ioctl(tcp, arg);
 
        switch (code) {
+#ifdef EVIOCSREP
                case EVIOCSREP:
                        return repeat_ioctl(tcp, arg);
+#endif
                case EVIOCSKEYCODE:
                        return keycode_ioctl(tcp, arg);
+#ifdef EVIOCSKEYCODE_V2
                case EVIOCSKEYCODE_V2:
                        return keycode_V2_ioctl(tcp, arg);
+#endif
                case EVIOCSFF:
                        return ff_effect_ioctl(tcp, arg);
                case EVIOCRMFF:
+#ifdef EVIOCSCLOCKID
                case EVIOCSCLOCKID:
+#endif
                case EVIOCGRAB:
+#ifdef EVIOCREVOKE
                case EVIOCREVOKE:
+#endif
                        tprints(", ");
                        printnum_int(tcp, arg, "%u");
                        return 1;