diff -ruN -x '*.orig' -x '*.rej' source-old/include/linux/input.h source/include/linux/input.h --- source-old/include/linux/input.h 2026-02-24 04:13:42.000000000 +0000 +++ source/include/linux/input.h 2026-04-13 23:39:02.335147621 +0100 @@ -2,4 +2,6 @@ #include "linux/input.h" #elif __FreeBSD__ #include "freebsd/input.h" +#else +#include "linux/input.h" #endif diff -ruN -x '*.orig' -x '*.rej' source-old/meson.build source/meson.build --- source-old/meson.build 2026-02-24 04:13:42.000000000 +0000 +++ source/meson.build 2026-04-13 23:39:02.335340571 +0100 @@ -116,7 +116,7 @@ config_h.set('HAVE_VERSIONSORT', '1') endif -if cc.get_define('SYS_pidfd_open', prefix: '#include ') != '' +if cc.has_header('sys/syscall.h') and cc.get_define('SYS_pidfd_open', prefix: '#include ') != '' config_h.set('HAVE_PIDFD_OPEN', '1') endif @@ -162,7 +162,13 @@ # Dependencies pkgconfig = import('pkgconfig') -dep_udev = dependency('libudev') +have_udev = get_option('udev') +if have_udev + config_h.set('HAVE_UDEV', 1) + dep_udev = dependency('libudev') +else + dep_udev = declare_dependency() +endif dep_libevdev = dependency('libevdev', version: '>= 1.10.0') dep_lm = cc.find_library('m', required : false) @@ -228,6 +234,7 @@ ############ udev bits ############ +if have_udev executable('libinput-device-group', 'udev/libinput-device-group.c', dependencies : [dep_udev, dep_libwacom], @@ -272,13 +279,15 @@ output : '90-libinput-fuzz-override-litest.rules', configuration : litest_udev_rules_config) +endif + ############ Check for leftover udev rules ######## # This test should be defined first so we don't waste time testing anything # else if we're about to fail anyway. ninja test will execute tests in the # order of them defined in meson.build -if get_option('tests') +if have_udev and get_option('tests') test('leftover-rules', find_program('test/check-leftover-udev-rules.sh'), is_parallel : false, @@ -351,6 +360,9 @@ 'src/util-strings.c', 'src/util-prop-parsers.c', ] +if not have_udev + src_libinput_util += ['src/libudev-stub.c'] +endif libinput_util = static_library('libinput-util', src_libinput_util, dependencies : [dep_udev, dep_libevdev, dep_libwacom], @@ -491,6 +503,10 @@ dep_libinput = declare_dependency( link_with : lib_libinput, dependencies : deps_libinput) +pkgconfig_requires_private = [] +if have_udev + pkgconfig_requires_private += dep_udev +endif meson.override_dependency('libinput', dep_libinput) @@ -500,7 +516,7 @@ description : 'Input device library', version : meson.project_version(), libraries : lib_libinput, - requires_private : dep_udev, + requires_private : pkgconfig_requires_private, variables : [ 'plugindir=${libdir}/libinput/plugins' ] @@ -537,6 +553,7 @@ dep_libinput_util_libinput = declare_dependency(link_with : libinput_util_libinput) ############ tools ############ +if host_machine.system() != 'redox' libinput_tool_path = dir_libexec config_h.set_quoted('LIBINPUT_TOOL_PATH', libinput_tool_path) tools_shared_sources = [ 'tools/shared.c' ] @@ -838,6 +855,7 @@ install_tag : 'tests', install : true, ) +endif # This is the test suite runner, we allow disabling that one because of # dependencies diff -ruN -x '*.orig' -x '*.rej' source-old/meson_options.txt source/meson_options.txt --- source-old/meson_options.txt 2026-02-24 04:13:42.000000000 +0000 +++ source/meson_options.txt 2026-04-13 23:39:02.335794827 +0100 @@ -2,6 +2,10 @@ type: 'string', value: '', description: 'udev base directory [default=$prefix/lib/udev]') +option('udev', + type: 'boolean', + value: true, + description: 'Enable libudev integration (default=true)') option('epoll-dir', type: 'string', value: '', diff -ruN -x '*.orig' -x '*.rej' source-old/src/timer.c source/src/timer.c --- source-old/src/timer.c 2026-02-24 04:13:42.000000000 +0000 +++ source/src/timer.c 2026-04-13 23:39:02.336885230 +0100 @@ -26,9 +26,19 @@ #include #include #include -#include #include +#if defined(__has_include) +#if __has_include() +#include +#define LIBINPUT_HAVE_TIMERFD 1 +#endif +#endif + +#ifndef LIBINPUT_HAVE_TIMERFD +#define LIBINPUT_HAVE_TIMERFD 0 +#endif + #include "libinput-private.h" #include "timer.h" @@ -63,9 +73,7 @@ static void libinput_timer_arm_timer_fd(struct libinput *libinput) { - int r; struct libinput_timer *timer; - struct itimerspec its = { { 0, 0 }, { 0, 0 } }; uint64_t earliest_expire = UINT64_MAX; list_for_each(timer, &libinput->timer.list, link) { @@ -73,6 +81,12 @@ earliest_expire = timer->expire; } + libinput->timer.next_expiry = earliest_expire; + +#if LIBINPUT_HAVE_TIMERFD + int r; + struct itimerspec its = { { 0, 0 }, { 0, 0 } }; + if (earliest_expire != UINT64_MAX) { its.it_value.tv_sec = earliest_expire / ms2us(1000); its.it_value.tv_nsec = (earliest_expire % ms2us(1000)) * 1000; @@ -83,8 +97,7 @@ log_error(libinput, "timer: timerfd_settime error: %s\n", strerror(errno)); - - libinput->timer.next_expiry = earliest_expire; +#endif } void @@ -170,6 +183,7 @@ static void libinput_timer_dispatch(void *data) { + #if LIBINPUT_HAVE_TIMERFD struct libinput *libinput = data; uint64_t now; uint64_t discard; @@ -187,18 +201,25 @@ return; libinput_timer_handler(libinput, now); + #else + (void)data; + #endif } int libinput_timer_subsys_init(struct libinput *libinput) { + list_init(&libinput->timer.list); + libinput->timer.fd = -1; + libinput->timer.source = NULL; + libinput->timer.next_expiry = 0; + + #if LIBINPUT_HAVE_TIMERFD libinput->timer.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); if (libinput->timer.fd < 0) return -1; - list_init(&libinput->timer.list); - libinput->timer.source = libinput_add_fd(libinput, libinput->timer.fd, libinput_timer_dispatch, @@ -207,6 +228,7 @@ close(libinput->timer.fd); return -1; } + #endif return 0; } @@ -229,8 +251,10 @@ /* All timer users should have destroyed their timers now */ assert(list_empty(&libinput->timer.list)); - libinput_remove_source(libinput, libinput->timer.source); - close(libinput->timer.fd); + if (libinput->timer.source) + libinput_remove_source(libinput, libinput->timer.source); + if (libinput->timer.fd >= 0) + close(libinput->timer.fd); } /** diff -ruN -x '*.orig' -x '*.rej' source-old/src/util-strings.h source/src/util-strings.h --- source-old/src/util-strings.h 2026-02-24 04:13:42.000000000 +0000 +++ source/src/util-strings.h 2026-04-13 23:39:02.337008079 +0100 @@ -288,7 +288,7 @@ } } -#ifdef HAVE_LOCALE_H +#if defined(HAVE_LOCALE_H) && !defined(__redox__) /* Create a "C" locale to force strtod to use '.' as separator */ locale_t c_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); if (c_locale == (locale_t)0) diff -ruN -x '*.orig' -x '*.rej' source-old/src/util-time.h source/src/util-time.h --- source-old/src/util-time.h 2026-02-24 04:13:42.000000000 +0000 +++ source/src/util-time.h 2026-04-13 23:39:02.337090072 +0100 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include