~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/os/os_clock.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 2001-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 */
7
 
 
8
 
#include "db_config.h"
9
 
 
10
 
#ifndef lint
11
 
static const char revid[] = "$Id$";
12
 
#endif /* not lint */
13
 
 
14
 
#ifndef NO_SYSTEM_INCLUDES
15
 
#include <sys/types.h>
16
 
 
17
 
#if TIME_WITH_SYS_TIME
18
 
#include <sys/time.h>
19
 
#include <time.h>
20
 
#else
21
 
#if HAVE_SYS_TIME_H
22
 
#include <sys/time.h>
23
 
#else
24
 
#include <time.h>
25
 
#endif /* HAVE_SYS_TIME_H */
26
 
#endif /* TIME_WITH SYS_TIME */
27
 
 
28
 
#include <string.h>
29
 
#endif
30
 
 
31
 
#include "db_int.h"
32
 
 
33
 
/*
34
 
 * __os_clock --
35
 
 *      Return the current time-of-day clock in seconds and microseconds.
36
 
 *
37
 
 * PUBLIC: int __os_clock __P((DB_ENV *, u_int32_t *, u_int32_t *));
38
 
 */
39
 
int
40
 
__os_clock(dbenv, secsp, usecsp)
41
 
        DB_ENV *dbenv;
42
 
        u_int32_t *secsp, *usecsp;      /* Seconds and microseconds. */
43
 
{
44
 
#if defined(HAVE_GETTIMEOFDAY)
45
 
        struct timeval tp;
46
 
        int ret;
47
 
 
48
 
retry:  if (gettimeofday(&tp, NULL) != 0) {
49
 
                if ((ret = __os_get_errno()) == EINTR)
50
 
                        goto retry;
51
 
                __db_err(dbenv, "gettimeofday: %s", strerror(ret));
52
 
                return (ret);
53
 
        }
54
 
 
55
 
        if (secsp != NULL)
56
 
                *secsp = tp.tv_sec;
57
 
        if (usecsp != NULL)
58
 
                *usecsp = tp.tv_usec;
59
 
#endif
60
 
#if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_CLOCK_GETTIME)
61
 
        struct timespec tp;
62
 
        int ret;
63
 
 
64
 
retry:  if (clock_gettime(CLOCK_REALTIME, &tp) != 0) {
65
 
                if ((ret = __os_get_errno()) == EINTR)
66
 
                        goto retry;
67
 
                __db_err(dbenv, "clock_gettime: %s", strerror(ret));
68
 
                return (ret);
69
 
        }
70
 
 
71
 
        if (secsp != NULL)
72
 
                *secsp = tp.tv_sec;
73
 
        if (usecsp != NULL)
74
 
                *usecsp = tp.tv_nsec / 1000;
75
 
#endif
76
 
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_CLOCK_GETTIME)
77
 
        time_t now;
78
 
        int ret;
79
 
 
80
 
        if (time(&now) == (time_t)-1) {
81
 
                ret = __os_get_errno();
82
 
                __db_err(dbenv, "time: %s", strerror(ret));
83
 
                return (ret);
84
 
        }
85
 
 
86
 
        if (secsp != NULL)
87
 
                *secsp = now;
88
 
        if (usecsp != NULL)
89
 
                *usecsp = 0;
90
 
#endif
91
 
        return (0);
92
 
}