Package: util-linux
Version: 2.12r
Author: Guillem Jover <guillem@debian.org>
Status: fixed
Description:
 Detect at runtime if we have gettimeofday() available.

--- configure	2004-12-21 00:20:35.000000000 +0200
+++ configure	2006-02-12 09:38:07.000000000 +0200
@@ -315,6 +315,7 @@
 
 #
 # F6. For agetty.c: is updwtmp() available?
+# F7. For mcookie.c: is gettimeofday() available?
 #
 echo '
 #include <string.h>
@@ -531,6 +532,29 @@
 fi
 rm -f conftest conftest.c
 
+#
+# F7. For mcookie.c: is gettimeofday() available?
+#
+echo '
+#include <sys/time.h>
+#include <unistd.h>
+int main()
+{
+  struct timeval tv;
+  struct timezone tz;
+  gettimeofday(&tv, &tz);
+  exit(0);
+}
+' > conftest.c
+eval $compile
+if test -s conftest && ./conftest 2>/dev/null; then
+        echo "#define HAVE_gettimeofday" >> defines.h
+        echo "You have gettimeofday()"
+else
+        echo "You don't have gettimeofday()"
+fi
+rm -f conftest conftest.c
+
 
 #
 # 7. Does xgettext exist and take the option --foreign-user?
--- misc-utils/mcookie.c	2002-03-09 01:00:52.000000000 +0200
+++ misc-utils/mcookie.c	2006-02-12 09:38:07.000000000 +0200
@@ -20,18 +20,16 @@
  *
  */
 
-#ifdef __linux__
-#define HAVE_GETTIMEOFDAY 1
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include "md5.h"
-#if HAVE_GETTIMEOFDAY
+#include "../defines.h"
+#ifdef HAVE_gettimeofday
 #include <sys/time.h>
-#include <unistd.h>
 #endif
+#include <time.h>
+#include <unistd.h>
 #include "nls.h"
 
 #define BUFFERSIZE 4096
@@ -79,7 +77,7 @@
    pid_t             pid;
    char              *file = NULL;
    int               r;
-#if HAVE_GETTIMEOFDAY
+#ifdef HAVE_gettimeofday
    struct timeval    tv;
    struct timezone   tz;
 #else
@@ -98,7 +96,7 @@
 
    MD5Init( &ctx );
    
-#if HAVE_GETTIMEOFDAY
+#ifdef HAVE_gettimeofday
    gettimeofday( &tv, &tz );
    MD5Update( &ctx, (unsigned char *)&tv, sizeof( tv ) );
 #else
