Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FreeBSD support #3956

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions package-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ shift 2
opt_nopackage=0
opt_devbuild=0
opt_buildid=false
opt_64_only=0
opt_32_only=0

CC=${CC:="gcc"}
CXX=${CXX:="g++"}
Expand All @@ -41,6 +43,12 @@ while [ $# -gt 0 ]; do
"--build-id")
opt_buildid=true
;;
"--64-only")
opt_64_only=1
Joshua-Ashton marked this conversation as resolved.
Show resolved Hide resolved
;;
"--32-only")
opt_32_only=1
;;
*)
echo "Unrecognized option: $1" >&2
exit 1
Expand Down Expand Up @@ -81,8 +89,12 @@ function package {
rm -R "dxvk-native-$DXVK_VERSION"
}

build_arch 64 lib
build_arch 32 lib32
if [ $opt_32_only -eq 0 ]; then
build_arch 64 lib
fi
if [ $opt_64_only -eq 0 ]; then
build_arch 32 lib32
fi

if [ $opt_nopackage -eq 0 ]; then
package
Expand Down
4 changes: 4 additions & 0 deletions src/util/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ namespace dxvk {
switch (priority) {
default:
case ThreadPriority::Normal: policy = SCHED_OTHER; break;
#ifndef __linux__
case ThreadPriority::Lowest: policy = SCHED_OTHER; break;
#else
case ThreadPriority::Lowest: policy = SCHED_IDLE; break;
#endif
}
::pthread_setschedparam(this->native_handle(), policy, &param);
}
Expand Down
15 changes: 15 additions & 0 deletions src/util/util_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#ifdef __linux__
#include <unistd.h>
#include <limits.h>
#elif defined(__FreeBSD__)
#include <sys/sysctl.h>
#include <unistd.h>
#include <limits.h>
#endif

#include "util_env.h"
Expand Down Expand Up @@ -85,6 +89,17 @@ namespace dxvk::env {
size_t count = readlink("/proc/self/exe", exePath.data(), exePath.size());

return std::string(exePath.begin(), exePath.begin() + count);
#elif defined(__FreeBSD__)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid()};
char exePath[PATH_MAX] = {};
size_t size = PATH_MAX;

if (sysctl(mib, 4, exePath, &size, NULL, 0) != 0) {
// throw error here?
return "";
}

return std::string(exePath);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/util_win32_compat.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(__linux__)
#if defined(__unix__)

#include <windows.h>
#include <dlfcn.h>
Expand Down