Merge pull request #214 from dgrove-oss/tweak-linux_base
Remove unused include of sys/user.h
diff --git a/src/BlocksRuntime/runtime.c b/src/BlocksRuntime/runtime.c
index 1e10636..164fe6e 100644
--- a/src/BlocksRuntime/runtime.c
+++ b/src/BlocksRuntime/runtime.c
@@ -12,8 +12,10 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#if HAVE_OBJC
#define __USE_GNU
#include <dlfcn.h>
+#endif
#if __has_include(<os/assumes.h>)
#include <os/assumes.h>
#else
@@ -202,6 +204,7 @@
static void (*_Block_destructInstance) (const void *aBlock) = _Block_destructInstance_default;
+#if HAVE_OBJC
/**************************************************************************
GC support SPI functions - called from ObjC runtime and CoreFoundation
***************************************************************************/
@@ -252,6 +255,7 @@
_Block_release_object = release;
_Block_destructInstance = dlsym(RTLD_DEFAULT, "objc_destructInstance");
}
+#endif // HAVE_OBJC
// Called from CF to indicate MRR. Newer version uses a versioned structure, so we can add more functions
// without defining a new entry point.
diff --git a/src/Makefile.am b/src/Makefile.am
index 1e2ba65..a574288 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,8 +88,10 @@
libdispatch_la_SOURCES+= BlocksRuntime/data.c BlocksRuntime/runtime.c
CBLOCKS_FLAGS+= -I$(top_srcdir)/src/BlocksRuntime
CXXBLOCKS_FLAGS+= -I$(top_srcdir)/src/BlocksRuntime
+if USE_OBJC
BLOCKS_RUNTIME_LIBS=-ldl
endif
+endif
libdispatch_la_LDFLAGS=-avoid-version
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS) $(BLOCKS_RUNTIME_LIBS)
diff --git a/src/swift/Data.swift b/src/swift/Data.swift
index 30a20b8..72f53d6 100644
--- a/src/swift/Data.swift
+++ b/src/swift/Data.swift
@@ -50,7 +50,9 @@
///
/// - parameter bytes: A pointer to the memory. It will be copied.
public init(bytes buffer: UnsafeBufferPointer<UInt8>) {
- let d = dispatch_data_create(buffer.baseAddress!, buffer.count, nil, _dispatch_data_destructor_default())
+ let d = buffer.baseAddress == nil ? _swift_dispatch_data_empty()
+ : dispatch_data_create(buffer.baseAddress!, buffer.count, nil,
+ _dispatch_data_destructor_default())
self.init(data: d)
}
@@ -60,7 +62,8 @@
/// - parameter deallocator: Specifies the mechanism to free the indicated buffer.
public init(bytesNoCopy bytes: UnsafeBufferPointer<UInt8>, deallocator: Deallocator = .free) {
let (q, b) = deallocator._deallocator
- let d = dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)
+ let d = bytes.baseAddress == nil ? _swift_dispatch_data_empty()
+ : dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)
self.init(data: d)
}
diff --git a/src/swift/Time.swift b/src/swift/Time.swift
index 46a71d6..af31f6c 100644
--- a/src/swift/Time.swift
+++ b/src/swift/Time.swift
@@ -37,6 +37,12 @@
/// - uptimeNanoseconds: The number of nanoseconds since boot, excluding
/// time the system spent asleep
/// - Returns: A new `DispatchTime`
+ /// - Discussion: This clock is the same as the value returned by
+ /// `mach_absolute_time` when converted into nanoseconds.
+ /// Note that `DispatchTime(uptimeNanoseconds: 0)` is
+ /// equivalent to `DispatchTime.now()`, that is, its value
+ /// represents the number of nanoseconds since boot (excluding
+ /// system sleep time), not zero nanoseconds since boot.
public init(uptimeNanoseconds: UInt64) {
self.rawValue = dispatch_time_t(uptimeNanoseconds)
}