This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] time: Define _STRUCT_TIMESPEC in <bits/types/struct_timespec.h>
- From: Florian Weimer <fweimer at redhat dot com>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 21 Jun 2018 13:24:09 +0200
- Subject: Re: [PATCH] time: Define _STRUCT_TIMESPEC in <bits/types/struct_timespec.h>
- References: <20180621064654.2D7DA4289B0D0@oldenburg.str.redhat.com> <CAKCAbMhgXiesDY+prfjZ_q8hHWUzj=s1r_qb_tcwyOQ_iO3+PQ@mail.gmail.com>
On 06/21/2018 01:00 PM, Zack Weinberg wrote:
On Thu, Jun 21, 2018 at 2:46 AM, Florian Weimer <fweimer@redhat.com> wrote:
After commit d76d3703551a362b472c866b5b6089f66f8daa8e ("Fix missing
timespec definition for sys/stat.h (BZ #21371)"), sanitizer builds start
to fail due to a conflicting definition of struct timespec in
<linux/time.h>. Define _STRUCT_TIMESPEC, which is already checked in
the kernel header, to support including <linux/time.h> after
<sys/stat.h>.
Should it go the other way around as well? That is, if
_STRUCT_TIMESPEC is already defined, should we suppress our
definition?
Hmm, sure, that would be possible.
Either way I think there should be a comment saying that linux/time.h
checks this macro.
It's in generic code, so I wasn't sure if it was okay to refer to
<linux/time.h>. But I can certainly add that.
What about the attached patch?
Thanks,
Florian
Subject: [PATCH] time: Define _STRUCT_TIMESPEC in <bits/types/struct_timespec.h>
To: libc-alpha@sourceware.org
After commit d76d3703551a362b472c866b5b6089f66f8daa8e ("Fix missing
timespec definition for sys/stat.h (BZ #21371)"), sanitizer builds
start to fail due to a conflicting definition of struct timespec in
<linux/time.h>. Use _STRUCT_TIMESPEC as the header file inclusion
guard, which is already checked in the kernel header, to support
including <linux/time.h> and <sys/stat.h> in the same translation
unit.
2018-06-21 Florian Weimer <fweimer@redhat.com>
* time/bits/types/struct_timespec.h (_STRUCT_TIMESPEC): Define.
diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index 644db9fdb6..5b77c52b4f 100644
--- a/time/bits/types/struct_timespec.h
+++ b/time/bits/types/struct_timespec.h
@@ -1,5 +1,6 @@
-#ifndef __timespec_defined
-#define __timespec_defined 1
+/* NB: Include guard matches what <linux/time.h> uses. */
+#ifndef _STRUCT_TIMESPEC
+#define _STRUCT_TIMESPEC 1
#include <bits/types.h>