diff options
author | Vicent Marti <tanoku@gmail.com> | 2016-09-13 15:52:43 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2016-09-13 15:52:43 +0200 |
commit | 2749ff46d8db3fae270334cace82201d49e38c54 (patch) | |
tree | adec8b173c4895380252d329cde6bdda005cc44e | |
parent | bba704adf79e86ac8efd2b18cc57b478077a2a19 (diff) | |
download | libgit2-2749ff46d8db3fae270334cace82201d49e38c54.tar.gz |
time: Export `git_time_monotonic`vmg/time
-rw-r--r-- | include/git2/sys/time.h | 31 | ||||
-rw-r--r-- | src/util.c | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/include/git2/sys/time.h b/include/git2/sys/time.h new file mode 100644 index 000000000..e4f87e6e1 --- /dev/null +++ b/include/git2/sys/time.h @@ -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 + diff --git a/src/util.c b/src/util.c index e9cccea20..76ca711b2 100644 --- a/src/util.c +++ b/src/util.c @@ -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) { |