Skip to content

Commit aa73b31

Browse files
committed
merge darwin/darwin-002
2 parents 954ace4 + a535573 commit aa73b31

21 files changed

+141
-106
lines changed

PATCHES

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
The libdispatch project exists in a parallel open source repository at:
2-
http://svn.macosforge.org/repository/libdispatch/trunk
2+
http://github.com/apple/swift-corelibs-libdispatch
3+
4+
Externally contributed changes are synchronized back to the internal repository
5+
via pull request of the result of `git am` of the contributed patch series.
36

4-
Externally committed revisions are periodically synchronized back to the
5-
internal repository (this repository).
7+
Internal changes are synchronized from the internal darwin/trunk branch to the
8+
external repository via `gi am` on the github darwin/trunk branch and merge to
9+
github master.
610

711
Key:
812
APPLIED: change set was applied to internal repository.
913
INTERNAL: change set originated internally (i.e. already applied).
1014
SKIPPED: change set was skipped.
1115

16+
svn revisions until r218 from legacy open source repository at
17+
http://svn.macosforge.org/repository/libdispatch/trunk
18+
1219
[ 1] SKIPPED
1320
[ 2] SKIPPED
1421
[ 3] INTERNAL rdar://problem/7148356
@@ -192,3 +199,45 @@ Key:
192199
[ 181]
193200
[ 182]
194201
[ 183] INTERNAL rdar://problem/7581831
202+
[ 202] INTERNAL libdispatch-187.5
203+
[ 212] INTERNAL libdispatch-228.18
204+
[ 213] INTERNAL rdar://problem/11754320
205+
[ 216] INTERNAL libdispatch-339.1.9
206+
[ 217] INTERNAL libdispatch-442.1.4
207+
[ 218] INTERNAL libdispatch-500.1.5
208+
209+
github commits starting with 29bdc2f from
210+
211+
http://github.com/apple/swift-corelibs-libdispatch
212+
213+
[29bdc2f] INTERNAL libdispatch-500.1.5
214+
[a60acd6] APPLIED rdar://23661056
215+
[39ac720] APPLIED rdar://23705483
216+
[acd56f6] APPLIED rdar://23754944
217+
[394d9a1] APPLIED rdar://23772602
218+
[3691f26] APPLIED rdar://23868354
219+
[8904f45] APPLIED rdar://23868354
220+
[6dbebd6] APPLIED rdar://23868354
221+
[b2ccfeb] APPLIED rdar://23868354
222+
[e7ca00f] APPLIED rdar://23868354
223+
[35eb408] APPLIED rdar://25159995
224+
[32411c2] APPLIED rdar://25159995
225+
[31586d5] APPLIED rdar://25159995
226+
[50faff5] APPLIED rdar://25159995
227+
[3ce4e3d] APPLIED rdar://25159995
228+
[b647aee] APPLIED rdar://25159995
229+
[ab7e16c] APPLIED rdar://25159995
230+
[cef2960] APPLIED rdar://25159995
231+
[dfa43cd] APPLIED rdar://25159995
232+
[8b9c3a9] APPLIED rdar://25159995
233+
[fefb6cf] APPLIED rdar://25159995
234+
[1a9c57f] APPLIED rdar://25159995
235+
[c04488a] APPLIED rdar://25159995
236+
[f1d58d1] APPLIED rdar://25159995
237+
[be83e85] APPLIED rdar://25159995
238+
[79fbb13] APPLIED rdar://25159995
239+
[6ead519] APPLIED rdar://25159995
240+
[1fa1513] APPLIED rdar://25159995
241+
[4a6ec51] APPLIED rdar://25159995
242+
[bc16cc9] APPLIED rdar://25159995
243+
[954ace4] APPLIED rdar://25159995

config/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
don't. */
2222
#define HAVE_DECL_NOTE_REAP 1
2323

24+
/* Define to 1 if you have the declaration of `NOTE_REVOKE', and to 0 if you
25+
don't. */
26+
#define HAVE_DECL_NOTE_REVOKE 1
27+
2428
/* Define to 1 if you have the declaration of `NOTE_SIGNAL', and to 0 if you
2529
don't. */
2630
#define HAVE_DECL_NOTE_SIGNAL 1

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ AM_CONDITIONAL(USE_MIG, $have_mach)
273273
#
274274
AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC], [], [],
275275
[[#include <time.h>]])
276-
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_SIGNAL], [], [],
276+
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL], [], [],
277277
[[#include <sys/event.h>]])
278278
AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
279279
AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])

dispatch/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ dispatch_HEADERS= \
2626
if HAVE_SWIFT
2727
dispatch_HEADERS+=module.map
2828
endif
29-

dispatch/dispatch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include <unistd.h>
3535
#include <fcntl.h>
3636

37+
#if defined(__linux__) && defined(__DISPATCH_BUILDING_SWIFT_MODULE__)
38+
#include <stdio.h> // for off_t
39+
#endif
40+
3741
#ifndef __OSX_AVAILABLE_STARTING
3842
#define __OSX_AVAILABLE_STARTING(x, y)
3943
#endif

os/linux_base.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
/*
2-
* @APPLE_APACHE_LICENSE_HEADER_START@
2+
* This source file is part of the Swift.org open source project
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
4+
* Copyright (c) 2015 Apple Inc. and the Swift project authors
75
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
6+
* Licensed under Apache License v2.0 with Runtime Library Exception
97
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
8+
* See http://swift.org/LICENSE.txt for license information
9+
* See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1510
*
16-
* @APPLE_APACHE_LICENSE_HEADER_END@
1711
*/
1812

1913
#ifndef __OS_LINUX_BASE__
@@ -23,7 +17,7 @@
2317
#include <sys/user.h>
2418

2519
// marker for hacks we have made to make progress
26-
#define __LINUX_PORT_HDD__ 1
20+
#define __LINUX_PORT_HDD__ 1
2721

2822
/*
2923
* Stub out defines for some mach types and related macros
@@ -120,8 +114,8 @@ struct voucher_offsets_s {
120114
#endif
121115
#define OS_EXPORT
122116

123-
#ifdef OS_WARN_RESULT_NEEDS_RELEASE
124-
#undef OS_WARN_RESULT_NEEDS_RELEASE
117+
#ifdef OS_WARN_RESULT_NEEDS_RELEASE
118+
#undef OS_WARN_RESULT_NEEDS_RELEASE
125119
#endif
126120

127121
#ifdef OS_WARN_RESULT
@@ -138,7 +132,7 @@ struct voucher_offsets_s {
138132
// These and similar macros come from Availabilty.h on OS X
139133
// Need a better way to do this long term.
140134
#define __OSX_AVAILABLE_BUT_DEPRECATED(a,b,c,d) //
141-
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(a,b,c,d,msg) //
135+
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(a,b,c,d,msg) //
142136

143137

144138

private/voucher_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ OS_VOUCHER_EXPORT OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT OS_NOTHROW
427427
voucher_t
428428
voucher_create_with_mach_msg(mach_msg_header_t *msg);
429429

430-
#endif
430+
#endif // __APPLE__
431431
__END_DECLS
432432

433433
#endif // __OS_VOUCHER_PRIVATE__

src/init.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ extern struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent
268268
__attribute__((__alias__("_dispatch_queue_attrs")));
269269
#endif
270270

271+
// _dispatch_queue_attr_concurrent is aliased using libdispatch.aliases
272+
// and the -alias_list linker option on Darwin but needs to be done manually
273+
// for other platforms.
274+
#ifndef __APPLE__
275+
extern struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent
276+
__attribute__((__alias__("_dispatch_queue_attrs")));
277+
#endif
278+
271279
#pragma mark -
272280
#pragma mark dispatch_vtables
273281

@@ -359,7 +367,7 @@ DISPATCH_VTABLE_INSTANCE(mach_msg,
359367
.do_invoke = _dispatch_mach_msg_invoke,
360368
.do_debug = _dispatch_mach_msg_debug,
361369
);
362-
#endif
370+
#endif // HAVE_MACH
363371

364372
#if !USE_OBJC
365373
DISPATCH_VTABLE_INSTANCE(data,
@@ -817,7 +825,7 @@ _dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
817825
_dispatch_free_unwind_tsd();
818826
_dispatch_set_unwind_tsd(u);
819827
}
820-
#endif
828+
#endif // HAVE_MACH
821829

822830
#endif // DISPATCH_USE_CLIENT_CALLOUT
823831

@@ -1172,7 +1180,7 @@ const struct dispatch_source_type_s _dispatch_source_type_vnode = {
11721180
.mask = NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK|
11731181
NOTE_RENAME
11741182
#if HAVE_DECL_NOTE_REVOKE
1175-
|NOTE_REVOKE
1183+
|NOTE_REVOKE
11761184
#endif
11771185
#if HAVE_DECL_NOTE_NONE
11781186
|NOTE_NONE

src/inline_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DISPATCH_NOTHROW void
4343
_dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
4444
dispatch_mach_msg_t dmsg, mach_error_t error,
4545
dispatch_mach_handler_function_t f);
46-
#endif
46+
#endif // HAVE_MACH
4747

4848
#else // !DISPATCH_USE_CLIENT_CALLOUT
4949

@@ -70,7 +70,7 @@ _dispatch_client_callout4(void *ctxt, dispatch_mach_reason_t reason,
7070
{
7171
return f(ctxt, reason, dmsg, error);
7272
}
73-
#endif
73+
#endif // HAVE_MACH
7474

7575
#endif // !DISPATCH_USE_CLIENT_CALLOUT
7676

src/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ DISPATCH_NOINLINE
345345
void _dispatch_bug_client(const char* msg);
346346
DISPATCH_NOINLINE
347347
void _dispatch_bug_mach_client(const char *msg, mach_msg_return_t kr);
348-
#endif
348+
#endif // HAVE_MACH
349349
DISPATCH_NOINLINE
350350
void _dispatch_bug_kevent_client(const char* msg, const char* filter,
351351
const char *operation, int err);
@@ -549,7 +549,7 @@ void _dispatch_vtable_init(void);
549549
char *_dispatch_get_build(void);
550550

551551
uint64_t _dispatch_timeout(dispatch_time_t when);
552-
uint64_t _dispatch_time_to_nanoseconds(dispatch_time_t when);
552+
uint64_t _dispatch_time_nanoseconds_since_epoch(dispatch_time_t when);
553553

554554
extern bool _dispatch_safe_fork, _dispatch_child_of_unsafe_fork;
555555

src/io.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ dispatch_io_create_with_path(dispatch_io_type_t type, const char *path,
390390
(path_data->oflag & O_NOFOLLOW) == O_NOFOLLOW
391391
#ifndef __linux__
392392
|| (path_data->oflag & O_SYMLINK) == O_SYMLINK
393-
#endif
393+
#endif
394394
? lstat(path_data->path, &st) : stat(path_data->path, &st),
395395
case 0:
396396
err = _dispatch_io_validate_type(channel, st.st_mode);
@@ -1601,7 +1601,8 @@ _dispatch_disk_init(dispatch_fd_entry_t fd_entry, dev_t dev)
16011601
TAILQ_INIT(&disk->operations);
16021602
disk->cur_rq = TAILQ_FIRST(&disk->operations);
16031603
char label[45];
1604-
snprintf(label, sizeof(label), "com.apple.libdispatch-io.deviceq.%d", (int)dev);
1604+
snprintf(label, sizeof(label), "com.apple.libdispatch-io.deviceq.%d",
1605+
(int)dev);
16051606
disk->pick_queue = dispatch_queue_create(label, NULL);
16061607
TAILQ_INSERT_TAIL(&_dispatch_io_devs[hash], disk, disk_list);
16071608
out:
@@ -2107,7 +2108,7 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
21072108
// TODO: set disk status on error
21082109
default: (void)dispatch_assume_zero(err); break;
21092110
);
2110-
#endif
2111+
#endif
21112112
}
21122113

21132114
static int
@@ -2398,10 +2399,11 @@ _dispatch_operation_debug_attr(dispatch_operation_t op, char* buf,
23982399
"write", op->fd_entry ? op->fd_entry->fd : -1, op->fd_entry,
23992400
op->channel, op->op_q, oqtarget && oqtarget->dq_label ?
24002401
oqtarget->dq_label : "", oqtarget, target && target->dq_label ?
2401-
target->dq_label : "", target, (long long)op->offset, op->length, op->total,
2402-
op->undelivered + op->buf_len, op->flags, op->err, op->params.low,
2403-
op->params.high, op->params.interval_flags &
2404-
DISPATCH_IO_STRICT_INTERVAL ? "(strict)" : "", (unsigned long long)op->params.interval);
2402+
target->dq_label : "", target, (long long)op->offset, op->length,
2403+
op->total, op->undelivered + op->buf_len, op->flags, op->err,
2404+
op->params.low, op->params.high, op->params.interval_flags &
2405+
DISPATCH_IO_STRICT_INTERVAL ? "(strict)" : "",
2406+
(unsigned long long)op->params.interval);
24052407
}
24062408

24072409
size_t

src/object.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ - (NSString *)debugDescription {
538538
objc_terminate();
539539
}
540540
}
541-
#endif
541+
#endif // HAVE_MACH
542542

543543
#endif // DISPATCH_USE_CLIENT_CALLOUT
544544

src/queue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ _dispatch_root_queue_init_pthread_pool(dispatch_root_queue_context_t qc,
867867
&pqc->dpq_thread_attr, qc->dgq_qos, 0));
868868
#endif
869869
}
870-
#endif
870+
#endif // HAVE_PTHREAD_WORKQUEUES
871871
#if USE_MACH_SEM
872872
// override the default FIFO behavior for the pool semaphores
873873
kern_return_t kr = semaphore_create(mach_task_self(),
@@ -1477,7 +1477,7 @@ static const int _dispatch_mgr_sched_qos2prio[] = {
14771477
[_DISPATCH_QOS_CLASS_USER_INITIATED] = 37,
14781478
[_DISPATCH_QOS_CLASS_USER_INTERACTIVE] = 47,
14791479
};
1480-
#endif
1480+
#endif // HAVE_PTHREAD_WORKQUEUE_QOS
14811481

14821482
static void
14831483
_dispatch_mgr_sched_init(void *ctxt DISPATCH_UNUSED)

src/semaphore.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ _dispatch_semaphore_wait_slow(dispatch_semaphore_t dsema,
368368
}
369369
#elif USE_POSIX_SEM
370370
do {
371-
uint64_t nsec = _dispatch_time_to_nanoseconds(timeout);
371+
uint64_t nsec = _dispatch_time_nanoseconds_since_epoch(timeout);
372372
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
373373
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
374374
ret = slowpath(sem_timedwait(&dsema->dsema_sem, &_timeout));
@@ -378,19 +378,6 @@ _dispatch_semaphore_wait_slow(dispatch_semaphore_t dsema,
378378
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
379379
break;
380380
}
381-
#elif USE_FUTEX_SEM
382-
do {
383-
uint64_t nsec = _dispatch_timeout(timeout);
384-
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
385-
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
386-
pthread_workqueue_signal_np();
387-
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
388-
} while (ret == false && errno == EINTR);
389-
390-
if (!(ret == false && errno == ETIMEDOUT)) {
391-
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
392-
break;
393-
}
394381
#elif USE_WIN32_SEM
395382
nsec = _dispatch_timeout(timeout);
396383
msec = (DWORD)(nsec / (uint64_t)1000000);
@@ -635,7 +622,7 @@ _dispatch_group_wait_slow(dispatch_semaphore_t dsema, dispatch_time_t timeout)
635622
}
636623
#elif USE_POSIX_SEM
637624
do {
638-
uint64_t nsec = _dispatch_time_to_nanoseconds(timeout);
625+
uint64_t nsec = _dispatch_time_nanoseconds_since_epoch(timeout);
639626
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
640627
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
641628
ret = slowpath(sem_timedwait(&dsema->dsema_sem, &_timeout));
@@ -784,14 +771,10 @@ _dispatch_thread_semaphore_create(void)
784771
}
785772
return s4;
786773
#elif USE_POSIX_SEM
787-
sem_t* s4 = malloc(sizeof(sem_t));
774+
sem_t *s4 = _dispatch_calloc(1ul, sizeof(sem_t));
788775
int ret = sem_init(s4, 0, 0);
789776
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
790777
return (_dispatch_thread_semaphore_t)s4;
791-
#elif USE_FUTEX_SEM
792-
dispatch_futex_t ftx = (typeof(ftx))_dispatch_continuation_alloc();
793-
*ftx = DISPATCH_FUTEX_INIT;
794-
return (_dispatch_thread_semaphore_t)ftx;
795778
#elif USE_WIN32_SEM
796779
HANDLE tmp;
797780
while (!dispatch_assume(tmp = CreateSemaphore(NULL, 0, LONG_MAX, NULL))) {
@@ -814,7 +797,7 @@ _dispatch_thread_semaphore_dispose(_dispatch_thread_semaphore_t sema)
814797
DISPATCH_VERIFY_MIG(kr);
815798
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
816799
#elif USE_POSIX_SEM
817-
sem_t *s4 = (sem_t*)sema;
800+
sem_t *s4 = (sem_t *)sema;
818801
int ret = sem_destroy(s4);
819802
free(s4);
820803
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
@@ -841,7 +824,7 @@ _dispatch_thread_semaphore_signal(_dispatch_thread_semaphore_t sema)
841824
kern_return_t kr = semaphore_signal(s4);
842825
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
843826
#elif USE_POSIX_SEM
844-
sem_t *s4 = (sem_t*)sema;
827+
sem_t *s4 = (sem_t *)sema;
845828
int ret = sem_post(s4);
846829
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
847830
#elif USE_FUTEX_SEM
@@ -870,7 +853,7 @@ _dispatch_thread_semaphore_wait(_dispatch_thread_semaphore_t sema)
870853
} while (slowpath(kr == KERN_ABORTED));
871854
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
872855
#elif USE_POSIX_SEM
873-
sem_t *s4 = (sem_t*)sema;
856+
sem_t *s4 = (sem_t *)sema;
874857
int ret;
875858
do {
876859
ret = sem_wait(s4);

0 commit comments

Comments
 (0)