Bug 239621 - sys/auxv.h isn't sufficient on powerpc*: PPC_FEATURE_* are not defined
Summary: sys/auxv.h isn't sufficient on powerpc*: PPC_FEATURE_* are not defined
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: powerpc Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2019-08-03 18:57 UTC by Jan Beich
Modified: 2019-08-03 18:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2019-08-03 18:57:56 UTC
<sys/auxv.h> on armv6 and armv7 pulls HWCAP_* definitions from <machine/elf.h> but on powerpc* PPC_FEATURE_* are not pulled from <machine/cpu.h>. Such behavior is inconsistent with Linux where <sys/auxv.h> pulls <asm/cputable.h>. Found via multimedia/dav1d.

$ cat a.c
#ifdef __linux__
#define HAVE_GETAUXVAL
#endif

#ifdef __FreeBSD__
#define HAVE_ELF_AUX_INFO
#endif

#if (defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO))
#include <sys/auxv.h>
#define HAVE_AUX
#endif

unsigned dav1d_get_cpu_flags_ppc(void) {
    unsigned flags = 0;
#if defined(HAVE_GETAUXVAL)
    unsigned long hw_cap = getauxval(AT_HWCAP);
#elif defined(HAVE_ELF_AUX_INFO)
    unsigned long hw_cap = 0;
    elf_aux_info(AT_HWCAP, &hw_cap, sizeof(hw_cap));
#endif
#ifdef HAVE_AUX
    flags |= (hw_cap & PPC_FEATURE_HAS_VSX) ? DAV1D_PPC_CPU_FLAG_VSX : 0;
#endif
    return flags;
}

$ gcc8 -c a.c
a.c: In function 'dav1d_get_cpu_flags_ppc':
a.c:23:24: error: 'PPC_FEATURE_HAS_VSX' undeclared (first use in this function)
     flags |= (hw_cap & PPC_FEATURE_HAS_VSX) ? DAV1D_PPC_CPU_FLAG_VSX : 0;
                        ^~~~~~~~~~~~~~~~~~~
a.c:23:24: note: each undeclared identifier is reported only once for each function it appears in
a.c:23:47: error: 'DAV1D_PPC_CPU_FLAG_VSX' undeclared (first use in this function)
     flags |= (hw_cap & PPC_FEATURE_HAS_VSX) ? DAV1D_PPC_CPU_FLAG_VSX : 0;
                                               ^~~~~~~~~~~~~~~~~~~~~~