Browse Source

fcntl.h: fix a missing `struct timespec` definition

If a source file is compiled with:

  #define _XOPEN_SOURCE 700
  #define _POSIX_C_SOURCE 200112L

Then including fcntl.h results in the following error:

  In file included from fcntl.h:37:0,
                   from test.c:4:
  sys/stat.h:371:54: error: array type has incomplete element type ‘struct timespec’
   extern int futimens (int __fd, const struct timespec __times[2]) __THROW;

To fix that, we force the definition of struct timespec in fcntl.h when
__USE_XOPEN2K8 is defined. This mimics the behavior of glibc which
contains the following line in its io/fcntl.h header (included by
fcntlh.h):
  #ifdef __USE_XOPEN2K8
  # include <bits/types/struct_timespec.h>
  #endif

This bug was spotted during the compilation of BoringSSL against uClibc.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
Damien Riegel 7 years ago
parent
commit
657c4a9d6c
1 changed files with 3 additions and 0 deletions
  1. 3 0
      include/fcntl.h

+ 3 - 0
include/fcntl.h

@@ -34,6 +34,9 @@ __BEGIN_DECLS
 
 /* For XPG all symbols from <sys/stat.h> should also be available.  */
 #ifdef __USE_XOPEN
+# ifdef __USE_XOPEN2K8
+#  define __need_timespec
+# endif
 # include <sys/stat.h>
 #endif