[FFmpeg-devel] [PATCH 02/16] configure, avutil: add support for HorizonOS
averne
averne381 at gmail.com
Thu May 30 22:43:04 EEST 2024
HorizonOS (HOS) is the operating system of the Nintendo Switch.
This patch enables integration with the homebrew toolchain developped by the devkitPro team. Its two main components are devkitA64 (common toolchain for aarch64 targets) and libnx (library implementing interaction with the HOS kernel and system daemons, termed sysmodules).
Signed-off-by: averne <averne381 at gmail.com>
---
configure | 8 ++++++++
libavutil/cpu.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/configure b/configure
index 96b181fd21..09fb2aed1b 100755
--- a/configure
+++ b/configure
@@ -5967,6 +5967,10 @@ case $target_os in
;;
minix)
;;
+ horizon)
+ enable section_data_rel_ro
+ add_extralibs -lnx
+ ;;
none)
;;
*)
@@ -7710,6 +7714,10 @@ haiku)
disable memalign
fi
;;
+horizon)
+ disable sysctl
+ disable sysctlbyname
+ ;;
esac
flatten_extralibs(){
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 9ac2f01c20..6a77df5e34 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -48,6 +48,9 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef __SWITCH__
+#include <switch.h>
+#endif
static atomic_int cpu_flags = -1;
static atomic_int cpu_count = -1;
@@ -247,6 +250,10 @@ int av_cpu_count(void)
#elif HAVE_WINRT
GetNativeSystemInfo(&sysinfo);
nb_cpus = sysinfo.dwNumberOfProcessors;
+#elif defined(__SWITCH__)
+ u64 core_mask = 0;
+ Result rc = svcGetInfo(&core_mask, InfoType_CoreMask, CUR_PROCESS_HANDLE, 0);
+ nb_cpus = R_SUCCEEDED(rc) ? av_popcount64(core_mask) : 3;
#endif
if (!atomic_exchange_explicit(&printed, 1, memory_order_relaxed))
--
2.45.1
More information about the ffmpeg-devel
mailing list