[Midnightbsd-cvs] src [7722] trunk/contrib/libdispatch/src: fix several bugs with the build

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Aug 12 12:54:53 EDT 2016


Revision: 7722
          http://svnweb.midnightbsd.org/src/?rev=7722
Author:   laffer1
Date:     2016-08-12 12:54:53 -0400 (Fri, 12 Aug 2016)
Log Message:
-----------
fix several bugs with the build

Modified Paths:
--------------
    trunk/contrib/libdispatch/src/os_shims.h
    trunk/contrib/libdispatch/src/private.h
    trunk/contrib/libdispatch/src/queue.c

Added Paths:
-----------
    trunk/contrib/libdispatch/src/shims/time_2.h

Removed Paths:
-------------
    trunk/contrib/libdispatch/src/shims/time.h

Modified: trunk/contrib/libdispatch/src/os_shims.h
===================================================================
--- trunk/contrib/libdispatch/src/os_shims.h	2016-08-12 16:53:55 UTC (rev 7721)
+++ trunk/contrib/libdispatch/src/os_shims.h	2016-08-12 16:54:53 UTC (rev 7722)
@@ -65,6 +65,6 @@
 #include "shims/malloc_zone.h"
 #include "shims/tsd.h"
 #include "shims/perfmon.h"
-#include "shims/time.h"
+#include "shims/time_2.h"
 
 #endif

Modified: trunk/contrib/libdispatch/src/private.h
===================================================================
--- trunk/contrib/libdispatch/src/private.h	2016-08-12 16:53:55 UTC (rev 7721)
+++ trunk/contrib/libdispatch/src/private.h	2016-08-12 16:54:53 UTC (rev 7722)
@@ -31,6 +31,11 @@
 #include <TargetConditionals.h>
 #endif
 
+#if HAVE_MACH
+#include <mach/boolean.h>
+#include <mach/mach.h>
+#include <mach/message.h>
+#endif
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -81,6 +86,39 @@
 libdispatch_init(void);
 #endif
 
+#if HAVE_MACH
+#define DISPATCH_COCOA_COMPAT 1
+#if DISPATCH_COCOA_COMPAT
+
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+DISPATCH_EXPORT DISPATCH_NOTHROW
+mach_port_t
+_dispatch_get_main_queue_port_4CF(void);
+
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+DISPATCH_EXPORT DISPATCH_NOTHROW
+void
+_dispatch_main_queue_callback_4CF(mach_msg_header_t *msg);
+
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+DISPATCH_EXPORT
+void (*dispatch_begin_thread_4GC)(void);
+
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+DISPATCH_EXPORT
+void (*dispatch_end_thread_4GC)(void);
+
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+DISPATCH_EXPORT
+void *(*_dispatch_begin_NSAutoReleasePool)(void);
+
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+DISPATCH_EXPORT
+void (*_dispatch_end_NSAutoReleasePool)(void *);
+
+#endif
+#endif /* HAVE_MACH */
+
 /* pthreads magic */
 
 DISPATCH_NOTHROW void dispatch_atfork_prepare(void);
@@ -88,6 +126,15 @@
 DISPATCH_NOTHROW void dispatch_atfork_child(void);
 DISPATCH_NOTHROW void dispatch_init_pthread(pthread_t);
 
+#if HAVE_MACH
+/*
+ * Extract the context pointer from a mach message trailer.
+ */
+__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
+void *
+dispatch_mach_msg_get_context(mach_msg_header_t *msg);
+#endif
+
 __DISPATCH_END_DECLS
 
 #endif

Modified: trunk/contrib/libdispatch/src/queue.c
===================================================================
--- trunk/contrib/libdispatch/src/queue.c	2016-08-12 16:53:55 UTC (rev 7721)
+++ trunk/contrib/libdispatch/src/queue.c	2016-08-12 16:54:53 UTC (rev 7722)
@@ -531,7 +531,7 @@
 // 3 - _unused_
 // 4,5,6,7,8,9 - global queues
 // we use 'xadd' on Intel, so the initial value == next assigned
-unsigned long volatile _dispatch_queue_serial_numbers = 10;
+static unsigned long _dispatch_queue_serial_numbers = 10;
 
 // Note to later developers: ensure that any initialization changes are
 // made for statically allocated queues (i.e. _dispatch_main_q).

Deleted: trunk/contrib/libdispatch/src/shims/time.h
===================================================================
--- trunk/contrib/libdispatch/src/shims/time.h	2016-08-12 16:53:55 UTC (rev 7721)
+++ trunk/contrib/libdispatch/src/shims/time.h	2016-08-12 16:54:53 UTC (rev 7722)
@@ -1,122 +0,0 @@
-/*
- * 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@
- */
-
-/*
- * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
- * which are subject to change in future releases of Mac OS X. Any applications
- * relying on these interfaces WILL break.
- */
-
-#ifndef __DISPATCH_SHIMS_TIME__
-#define __DISPATCH_SHIMS_TIME__
-
-#ifndef __DISPATCH_INDIRECT__
-#error "Please #include <dispatch/dispatch.h> instead of this file directly."
-#endif
-
-uint64_t _dispatch_get_nanoseconds(void);
-
-#if TARGET_OS_WIN32
-static inline unsigned int
-sleep(unsigned int seconds)
-{
-	Sleep(seconds * 1000); // milliseconds
-	return 0;
-}
-#endif
-
-#if (defined(__i386__) || defined(__x86_64__)) && HAVE_MACH_ABSOLUTE_TIME
-// x86 currently implements mach time in nanoseconds; this is NOT likely to change
-#define _dispatch_time_mach2nano(x) (x)
-#define _dispatch_time_nano2mach(x) (x)
-#else
-typedef struct _dispatch_host_time_data_s {
-	long double frac;
-	bool ratio_1_to_1;
-	dispatch_once_t pred;
-} _dispatch_host_time_data_s;
-extern _dispatch_host_time_data_s _dispatch_host_time_data;
-extern void _dispatch_get_host_time_init(void *context);
-
-static inline uint64_t
-_dispatch_time_mach2nano(uint64_t machtime)
-{
-	_dispatch_host_time_data_s *const data = &_dispatch_host_time_data;
-	dispatch_once_f(&data->pred, NULL, _dispatch_get_host_time_init);
-
-	return (uint64_t)(machtime * data->frac);
-}
-
-static inline int64_t
-_dispatch_time_nano2mach(int64_t nsec)
-{
-	_dispatch_host_time_data_s *const data = &_dispatch_host_time_data;
-	dispatch_once_f(&data->pred, NULL, _dispatch_get_host_time_init);
-
-	if (slowpath(_dispatch_host_time_data.ratio_1_to_1)) {
-		return nsec;
-	}
-
-	long double big_tmp = (long double)nsec;
-
-	// Divide by tbi.numer/tbi.denom to convert nsec to Mach absolute time
-	big_tmp /= data->frac;
-
-	// Clamp to a 64bit signed int
-	if (slowpath(big_tmp > INT64_MAX)) {
-		return INT64_MAX;
-	}
-	if (slowpath(big_tmp < INT64_MIN)) {
-		return INT64_MIN;
-	}
-	return (int64_t)big_tmp;
-}
-#endif
-
-static inline uint64_t
-_dispatch_absolute_time(void)
-{
-#if HAVE_MACH_ABSOLUTE_TIME
-	return mach_absolute_time();
-#elif TARGET_OS_WIN32
-	LARGE_INTEGER now;
-	if (!QueryPerformanceCounter(&now)) {
-		return 0;
-	}
-	return now.QuadPart;
-#else
-	struct timespec ts;
-	int ret;
-
-#if HAVE_DECL_CLOCK_UPTIME
-	ret = clock_gettime(CLOCK_UPTIME, &ts);
-#elif HAVE_DECL_CLOCK_MONOTONIC
-	ret = clock_gettime(CLOCK_MONOTONIC, &ts);
-#else
-#error "clock_gettime: no supported absolute time clock"
-#endif
-	(void)dispatch_assume_zero(ret);
-
-	/* XXXRW: Some kind of overflow detection needed? */
-	return (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec);
-#endif
-}
-
-#endif /* __DISPATCH_SHIMS_TIME__ */

Added: trunk/contrib/libdispatch/src/shims/time_2.h
===================================================================
--- trunk/contrib/libdispatch/src/shims/time_2.h	                        (rev 0)
+++ trunk/contrib/libdispatch/src/shims/time_2.h	2016-08-12 16:54:53 UTC (rev 7722)
@@ -0,0 +1,122 @@
+/*
+ * 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@
+ */
+
+/*
+ * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch
+ * which are subject to change in future releases of Mac OS X. Any applications
+ * relying on these interfaces WILL break.
+ */
+
+#ifndef __DISPATCH_SHIMS_TIME__
+#define __DISPATCH_SHIMS_TIME__
+
+#ifndef __DISPATCH_INDIRECT__
+#error "Please #include <dispatch/dispatch.h> instead of this file directly."
+#endif
+
+uint64_t _dispatch_get_nanoseconds(void);
+
+#if TARGET_OS_WIN32
+static inline unsigned int
+sleep(unsigned int seconds)
+{
+	Sleep(seconds * 1000); // milliseconds
+	return 0;
+}
+#endif
+
+#if (defined(__i386__) || defined(__x86_64__)) && HAVE_MACH_ABSOLUTE_TIME
+// x86 currently implements mach time in nanoseconds; this is NOT likely to change
+#define _dispatch_time_mach2nano(x) (x)
+#define _dispatch_time_nano2mach(x) (x)
+#else
+typedef struct _dispatch_host_time_data_s {
+	long double frac;
+	bool ratio_1_to_1;
+	dispatch_once_t pred;
+} _dispatch_host_time_data_s;
+extern _dispatch_host_time_data_s _dispatch_host_time_data;
+extern void _dispatch_get_host_time_init(void *context);
+
+static inline uint64_t
+_dispatch_time_mach2nano(uint64_t machtime)
+{
+	_dispatch_host_time_data_s *const data = &_dispatch_host_time_data;
+	dispatch_once_f(&data->pred, NULL, _dispatch_get_host_time_init);
+
+	return (uint64_t)(machtime * data->frac);
+}
+
+static inline int64_t
+_dispatch_time_nano2mach(int64_t nsec)
+{
+	_dispatch_host_time_data_s *const data = &_dispatch_host_time_data;
+	dispatch_once_f(&data->pred, NULL, _dispatch_get_host_time_init);
+
+	if (slowpath(_dispatch_host_time_data.ratio_1_to_1)) {
+		return nsec;
+	}
+
+	long double big_tmp = (long double)nsec;
+
+	// Divide by tbi.numer/tbi.denom to convert nsec to Mach absolute time
+	big_tmp /= data->frac;
+
+	// Clamp to a 64bit signed int
+	if (slowpath(big_tmp > INT64_MAX)) {
+		return INT64_MAX;
+	}
+	if (slowpath(big_tmp < INT64_MIN)) {
+		return INT64_MIN;
+	}
+	return (int64_t)big_tmp;
+}
+#endif
+
+static inline uint64_t
+_dispatch_absolute_time(void)
+{
+#if HAVE_MACH_ABSOLUTE_TIME
+	return mach_absolute_time();
+#elif TARGET_OS_WIN32
+	LARGE_INTEGER now;
+	if (!QueryPerformanceCounter(&now)) {
+		return 0;
+	}
+	return now.QuadPart;
+#else
+	struct timespec ts;
+	int ret;
+
+#if HAVE_DECL_CLOCK_UPTIME
+	ret = clock_gettime(CLOCK_UPTIME, &ts);
+#elif HAVE_DECL_CLOCK_MONOTONIC
+	ret = clock_gettime(CLOCK_MONOTONIC, &ts);
+#else
+#error "clock_gettime: no supported absolute time clock"
+#endif
+	(void)dispatch_assume_zero(ret);
+
+	/* XXXRW: Some kind of overflow detection needed? */
+	return (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec);
+#endif
+}
+
+#endif /* __DISPATCH_SHIMS_TIME__ */


Property changes on: trunk/contrib/libdispatch/src/shims/time_2.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list