Bug 26124 - Export <cpu-features.h>
Summary: Export <cpu-features.h>
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: 2.33
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-17 00:53 UTC by H.J. Lu
Modified: 2020-09-12 15:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2020-06-17 00:53:21 UTC
I got user requests to export <cpu-features.h> so that people can do

#if __has_include(<cpu-features.h>)
#include <cpu-features.h>
#endif
...

   if (HAS_CPU_FEATURE (SSE3))
...
   if (CPU_FEATURE_USABLE (SSE3))
...
Comment 1 Florian Weimer 2020-06-17 04:46:24 UTC
GCC already has this as __builtin_cpu_supports. Why isn't that sufficient?

GCC support is desirable so that GCC can turn the expression into a true value at compile time if the CPU feature is required by the current compilation environment.
Comment 2 H.J. Lu 2020-06-17 11:36:41 UTC
(In reply to Florian Weimer from comment #1)
> GCC already has this as __builtin_cpu_supports. Why isn't that sufficient?
> 
> GCC support is desirable so that GCC can turn the expression into a true
> value at compile time if the CPU feature is required by the current
> compilation environment.

__builtin_cpu_supports only supports a subset of <cpu-features.h>.
Comment 3 H.J. Lu 2020-06-17 19:32:38 UTC
A patch is posted at

https://sourceware.org/pipermail/libc-alpha/2020-June/115158.html
Comment 4 H.J. Lu 2020-09-12 15:04:31 UTC
Fixed in 2.33 by

commit 9620398097de3981c1adf5233e2b3478d36bc1b3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jun 29 18:30:54 2020 -0700

    x86: Install <sys/platform/x86.h> [BZ #26124]