Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1609181 - Detect ARM CPU features on FreeBSD. r=jcj
Implement `getauxval` via `elf_aux_info` to avoid code duplication.
`AT_HWCAP*` can be used on powerpc* and riscv64 as well.

--HG--
extra : amend_source : d58f4c5ae761b102d58b15ffa6bfc815bab7ea68
  • Loading branch information
jbeich committed Jan 27, 2020
1 parent 16c7915 commit 97df5ad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/freebl/blinit.c
Expand Up @@ -122,6 +122,22 @@ extern unsigned long getauxval(unsigned long type) __attribute__((weak));
static unsigned long (*getauxval)(unsigned long) = NULL;
#endif /* defined(__GNUC__) && __GNUC__ >= 2 && defined(__ELF__)*/

#if defined(__FreeBSD__) && !defined(__aarch64__) && __has_include(<sys/auxv.h>)
/* Avoid conflict with static declaration above */
#define getauxval freebl_getauxval
static unsigned long getauxval(unsigned long type)
{
/* Only AT_HWCAP* return unsigned long */
if (type != AT_HWCAP && type != AT_HWCAP2) {
return 0;
}

unsigned long ret = 0;
elf_aux_info(type, &ret, sizeof(ret));
return ret;
}
#endif

#ifndef AT_HWCAP2
#define AT_HWCAP2 26
#endif
Expand Down

0 comments on commit 97df5ad

Please sign in to comment.