Skip to content

Add Arm RTCD for OpenBSD #363

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion celt/arm/armcpu.c
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ static opus_uint32 opus_cpu_capabilities(void)
return flags;
}

#elif defined(__FreeBSD__)
#elif defined(HAVE_ELF_AUX_INFO)
#include <sys/auxv.h>

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

#elif defined(__OpenBSD__)
#include <sys/types.h>
#include <sys/sysctl.h>
#include <machine/armreg.h>
#include <machine/cpu.h>

static opus_uint32 opus_cpu_capabilities(void)
{
opus_uint32 flags = 0;

#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0)
const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 };
uint64_t isar0;
size_t len = sizeof(isar0);

if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) != -1)
{
if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL)
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
}
#endif

#if defined(OPUS_ARM_PRESUME_NEON_INTR) \
|| defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR)
flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG;
# if defined(OPUS_ARM_PRESUME_DOTPROD)
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
# endif
#endif
return flags;
}

#else
/* The feature registers which can tell us what the processor supports are
* accessible in priveleged modes only, so we can't have a general user-space
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1032,7 +1032,7 @@ AC_CHECK_FUNCS([lrintf])
AC_CHECK_FUNCS([lrint])
LIBS="$saved_LIBS"

AC_CHECK_FUNCS([__malloc_hook])
AC_CHECK_FUNCS([__malloc_hook elf_aux_info])

AC_SUBST([PC_BUILD])

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

# Check for restrict keyword