* mtime.c: high resolution time management functions
* Functions are prototyped in vlc_mtime.h.
*****************************************************************************
- * Copyright (C) 1998-2007 the VideoLAN team
+ * Copyright (C) 1998-2007 VLC authors and VideoLAN
* Copyright © 2006-2007 Rémi Denis-Courmont
* $Id$
*
* Rémi Denis-Courmont <rem$videolan,org>
* Gisle Vanem
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-#if !defined (_POSIX_TIMERS)
+#if !defined (_POSIX_TIMERS) || defined (_WIN32)
# define _POSIX_TIMERS (-1)
-# include <sys/time.h>
-#elif defined __APPLE__
-# include <sys/time.h>
-#else
+#endif
+#if (_POSIX_TIMERS > 0)
# include <time.h> /* clock_gettime() */
+#else
+# include <sys/time.h>
#endif
/**
return p_date->date;
}
-#ifndef HAVE_GETTIMEOFDAY
-
-#ifdef WIN32
-
-/*
- * Number of micro-seconds between the beginning of the Windows epoch
- * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
- *
- * This assumes all Win32 compilers have 64-bit support.
- */
-#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) || defined(__WATCOMC__)
-# define DELTA_EPOCH_IN_USEC 11644473600000000Ui64
-#else
-# define DELTA_EPOCH_IN_USEC 11644473600000000ULL
-#endif
-
-static uint64_t filetime_to_unix_epoch (const FILETIME *ft)
-{
- uint64_t res = (uint64_t) ft->dwHighDateTime << 32;
-
- res |= ft->dwLowDateTime;
- res /= 10; /* from 100 nano-sec periods to usec */
- res -= DELTA_EPOCH_IN_USEC; /* from Win epoch to Unix epoch */
- return (res);
-}
-
-static int gettimeofday (struct timeval *tv, void *tz )
-{
- FILETIME ft;
- uint64_t tim;
-
- if (!tv) {
- return VLC_EGENERIC;
- }
- GetSystemTimeAsFileTime (&ft);
- tim = filetime_to_unix_epoch (&ft);
- tv->tv_sec = (long) (tim / 1000000L);
- tv->tv_usec = (long) (tim % 1000000L);
- return (0);
-}
-
-#endif
-
-#endif
-
/**
* @return NTP 64-bits timestamp in host byte order.
*/