Compatibility with FreeBSD
authorMatheus Garcia <37114863+Krush206@users.noreply.github.com>
Sat, 21 Oct 2023 15:56:56 +0000 (15:56 +0000)
committernotaz <notasas@gmail.com>
Sun, 4 May 2025 15:19:30 +0000 (18:19 +0300)
linux/in_evdev.c
linux/plat.c
posix.h

index 46a16b7..4dc76be 100644 (file)
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
+#ifdef __FreeBSD__
+#include <dev/evdev/input.h>
+#else
 #include <linux/input.h>
+#endif
 #include <errno.h>
 
 #include "../input.h"
index 0b64d93..e750163 100644 (file)
@@ -58,7 +58,13 @@ static int plat_get_exe_dir(char *dst, int len)
        memcpy(dst, PICO_DATA_DIR, sizeof PICO_DATA_DIR);
        return sizeof(PICO_DATA_DIR) - 1;
 #else
-       int j, ret = readlink("/proc/self/exe", dst, len - 1);
+       int j, ret = readlink(
+#ifdef __FreeBSD__
+       "/proc/curproc/file",
+#else
+       "/proc/self/exe",
+#endif
+       dst, len - 1);
        if (ret < 0) {
                perror("readlink");
                ret = 0;
diff --git a/posix.h b/posix.h
index 003bb7a..8351def 100644 (file)
--- a/posix.h
+++ b/posix.h
@@ -2,7 +2,7 @@
 #define LIBPICOFE_POSIX_H
 
 /* define POSIX stuff: dirent, scandir, getcwd, mkdir */
-#if defined(__MACH__) || defined(__linux__) || defined(__MINGW32__) || defined(__PSP__) || defined(__PS2__)
+#if defined(__FreeBSD__) || defined(__MACH__) || defined(__linux__) || defined(__MINGW32__) || defined(__PSP__) || defined(__PS2__)
 
 #include <dirent.h>
 #include <unistd.h>