Skip to content

Commit

Permalink
time: Export git_time_monotonic
Browse files Browse the repository at this point in the history
  • Loading branch information
vmg committed Sep 13, 2016
1 parent bba704a commit 2749ff4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions include/git2/sys/time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_time_h__
#define INCLUDE_git_time_h__

#include "git2/common.h"

GIT_BEGIN_DECL

/**
* Return a monotonic time value, useful for measuring running time
* and setting up timeouts.
*
* The returned value is an arbitrary point in time -- it can only be
* used when comparing it to another `git_time_monotonic` call.
*
* The time is returned in seconds, with a decimal fraction that differs
* on accuracy based on the underlying system, but should be least
* accurate to Nanoseconds.
*
* This function cannot fail.
*/
GIT_EXTERN(double) git_time_monotonic(void);

GIT_END_DECL
#endif

5 changes: 5 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst)
return length;
}

double git_time_monotonic(void)
{
return git__timer();
}

#ifdef GIT_WIN32
int git__getenv(git_buf *out, const char *name)
{
Expand Down

0 comments on commit 2749ff4

Please sign in to comment.