~ubuntu-branches/ubuntu/raring/gnutls26/raring

« back to all changes in this revision

Viewing changes to gl/m4/gettimeofday.m4

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# serial 12
 
1
# serial 15
2
2
 
3
 
# Copyright (C) 2001-2003, 2005, 2007, 2009 Free Software Foundation, Inc.
 
3
# Copyright (C) 2001-2003, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
4
4
# This file is free software; the Free Software Foundation
5
5
# gives unlimited permission to copy and/or distribute it,
6
6
# with or without modifications, as long as this notice is preserved.
11
11
[
12
12
  AC_REQUIRE([AC_C_RESTRICT])
13
13
  AC_REQUIRE([gl_HEADER_SYS_TIME_H])
 
14
  AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
14
15
  AC_CHECK_FUNCS_ONCE([gettimeofday])
15
16
 
16
 
  AC_CACHE_CHECK([for gettimeofday with POSIX signature],
17
 
    [gl_cv_func_gettimeofday_posix_signature],
18
 
    [AC_COMPILE_IFELSE(
19
 
       [AC_LANG_PROGRAM(
20
 
          [[#include <sys/time.h>
21
 
            struct timeval c;
22
 
          ]],
23
 
          [[
24
 
            int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
25
 
            int x = f (&c, 0);
26
 
            return !(x | c.tv_sec | c.tv_usec);
27
 
          ]])],
28
 
        [gl_cv_func_gettimeofday_posix_signature=yes],
29
 
        [gl_cv_func_gettimeofday_posix_signature=no])])
30
 
 
31
 
  gl_FUNC_GETTIMEOFDAY_CLOBBER
32
 
 
33
 
  if test $gl_cv_func_gettimeofday_posix_signature != yes; then
34
 
    REPLACE_GETTIMEOFDAY=1
35
 
    SYS_TIME_H=sys/time.h
36
 
    if test $gl_cv_func_gettimeofday_clobber != yes; then
 
17
  gl_gettimeofday_timezone=void
 
18
  if test $ac_cv_func_gettimeofday != yes; then
 
19
    HAVE_GETTIMEOFDAY=0
 
20
    AC_LIBOBJ([gettimeofday])
 
21
    gl_PREREQ_GETTIMEOFDAY
 
22
  else
 
23
    gl_FUNC_GETTIMEOFDAY_CLOBBER
 
24
    AC_CACHE_CHECK([for gettimeofday with POSIX signature],
 
25
      [gl_cv_func_gettimeofday_posix_signature],
 
26
      [AC_COMPILE_IFELSE(
 
27
         [AC_LANG_PROGRAM(
 
28
            [[#include <sys/time.h>
 
29
              struct timeval c;
 
30
              int gettimeofday (struct timeval *restrict, void *restrict);
 
31
            ]],
 
32
            [[/* glibc uses struct timezone * rather than the POSIX void *
 
33
                 if _GNU_SOURCE is defined.  However, since the only portable
 
34
                 use of gettimeofday uses NULL as the second parameter, and
 
35
                 since the glibc definition is actually more typesafe, it is
 
36
                 not worth wrapping this to get a compliant signature.  */
 
37
              int (*f) (struct timeval *restrict, void *restrict)
 
38
                = gettimeofday;
 
39
              int x = f (&c, 0);
 
40
              return !(x | c.tv_sec | c.tv_usec);
 
41
            ]])],
 
42
          [gl_cv_func_gettimeofday_posix_signature=yes],
 
43
          [AC_COMPILE_IFELSE(
 
44
            [AC_LANG_PROGRAM(
 
45
              [[#include <sys/time.h>
 
46
int gettimeofday (struct timeval *restrict, struct timezone *restrict);
 
47
              ]])],
 
48
            [gl_cv_func_gettimeofday_posix_signature=almost],
 
49
            [gl_cv_func_gettimeofday_posix_signature=no])])])
 
50
    if test $gl_cv_func_gettimeofday_posix_signature = almost; then
 
51
      gl_gettimeofday_timezone='struct timezone'
 
52
    elif test $gl_cv_func_gettimeofday_posix_signature != yes; then
 
53
      REPLACE_GETTIMEOFDAY=1
37
54
      AC_LIBOBJ([gettimeofday])
38
55
      gl_PREREQ_GETTIMEOFDAY
39
56
    fi
40
57
  fi
 
58
  AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
 
59
    [Define this to 'void' or 'struct timezone' to match the system's
 
60
     declaration of the second argument to gettimeofday.])
41
61
])
42
62
 
43
63
 
56
76
  [gl_cv_func_gettimeofday_clobber],
57
77
  [AC_RUN_IFELSE(
58
78
     [AC_LANG_PROGRAM(
59
 
        [[#include <string.h>
60
 
          #include <sys/time.h>
61
 
          #include <time.h>
62
 
          #include <stdlib.h>
63
 
        ]],
64
 
        [[
65
 
          time_t t = 0;
66
 
          struct tm *lt;
67
 
          struct tm saved_lt;
68
 
          struct timeval tv;
69
 
          lt = localtime (&t);
70
 
          saved_lt = *lt;
71
 
          gettimeofday (&tv, NULL);
72
 
          return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
73
 
        ]])],
 
79
        [[#include <string.h>
 
80
          #include <sys/time.h>
 
81
          #include <time.h>
 
82
          #include <stdlib.h>
 
83
        ]],
 
84
        [[
 
85
          time_t t = 0;
 
86
          struct tm *lt;
 
87
          struct tm saved_lt;
 
88
          struct timeval tv;
 
89
          lt = localtime (&t);
 
90
          saved_lt = *lt;
 
91
          gettimeofday (&tv, NULL);
 
92
          return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
 
93
        ]])],
74
94
     [gl_cv_func_gettimeofday_clobber=no],
75
95
     [gl_cv_func_gettimeofday_clobber=yes],
76
96
     dnl When crosscompiling, assume it is broken.
78
98
 
79
99
 if test $gl_cv_func_gettimeofday_clobber = yes; then
80
100
   REPLACE_GETTIMEOFDAY=1
81
 
   SYS_TIME_H=sys/time.h
82
101
   gl_GETTIMEOFDAY_REPLACE_LOCALTIME
83
102
   AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
84
103
     [Define if gettimeofday clobbers the localtime buffer.])