libiberty/mkstemps.c: Include <time.h> if <sys/time.h> not available.
authorJoel Brobecker <brobecker@adacore.com>
Tue, 16 Sep 2014 18:32:09 +0000 (14:32 -0400)
committerJoel Brobecker <brobecker@adacore.com>
Fri, 8 May 2015 17:15:28 +0000 (10:15 -0700)
Attempting to build libiberty on LynxOS-178 fails trying to compile
mkstemps.c with the following error:

    mkstemps.c:84:18: error: storage size of 'tv' isn't known
       struct timeval tv;
                      ^

This file would normally include <sys/time.h> to get the type's
definition, but unfortunately LynxOS-178 does not want us to use
<sys/time.h>, only <time.h>. The configure script correctly finds
this out and generates a config.h file where HAVE_SYS_TIME_H is
undefined:

/* Define to 1 if you have the <sys/time.h> header file. */
/* #undef HAVE_SYS_TIME_H */

This patch fixes the build issue by falling back on including <time.h>
if <sys/time.h> could not be included (and provided that HAVE_TIME_H
is defined, of course).

libiberty/ChangeLog:

        * mkstemps.c: #include <time.h> if HAVE_TIME_H is defined
        but not HAVE_SYS_TIME_H.

libiberty/ChangeLog
libiberty/mkstemps.c

index 50098071d39b276743fb313d4aa1cde34dd22756..923613d8caf98a97b64d3ccf94e2274dcf865947 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-08  Joel Brobecker  <brobecker@adacore.com>
+
+       * mkstemps.c: #include <time.h> if HAVE_TIME_H is defined
+       but not HAVE_SYS_TIME_H.
+
 2015-04-22  Eli Zaretskii  <eliz@gnu.org>
 
        * setenv.c <environ>: Declare only if not a macro.
index a0e68a73b4915d27d97b3b9d5d3779f6c3f7023f..0e06fe17059a03c9a0d343beecaa5d60b8dae00d 100644 (file)
@@ -35,6 +35,8 @@
 #endif
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
+#elif HAVE_TIME_H
+#include <time.h>
 #endif
 #include "ansidecl.h"
 
This page took 0.0395 seconds and 4 git commands to generate.