/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped2223#include <tv.h>24#include <tm.h>2526#include "FEATURE/tvlib"2728int29tvgettime(Tv_t* tv)30{3132#if _lib_clock_gettime && defined(CLOCK_REALTIME)3334struct timespec s;3536clock_gettime(CLOCK_REALTIME, &s);37tv->tv_sec = s.tv_sec;38tv->tv_nsec = s.tv_nsec;3940#else4142#if defined(tmgettimeofday)4344struct timeval v;4546tmgettimeofday(&v);47tv->tv_sec = v.tv_sec;48tv->tv_nsec = v.tv_usec * 1000;4950#else5152static time_t s;53static uint32_t n;5455if ((tv->tv_sec = time(NiL)) != s)56{57s = tv->tv_sec;58n = 0;59}60else61n += 1000;62tv->tv_nsec = n;6364#endif6566#endif6768return 0;69}707172