~ubuntu-branches/ubuntu/natty/curl/natty-proposed

« back to all changes in this revision

Viewing changes to tests/libtest/testutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-05-24 21:12:19 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (3.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20090524211219-7jgcwuhl04ixuqsm
Tags: upstream-7.19.5
ImportĀ upstreamĀ versionĀ 7.19.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: testutil.c,v 1.6 2008-05-12 02:04:22 yangtse Exp $
 
21
 * $Id: testutil.c,v 1.8 2008-09-20 04:26:57 yangtse Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
25
25
 
26
26
#include "testutil.h"
 
27
#include "memdebug.h"
27
28
 
28
29
#if defined(WIN32) && !defined(MSDOS)
29
30
 
54
55
  */
55
56
  struct timeval now;
56
57
  struct timespec tsnow;
57
 
  (void)clock_gettime(CLOCK_MONOTONIC, &tsnow);
58
 
  now.tv_sec = tsnow.tv_sec;
59
 
  now.tv_usec = tsnow.tv_nsec / 1000;
 
58
  if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
 
59
    now.tv_sec = tsnow.tv_sec;
 
60
    now.tv_usec = tsnow.tv_nsec / 1000;
 
61
  }
 
62
  /*
 
63
  ** Even when the configure process has truly detected monotonic clock
 
64
  ** availability, it might happen that it is not actually available at
 
65
  ** run-time. When this occurs simply fallback to other time source.
 
66
  */
 
67
#ifdef HAVE_GETTIMEOFDAY
 
68
  else
 
69
    (void)gettimeofday(&now, NULL);
 
70
#else
 
71
  else {
 
72
    now.tv_sec = (long)time(NULL);
 
73
    now.tv_usec = 0;
 
74
  }
 
75
#endif
60
76
  return now;
61
77
}
62
78