Skip to content

Commit 7bf307c

Browse files
committed
updates to compile with latest Swift
1 parent e1dbd69 commit 7bf307c

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ AC_ARG_WITH([swift-toolchain],
108108
[AS_HELP_STRING([--with-swift-toolchain], [Specify path to Swift toolchain])],
109109
[swift_toolchain_path=${withval}
110110
AC_DEFINE(HAVE_SWIFT, 1, [Define if building for Swift])
111-
SWIFTC="$swift_toolchain_path/bin/swiftc"
111+
SWIFT_TOOLCHAIN_PATH="$swift_toolchain_path"
112112
have_swift=true],
113113
[have_swift=false]
114114
)
115115
AM_CONDITIONAL(HAVE_SWIFT, $have_swift)
116-
AC_SUBST([SWIFTC])
116+
AC_SUBST([SWIFT_TOOLCHAIN_PATH])
117117

118118
AC_USE_SYSTEM_EXTENSIONS
119119
AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects])

dispatch/dispatch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include <stdarg.h>
3333
#include <unistd.h>
3434
#include <fcntl.h>
35+
#ifndef __APPLE__
36+
#include <stdio.h>
37+
#include <sys/types.h>
38+
#endif
3539

3640
#ifndef __OSX_AVAILABLE_STARTING
3741
#define __OSX_AVAILABLE_STARTING(x, y)

src/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,14 @@ else
7373
endif
7474
endif
7575

76+
if HAVE_SWIFT
77+
SWIFTC=${SWIFT_TOOLCHAIN_PATH}/bin/swiftc
78+
SWIFT_RUNTIME_LIBS=$(SWIFT_TOOLCHAIN_PATH)/lib/swift/linux
79+
SWIFT_LIBS=-L$(SWIFT_RUNTIME_LIBS) -lswiftCore
80+
endif
81+
7682
libdispatch_la_LDFLAGS=-avoid-version
77-
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS)
83+
libdispatch_la_LIBADD=$(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS) $(SWIFT_LIBS)
7884

7985
if HAVE_DARWIN_LD
8086
libdispatch_la_LDFLAGS+=-Wl,-compatibility_version,1 \

src/swift/Dispatch.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import CDispatch
3232

3333
public typealias dispatch_object_t = DispatchObject
3434
public class DispatchObject {
35-
let cobj:COpaquePointer;
35+
let cobj:OpaquePointer;
3636

3737
deinit {
3838
CDispatch.dispatch_release(_to_dot(cobj))
3939
}
4040

41-
init(_ cobj:COpaquePointer) {
41+
init(_ cobj:OpaquePointer) {
4242
self.cobj = cobj;
4343
}
4444
}
@@ -312,7 +312,7 @@ public func dispatch_block_testcancel(block:dispatch_block_t) -> Int {
312312
// source.h
313313
//////////
314314

315-
public typealias dispatch_source_type_t = COpaquePointer
315+
public typealias dispatch_source_type_t = OpaquePointer
316316

317317
public var DISPATCH_SOURCE_TYPE_DATA_ADD: dispatch_source_type_t {
318318
return _swift_dispatch_source_type_data_add()
@@ -601,7 +601,7 @@ public func dispatch_io_set_interval(channel:dispatch_io_t,
601601
internal let mainQueue:dispatch_queue_t = DispatchQueue(CDispatch.dispatch_get_main_queue())
602602

603603
@_silgen_name("_swift_dispatch_object_type_punner")
604-
internal func _to_dot(x:COpaquePointer) -> CDispatch.dispatch_object_t
604+
internal func _to_dot(x:OpaquePointer) -> CDispatch.dispatch_object_t
605605

606606
@warn_unused_result
607607
@_silgen_name("_swift_dispatch_queue_concurrent")

tests/Makefile.am

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#
33
#
44

5+
if HAVE_SWIFT
6+
SWIFT_RUNTIME_LIBS=$(SWIFT_TOOLCHAIN_PATH)/lib/swift/linux
7+
SWIFT_LIBS=-L$(SWIFT_RUNTIME_LIBS) -lswiftCore
8+
endif
9+
510
AUTOMAKE_OPTIONS = subdir-objects
611

712
noinst_LTLIBRARIES=libbsdtests.la
@@ -121,7 +126,7 @@ if !BUILD_OWN_PTHREAD_WORKQUEUES
121126
endif
122127
endif
123128

124-
LDADD=libbsdtests.la $(top_builddir)/src/libdispatch.la $(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS)
129+
LDADD=libbsdtests.la $(top_builddir)/src/libdispatch.la $(KQUEUE_LIBS) $(PTHREAD_WORKQUEUE_LIBS) $(BSD_OVERLAY_LIBS) $(SWIFT_LIBS)
125130
libbsdtests_la_LDFLAGS=-avoid-version
126131

127132
bsdtestsummarize_LDADD=-lm $(BSD_OVERLAY_LIBS)

0 commit comments

Comments
 (0)