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

averne averne381 at gmail.com
Sat Jun 1 00:06:39 EEST 2024


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


More information about the ffmpeg-devel mailing list