This is the mail archive of the
mailing list for the glibc project.
Re: New way for syncing with kernel headers
On 12/08/2017 09:32 PM, Dmitry V. Levin wrote:
On Fri, Dec 08, 2017 at 02:21:27PM +0100, Florian Weimer wrote:
Would this be an acceptable way to obtain definitions from the Linux
headers in places where namespace cleanliness is not a must?
/* Obtain the definitions of the MEMBARRIER_CMD_* constants. */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
# include <linux/membarrier.h>
/* Definitions from Linux 4.14 follow. */
MEMBARRIER_CMD_QUERY = 0,
MEMBARRIER_CMD_SHARED = 1,
MEMBARRIER_CMD_PRIVATE_EXPEDITED = 8,
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = 16,
Isn't it going to break when userspace uses e.g.
LINUX_VERSION_CODE == KERNEL_VERSION(4, 13, 0)
and includes <linux/membarrier.h> after this header?
Ugh, good point.
If I use 4.3 as the version guard (where <linux/membarrier.h> was
introduced first), someone with 4.13 kernel headers will not able to
compile a test using MEMBARRIER_CMD_PRIVATE_EXPEDITED. So that doesn't
But if we copy the header contents, like we currently do in most cases,
you can include the UAPI header afterwards, either. So maybe the
proposed approach is still an improvement because you don't have to
include the UAPI header at all if your glibc version is sufficiently
recent because the glibc header will give you the UAPI header plus
whatever system call wrappers glibc provides.