Path: blob/master/thirdparty/linuxbsd_headers/pulse/timeval.h
9905 views
#ifndef footimevalhfoo1#define footimevalhfoo23/***4This file is part of PulseAudio.56Copyright 2004-2006 Lennart Poettering7Copyright 2006 Pierre Ossman <[email protected]> for Cendio AB89PulseAudio is free software; you can redistribute it and/or modify10it under the terms of the GNU Lesser General Public License as11published by the Free Software Foundation; either version 2.1 of the12License, or (at your option) any later version.1314PulseAudio is distributed in the hope that it will be useful, but15WITHOUT ANY WARRANTY; without even the implied warranty of16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17Lesser General Public License for more details.1819You should have received a copy of the GNU Lesser General Public20License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.21***/2223#include <pulse/cdecl.h>24#include <pulse/gccmacro.h>25#include <pulse/sample.h>26#include <pulse/version.h>2728/** \file29* Utility functions for handling timeval calculations */3031PA_C_DECL_BEGIN3233/** The number of milliseconds in a second */34#define PA_MSEC_PER_SEC ((pa_usec_t) 1000ULL)3536/** The number of microseconds in a second */37#define PA_USEC_PER_SEC ((pa_usec_t) 1000000ULL)3839/** The number of nanoseconds in a second */40#define PA_NSEC_PER_SEC ((unsigned long long) 1000000000ULL)4142/** The number of microseconds in a millisecond */43#define PA_USEC_PER_MSEC ((pa_usec_t) 1000ULL)4445/** The number of nanoseconds in a millisecond */46#define PA_NSEC_PER_MSEC ((unsigned long long) 1000000ULL)4748/** The number of nanoseconds in a microsecond */49#define PA_NSEC_PER_USEC ((unsigned long long) 1000ULL)5051/** Invalid time in usec. \since 0.9.15 */52#define PA_USEC_INVALID ((pa_usec_t) -1)5354/** Biggest time in usec. \since 0.9.18 */55#define PA_USEC_MAX ((pa_usec_t) -2)5657struct timeval;5859/** Return the current wallclock timestamp, just like UNIX gettimeofday(). */60struct timeval *pa_gettimeofday(struct timeval *tv);6162/** Calculate the difference between the two specified timeval63* structs. */64pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) PA_GCC_PURE;6566/** Compare the two timeval structs and return 0 when equal, negative when a < b, positive otherwise */67int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) PA_GCC_PURE;6869/** Return the time difference between now and the specified timestamp */70pa_usec_t pa_timeval_age(const struct timeval *tv);7172/** Add the specified time in microseconds to the specified timeval structure */73struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v);7475/** Subtract the specified time in microseconds to the specified timeval structure. \since 0.9.11 */76struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v);7778/** Store the specified usec value in the timeval struct. \since 0.9.7 */79struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v);8081/** Load the specified tv value and return it in usec. \since 0.9.7 */82pa_usec_t pa_timeval_load(const struct timeval *tv);8384PA_C_DECL_END8586#endif878889