Misc FreeBSD fixes (#1926)

* helpers: drop incomplete GNU/kFreeBSD bits

Debian with FreeBSD kernel lacks Wayland-related packages and is not
officially supported since Jessie.

* KeybindManager: check VT ioctl availability instead of hardcoding

* plugins: add missing header for libc++ after 430778293e

src/plugins/PluginAPI.cpp:299:33: error: implicit instantiation of undefined template 'std::basic_istringstream<char>'
    std::istringstream          inStream(SYMBOLS);
                                ^
/usr/include/c++/v1/iosfwd:140:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_istringstream;
                               ^

* plugins: prefer llvm-nm with Clang after 430778293e

nm: invalid option -- j
This commit is contained in:
Jan Beich 2023-03-31 19:39:04 +00:00 committed by GitHub
parent 7680cd549c
commit 16bc5997bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -6,11 +6,11 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/sysctl.h> #include <sys/sysctl.h>
#if defined(__DragonFly__) #if defined(__DragonFly__)
#include <sys/kinfo.h> // struct kinfo_proc #include <sys/kinfo.h> // struct kinfo_proc
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #elif defined(__FreeBSD__)
#include <sys/user.h> // struct kinfo_proc #include <sys/user.h> // struct kinfo_proc
#endif #endif
@ -23,7 +23,7 @@
#endif #endif
#if defined(__DragonFly__) #if defined(__DragonFly__)
#define KP_PPID(kp) kp.kp_ppid #define KP_PPID(kp) kp.kp_ppid
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #elif defined(__FreeBSD__)
#define KP_PPID(kp) kp.ki_ppid #define KP_PPID(kp) kp.ki_ppid
#else #else
#define KP_PPID(kp) kp.p_ppid #define KP_PPID(kp) kp.p_ppid

View file

@ -469,11 +469,11 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
// vtnr is bugged for some reason. // vtnr is bugged for some reason.
unsigned int ttynum = 0; unsigned int ttynum = 0;
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) #if defined(VT_GETSTATE)
struct vt_stat st; struct vt_stat st;
if (!ioctl(0, VT_GETSTATE, &st)) if (!ioctl(0, VT_GETSTATE, &st))
ttynum = st.v_active; ttynum = st.v_active;
#elif defined(__DragonFly__) || defined(__FreeBSD__) #elif defined(VT_GETACTIVE)
int vt; int vt;
if (!ioctl(0, VT_GETACTIVE, &vt)) if (!ioctl(0, VT_GETACTIVE, &vt))
ttynum = vt; ttynum = vt;

View file

@ -7,6 +7,8 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
#include <sstream>
APICALL bool HyprlandAPI::registerCallbackStatic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN* fn) { APICALL bool HyprlandAPI::registerCallbackStatic(HANDLE handle, const std::string& event, HOOK_CALLBACK_FN* fn) {
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle); auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
@ -277,8 +279,13 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
const auto FPATH = std::filesystem::canonical("/proc/self/exe"); const auto FPATH = std::filesystem::canonical("/proc/self/exe");
#endif #endif
#ifdef __clang__
const auto SYMBOLS = execAndGet(("llvm-nm -D -j " + FPATH.string()).c_str());
const auto SYMBOLSDEMANGLED = execAndGet(("llvm-nm -D -j --demangle " + FPATH.string()).c_str());
#else
const auto SYMBOLS = execAndGet(("nm -D -j " + FPATH.string()).c_str()); const auto SYMBOLS = execAndGet(("nm -D -j " + FPATH.string()).c_str());
const auto SYMBOLSDEMANGLED = execAndGet(("nm -D -j --demangle=auto " + FPATH.string()).c_str()); const auto SYMBOLSDEMANGLED = execAndGet(("nm -D -j --demangle=auto " + FPATH.string()).c_str());
#endif
auto demangledFromID = [&](size_t id) -> std::string { auto demangledFromID = [&](size_t id) -> std::string {
size_t pos = 0; size_t pos = 0;