@@ -191,6 +191,54 @@ static opus_uint32 opus_cpu_capabilities(void)
191191 return flags ;
192192}
193193
194+ #elif defined(__FreeBSD__ )
195+ #include <sys/auxv.h>
196+
197+ static opus_uint32 opus_cpu_capabilities (void )
198+ {
199+ long hwcap = 0 ;
200+ opus_uint32 flags = 0 ;
201+
202+ # if defined(OPUS_ARM_MAY_HAVE_MEDIA ) \
203+ || defined(OPUS_ARM_MAY_HAVE_NEON ) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR )
204+ /* FreeBSD requires armv6+, which always supports media instructions */
205+ flags |= OPUS_CPU_ARM_MEDIA_FLAG ;
206+ # endif
207+
208+ elf_aux_info (AT_HWCAP , & hwcap , sizeof hwcap );
209+
210+ # if defined(OPUS_ARM_MAY_HAVE_EDSP ) || defined(OPUS_ARM_MAY_HAVE_MEDIA ) \
211+ || defined(OPUS_ARM_MAY_HAVE_NEON ) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR )
212+ # ifdef HWCAP_EDSP
213+ if (hwcap & HWCAP_EDSP )
214+ flags |= OPUS_CPU_ARM_EDSP_FLAG ;
215+ # endif
216+
217+ # if defined(OPUS_ARM_MAY_HAVE_NEON ) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR )
218+ # ifdef HWCAP_NEON
219+ if (hwcap & HWCAP_NEON )
220+ flags |= OPUS_CPU_ARM_NEON_FLAG ;
221+ # elif defined(HWCAP_ASIMD )
222+ if (hwcap & HWCAP_ASIMD )
223+ flags |= OPUS_CPU_ARM_NEON_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_EDSP_FLAG ;
224+ # endif
225+ # endif
226+ # if defined(OPUS_ARM_MAY_HAVE_DOTPROD ) && defined(HWCAP_ASIMDDP )
227+ if (hwcap & HWCAP_ASIMDDP )
228+ flags |= OPUS_CPU_ARM_DOTPROD_FLAG ;
229+ # endif
230+ # endif
231+
232+ #if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR )
233+ flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG ;
234+ # if defined(OPUS_ARM_PRESUME_DOTPROD )
235+ flags |= OPUS_CPU_ARM_DOTPROD_FLAG ;
236+ # endif
237+ #endif
238+
239+ return (flags );
240+ }
241+
194242#else
195243/* The feature registers which can tell us what the processor supports are
196244 * accessible in priveleged modes only, so we can't have a general user-space
0 commit comments