]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/Clock.cc
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / common / Clock.cc
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15
16#include "common/Clock.h"
17#include "common/ceph_context.h"
18#include "common/config.h"
19#include "include/utime.h"
20
21#include <time.h>
22
23utime_t ceph_clock_now()
24{
25#if defined(__linux__)
26 struct timespec tp;
27 clock_gettime(CLOCK_REALTIME, &tp);
28 utime_t n(tp);
29#else
30 struct timeval tv;
31 gettimeofday(&tv, NULL);
32 utime_t n(&tv);
33#endif
34 return n;
35}
36
37time_t ceph_clock_gettime()
38{
39 return time(NULL);
40}