[libbluray-devel] Move code from time.h to time.c

hpi1 git at videolan.org
Thu Feb 19 12:20:26 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Feb 18 21:35:27 2015 +0200| [51820f9075037363616f614a1122bb5310549e4f] | committer: hpi1

Move code from time.h to time.c

Avoid pulling system-dependent headers to other files.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=51820f9075037363616f614a1122bb5310549e4f
---

 Makefile.am     |    3 ++-
 src/util/time.c |   75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/util/time.h |   54 +++------------------------------------
 3 files changed, 80 insertions(+), 52 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b01688d..e03e926 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -121,7 +121,8 @@ libbluray_la_SOURCES = \
 	src/util/refcnt.c \
 	src/util/strutl.h \
 	src/util/strutl.c \
-	src/util/time.h
+	src/util/time.h \
+	src/util/time.c
 
 if HAVE_DARWIN
 libbluray_la_SOURCES+= \
diff --git a/src/util/time.c b/src/util/time.c
new file mode 100644
index 0000000..e0480c5
--- /dev/null
+++ b/src/util/time.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of libbluray
+ * Copyright (C) 2010  VideoLAN
+ *
+ * This library 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 library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "time.h"
+
+#include <stdint.h>
+
+#if defined(_WIN32)
+#   include <windows.h>
+#elif defined(HAVE_SYS_TIME_H)
+#   include <sys/time.h>
+#else
+#   error no time support found
+#endif
+
+#if defined(_WIN32)
+
+static uint64_t _bd_get_scr_impl(void)
+{
+    HANDLE thread;
+    DWORD_PTR mask;
+    LARGE_INTEGER frequency, counter;
+
+    thread = GetCurrentThread();
+    mask = SetThreadAffinityMask(thread, 1);
+    QueryPerformanceFrequency(&frequency);
+    QueryPerformanceCounter(&counter);
+    SetThreadAffinityMask(thread, mask);
+
+    return (uint64_t)(counter.QuadPart * 1000.0 / frequency.QuadPart) * 90;
+}
+
+#elif defined(HAVE_SYS_TIME_H)
+
+static uint64_t _bd_get_scr_impl(void)
+{
+    struct timeval tv;
+    gettimeofday(&tv, 0);
+    return ((uint64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000) * 90;
+}
+
+#endif
+
+uint64_t bd_get_scr(void)
+{
+    static uint64_t t0 = (uint64_t)-1;
+
+    uint64_t now = _bd_get_scr_impl();
+
+    if (t0 > now) {
+        t0 = now;
+    }
+
+    return now - t0;
+}
diff --git a/src/util/time.h b/src/util/time.h
index b512c99..62a1fcb 100644
--- a/src/util/time.h
+++ b/src/util/time.h
@@ -20,58 +20,10 @@
 #ifndef LIBBLURAY_TIME_H_
 #define LIBBLURAY_TIME_H_
 
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "attributes.h"
 
-#if defined(_WIN32)
-#   include <windows.h>
-#elif defined(HAVE_SYS_TIME_H)
-#   include <sys/time.h>
-#else
-#   error no time support found
-#endif
-
-
-#if defined(_WIN32)
-static uint64_t _bd_get_scr_impl(void)
-{
-    HANDLE thread;
-    DWORD_PTR mask;
-    LARGE_INTEGER frequency, counter;
-
-    thread = GetCurrentThread();
-    mask = SetThreadAffinityMask(thread, 1);
-    QueryPerformanceFrequency(&frequency);
-    QueryPerformanceCounter(&counter);
-    SetThreadAffinityMask(thread, mask);
-
-    return (uint64_t)(counter.QuadPart * 1000.0 / frequency.QuadPart) * 90;
-}
-
-#elif defined(HAVE_SYS_TIME_H)
-
-static uint64_t _bd_get_scr_impl(void)
-{
-    struct timeval tv;
-    gettimeofday(&tv, 0);
-    return ((uint64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000) * 90;
-}
-
-#endif
-
-static uint64_t bd_get_scr(void)
-{
-    static uint64_t t0 = (uint64_t)-1;
-
-    uint64_t now = _bd_get_scr_impl();
-
-    if (t0 > now) {
-        t0 = now;
-    }
-
-    return now - t0;
-}
+#include <stdint.h>
 
+BD_PRIVATE uint64_t bd_get_scr(void);
 
 #endif // LIBBLURAY_TIME_H_



More information about the libbluray-devel mailing list