Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compnerd/1324.41.2 updates #584

Open
wants to merge 30 commits into
base: rokhinip-darwin-libdispatch-1324.41.2-merge-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8e89295
dispatch: adjust the print specifies to avoid some warnings (NFCI)
compnerd Nov 12, 2021
b78af30
dispatch: silence a warning on Windows (NFC)
compnerd Nov 12, 2021
bd216a1
dispatch: make assertions LLP64 friendly (NFCI)
compnerd Nov 12, 2021
a72dfbd
dispatch: host declaration of `dispatch_pthread_root_queue_observer_h…
compnerd Nov 12, 2021
220b322
dispatch: adjust for LLP64 environments
compnerd Nov 12, 2021
26a5511
dispatch: follow `os/base.h` inclusion pattern
compnerd Nov 12, 2021
7b5aa71
dispatch: exclude workgroup support on non-Apple targets
compnerd Nov 12, 2021
28c3270
os: update unix and windows base.h
compnerd Nov 12, 2021
025bbb4
windows: add a shim for Windows
compnerd Nov 12, 2021
25758bd
dispatch: exclude some mach_port_t usage
compnerd Nov 12, 2021
811b4a1
time: explicitly size the time macros
compnerd Nov 12, 2021
e597c94
dispatch: use reserved spelling for `typeof`
compnerd Nov 12, 2021
093d3a8
private: use `dispatch_qos_class_t` rather than `qos_class_t`
compnerd Nov 12, 2021
48932f3
shims: convert `_dispatch_preemption_yeild` to an expression
compnerd Nov 12, 2021
c1f3660
os: replace `__header_always_inline` with `DISPATCH_ALWAYS_INLINE`
compnerd Nov 12, 2021
956c270
shims: add a definition for `os_atomic_init`
compnerd Nov 12, 2021
0bc1ee2
dispatch: use platform specific paths for setting thread names
compnerd Nov 12, 2021
d5455e1
shims: adopt `_os_atomic_auto_dependency` from osfmk
compnerd Nov 12, 2021
9502860
dispatch: repair the signal thread construction on Windows
compnerd Nov 19, 2021
1ba15ff
dispatch: remove an unused function
compnerd Nov 12, 2021
100c055
private: remove reference to mach.h
compnerd Nov 12, 2021
8979120
dispatch: repair the context for the cooperative root queue
compnerd Nov 13, 2021
fc4eb88
Block: adjust the type constructor for Windows
compnerd Nov 13, 2021
f251ab8
Queue: make the Swift overlay build again
compnerd Nov 13, 2021
9d366f9
Voucher portability fixes.
3405691582 Nov 13, 2021
7e99220
build: add an additional installed header
compnerd Nov 13, 2021
8ca15bc
Fix initializing of dispatch_block_flags_t.
3405691582 Nov 14, 2021
be92ae7
dispatch: explicitly cast to avoid truncation warning
compnerd Nov 19, 2021
c4c3516
dispatch: remove stray `void`
compnerd Nov 19, 2021
ef765a3
shims: add a new HAVE_WAIT_ON_ADDRESS and adopt in locks
compnerd Nov 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dispatch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ install(FILES
semaphore.h
source.h
time.h
workloop.h
DESTINATION
"${INSTALL_DISPATCH_HEADERS_DIR}")
if(ENABLE_SWIFT)
Expand Down
2 changes: 1 addition & 1 deletion dispatch/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define DISPATCH_CONST __attribute__((__const__))
#define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
#define DISPATCH_MALLOC __attribute__((__malloc__))
#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
#define DISPATCH_ALWAYS_INLINE __attribute__((unused, __always_inline__))
#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__))
#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg)))
#elif defined(_MSC_VER)
Expand Down
2 changes: 2 additions & 0 deletions dispatch/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
#endif

#include <os/object.h>
#if HAVE_MACH
#include <os/workgroup.h>
#endif
#include <dispatch/base.h>
#include <dispatch/time.h>
#include <dispatch/object.h>
Expand Down
2 changes: 1 addition & 1 deletion dispatch/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct timespec;
*/
typedef uint64_t dispatch_time_t;

enum {
enum : unsigned long long {
DISPATCH_WALLTIME_NOW DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = ~1ull,
};

Expand Down
2 changes: 2 additions & 0 deletions dispatch/workloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ void
dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop,
dispatch_autorelease_frequency_t frequency);

#if HAVE_MACH
/*!
* @function dispatch_workloop_set_os_workgroup
*
Expand All @@ -159,6 +160,7 @@ DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop,
os_workgroup_t workgroup);
#endif

__END_DECLS

Expand Down
7 changes: 7 additions & 0 deletions os/clock.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#ifndef __OS_CLOCK__
#define __OS_CLOCK__

#if defined(__APPLE__)
#include <os/base.h>
#elif defined(_WIN32)
#include <os/generic_win_base.h>
#elif defined(__unix__)
#include <os/generic_unix_base.h>
#endif

#include <stdint.h>

/*
Expand Down
7 changes: 6 additions & 1 deletion os/eventlink_private.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#ifndef __OS_EVENTLINK__
#define __OS_EVENTLINK__

#include <os/object.h>
#if HAVE_MACH
#include <mach/mach.h>
#endif

#include <os/object.h>
#include <os/clock.h>

__BEGIN_DECLS
Expand Down Expand Up @@ -108,6 +111,7 @@ OS_EXPORT OS_OBJECT_WARN_UNUSED_RESULT
int
os_eventlink_activate(os_eventlink_t eventlink);

#if HAVE_MACH
/*!
* @function os_eventlink_extract_remote_port
*
Expand Down Expand Up @@ -138,6 +142,7 @@ os_eventlink_extract_remote_port(os_eventlink_t eventlink, mach_port_t *port_out
OS_EXPORT OS_OBJECT_RETURNS_RETAINED
os_eventlink_t _Nullable
os_eventlink_create_with_port(const char *name, mach_port_t mach_port);
#endif

/*!
* @function os_eventlink_create_remote_with_eventlink
Expand Down
8 changes: 8 additions & 0 deletions os/generic_unix_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
#define API_DEPRECATED_WITH_REPLACEMENT(...)
#endif

#ifndef SPI_AVAILABLE
#define SPI_AVAILABLE(...)
#endif

#ifndef SPI_DEPRECATED
#define SPI_DEPRECATED(...)
#endif

#if __GNUC__
#define OS_EXPECT(x, v) __builtin_expect((x), (v))
#define OS_UNUSED __attribute__((__unused__))
Expand Down
20 changes: 20 additions & 0 deletions os/generic_win_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ typedef void pthread_attr_t;
#define API_DEPRECATED_WITH_REPLACEMENT(...)
#endif

#ifndef SPI_AVAILABLE
#define SPI_AVAILABLE(...)
#endif

#ifndef SPI_DEPRECATED
#define SPI_DEPRECATED(...)
#endif

#if !defined(__has_attribute)
#define __has_attribute(attibute) 0
#endif
Expand Down Expand Up @@ -99,6 +107,18 @@ typedef void pthread_attr_t;
#define OS_SWIFT_UNAVAILABLE(msg)
#endif

#if __has_attribute(swift_private)
# define OS_REFINED_FOR_SWIFT __attribute__((__swift_private__))
#else
# define OS_REFINED_FOR_SWIFT
#endif

#if __has_attribute(swift_name)
# define OS_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
#else
# define OS_SWIFT_NAME(_name)
#endif

#define __OS_STRINGIFY(s) #s
#define OS_STRINGIFY(s) __OS_STRINGIFY(s)

Expand Down
3 changes: 2 additions & 1 deletion os/voucher_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,15 @@ voucher_adopt(voucher_t _Nullable voucher OS_OBJECT_CONSUMED);
*/

SPI_AVAILABLE(macos(12.0), ios(15.0))
__header_always_inline bool
DISPATCH_ALWAYS_INLINE static bool
voucher_needs_adopt(voucher_t _Nullable voucher)
{
#if __APPLE__
if (_pthread_has_direct_tsd()) {
return (((void *) voucher) != _pthread_getspecific_direct(OS_VOUCHER_TSD_KEY));
}
#endif
(void)voucher;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion private/channel_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ dispatch_channel_create(const char *_Nullable label,
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0), bridgeos(4.0))
DISPATCH_EXPORT DISPATCH_NOTHROW DISPATCH_NONNULL_ALL
void
dispatch_channel_wakeup(dispatch_channel_t channel, qos_class_t qos_class);
dispatch_channel_wakeup(dispatch_channel_t channel, dispatch_qos_class_t qos_class);

/*! @typedef dispatch_channel_enumerator_handler_t
*
Expand Down
2 changes: 2 additions & 0 deletions private/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
#endif
#include <dispatch/workloop_private.h>
#include <dispatch/source_private.h>
#if HAVE_MACH
#include <dispatch/mach_private.h>
#endif
#include <dispatch/data_private.h>
#include <dispatch/io_private.h>
#include <dispatch/layout_private.h>
Expand Down
2 changes: 1 addition & 1 deletion private/queue_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ SPI_AVAILABLE(macos(12.0), ios(15.0))
DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2
void
dispatch_async_swift_job(dispatch_queue_t queue, void *swift_job,
qos_class_t qos);
dispatch_qos_class_t qos);

__END_DECLS

Expand Down
2 changes: 1 addition & 1 deletion private/time_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ __BEGIN_DECLS
* dispatch_source_set_timer(ds, t, 10 * NSEC_PER_SEC, 0);
* dispatch_activate(ds);
*/
enum {
enum : unsigned long long {
DISPATCH_MONOTONICTIME_NOW DISPATCH_ENUM_API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) = (1ull << 63)
};

Expand Down
4 changes: 2 additions & 2 deletions src/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _dispatch_benchmark_init(void *context)
} while (i < cnt);
delta = _dispatch_uptime() - start;

lcost = (typeof(lcost)) delta;
lcost = (__typeof__(lcost)) delta;
#if HAVE_MACH_ABSOLUTE_TIME
lcost *= bdata->tbi.numer;
lcost /= bdata->tbi.denom;
Expand Down Expand Up @@ -113,7 +113,7 @@ dispatch_benchmark_f(size_t count, register void *ctxt,
} while (i < count);
delta = _dispatch_uptime() - start;

conversion = (typeof(conversion)) delta;
conversion = (__typeof__(conversion)) delta;
#if HAVE_MACH_ABSOLUTE_TIME
conversion *= bdata.tbi.numer;
big_denom = bdata.tbi.denom;
Expand Down
4 changes: 2 additions & 2 deletions src/event/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,9 @@ _dispatch_timer_heap_update(dispatch_timer_heap_t dth,
#pragma mark timer unote

#define _dispatch_timer_du_debug(what, du) \
_dispatch_debug("kevent-source[%p]: %s kevent[%p] { ident = 0x%x }", \
_dispatch_debug("kevent-source[%p]: %s kevent[%p] { ident = 0x%llx }", \
_dispatch_wref2ptr((du)->du_owner_wref), what, \
(du), (du)->du_ident)
(du), (unsigned long long)(du)->du_ident)

DISPATCH_ALWAYS_INLINE
static inline unsigned int
Expand Down
6 changes: 6 additions & 0 deletions src/event/event_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ _dispatch_event_loop_end_ownership(dispatch_wlh_t wlh, uint64_t old_state,
(void)wlh; (void)old_state; (void)new_state; (void)flags;
}

void
_dispatch_event_loop_ensure_ownership(dispatch_wlh_t wlh)
{
(void)wlh;
}

#if DISPATCH_WLH_DEBUG
void
_dispatch_event_loop_assert_not_owned(dispatch_wlh_t wlh)
Expand Down
1 change: 1 addition & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ struct dispatch_queue_global_s _dispatch_root_queues[] = {
#define _DISPATCH_COOPERATIVE_ROOT_QUEUE_ENTRY(n, flags, ...) \
[_DISPATCH_ROOT_QUEUE_IDX(n, flags)] = { \
.do_vtable = DISPATCH_VTABLE(queue_concurrent), \
.do_ctxt = _dispatch_root_queue_ctxt(_DISPATCH_ROOT_QUEUE_IDX(n, flags)), \
.dq_priority = flags | ((flags & DISPATCH_PRIORITY_FLAG_FALLBACK) ? \
_dispatch_priority_make_fallback(DISPATCH_QOS_##n) : \
_dispatch_priority_make(DISPATCH_QOS_##n, 0)), \
Expand Down
20 changes: 14 additions & 6 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ upcast(dispatch_object_t dou)
#endif // __OBJC__

#include <os/object.h>
#if HAVE_MACH
#include <os/workgroup_base.h>
#include <os/workgroup_object.h>
#include <os/workgroup_interval.h>
#include <os/workgroup_parallel.h>
#endif
#include <dispatch/time.h>
#include <dispatch/object.h>
#include <dispatch/queue.h>
Expand All @@ -241,14 +243,18 @@ upcast(dispatch_object_t dou)
#endif
#include "os/object_private.h"
#include "os/eventlink_private.h"
#if HAVE_MACH
#include "os/workgroup_object_private.h"
#include "os/workgroup_interval_private.h"
#endif
#include "apply_private.h"
#include "queue_private.h"
#include "channel_private.h"
#include "workloop_private.h"
#include "source_private.h"
#if HAVE_MACH
#include "mach_private.h"
#endif
#include "data_private.h"
#include "time_private.h"
#include "os/voucher_private.h"
Expand Down Expand Up @@ -587,23 +593,23 @@ void _dispatch_log(const char *msg, ...);
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assert(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
_dispatch_assert(long long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
{
if (unlikely(DISPATCH_DEBUG && !e)) _dispatch_abort(line, e);
}
#define dispatch_assert(e) _dispatch_assert((long)(e), __LINE__)
#define dispatch_assert(e) _dispatch_assert((long long)(e), __LINE__)

/*
* A lot of API return zero upon success and not-zero on fail. Let's capture
* and log the non-zero value
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assert_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
_dispatch_assert_zero(long long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
{
if (unlikely(DISPATCH_DEBUG && e)) _dispatch_abort(line, e);
}
#define dispatch_assert_zero(e) _dispatch_assert_zero((long)(e), __LINE__)
#define dispatch_assert_zero(e) _dispatch_assert_zero((long long)(e), __LINE__)

/*
* For reporting bugs or impedance mismatches between libdispatch and external
Expand All @@ -613,12 +619,12 @@ _dispatch_assert_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assume(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
_dispatch_assume(long long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
{
if (unlikely(!e)) _dispatch_bug(line, e);
}
#define dispatch_assume(e) \
({ __typeof__(e) _e = (e); _dispatch_assume((long)_e, __LINE__); _e; })
({ __typeof__(e) _e = (e); _dispatch_assume((long long)_e, __LINE__); _e; })

/*
* A lot of API return zero upon success and not-zero on fail. Let's capture
Expand Down Expand Up @@ -1180,7 +1186,9 @@ extern bool _dispatch_kevent_workqueue_enabled;

/* #includes dependent on internal.h */
#include "object_internal.h"
#if HAVE_MACH
#include "workgroup_internal.h"
#endif
#include "eventlink_internal.h"
#include "semaphore_internal.h"
#include "introspection_internal.h"
Expand Down
Loading