[PATCH v2 libinput] FreeBSD portability fixes

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 11 04:21:04 UTC 2017


On Fri, Dec 01, 2017 at 04:59:43PM +0300, Greg V wrote:
> ---
>  .gitignore            |  1 +
>  include/linux/input.h |  4 ++++
>  meson.build           | 39 ++++++++++++++++++++++++++++++++++++++-
>  src/libinput-util.h   |  4 ++++
>  test/litest.c         |  9 ++++-----
>  test/litest.h         |  8 ++++++++
>  test/test-pointer.c   |  2 ++
>  7 files changed, 61 insertions(+), 6 deletions(-)
> 
> diff --git a/.gitignore b/.gitignore
> index d35d0c3e..a2ef14cd 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -9,3 +9,4 @@
>  *.gcda
>  *.gcno
>  tags
> +/build
> diff --git a/include/linux/input.h b/include/linux/input.h
> index 06316b27..11ff9cce 100644
> --- a/include/linux/input.h
> +++ b/include/linux/input.h
> @@ -8,10 +8,14 @@
>  #ifndef _INPUT_H
>  #define _INPUT_H
>  
> +#include <config.h>
> +
>  #include <sys/time.h>
>  #include <sys/ioctl.h>
>  #include <sys/types.h>
> +#ifdef __linux__
>  #include <linux/types.h>
> +#endif
>  
>  #include "input-event-codes.h"
>  
> diff --git a/meson.build b/meson.build
> index b82fd42e..29329e6e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -39,6 +39,35 @@ if cc.get_define('static_assert', prefix : prefix) == ''
>  	config_h.set('static_assert(...)', '/* */')
>  endif
>  
> +if not cc.has_header_symbol('errno.h', 'program_invocation_short_name', prefix : prefix)
> +	if cc.has_header_symbol('stdlib.h', 'getprogname')
> +		config_h.set('program_invocation_short_name', 'getprogname()')
> +	endif
> +endif
> +
> +if cc.has_header('xlocale.h')
> +	config_h.set('HAVE_XLOCALE_H', '1')
> +endif
> +
> +if not cc.has_header_symbol('sys/ptrace.h', 'PTRACE_ATTACH', prefix : prefix)
> +	config_h.set('PTRACE_ATTACH', 'PT_ATTACH')
> +	config_h.set('PTRACE_CONT', 'PT_CONTINUE')
> +	config_h.set('PTRACE_DETACH', 'PT_DETACH')
> +endif
> +
> +if target_machine.system() != 'linux'
> +	config_h.set('__u8', 'uint8_t')
> +	config_h.set('__u16', 'uint16_t')
> +	config_h.set('__u32', 'uint32_t')
> +	config_h.set('__u64', 'uint64_t')
> +	config_h.set('__s8', 'int8_t')
> +	config_h.set('__s16', 'int16_t')
> +	config_h.set('__s32', 'int32_t')
> +	config_h.set('__s64', 'int64_t')
> +	config_h.set('_IOC_READ', 'IOC_OUT')
> +	config_h.set('_IOC_WRITE', 'IOC_IN')
> +endif
> +
>  # Dependencies
>  pkgconfig = import('pkgconfig')
>  dep_udev = dependency('libudev')
> @@ -47,6 +76,11 @@ dep_libevdev = dependency('libevdev', version : '>= 0.4')
>  dep_lm = cc.find_library('m', required : false)
>  dep_rt = cc.find_library('rt', required : false)
>  
> +if target_machine.system() != 'linux'
> +	dep_libepoll = declare_dependency(link_args : ['-lepoll-shim'], include_directories : [
> +		include_directories(join_paths(get_option('prefix'), 'include', 'libepoll-shim')) ])

this can't be right. you're looking in the prefix for the include
directories. That should be some external configuration, independent of the
prefix.

> +endif
> +
>  # Include directories
>  includes_include = include_directories('include')
>  includes_src = include_directories('src')
> @@ -193,6 +227,9 @@ deps_libinput = [
>  	dep_libwacom,
>  	dep_libinput_util
>  ]
> +if target_machine.system() != 'linux'
> +	deps_libinput += [ dep_libepoll ]
> +endif
>  
>  libinput_version_h_config = configuration_data()
>  libinput_version_h_config.set('LIBINPUT_VERSION_MAJOR', libinput_version[0])
> @@ -601,7 +638,7 @@ if get_option('tests')
>  		'test/litest.c'
>  	]
>  
> -	dep_dl = cc.find_library('dl')
> +	dep_dl = cc.find_library('dl', required : false)
>  	deps_litest = [
>  		dep_libinput,
>  		dep_check,
> diff --git a/src/libinput-util.h b/src/libinput-util.h
> index 57bcdbb5..6bd95474 100644
> --- a/src/libinput-util.h
> +++ b/src/libinput-util.h
> @@ -31,11 +31,15 @@
>  #include <errno.h>
>  #include <limits.h>
>  #include <locale.h>
> +#ifdef HAVE_XLOCALE_H
> +#include <xlocale.h>
> +#endif
>  #include <math.h>
>  #include <stdarg.h>
>  #include <stdbool.h>
>  #include <stddef.h>
>  #include <stdio.h>
> +#include <stdlib.h>
>  #include <string.h>
>  #include <time.h>
>  #include <unistd.h>
> diff --git a/test/litest.c b/test/litest.c
> index 05726726..fd56347a 100644
> --- a/test/litest.c
> +++ b/test/litest.c
> @@ -42,7 +42,6 @@
>  #include "linux/input.h"
>  #include <sys/ptrace.h>
>  #include <sys/resource.h>
> -#include <sys/sendfile.h>
>  #include <sys/timerfd.h>
>  #include <sys/wait.h>
>  #include <sys/stat.h>
> @@ -1032,7 +1031,7 @@ litest_copy_file(const char *dest, const char *src, const char *header)
>  				 src,
>  				 strerror(errno));
>  	/* lazy, just check for error and empty file copy */
> -	litest_assert_int_gt(sendfile(out, in, NULL, 40960), 0);
> +	litest_assert_int_gt(litest_send_file(out, in), 0);
>  	close(out);
>  	close(in);
>  
> @@ -3537,10 +3536,10 @@ is_debugger_attached(void)
>  
>  	if (pid == 0) {
>  		int ppid = getppid();
> -		if (ptrace(PTRACE_ATTACH, ppid, NULL, NULL) == 0) {
> +		if (ptrace(PTRACE_ATTACH, ppid, NULL, 0) == 0) {
>  			waitpid(ppid, NULL, 0);
> -			ptrace(PTRACE_CONT, NULL, NULL);
> -			ptrace(PTRACE_DETACH, ppid, NULL, NULL);
> +			ptrace(PTRACE_CONT, ppid, NULL, 0);
> +			ptrace(PTRACE_DETACH, ppid, NULL, 0);
>  			rc = 0;
>  		} else {
>  			rc = 1;

split this one out please, I'd rather not have it hidden in a bsd-suppport
patch, thanks.

Cheers,
   Peter


> diff --git a/test/litest.h b/test/litest.h
> index faa469c0..7406c125 100644
> --- a/test/litest.h
> +++ b/test/litest.h
> @@ -1006,6 +1006,14 @@ litest_touchpad_is_external(struct litest_device *dev)
>  	return is_external;
>  }
>  
> +static inline int
> +litest_send_file(int sock, int fd)
> +{
> +	char buf[40960];
> +	int n = read(fd, buf, 40960);
> +	return write(sock, buf, n);
> +}
> +
>  #undef ck_assert_double_eq
>  #undef ck_assert_double_ne
>  #undef ck_assert_double_lt
> diff --git a/test/test-pointer.c b/test/test-pointer.c
> index 7324c0f6..14801aeb 100644
> --- a/test/test-pointer.c
> +++ b/test/test-pointer.c
> @@ -30,7 +30,9 @@
>  #include <libinput.h>
>  #include <math.h>
>  #include <unistd.h>
> +#ifdef __linux__
>  #include <values.h>
> +#endif
>  
>  #include "libinput-util.h"
>  #include "litest.h"
> -- 
> 2.15.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list