source: roaraudio/libroarpulse/timeval.c @ 4960:60cdebcb83ef

Last change on this file since 4960:60cdebcb83ef was 4708:c9d40761088a, checked in by phi, 9 years ago

updated copyright statements

File size: 2.4 KB
Line 
1//timeval.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from libpulse*. They are mostly copyrighted by:
7 *  Lennart Poettering <poettering@users.sourceforge.net> and
8 *  Pierre Ossman <drzeus@drzeus.cx>
9 *
10 *  This file is part of libroarpulse a part of RoarAudio,
11 *  a cross-platform sound system for both, home and professional use.
12 *  See README for details.
13 *
14 *  This file is free software; you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License version 3
16 *  as published by the Free Software Foundation.
17 *
18 *  RoarAudio is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with this software; see the file COPYING.  If not, write to
25 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
27 *
28 *  NOTE for everyone want's to change something and send patches:
29 *  read README and HACKING! There a addition information on
30 *  the license of this document you need to read before you send
31 *  any patches.
32 *
33 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
34 *  or libpulse*:
35 *  The libs libroaresd, libroararts and libroarpulse link this libroar
36 *  and are therefore GPL. Because of this it may be illigal to use
37 *  them with any software that uses libesd, libartsc or libpulse*.
38 */
39
40#include <libroarpulse/libroarpulse.h>
41
42struct timeval *pa_gettimeofday(struct timeval *tv) {
43#ifdef ROAR_HAVE_GETTIMEOFDAY
44 if ( gettimeofday(tv, NULL) == -1 ) {
45  return NULL;
46 } else {
47  return tv;
48 }
49#else
50 return NULL;
51#endif
52}
53
54pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b);
55int pa_timeval_cmp(const struct timeval *a, const struct timeval *b);
56pa_usec_t pa_timeval_age(const struct timeval *tv);
57struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) {
58 unsigned long long int secs;
59
60 if ( tv == NULL )
61  return NULL;
62
63 secs = v/1000000LLU;
64
65 tv->tv_sec += secs;
66
67 v -= secs*1000000LLU;
68
69 tv->tv_usec += v;
70
71 while ( tv->tv_usec > 1000000LLU ) {
72  tv->tv_usec -= 1000000LLU;
73  tv->tv_sec  += 1;
74 }
75
76 return tv;
77}
78
79
80//ll
Note: See TracBrowser for help on using the repository browser.