[libdispatch-changes] [78] trunk/src
source_changes at macosforge.org
source_changes at macosforge.org
Sat Oct 31 15:17:15 PDT 2009
Revision: 78
http://trac.macosforge.org/projects/libdispatch/changeset/78
Author: robert at fledge.watson.org
Date: 2009-10-31 15:17:13 -0700 (Sat, 31 Oct 2009)
Log Message:
-----------
Move mach2nano/nano2mach from source.c to shims/time.c.
Submitted by: Paolo Bonzini <bonzini at gnu.org>
Modified Paths:
--------------
trunk/src/Makefile.am
trunk/src/shims/time.h
trunk/src/source.c
Added Paths:
-----------
trunk/src/shims/time.c
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-10-31 11:54:09 UTC (rev 77)
+++ trunk/src/Makefile.am 2009-10-31 22:17:13 UTC (rev 78)
@@ -17,7 +17,8 @@
time.c
libshims_la_SOURCES= \
- shims/mach.c
+ shims/mach.c \
+ shims/time.c
libdispatch_la_CFLAGS=-Wall
INCLUDES=-I$(top_builddir) -I$(top_srcdir) \
Added: trunk/src/shims/time.c
===================================================================
--- trunk/src/shims/time.c (rev 0)
+++ trunk/src/shims/time.c 2009-10-31 22:17:13 UTC (rev 78)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+// for architectures that don't always return mach_absolute_time() in nanoseconds
+#if !defined(__i386__) && !defined(__x86_64__) && defined(HAVE_MACH_ABSOLUTE_TIME)
+static mach_timebase_info_data_t tbi;
+static dispatch_once_t tbi_pred;
+
+static void
+_dispatch_convert_init(void *context __attribute__((unused)))
+{
+ dispatch_assume_zero(mach_timebase_info(&tbi));
+}
+
+uint64_t
+_dispatch_convert_mach2nano(uint64_t val)
+{
+#ifdef __LP64__
+ __uint128_t tmp;
+#else
+ long double tmp;
+#endif
+
+ dispatch_once_f(&tbi_pred, NULL, _dispatch_convert_init);
+
+ tmp = val;
+ tmp *= tbi.numer;
+ tmp /= tbi.denom;
+
+ return tmp;
+}
+
+uint64_t
+_dispatch_convert_nano2mach(uint64_t val)
+{
+#ifdef __LP64__
+ __uint128_t tmp;
+#else
+ long double tmp;
+#endif
+
+ dispatch_once_f(&tbi_pred, NULL, _dispatch_convert_init);
+
+ tmp = val;
+ tmp *= tbi.denom;
+ tmp /= tbi.numer;
+
+ return tmp;
+}
+#endif
+
Modified: trunk/src/shims/time.h
===================================================================
--- trunk/src/shims/time.h 2009-10-31 11:54:09 UTC (rev 77)
+++ trunk/src/shims/time.h 2009-10-31 22:17:13 UTC (rev 78)
@@ -27,6 +27,15 @@
#ifndef __DISPATCH_SHIMS_TIME__
#define __DISPATCH_SHIMS_TIME__
+#if defined(__i386__) || defined(__x86_64__) || !defined(HAVE_MACH_ABSOLUTE_TIME)
+// these architectures always return mach_absolute_time() in nanoseconds
+#define _dispatch_convert_mach2nano(x) (x)
+#define _dispatch_convert_nano2mach(x) (x)
+#else
+extern uint64_t _dispatch_convert_mach2nano(uint64_t val);
+extern uint64_t _dispatch_convert_nano2mach(uint64_t val);
+#endif
+
static inline uint64_t
_dispatch_absolute_time(void)
{
Modified: trunk/src/source.c
===================================================================
--- trunk/src/source.c 2009-10-31 11:54:09 UTC (rev 77)
+++ trunk/src/source.c 2009-10-31 22:17:13 UTC (rev 78)
@@ -1443,57 +1443,6 @@
}
}
-#if defined(__i386__) || defined(__x86_64__) || !defined(HAVE_MACH_ABSOLUTE_TIME)
-// these architectures always return mach_absolute_time() in nanoseconds
-#define _dispatch_convert_mach2nano(x) (x)
-#define _dispatch_convert_nano2mach(x) (x)
-#else
-static mach_timebase_info_data_t tbi;
-static dispatch_once_t tbi_pred;
-
-static void
-_dispatch_convert_init(void *context __attribute__((unused)))
-{
- dispatch_assume_zero(mach_timebase_info(&tbi));
-}
-
-static uint64_t
-_dispatch_convert_mach2nano(uint64_t val)
-{
-#ifdef __LP64__
- __uint128_t tmp;
-#else
- long double tmp;
-#endif
-
- dispatch_once_f(&tbi_pred, NULL, _dispatch_convert_init);
-
- tmp = val;
- tmp *= tbi.numer;
- tmp /= tbi.denom;
-
- return tmp;
-}
-
-static uint64_t
-_dispatch_convert_nano2mach(uint64_t val)
-{
-#ifdef __LP64__
- __uint128_t tmp;
-#else
- long double tmp;
-#endif
-
- dispatch_once_f(&tbi_pred, NULL, _dispatch_convert_init);
-
- tmp = val;
- tmp *= tbi.denom;
- tmp /= tbi.numer;
-
- return tmp;
-}
-#endif
-
// approx 1 year (60s * 60m * 24h * 365d)
#define FOREVER_SEC 3153600l
#define FOREVER_NSEC 31536000000000000ull
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-changes/attachments/20091031/7d9dc1dc/attachment.html>
More information about the libdispatch-changes
mailing list