Changeset View
Changeset View
Standalone View
Standalone View
graphics/igt-gpu-tools/files/patch-lib_igt__aux.c
- This file was added.
--- lib/igt_aux.c.orig 2022-08-17 23:41:16 UTC | |||||
+++ lib/igt_aux.c | |||||
@@ -52,7 +52,9 @@ | |||||
#include <assert.h> | |||||
#include <grp.h> | |||||
+#ifdef __linux__ | |||||
#include <proc/readproc.h> | |||||
+#endif | |||||
#include <libudev.h> | |||||
#include "drmtest.h" | |||||
@@ -75,6 +77,14 @@ | |||||
#include <libgen.h> /* for dirname() */ | |||||
#endif | |||||
+#ifdef __FreeBSD__ | |||||
+#define gettid() getpid() | |||||
+#define setpgrp() setpgid(0, 0) | |||||
+typedef struct { | |||||
+ char state; | |||||
+} proc_t; | |||||
+#endif | |||||
+ | |||||
/** | |||||
* SECTION:igt_aux | |||||
* @short_description: Auxiliary libraries and support functions | |||||
@@ -1217,6 +1227,7 @@ int igt_is_process_running(const char *comm) | |||||
*/ | |||||
int igt_is_process_running(const char *comm) | |||||
{ | |||||
+#ifdef __linux__ | |||||
PROCTAB *proc; | |||||
proc_t *proc_info; | |||||
bool found = false; | |||||
@@ -1235,6 +1246,9 @@ int igt_is_process_running(const char *comm) | |||||
closeproc(proc); | |||||
return found; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return false; | |||||
+#endif | |||||
} | |||||
/** | |||||
@@ -1251,6 +1265,7 @@ int igt_terminate_process(int sig, const char *comm) | |||||
*/ | |||||
int igt_terminate_process(int sig, const char *comm) | |||||
{ | |||||
+#ifdef __linux__ | |||||
PROCTAB *proc; | |||||
proc_t *proc_info; | |||||
int err = 0; | |||||
@@ -1272,6 +1287,9 @@ int igt_terminate_process(int sig, const char *comm) | |||||
closeproc(proc); | |||||
return err; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return 0; | |||||
+#endif | |||||
} | |||||
struct pinfo { | |||||
@@ -1343,6 +1361,7 @@ igt_show_stat(proc_t *info, int *state, const char *fn | |||||
static void | |||||
igt_show_stat(proc_t *info, int *state, const char *fn) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct pinfo p = { .pid = info->tid, .comm = info->cmd, .fn = fn }; | |||||
if (!*state) | |||||
@@ -1350,11 +1369,13 @@ igt_show_stat(proc_t *info, int *state, const char *fn | |||||
__igt_show_stat(&p); | |||||
++*state; | |||||
+#endif | |||||
} | |||||
static void | |||||
__igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct dirent *d; | |||||
struct stat st; | |||||
char path[PATH_MAX]; | |||||
@@ -1407,6 +1428,7 @@ again: | |||||
} | |||||
closedir(dp); | |||||
+#endif | |||||
} | |||||
/* | |||||
@@ -1416,6 +1438,7 @@ __igt_lsof(const char *dir) | |||||
static void | |||||
__igt_lsof(const char *dir) | |||||
{ | |||||
+#ifdef __linux__ | |||||
PROCTAB *proc; | |||||
proc_t *proc_info; | |||||
@@ -1456,6 +1479,7 @@ __igt_lsof(const char *dir) | |||||
} | |||||
closeproc(proc); | |||||
+#endif | |||||
} | |||||
/** | |||||
@@ -1492,6 +1516,7 @@ static void pulseaudio_unload_module(proc_t *proc_info | |||||
static void pulseaudio_unload_module(proc_t *proc_info) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct igt_helper_process pa_proc = {}; | |||||
char xdg_dir[PATH_MAX]; | |||||
const char *homedir; | |||||
@@ -1513,6 +1538,7 @@ static void pulseaudio_unload_module(proc_t *proc_info | |||||
system("for i in $(pacmd list-sources|grep module:|cut -d : -f 2); do pactl unload-module $i; done"); | |||||
} | |||||
igt_wait_helper(&pa_proc); | |||||
+#endif | |||||
} | |||||
static int pipewire_pulse_pid = 0; | |||||
@@ -1521,6 +1547,7 @@ static void pipewire_reserve_wait(void) | |||||
static void pipewire_reserve_wait(void) | |||||
{ | |||||
+#ifdef __linux__ | |||||
char xdg_dir[PATH_MAX]; | |||||
const char *homedir; | |||||
struct passwd *pw; | |||||
@@ -1562,6 +1589,7 @@ static void pipewire_reserve_wait(void) | |||||
*/ | |||||
exit(system("pw-reserve -n Audio0 -r")); | |||||
} | |||||
+#endif | |||||
} | |||||
/* Maximum time waiting for pw-reserve to start running */ | |||||
@@ -1569,6 +1597,7 @@ int pipewire_pulse_start_reserve(void) | |||||
int pipewire_pulse_start_reserve(void) | |||||
{ | |||||
+#ifdef __linux__ | |||||
bool is_pw_reserve_running = false; | |||||
proc_t *proc_info; | |||||
int attempts = 0; | |||||
@@ -1614,6 +1643,9 @@ int pipewire_pulse_start_reserve(void) | |||||
*/ | |||||
return 0; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return 1; | |||||
+#endif | |||||
} | |||||
void pipewire_pulse_stop_reserve(void) | |||||
@@ -1647,6 +1679,7 @@ __igt_lsof_audio_and_kill_proc(proc_t *proc_info, char | |||||
static int | |||||
__igt_lsof_audio_and_kill_proc(proc_t *proc_info, char *proc_path) | |||||
{ | |||||
+#ifdef __linux__ | |||||
const char *audio_dev = "/dev/snd/"; | |||||
char path[PATH_MAX * 2]; | |||||
struct dirent *d; | |||||
@@ -1747,6 +1780,9 @@ __igt_lsof_audio_and_kill_proc(proc_t *proc_info, char | |||||
closedir(dp); | |||||
return fail; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return 1; | |||||
+#endif | |||||
} | |||||
/* | |||||
@@ -1759,6 +1795,7 @@ igt_lsof_kill_audio_processes(void) | |||||
int | |||||
igt_lsof_kill_audio_processes(void) | |||||
{ | |||||
+#ifdef __linux__ | |||||
char path[PATH_MAX]; | |||||
proc_t *proc_info; | |||||
PROCTAB *proc; | |||||
@@ -1779,6 +1816,9 @@ igt_lsof_kill_audio_processes(void) | |||||
closeproc(proc); | |||||
return fail; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return 1; | |||||
+#endif | |||||
} | |||||
static struct igt_siglatency { |