summaryrefslogtreecommitdiffstats
path: root/src/polypcore/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-04-06 23:31:40 +0000
committerLennart Poettering <lennart@poettering.net>2006-04-06 23:31:40 +0000
commit1be00173c134b837ddda2eba77b2d914ce244140 (patch)
treeed5b1136f3063ff52ef9e4425dc254667bdd0da6 /src/polypcore/util.c
parente872c751e1bde9dc996d967e32c457d9c8f0f0fc (diff)
change pa_gettimeofday() to return a pointer to the struct timeval*, instead of an int
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@645 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polypcore/util.c')
-rw-r--r--src/polypcore/util.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/polypcore/util.c b/src/polypcore/util.c
index f810b3bf..b37a25a3 100644
--- a/src/polypcore/util.c
+++ b/src/polypcore/util.c
@@ -418,9 +418,11 @@ char *pa_strlcpy(char *b, const char *s, size_t l) {
return b;
}
-int pa_gettimeofday(struct timeval *tv) {
+struct timeval *pa_gettimeofday(struct timeval *tv) {
#ifdef HAVE_GETTIMEOFDAY
- return gettimeofday(tv, NULL);
+ assert(tv);
+
+ return gettimeofday(tv, NULL) < 0 ? NULL : tv;
#elif defined(OS_IS_WIN32)
/*
* Copied from implementation by Steven Edwards (LGPL).
@@ -437,18 +439,18 @@ int pa_gettimeofday(struct timeval *tv) {
LARGE_INTEGER li;
__int64 t;
- if (tv) {
- GetSystemTimeAsFileTime(&ft);
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
- t = li.QuadPart; /* In 100-nanosecond intervals */
- t -= EPOCHFILETIME; /* Offset to the Epoch time */
- t /= 10; /* In microseconds */
- tv->tv_sec = (long)(t / 1000000);
- tv->tv_usec = (long)(t % 1000000);
- }
+ assert(tv);
- return 0;
+ GetSystemTimeAsFileTime(&ft);
+ li.LowPart = ft.dwLowDateTime;
+ li.HighPart = ft.dwHighDateTime;
+ t = li.QuadPart; /* In 100-nanosecond intervals */
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */
+ t /= 10; /* In microseconds */
+ tv->tv_sec = (long)(t / 1000000);
+ tv->tv_usec = (long)(t % 1000000);
+
+ return tv;
#else
#error "Platform lacks gettimeofday() or equivalent function."
#endif
@@ -503,8 +505,8 @@ int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) {
pa_usec_t pa_timeval_age(const struct timeval *tv) {
struct timeval now;
assert(tv);
- pa_gettimeofday(&now);
- return pa_timeval_diff(&now, tv);
+
+ return pa_timeval_diff(pa_gettimeofday(&now), tv);
}
/* Add the specified time inmicroseconds to the specified timeval structure */