]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/Clock.h
import ceph quincy 17.2.4
[ceph.git] / ceph / src / common / Clock.h
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#ifndef CEPH_CLOCK_H
16#define CEPH_CLOCK_H
17
18#include "include/utime.h"
19
20#include <time.h>
21
11fdf7f2
TL
22static inline utime_t ceph_clock_now()
23{
24#if defined(__linux__)
25 struct timespec tp;
26 clock_gettime(CLOCK_REALTIME, &tp);
27 utime_t n(tp);
28#else
29 struct timeval tv;
30 gettimeofday(&tv, nullptr);
31 utime_t n(&tv);
32#endif
33 return n;
34}
7c673cae
FG
35
36#endif