<div dir="ltr">Kamil,<div><br></div><div>Thank you for the patch review. I just submitted a new diff following your suggestions.</div><div><br></div><div>Unfortunately there are some major differences in the way that FreeBSD handles signals</div><div>and return values compared to Linux. This makes directly modifying tests with #ifdefs necessary in</div><div>some cases. I have and will continue to try to keep the tests as untouched as possible, though.</div><div><br></div><div>Thank you,</div><div>Jake Freeland</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 14, 2022 at 3:17 PM Kamil Konieczny <<a href="mailto:kamil.konieczny@linux.intel.com">kamil.konieczny@linux.intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Jake,<br>
<br>
On 2022-09-10 at 19:25:30 -0500, Jake Freeland wrote:<br>
> Signed-off-by: Jake Freeland <<a href="mailto:jfree@freebsd.org" target="_blank">jfree@freebsd.org</a>><br>
> ---<br>
> benchmarks/gem_exec_tracer.c | 4 +<br>
> benchmarks/gem_syslatency.c | 6 ++<br>
> include/linux-uapi/sync_file.h | 5 ++<br>
> lib/i915/gem_mman.c | 4 +-<br>
> lib/i915/intel_memory_region.c | 4 +<br>
> lib/i915/perf.c | 2 +<br>
> lib/igt_audio.c | 4 +<br>
> lib/igt_aux.c | 6 +-<br>
> lib/igt_aux.h | 6 +-<br>
> lib/igt_core.c | 8 +-<br>
> lib/igt_core.h | 5 ++<br>
> lib/igt_debugfs.c | 2 +<br>
> lib/igt_device.c | 2 +<br>
> lib/igt_device_scan.c | 4 +<br>
> lib/igt_eld.c | 4 +<br>
> lib/igt_frame.c | 4 +<br>
> lib/igt_freebsd.h | 123 ++++++++++++++++++++++++++++<br>
> lib/igt_kmod.h | 2 +<br>
> lib/igt_kms.c | 4 +<br>
> lib/igt_os.c | 19 +++++<br>
> lib/igt_perf.c | 2 +<br>
> lib/igt_perf.h | 4 +<br>
> lib/igt_pm.c | 2 +<br>
> lib/igt_sysfs.c | 2 +<br>
> lib/igt_vgem.c | 2 +-<br>
> lib/tests/igt_exit_handler.c | 4 +<br>
> lib/tests/igt_fork.c | 2 +-<br>
> lib/tests/igt_tests_common.h | 9 ++<br>
> runner/executor.c | 6 ++<br>
> runner/job_list.c | 5 ++<br>
> tests/i915/gem_close_race.c | 2 +<br>
> tests/i915/gem_mmap_gtt.c | 24 +++---<br>
> tests/i915/gem_mmap_offset.c | 16 ++--<br>
> tests/i915/i915_module_load.c | 2 +<br>
> tests/i915/i915_pm_backlight.c | 4 +<br>
> tests/i915/i915_pm_rpm.c | 8 ++<br>
> tests/kms_content_protection.c | 2 +<br>
> tests/kms_flip.c | 4 +<br>
> tests/kms_sysfs_edid_timing.c | 4 +<br>
> tests/tools_test.c | 10 ++-<br>
> tools/i915-perf/i915_perf_control.c | 2 +-<br>
> tools/intel_gvtg_test.c | 4 +<br>
> 42 files changed, 301 insertions(+), 37 deletions(-)<br>
> create mode 100644 lib/igt_freebsd.h<br>
> <br>
> diff --git a/benchmarks/gem_exec_tracer.c b/benchmarks/gem_exec_tracer.c<br>
> index e6973991..7e86473e 100644<br>
> --- a/benchmarks/gem_exec_tracer.c<br>
> +++ b/benchmarks/gem_exec_tracer.c<br>
> @@ -41,6 +41,10 @@<br>
> #include "intel_aub.h"<br>
> #include "intel_chipset.h"<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include "igt_freebsd.h"<br>
> +#endif<br>
> +<br>
<br>
Is it possible to keep changes as minimal as possible ?<br>
E.g. change as much as you can in libs and/or includes, so you<br>
can do not touch tests or benchmarks ?<br>
<br>
> static int (*libc_close)(int fd);<br>
> static int (*libc_ioctl)(int fd, unsigned long request, void *argp);<br>
> <br>
> diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c<br>
> index 035ee934..dafc6ac0 100644<br>
> --- a/benchmarks/gem_syslatency.c<br>
> +++ b/benchmarks/gem_syslatency.c<br>
> @@ -42,12 +42,18 @@<br>
> #include <limits.h><br>
> #include "drm.h"<br>
> <br>
> +#ifdef __linux__<br>
> #include <linux/unistd.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include "igt_freebsd.h"<br>
> +#endif<br>
> <br>
> #include "i915/gem_create.h"<br>
> #include "i915/gem_ring.h"<br>
> <br>
> +#ifdef __linux__<br>
> #define sigev_notify_thread_id _sigev_un._tid<br>
> +#endif<br>
> <br>
> static volatile int done;<br>
> <br>
> diff --git a/include/linux-uapi/sync_file.h b/include/linux-uapi/sync_file.h<br>
> index b4f2db00..270c1cbc 100644<br>
> --- a/include/linux-uapi/sync_file.h<br>
> +++ b/include/linux-uapi/sync_file.h<br>
> @@ -12,8 +12,13 @@<br>
> #ifndef _LINUX_SYNC_H<br>
> #define _LINUX_SYNC_H<br>
> <br>
> +#ifdef __linux__<br>
> #include <linux/ioctl.h><br>
> #include <linux/types.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include <sys/ioctl.h><br>
> +#include "igt_freebsd.h"<br>
> +#endif<br>
> <br>
> /**<br>
> * struct sync_merge_data - data passed to merge ioctl<br>
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c<br>
> index aa9ac6f3..0b41ba70 100644<br>
> --- a/lib/i915/gem_mman.c<br>
> +++ b/lib/i915/gem_mman.c<br>
> @@ -118,7 +118,7 @@ void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)<br>
> if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))<br>
> return NULL;<br>
> <br>
> - ptr = mmap64(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);<br>
> + ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);<br>
<br>
Please move all mmap changes to separate patch, it will improve<br>
readeability.<br>
<br>
> if (ptr == MAP_FAILED)<br>
> ptr = NULL;<br>
> else<br>
> @@ -331,7 +331,7 @@ void *__gem_mmap_offset(int fd, uint32_t handle, uint64_t offset, uint64_t size,<br>
> if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &arg))<br>
> return NULL;<br>
> <br>
> - ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset + offset);<br>
> + ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset + offset);<br>
> <br>
> if (ptr == MAP_FAILED)<br>
> ptr = NULL;<br>
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c<br>
> index 93a18982..ca7f9140 100644<br>
> --- a/lib/i915/intel_memory_region.c<br>
> +++ b/lib/i915/intel_memory_region.c<br>
> @@ -21,7 +21,11 @@<br>
> * IN THE SOFTWARE.<br>
> */<br>
> <br>
> +#ifdef __linux__<br>
> #include <linux/limits.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include <limits.h><br>
> +#endif<br>
> #include <signal.h><br>
> #include <sys/ioctl.h><br>
> #include <sys/time.h><br>
> diff --git a/lib/i915/perf.c b/lib/i915/perf.c<br>
> index d88835ff..beda6b8a 100644<br>
> --- a/lib/i915/perf.c<br>
> +++ b/lib/i915/perf.c<br>
> @@ -29,7 +29,9 @@<br>
> #include <fcntl.h><br>
> #include <sys/ioctl.h><br>
> #include <sys/stat.h><br>
> +#ifdef __linux__<br>
> #include <sys/sysmacros.h><br>
> +#endif<br>
> #include <sys/types.h><br>
> #include <unistd.h><br>
> <br>
> diff --git a/lib/igt_audio.c b/lib/igt_audio.c<br>
> index e0b1bafe..201a39c6 100644<br>
> --- a/lib/igt_audio.c<br>
> +++ b/lib/igt_audio.c<br>
> @@ -26,6 +26,10 @@<br>
> <br>
> #include "config.h"<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <limits.h><br>
> +#endif<br>
> +<br>
> #include <errno.h><br>
> #include <fcntl.h><br>
> #include <gsl/gsl_fft_real.h><br>
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c<br>
> index edb53425..ba2d52e8 100644<br>
> --- a/lib/igt_aux.c<br>
> +++ b/lib/igt_aux.c<br>
> @@ -52,7 +52,9 @@<br>
> #include <assert.h><br>
> #include <grp.h><br>
> <br>
> +#ifdef __linux__<br>
> #include <proc/readproc.h><br>
> +#endif<br>
> #include <libudev.h><br>
> <br>
> #include "drmtest.h"<br>
> @@ -323,10 +325,10 @@ void igt_fork_signal_helper(void)<br>
> * and we send the signal at exactly the wrong time).<br>
> */<br>
> signal(SIGCONT, sig_handler);<br>
> - setpgrp(); /* define a new process group for the tests */<br>
> + setpgid(0, 0); /* define a new process group for the tests */<br>
> <br>
> igt_fork_helper(&signal_helper) {<br>
> - setpgrp(); /* Escape from the test process group */<br>
> + setpgid(0, 0); /* Escape from the test process group */<br>
> <br>
> /* Pass along the test process group identifier,<br>
> * negative pid => send signal to everyone in the group.<br>
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h<br>
> index c8d487b6..912f36c1 100644<br>
> --- a/lib/igt_aux.h<br>
> +++ b/lib/igt_aux.h<br>
> @@ -34,9 +34,7 @@<br>
> #include <sys/time.h><br>
> #include <sys/types.h><br>
> #include <unistd.h><br>
> -#ifdef __linux__<br>
> -# include <sys/syscall.h><br>
> -#endif<br>
> +#include <sys/syscall.h><br>
> <br>
> #include <i915/gem_submission.h><br>
> <br>
> @@ -48,8 +46,8 @@<br>
> # ifndef HAVE_GETTID<br>
> # define gettid() (pid_t)(syscall(__NR_gettid))<br>
> # endif<br>
> -#endif<br>
> #define sigev_notify_thread_id _sigev_un._tid<br>
> +#endif<br>
> <br>
> /* auxialiary igt helpers from igt_aux.c */<br>
> /* generally useful helpers */<br>
> diff --git a/lib/igt_core.c b/lib/igt_core.c<br>
> index e7425326..17d5e013 100644<br>
> --- a/lib/igt_core.c<br>
> +++ b/lib/igt_core.c<br>
> @@ -43,9 +43,7 @@<br>
> #include <unistd.h><br>
> #include <sys/wait.h><br>
> #include <sys/types.h><br>
> -#ifdef __linux__<br>
> #include <sys/syscall.h><br>
> -#endif<br>
> #include <pthread.h><br>
> #include <sys/utsname.h><br>
> #include <termios.h><br>
> @@ -786,6 +784,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)<br>
> <br>
> static void oom_adjust_for_doom(void)<br>
> {<br>
> +#ifdef __linux__<br>
> int fd;<br>
> const char always_kill[] = "1000";<br>
> <br>
> @@ -793,7 +792,7 @@ static void oom_adjust_for_doom(void)<br>
> igt_assert(fd != -1);<br>
> igt_assert(write(fd, always_kill, sizeof(always_kill)) == sizeof(always_kill));<br>
> close(fd);<br>
> -<br>
> +#endif<br>
> }<br>
> <br>
> /**<br>
> @@ -2224,6 +2223,9 @@ bool __igt_fork_helper(struct igt_helper_process *proc)<br>
> case 0:<br>
> reset_helper_process_list();<br>
> oom_adjust_for_doom();<br>
> +#ifdef __FreeBSD__<br>
> + raise(SIGTERM);<br>
> +#endif<br>
> <br>
> return true;<br>
> default:<br>
> diff --git a/lib/igt_core.h b/lib/igt_core.h<br>
> index aa98e8ed..295bb5d9 100644<br>
> --- a/lib/igt_core.h<br>
> +++ b/lib/igt_core.h<br>
> @@ -31,7 +31,9 @@<br>
> #define IGT_CORE_H<br>
> <br>
> #include <assert.h><br>
> +#ifdef __linux__<br>
> #include <byteswap.h><br>
> +#endif<br>
> #include <setjmp.h><br>
> #include <stdbool.h><br>
> #include <stdint.h><br>
> @@ -47,6 +49,9 @@<br>
> #define IGT_LOG_DOMAIN (NULL)<br>
> #endif<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include "igt_freebsd.h"<br>
> +#endif<br>
> <br>
> #ifndef STATIC_ANALYSIS_BUILD<br>
> #if defined(__clang_analyzer__) || defined(__COVERITY__) || defined(__KLOCWORK__)<br>
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c<br>
> index a56688a5..fa1e3b69 100644<br>
> --- a/lib/igt_debugfs.c<br>
> +++ b/lib/igt_debugfs.c<br>
> @@ -25,7 +25,9 @@<br>
> #include <inttypes.h><br>
> #include <sys/stat.h><br>
> #include <sys/mount.h><br>
> +#ifdef __linux__<br>
> #include <sys/sysmacros.h><br>
> +#endif<br>
> #include <dirent.h><br>
> #include <errno.h><br>
> #include <stdio.h><br>
> diff --git a/lib/igt_device.c b/lib/igt_device.c<br>
> index fddfba72..49b77122 100644<br>
> --- a/lib/igt_device.c<br>
> +++ b/lib/igt_device.c<br>
> @@ -25,7 +25,9 @@<br>
> #include <fcntl.h><br>
> <br>
> #include <sys/stat.h><br>
> +#ifdef __linux__<br>
> #include <sys/sysmacros.h><br>
> +#endif<br>
> #include "igt.h"<br>
> #include "igt_device.h"<br>
> #include "igt_sysfs.h"<br>
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c<br>
> index eb6b45b8..6a921d52 100644<br>
> --- a/lib/igt_device_scan.c<br>
> +++ b/lib/igt_device_scan.c<br>
> @@ -32,7 +32,11 @@<br>
> #include <fcntl.h><br>
> #include <glib.h><br>
> #include <libudev.h><br>
> +#ifdef __linux__<br>
> #include <linux/limits.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include <limits.h><br>
> +#endif<br>
> #include <sys/stat.h><br>
> #include <sys/time.h><br>
> #include <sys/types.h><br>
> diff --git a/lib/igt_eld.c b/lib/igt_eld.c<br>
> index ef6625df..e05ad6de 100644<br>
> --- a/lib/igt_eld.c<br>
> +++ b/lib/igt_eld.c<br>
> @@ -23,6 +23,10 @@<br>
> * Authors: Simon Ser <<a href="mailto:simon.ser@intel.com" target="_blank">simon.ser@intel.com</a>><br>
> */<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <limits.h><br>
> +#endif<br>
> +<br>
> #include "config.h"<br>
> <br>
> #include <dirent.h><br>
> diff --git a/lib/igt_frame.c b/lib/igt_frame.c<br>
> index 45523a79..ab74e678 100644<br>
> --- a/lib/igt_frame.c<br>
> +++ b/lib/igt_frame.c<br>
> @@ -24,6 +24,10 @@<br>
> * Paul Kocialkowski <<a href="mailto:paul.kocialkowski@linux.intel.com" target="_blank">paul.kocialkowski@linux.intel.com</a>><br>
> */<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <limits.h><br>
> +#endif<br>
> +<br>
> #include "config.h"<br>
> <br>
> #include <fcntl.h><br>
> diff --git a/lib/igt_freebsd.h b/lib/igt_freebsd.h<br>
> new file mode 100644<br>
> index 00000000..ea2603e4<br>
> --- /dev/null<br>
> +++ b/lib/igt_freebsd.h<br>
> @@ -0,0 +1,123 @@<br>
> +/*<br>
> + * Copyright © 2022 Intel Corporation<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice (including the next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
> + * IN THE SOFTWARE.<br>
<br>
Please use SPDX licence.<br>
<br>
> + *<br>
> + * Authors:<br>
> + * Jake Freeland <<a href="mailto:jfree@freebsd.org" target="_blank">jfree@freebsd.org</a>><br>
> + *<br>
> + */<br>
> +<br>
> +#if !defined(IGT_FREEBSD_H) && defined(__FreeBSD__)<br>
> +#define IGT_FREEBSD_H<br>
> +<br>
> +#include <sys/errno.h><br>
> +#include <sys/mman.h><br>
> +#include <sys/mount.h><br>
> +#include <sys/sched.h><br>
> +#include <sys/types.h><br>
> +#include <sys/watchdog.h><br>
> +<br>
> +#include <pthread.h><br>
> +#include <setjmp.h><br>
> +#include <signal.h><br>
> +#include <unistd.h><br>
> +<br>
> +/*<br>
> + * Proper substitutions:<br>
> + * The following macros replace Linux-specific functions<br>
> + * and macros with their FreeBSD equivalents.<br>
> + */<br>
> +<br>
> +#define __s32 int32_t<br>
> +#define __u32 uint32_t<br>
> +#define __u64 uint64_t<br>
> +<br>
> +#define sighandler_t sig_t<br>
> +#define ino64_t ino_t<br>
> +<br>
> +#define jmp_buf sigjmp_buf<br>
> +<br>
> +#define PTRACE_TRACEME PT_TRACE_ME<br>
> +#define PTRACE_ATTACH PT_ATTACH<br>
> +#define PTRACE_PEEKDATA PT_READ_D<br>
> +#define PTRACE_POKEDATA PT_WRITE_D<br>
> +#define PTRACE_DETACH PT_DETACH<br>
> +<br>
> +#define I2C_RDWR I2CRDWR<br>
> +#define I2C_M_RD IIC_M_RD<br>
> +#define i2c_msg iic_msg<br>
> +#define i2c_rdwr_ioctl_data iic_rdwr_data<br>
> +<br>
> +#define _IOC_TYPE(nr) (((nr) >> 8) & 255)<br>
> +<br>
> +#define SYS_getdents64 SYS_freebsd11_getdents<br>
> +<br>
> +#define mount(src, dest, fstype, flags, data) \<br>
> + mount(fstype, dest, flags, data)<br>
> +<br>
> +/*<br>
> + * Improper substitutions:<br>
> + * The following macros are temporary replacements for functions<br>
> + * and macros that exist on Linux and do not exist on FreeBSD.<br>
> + */<br>
> +<br>
> +#define ETIME ETIMEDOUT<br>
> +<br>
> +#define MAP_POPULATE MAP_PREFAULT_READ<br>
> +<br>
> +#define MADV_HUGEPAGE MADV_SEQUENTIAL<br>
> +#define MADV_DONTFORK MADV_NOSYNC<br>
> +<br>
> +#define WDIOC_KEEPALIVE WDIOCPATPAT<br>
> +<br>
> +#define SCHED_RESET_ON_FORK 0<br>
> +#define SCHED_IDLE SCHED_OTHER<br>
> +<br>
> +#define gettid() getpid()<br>
> +<br>
> +#define pthread_sigqueue(pid, signo, value) \<br>
> + sigqueue(pid, signo, value)<br>
> +<br>
> +#define signalfd(fd, mask, flags) -ENOSYS<br>
> +#define timerfd_create(c, f) -ENOSYS<br>
> +#define timerfd_settime(fd, f, n, o) -ENOSYS<br>
> +<br>
> +/*<br>
> + * Macro conflict resolution.<br>
> + */<br>
> +<br>
> +#undef ALIGN<br>
> +#undef PAGE_SIZE<br>
> +<br>
> +struct signalfd_siginfo {<br>
> + uint32_t ssi_signo;<br>
> + uint32_t ssi_pid;<br>
> +};<br>
> +<br>
> +struct kmod_module {<br>
> + size_t size;<br>
> +};<br>
> +<br>
> +typedef struct {<br>
> + char state;<br>
> +} proc_t;<br>
> +<br>
> +#endif /* IGT_FREEBSD_H */<br>
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h<br>
> index f98dd29f..6596092b 100644<br>
> --- a/lib/igt_kmod.h<br>
> +++ b/lib/igt_kmod.h<br>
> @@ -24,7 +24,9 @@<br>
> #ifndef IGT_KMOD_H<br>
> #define IGT_KMOD_H<br>
> <br>
> +#ifdef __linux__<br>
> #include <libkmod.h><br>
> +#endif<br>
> <br>
> #include "igt_list.h"<br>
> <br>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c<br>
> index 1ba3bd2a..f0208c10 100644<br>
> --- a/lib/igt_kms.c<br>
> +++ b/lib/igt_kms.c<br>
> @@ -43,6 +43,10 @@<br>
> #include <sys/kd.h><br>
> #endif<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <sys/consio.h><br>
> +#endif<br>
> +<br>
> #include <libudev.h><br>
> #include <poll.h><br>
> #include <errno.h><br>
> diff --git a/lib/igt_os.c b/lib/igt_os.c<br>
> index bdd5d933..ae426e3a 100644<br>
> --- a/lib/igt_os.c<br>
> +++ b/lib/igt_os.c<br>
> @@ -44,6 +44,9 @@<br>
> #include <sys/sysinfo.h><br>
> #elif defined(HAVE_SWAPCTL) /* Solaris */<br>
> #include <sys/swap.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include <sys/sysctl.h><br>
> +#include <sys/types.h><br>
> #endif<br>
> #include <sys/resource.h><br>
> <br>
> @@ -148,6 +151,15 @@ igt_get_avail_ram_mb(void)<br>
> npages = sysconf(_SC_AVPHYS_PAGES);<br>
> <br>
> retval = (uint64_t) pagesize * npages;<br>
> +#elif defined(__FreeBSD__) /* FreeBSD */<br>
-------------------------------- ^<br>
You do not need to repeat it here.<br>
<br>
> + uint64_t npages, pagesize;<br>
> + size_t npages_len = sizeof(npages);<br>
> + size_t pagesize_len = sizeof(pagesize);<br>
> +<br>
> + sysctlbyname("vm.stats.vm.v_free_count", &npages, &npages_len, NULL, 0);<br>
> + sysctlbyname("vm.stats.vm.v_page_size", &pagesize, &pagesize_len, NULL, 0);<br>
> +<br>
> + retval = pagesize * npages;<br>
> #else<br>
> #error "Unknown how to get available RAM for this OS"<br>
> #endif<br>
> @@ -210,6 +222,13 @@ igt_get_total_swap_mb(void)<br>
> free(buf);<br>
> <br>
> retval = (uint64_t) pagesize * totalpages;<br>
> +#elif defined(__FreeBSD__) /* FreeBSD */<br>
-------------------------------- ^<br>
Same here.<br>
<br>
Regards,<br>
Kamil<br>
<br>
<br>
> + uint64_t swap_total;<br>
> + size_t swap_total_len = sizeof(swap_total);<br>
> +<br>
> + sysctlbyname("vm.swap_total", &swap_total, &swap_total_len, NULL, 0);<br>
> +<br>
> + retval = swap_total;<br>
> #else<br>
> #warning "Unknown how to get swap size for this OS"<br>
> return 0;<br>
> diff --git a/lib/igt_perf.c b/lib/igt_perf.c<br>
> index b743859f..11c91c5f 100644<br>
> --- a/lib/igt_perf.c<br>
> +++ b/lib/igt_perf.c<br>
> @@ -4,8 +4,10 @@<br>
> #include <stdlib.h><br>
> #include <string.h><br>
> #include <sys/stat.h><br>
> +#ifdef __linux__<br>
> #include <sys/sysinfo.h><br>
> #include <sys/sysmacros.h><br>
> +#endif<br>
> #include <time.h><br>
> #include <unistd.h><br>
> <br>
> diff --git a/lib/igt_perf.h b/lib/igt_perf.h<br>
> index a8328c70..0cd91386 100644<br>
> --- a/lib/igt_perf.h<br>
> +++ b/lib/igt_perf.h<br>
> @@ -27,10 +27,13 @@<br>
> <br>
> #include <stdint.h><br>
> <br>
> +#ifdef __linux__<br>
> #include <linux/perf_event.h><br>
> +#endif<br>
> <br>
> #include "igt_gt.h"<br>
> <br>
> +#ifdef __linux__<br>
> static inline int<br>
> perf_event_open(struct perf_event_attr *attr,<br>
> pid_t pid,<br>
> @@ -50,6 +53,7 @@ perf_event_open(struct perf_event_attr *attr,<br>
> attr->size = sizeof(*attr);<br>
> return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags);<br>
> }<br>
> +#endif /* __linux__ */<br>
> <br>
> uint64_t igt_perf_type_id(const char *device);<br>
> int igt_perf_open(uint64_t type, uint64_t config);<br>
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c<br>
> index 99251b40..a6036e03 100644<br>
> --- a/lib/igt_pm.c<br>
> +++ b/lib/igt_pm.c<br>
> @@ -33,7 +33,9 @@<br>
> #include <string.h><br>
> #include <unistd.h><br>
> #include <sys/stat.h><br>
> +#ifdef __linux__<br>
> #include <sys/sysmacros.h><br>
> +#endif<br>
> #include <sys/types.h><br>
> #include <dirent.h><br>
> <br>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c<br>
> index 9c307694..a913be4c 100644<br>
> --- a/lib/igt_sysfs.c<br>
> +++ b/lib/igt_sysfs.c<br>
> @@ -24,7 +24,9 @@<br>
> <br>
> #include <inttypes.h><br>
> #include <sys/stat.h><br>
> +#ifdef __linux__<br>
> #include <sys/sysmacros.h><br>
> +#endif<br>
> #include <sys/mount.h><br>
> #include <errno.h><br>
> #include <stdarg.h><br>
> diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c<br>
> index 7f933b23..468383c7 100644<br>
> --- a/lib/igt_vgem.c<br>
> +++ b/lib/igt_vgem.c<br>
> @@ -76,7 +76,7 @@ void *__vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot)<br>
> if (drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg))<br>
> return NULL;<br>
> <br>
> - ptr = mmap64(0, bo->size, prot, MAP_SHARED, fd, arg.offset);<br>
> + ptr = mmap(0, bo->size, prot, MAP_SHARED, fd, arg.offset);<br>
> if (ptr == MAP_FAILED)<br>
> return NULL;<br>
> <br>
> diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c<br>
> index 892a7f14..d2381944 100644<br>
> --- a/lib/tests/igt_exit_handler.c<br>
> +++ b/lib/tests/igt_exit_handler.c<br>
> @@ -125,5 +125,9 @@ int main(int argc, char **argv)<br>
> internal_assert_wexited(status, IGT_EXIT_SKIP);<br>
> <br>
> status = testfunc(SIG);<br>
> +#ifdef __linux__<br>
> internal_assert_wsignaled(status, SIGTERM);<br>
> +#elif defined(__FreeBSD__)<br>
> + internal_assert(status == 0);<br>
> +#endif<br>
> }<br>
> diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c<br>
> index d19d0945..c7193b06 100644<br>
> --- a/lib/tests/igt_fork.c<br>
> +++ b/lib/tests/igt_fork.c<br>
> @@ -109,7 +109,7 @@ __noreturn static void igt_fork_timeout_leak(void)<br>
> __noreturn static void subtest_leak(void)<br>
> {<br>
> pid_t *children =<br>
> - mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> + mmap(0, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANON, -1, 0);<br>
> const int num_children = 4096 / sizeof(*children);<br>
> <br>
> igt_subtest_init(fake_argc, fake_argv);<br>
> diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h<br>
> index 058f6265..e8183897 100644<br>
> --- a/lib/tests/igt_tests_common.h<br>
> +++ b/lib/tests/igt_tests_common.h<br>
> @@ -48,8 +48,17 @@ static inline void internal_assert_wexited(int wstatus, int exitcode)<br>
> <br>
> static inline void internal_assert_wsignaled(int wstatus, int signal)<br>
> {<br>
> +#ifdef __linux__<br>
> internal_assert(WIFSIGNALED(wstatus) &&<br>
> WTERMSIG(wstatus) == signal);<br>
> +#elif defined(__FreeBSD__)<br>
> + if (WIFSIGNALED(wstatus))<br>
> + internal_assert(WTERMSIG(wstatus) == signal);<br>
> + else if (WIFEXITED(wstatus))<br>
> + internal_assert(WEXITSTATUS(wstatus) == signal + 128);<br>
> + else<br>
> + internal_assert(0);<br>
> +#endif<br>
> }<br>
> <br>
> static inline void internal_assert_not_wsignaled(int wstatus)<br>
> diff --git a/runner/executor.c b/runner/executor.c<br>
> index 964d0063..c54072cf 100644<br>
> --- a/runner/executor.c<br>
> +++ b/runner/executor.c<br>
> @@ -2,7 +2,9 @@<br>
> #include <errno.h><br>
> #include <fcntl.h><br>
> #include <glib.h><br>
> +#ifdef __linux__<br>
> #include <linux/watchdog.h><br>
> +#endif<br>
> #if HAVE_OPING<br>
> #include <oping.h><br>
> #endif<br>
> @@ -33,6 +35,10 @@<br>
> #define KMSG_HEADER "[IGT] "<br>
> #define KMSG_WARN 4<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <sys/watchdog.h><br>
> +#endif<br>
> +<br>
> static struct {<br>
> int *fds;<br>
> size_t num_dogs;<br>
> diff --git a/runner/job_list.c b/runner/job_list.c<br>
> index 520a98da..6bfa7162 100644<br>
> --- a/runner/job_list.c<br>
> +++ b/runner/job_list.c<br>
> @@ -1,7 +1,12 @@<br>
> #include <ctype.h><br>
> #include <errno.h><br>
> #include <fcntl.h><br>
> +#ifdef __linux__<br>
> #include <linux/limits.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include <sys/wait.h><br>
> +#include <limits.h><br>
> +#endif<br>
> #include <stdio.h><br>
> #include <stdlib.h><br>
> #include <string.h><br>
> diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c<br>
> index 938fde8f..42fe1657 100644<br>
> --- a/tests/i915/gem_close_race.c<br>
> +++ b/tests/i915/gem_close_race.c<br>
> @@ -61,7 +61,9 @@ static bool has_softpin;<br>
> static uint64_t exec_addr;<br>
> static uint64_t data_addr;<br>
> <br>
> +#ifdef __linux__<br>
> #define sigev_notify_thread_id _sigev_un._tid<br>
> +#endif<br>
> <br>
> static void selfcopy(int fd, uint32_t ctx, uint32_t handle, int loops)<br>
> {<br>
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c<br>
> index e39b9047..683eaf16 100644<br>
> --- a/tests/i915/gem_mmap_gtt.c<br>
> +++ b/tests/i915/gem_mmap_gtt.c<br>
> @@ -113,11 +113,11 @@ test_access(int fd)<br>
> mmap_arg.handle = handle;<br>
> do_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);<br>
> <br>
> - igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> + igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> MAP_SHARED, fd, mmap_arg.offset));<br>
> <br>
> /* Check that the same offset on the other fd doesn't work. */<br>
> - igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> + igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> MAP_SHARED, fd2, mmap_arg.offset) == MAP_FAILED);<br>
> igt_assert(errno == EACCES);<br>
> <br>
> @@ -128,7 +128,7 @@ test_access(int fd)<br>
> <br>
> /* Recheck that it works after flink. */<br>
> /* Check that the same offset on the other fd doesn't work. */<br>
> - igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> + igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> MAP_SHARED, fd2, mmap_arg.offset));<br>
> }<br>
> <br>
> @@ -159,11 +159,11 @@ test_short(int fd)<br>
> for (pages = 1; pages <= OBJECT_SIZE / PAGE_SIZE; pages <<= 1) {<br>
> uint8_t *r, *w;<br>
> <br>
> - w = mmap64(0, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,<br>
> + w = mmap(0, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,<br>
> MAP_SHARED, fd, mmap_arg.offset);<br>
> igt_assert(w != MAP_FAILED);<br>
> <br>
> - r = mmap64(0, pages * PAGE_SIZE, PROT_READ,<br>
> + r = mmap(0, pages * PAGE_SIZE, PROT_READ,<br>
> MAP_SHARED, fd, mmap_arg.offset);<br>
> igt_assert(r != MAP_FAILED);<br>
> <br>
> @@ -384,13 +384,13 @@ test_isolation(int i915)<br>
> <br>
> close(B);<br>
> <br>
> - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> igt_assert(ptr != MAP_FAILED);<br>
> munmap(ptr, 4096);<br>
> <br>
> close(A);<br>
> <br>
> - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> igt_assert(ptr == MAP_FAILED);<br>
> }<br>
> <br>
> @@ -400,7 +400,7 @@ test_close_race(int i915)<br>
> const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);<br>
> _Atomic uint32_t *handles;<br>
> <br>
> - handles = mmap64(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> + handles = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> igt_assert(handles != MAP_FAILED);<br>
> <br>
> igt_fork(child, ncpus + 1) {<br>
> @@ -418,7 +418,7 @@ test_close_race(int i915)<br>
> &mmap_arg) != -1) {<br>
> void *ptr;<br>
> <br>
> - ptr = mmap64(0, 4096,<br>
> + ptr = mmap(0, 4096,<br>
> PROT_WRITE, MAP_SHARED, i915,<br>
> mmap_arg.offset);<br>
> if (ptr != MAP_FAILED) {<br>
> @@ -444,7 +444,7 @@ test_flink_race(int i915)<br>
> const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);<br>
> _Atomic uint32_t *handles;<br>
> <br>
> - handles = mmap64(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> + handles = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> igt_assert(handles != MAP_FAILED);<br>
> <br>
> igt_fork(child, ncpus + 1) {<br>
> @@ -469,7 +469,7 @@ test_flink_race(int i915)<br>
> &mmap_arg) != -1) {<br>
> void *ptr;<br>
> <br>
> - ptr = mmap64(0, 4096,<br>
> + ptr = mmap(0, 4096,<br>
> PROT_WRITE, MAP_SHARED, fd,<br>
> mmap_arg.offset);<br>
> if (ptr != MAP_FAILED) {<br>
> @@ -566,7 +566,7 @@ test_ptrace(int fd)<br>
> for (int i = 0; i < sz / sizeof(long); i++) {<br>
> long ret;<br>
> <br>
> - ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i);<br>
> + ret = ptrace(PTRACE_PEEKDATA, pid, gtt + i, NULL);<br>
> igt_assert_eq_u64(ret, CC);<br>
> cpy[i] = ret;<br>
> <br>
> diff --git a/tests/i915/gem_mmap_offset.c b/tests/i915/gem_mmap_offset.c<br>
> index 5e6b19eb..0933ed94 100644<br>
> --- a/tests/i915/gem_mmap_offset.c<br>
> +++ b/tests/i915/gem_mmap_offset.c<br>
> @@ -66,7 +66,7 @@ __mmap_offset(int i915, uint32_t handle, uint64_t offset, uint64_t size,<br>
> if (mmap_offset_ioctl(i915, &arg))<br>
> return NULL;<br>
> <br>
> - ptr = mmap64(0, size, prot, MAP_SHARED, i915, arg.offset + offset);<br>
> + ptr = mmap(0, size, prot, MAP_SHARED, i915, arg.offset + offset);<br>
> if (ptr == MAP_FAILED)<br>
> ptr = NULL;<br>
> else<br>
> @@ -214,12 +214,12 @@ static void isolation(int i915)<br>
> t->name, B, b, offset_b);<br>
> <br>
> errno = 0;<br>
> - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, i915, offset_a);<br>
> + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, i915, offset_a);<br>
> igt_assert(ptr == MAP_FAILED);<br>
> igt_assert_eq(errno, EACCES);<br>
> <br>
> errno = 0;<br>
> - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, i915, offset_b);<br>
> + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, i915, offset_b);<br>
> igt_assert(ptr == MAP_FAILED);<br>
> igt_assert_eq(errno, EACCES);<br>
> <br>
> @@ -237,13 +237,13 @@ static void isolation(int i915)<br>
> <br>
> close(B);<br>
> <br>
> - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> igt_assert(ptr != MAP_FAILED);<br>
> munmap(ptr, 4096);<br>
> <br>
> close(A);<br>
> <br>
> - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> igt_assert(ptr == MAP_FAILED);<br>
> }<br>
> }<br>
> @@ -370,7 +370,7 @@ static void test_ptrace(int i915)<br>
> for (int i = 0; i < SZ / sizeof(long); i++) {<br>
> long ret;<br>
> <br>
> - ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i);<br>
> + ret = ptrace(PTRACE_PEEKDATA, pid, ptr + i, NULL);<br>
> igt_assert_eq_u64(ret, CC);<br>
> cpy[i] = ret;<br>
> <br>
> @@ -401,7 +401,7 @@ static void close_race(int i915, int timeout)<br>
> _Atomic uint32_t *handles;<br>
> size_t len = ALIGN((ncpus + 1) * sizeof(uint32_t), 4096);<br>
> <br>
> - handles = mmap64(0, len, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> + handles = mmap(0, len, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> igt_assert(handles != MAP_FAILED);<br>
> <br>
> igt_fork(child, ncpus + 1) {<br>
> @@ -420,7 +420,7 @@ static void close_race(int i915, int timeout)<br>
> &mmap_arg) != -1) {<br>
> void *ptr;<br>
> <br>
> - ptr = mmap64(0, 4096,<br>
> + ptr = mmap(0, 4096,<br>
> PROT_WRITE, MAP_SHARED, i915,<br>
> mmap_arg.offset);<br>
> if (ptr != MAP_FAILED) {<br>
> diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c<br>
> index 4c72157c..9bec4c18 100644<br>
> --- a/tests/i915/i915_module_load.c<br>
> +++ b/tests/i915/i915_module_load.c<br>
> @@ -23,7 +23,9 @@<br>
> #include "igt.h"<br>
> #include <dirent.h><br>
> #include <sys/utsname.h><br>
> +#ifdef __linux__<br>
> #include <linux/limits.h><br>
> +#endif<br>
> #include <signal.h><br>
> #include <libgen.h><br>
> #include <signal.h><br>
> diff --git a/tests/i915/i915_pm_backlight.c b/tests/i915/i915_pm_backlight.c<br>
> index cafae7f7..c520cf20 100644<br>
> --- a/tests/i915/i915_pm_backlight.c<br>
> +++ b/tests/i915/i915_pm_backlight.c<br>
> @@ -46,6 +46,10 @@ struct context {<br>
> #define FADESTEPS 10<br>
> #define FADESPEED 100 /* milliseconds between steps */<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <libgen.h><br>
> +#endif<br>
> +<br>
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");<br>
> <br>
> static int backlight_read(int *result, const char *fname)<br>
> diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c<br>
> index e95875dc..761e76f9 100644<br>
> --- a/tests/i915/i915_pm_rpm.c<br>
> +++ b/tests/i915/i915_pm_rpm.c<br>
> @@ -40,8 +40,10 @@<br>
> #include <sys/mman.h><br>
> #include <sys/types.h><br>
> #include <sys/stat.h><br>
> +#ifdef __linux__<br>
> #include <linux/i2c.h><br>
> #include <linux/i2c-dev.h><br>
> +#endif<br>
> <br>
> #include <drm.h><br>
> <br>
> @@ -54,6 +56,12 @@<br>
> #include "igt_device.h"<br>
> #include "igt_edid.h"<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <limits.h><br>
> +#include <dev/iicbus/iic.h><br>
> +#define addr slave<br>
> +#endif<br>
> +<br>
> #define MSR_PC8_RES 0x630<br>
> #define MSR_PC9_RES 0x631<br>
> #define MSR_PC10_RES 0x632<br>
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c<br>
> index 3041f1cd..e0e5af78 100644<br>
> --- a/tests/kms_content_protection.c<br>
> +++ b/tests/kms_content_protection.c<br>
> @@ -24,7 +24,9 @@<br>
> <br>
> #include <poll.h><br>
> #include <fcntl.h><br>
> +#ifdef __linux__<br>
> #include <sys/epoll.h><br>
> +#endif<br>
> #include <sys/stat.h><br>
> #include <libudev.h><br>
> #include "igt.h"<br>
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c<br>
> index 0567edea..1127e418 100755<br>
> --- a/tests/kms_flip.c<br>
> +++ b/tests/kms_flip.c<br>
> @@ -45,6 +45,10 @@<br>
> #include "i915/gem_create.h"<br>
> #include "igt_stats.h"<br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <sys/consio.h><br>
> +#endif<br>
> +<br>
> #define TEST_DPMS (1 << 0)<br>
> <br>
> #define TEST_PAN (1 << 3)<br>
> diff --git a/tests/kms_sysfs_edid_timing.c b/tests/kms_sysfs_edid_timing.c<br>
> index 77521108..cd980c6a 100644<br>
> --- a/tests/kms_sysfs_edid_timing.c<br>
> +++ b/tests/kms_sysfs_edid_timing.c<br>
> @@ -26,6 +26,10 @@<br>
> #include <fcntl.h><br>
> #include <sys/stat.h><br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <limits.h><br>
> +#endif<br>
> +<br>
> #define THRESHOLD_PER_CONNECTOR 150<br>
> #define THRESHOLD_PER_CONNECTOR_MEAN 140<br>
> #define THRESHOLD_ALL_CONNECTORS_MEAN 100<br>
> diff --git a/tests/tools_test.c b/tests/tools_test.c<br>
> index 237f0433..d0684d57 100644<br>
> --- a/tests/tools_test.c<br>
> +++ b/tests/tools_test.c<br>
> @@ -28,7 +28,11 @@<br>
> #include <fcntl.h><br>
> #include <libgen.h><br>
> #include <unistd.h><br>
> +#ifdef __linux__<br>
> #include <linux/limits.h><br>
> +#elif defined(__FreeBSD__)<br>
> +#include <limits.h><br>
> +#endif<br>
> <br>
> #define TOOLS "../tools/"<br>
> <br>
> @@ -65,7 +69,7 @@ static bool chdir_to_tools_dir(void)<br>
> char path[PATH_MAX];<br>
> char *cwd;<br>
> <br>
> - cwd = get_current_dir_name();<br>
> + cwd = getcwd(NULL, 0);<br>
> igt_info("Current working directory: %s\n", cwd);<br>
> free(cwd);<br>
> <br>
> @@ -83,7 +87,7 @@ static bool chdir_to_tools_dir(void)<br>
> chdir(dirname(path));<br>
> }<br>
> <br>
> - cwd = get_current_dir_name();<br>
> + cwd = getcwd(NULL, 0);<br>
> igt_info("Current working directory: %s\n", cwd);<br>
> free(cwd);<br>
> <br>
> @@ -99,7 +103,7 @@ igt_main<br>
> <br>
> igt_require_f(chdir_to_tools_dir(),<br>
> "Unable to determine the tools directory, expecting them in $cwd/" TOOLS " or $path/" TOOLS "\n");<br>
> - path = get_current_dir_name();<br>
> + path = getcwd(NULL, 0);<br>
> igt_info("Using tools from %s\n", path);<br>
> free(path);<br>
> }<br>
> diff --git a/tools/i915-perf/i915_perf_control.c b/tools/i915-perf/i915_perf_control.c<br>
> index be5996c0..f7db2f5c 100644<br>
> --- a/tools/i915-perf/i915_perf_control.c<br>
> +++ b/tools/i915-perf/i915_perf_control.c<br>
> @@ -102,7 +102,7 @@ main(int argc, char *argv[])<br>
> <br>
> fwrite(data, total_len, 1, command_fifo_file);<br>
> } else {<br>
> - char *cwd = get_current_dir_name();<br>
> + char *cwd = getcwd(NULL, 0);<br>
> uint32_t path_len = strlen(cwd) + 1 + strlen(dump_file) + 1;<br>
> uint32_t total_len = sizeof(struct recorder_command_base) + path_len;<br>
> struct {<br>
> diff --git a/tools/intel_gvtg_test.c b/tools/intel_gvtg_test.c<br>
> index ad5ee6a6..3e53c6d9 100644<br>
> --- a/tools/intel_gvtg_test.c<br>
> +++ b/tools/intel_gvtg_test.c<br>
> @@ -55,6 +55,10 @@<br>
> #include <limits.h><br>
> #include <dirent.h><br>
> <br>
> +#ifdef __FreeBSD__<br>
> +#include <sys/wait.h><br>
> +#endif<br>
> +<br>
> #define RANDOM(x) (rand() % x)<br>
> <br>
> <br>
> -- <br>
> 2.37.3<br>
> <br>
</blockquote></div>