diff mbox series

[FFmpeg-devel,02/16] configure, avutil: add support for HorizonOS

Message ID 2071da3c6620fd5ca9dd769a467f248796a51f67.1717083799.git.averne381@gmail.com
State New
Headers show
Series NVidia Tegra hardware decoding backend | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

averne May 30, 2024, 7:43 p.m. UTC
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@gmail.com>
---
 configure       | 8 ++++++++
 libavutil/cpu.c | 7 +++++++
 2 files changed, 15 insertions(+)

Comments

Rémi Denis-Courmont May 30, 2024, 8:37 p.m. UTC | #1
Le torstaina 30. toukokuuta 2024, 22.43.04 EEST averne a écrit :
> 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@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
> +    ;;

Are those really broken, or is this just a trick to force a fallback? In the 
later case, you don't need to disable them; just to put the HOS code ahead of 
the generic BSD code.

>  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))
averne May 31, 2024, 9:06 p.m. UTC | #2
Le 30/05/2024 à 22:37, Rémi Denis-Courmont a écrit :
> Le torstaina 30. toukokuuta 2024, 22.43.04 EEST averne a écrit :
>> 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@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
>> +    ;;
> 
> Are those really broken, or is this just a trick to force a fallback? In the 
> later case, you don't need to disable them; just to put the HOS code ahead of 
> the generic BSD code.
> 

Hi, those functions are only available for socket-related operations 
(see https://github.com/switchbrew/libnx/blob/master/nx/include/switch/services/bsd.h#L57). 
I think it makes sense to disable them to avoid potential confusion.

>>  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))
> 
>
diff mbox series

Patch

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))