Build - OpenBSD 3.7 i386 configure.in patch for struct timespec error

Steve Williams steve at celineandsteve.com
Sun Sep 4 14:41:27 GMT 2005


Hi,

This proposed patch against samba_3_0 originates from my OpenBSD 3.7 
i386 in the build farm, where samba_3_0 is failing to compile.  This is 
my first patch, (and there will be more), so if people would prefer a 
different way of my presenting the information, please don't hesitate to 
let me know.

./configure
make

yields:

> Compiling dynconfig.c
> In file included from dynconfig.c:21:
> include/includes.h:811: error: redefinition of `struct timespec'
> *** Error code 1
>
> Stop in /home/build/build_farm/samba_3_0/source (line 801 of Makefile).
> $ exit


Looking at "includes.h":
#ifndef HAVE_STRUCT_TIMESPEC
struct timespec {
        time_t tv_sec;            /* Seconds.  */
        long tv_nsec;           /* Nanoseconds.  */
};
#endif

and "config.h" says:
/* Whether we have struct timespec */
/* #undef HAVE_STRUCT_TIMESPEC */

Looking around, struct timespec is included in <sys/time.h>

Looking at "includes.h" once again:
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif

and then re-examining "config.h":
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1

so "includes.h" includes <sys/time.h>, while at the same time defining 
struct timespec because "HAVE_STRUCT_TIMESPEC" is undef'd.  So off to 
look at configure.in

Looking at configure.in, it just does a simple include of "time.h".
AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
    AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#include <time.h>
#if HAVE_AIO_H
...

Changing this logic to match the logic in "includes.h":
AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
    AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif
#if HAVE_AIO_H
...

This APPEARS to be a permissible change, as the same code is used in the 
"struct stat" check further down in configure.in..:
AC_CACHE_CHECK([whether struct stat has sub-second timestamps], 
samba_stat_hires,
    [
        AC_TRY_COMPILE(
            [
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
..

Applied the attached patch, re-ran autogen.sh and "config.h" yields:

/* Whether we have struct timespec */
#define HAVE_STRUCT_TIMESPEC 1

and running "make":
creating /home/build/build_farm/samba_3_0/source/utils/ntlm_auth_proto.h
Compiling dynconfig.c
Compiling param/loadparm.c
Compiling param/params.c

gets us past that problem :-)

Now to figure out how to send a proper "diff"

I am not sure if the same code should be replicated to....  I don't 
think so, as it is including "<sys/time.h>" reather than just "<time.h>.
AC_CACHE_CHECK([if gettimeofday takes tz 
argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
AC_TRY_RUN([
#include <sys/time.h>
...

Cheers,
Steve

-------------- next part --------------
$ diff -u samba_3_0/source/configure.in.org samba_3_0/source/configure.in
--- samba_3_0/source/configure.in.org   Sun Sep  4 08:04:01 2005
+++ samba_3_0/source/configure.in       Sun Sep  4 08:04:46 2005
@@ -956,7 +956,16 @@
 #include <stdlib.h>
 #include <stddef.h>
 #endif
-#include <time.h>
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
 #if HAVE_AIO_H
 #include <aio.h>
 #endif


More information about the samba-technical mailing list