On Tue, Jul 19, 2011 at 2:16 PM, Mike Frysinger <[email protected]> wrote:
> On Tue, Jul 19, 2011 at 00:33, Jie Zhang wrote:
>> When compiling with mingw64, I got redefinition of "struct timespec".
>> This patch should fix it. If no one objects, I will commit it in 24
>> hours.
>>
>> +#ifndef _TIMESPEC_DEFINED
>>  struct timespec { unsigned long tv_sec, tv_nsec; };
>> +#endif
>
> i dont like relying on undocumented conventions.  how about adding a
> configure check instead to see if struct timespec exists and then we
> can key off of that ?
>
I agree. I just wanted to save some time.

> AC_CHECK_MEMBER([struct timespec.tv_sec])
> AF_IF([test "x$ac_cv_member_struct_timespec_tv_sec" = "xyes"],[
>    AC_DEFINE([HAVE_STRUCT_TIMESPEC], [1], [We have struct timespec])
> ])
>
AC_CHECK_TYPE is better. How would you like the attached new version
of the patch?


Jie
  * sysdep.h (struct timespec): Only define when !HAVE_STRUCT_TIMESPEC.
  * configure.ac: Check struct timespec.

Index: sysdep.h
===================================================================
--- sysdep.h	(revision 1971)
+++ sysdep.h	(working copy)
@@ -75,7 +75,9 @@
 
 #ifndef HAVE_NANOSLEEP
 #include <unistd.h>
+#ifndef HAVE_STRUCT_TIMESPEC
 struct timespec { unsigned long tv_sec, tv_nsec; };
+#endif
 #define nanosleep(req, rem) usleep((req)->tv_sec * 1000 * 1000 + (req)->tv_nsec / 1000)
 #endif
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 1971)
+++ configure.ac	(working copy)
@@ -133,6 +133,8 @@
 	usleep
 ]))
 
+AC_CHECK_TYPE([struct timespec], [AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [Define to 1 if you have the struct timespec type])], [], [[#include <time.h>]])
+
 AC_CHECK_FUNC(clock_gettime, [], [ AC_CHECK_LIB(rt, clock_gettime) ])
 
 
------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to