Skip to content

Commit 863a41c

Browse files
committed
Add Arm RTCD for OpenBSD
Also fix FreeBSD CMake support on ARM.
1 parent 0b2ef79 commit 863a41c

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ endif()
590590
target_compile_definitions(opus
591591
PRIVATE
592592
$<$<BOOL:${HAVE_LRINT}>:HAVE_LRINT>
593-
$<$<BOOL:${HAVE_LRINTF}>:HAVE_LRINTF>)
593+
$<$<BOOL:${HAVE_LRINTF}>:HAVE_LRINTF>
594+
$<$<BOOL:${HAVE_ELF_AUX_INFO}>:HAVE_ELF_AUX_INFO>)
594595

595596
if(OPUS_BUILD_FRAMEWORK)
596597
set_target_properties(opus PROPERTIES

celt/arm/armcpu.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static opus_uint32 opus_cpu_capabilities(void)
191191
return flags;
192192
}
193193

194-
#elif defined(__FreeBSD__)
194+
#elif defined(HAVE_ELF_AUX_INFO)
195195
#include <sys/auxv.h>
196196

197197
static opus_uint32 opus_cpu_capabilities(void)
@@ -239,6 +239,38 @@ static opus_uint32 opus_cpu_capabilities(void)
239239
return (flags);
240240
}
241241

242+
#elif defined(__OpenBSD__)
243+
#include <sys/types.h>
244+
#include <sys/sysctl.h>
245+
#include <machine/armreg.h>
246+
#include <machine/cpu.h>
247+
248+
static opus_uint32 opus_cpu_capabilities(void)
249+
{
250+
opus_uint32 flags = 0;
251+
252+
#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0)
253+
const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 };
254+
uint64_t isar0;
255+
size_t len = sizeof(isar0);
256+
257+
if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) != -1)
258+
{
259+
if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
260+
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
261+
}
262+
#endif
263+
264+
#if defined(OPUS_ARM_PRESUME_NEON_INTR) \
265+
|| defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR)
266+
flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG;
267+
# if defined(OPUS_ARM_PRESUME_DOTPROD)
268+
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
269+
# endif
270+
#endif
271+
return flags;
272+
}
273+
242274
#else
243275
/* The feature registers which can tell us what the processor supports are
244276
* accessible in priveleged modes only, so we can't have a general user-space

cmake/OpusConfig.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ endif()
4848

4949
check_symbol_exists(lrintf "math.h" HAVE_LRINTF)
5050
check_symbol_exists(lrint "math.h" HAVE_LRINT)
51+
check_symbol_exists(elf_aux_info "sys/auxv.h" HAVE_ELF_AUX_INFO)
5152
cmake_pop_check_state()
5253

5354
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")

cmake/OpusFunctions.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION)
166166
endif()
167167
endif()
168168
elseif(OPUS_CPU_ARM)
169-
# ARM cpu detection is implemented for Windows and anything
170-
# using a Linux kernel (such as Android).
171-
if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android)")
169+
# ARM cpu detection is implemented for Windows, Linux, Android, FreeBSD
170+
# and OpenBSD.
171+
if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android|FreeBSD|OpenBSD)")
172172
set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
173173
endif ()
174174
else()

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ AC_CHECK_FUNCS([lrintf])
10401040
AC_CHECK_FUNCS([lrint])
10411041
LIBS="$saved_LIBS"
10421042

1043-
AC_CHECK_FUNCS([__malloc_hook])
1043+
AC_CHECK_FUNCS([__malloc_hook elf_aux_info])
10441044

10451045
AC_SUBST([PC_BUILD])
10461046

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ libm = cc.find_library('m', required : false)
8383
opus_conf.set('HAVE_LRINTF', cc.has_function('lrintf', prefix: '#include <math.h>', dependencies: libm))
8484
opus_conf.set('HAVE_LRINT', cc.has_function('lrint', prefix: '#include <math.h>', dependencies: libm))
8585
opus_conf.set('HAVE___MALLOC_HOOK', cc.has_function('__malloc_hook', prefix: '#include <malloc.h>'))
86+
opus_conf.set('HAVE_ELF_AUX_INFO', cc.has_function('elf_aux_info', prefix: '#include <sys/auxv.h>'))
8687
opus_conf.set('HAVE_STDINT_H', cc.check_header('stdint.h'))
8788

8889
# Check for restrict keyword

0 commit comments

Comments
 (0)