Skip to content

Commit 63b00aa

Browse files
committed
move DISPATCH_LINUX_UNAVAILABLE to base.h and match it with existing header annotation macros
switch guard for vm_deallocate to HAVE_MACH Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
1 parent 0c41eab commit 63b00aa

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

dispatch/base.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#define DISPATCH_MALLOC __attribute__((__malloc__))
6565
#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
6666
#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__))
67+
#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg)))
6768
#else
6869
/*! @parseOnly */
6970
#define DISPATCH_NORETURN
@@ -99,6 +100,16 @@
99100
#define DISPATCH_ALWAYS_INLINE
100101
/*! @parseOnly */
101102
#define DISPATCH_UNAVAILABLE
103+
/*! @parseOnly */
104+
#define DISPATCH_UNAVAILABLE_MSG(msg)
105+
#endif
106+
107+
#ifdef __linux__
108+
#define DISPATCH_LINUX_UNAVAILABLE() \
109+
DISPATCH_UNAVAILABLE_MSG( \
110+
"This interface is unavailable on linux systems")
111+
#else
112+
#define DISPATCH_LINUX_UNAVAILABLE()
102113
#endif
103114

104115
#ifndef DISPATCH_ALIAS_V2

dispatch/dispatch.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,10 @@
4747
#include <unistd.h>
4848
#include <fcntl.h>
4949

50-
#ifdef __has_attribute
51-
#if __has_attribute(unavailable)
52-
#define __DISPATCH_UNAVAILABLE(msg) __attribute__((__unavailable__(msg)))
53-
#endif
54-
#endif
55-
#ifndef __DISPATCH_UNAVAILABLE
56-
#define __DISPATCH_UNAVAILABLE(msg)
57-
#endif
58-
5950
#ifdef __linux__
6051
#ifdef __DISPATCH_BUILDING_SWIFT_MODULE__
6152
#include <stdio.h> // for off_t
6253
#endif
63-
#define DISPATCH_LINUX_UNAVAILABLE() \
64-
__DISPATCH_UNAVAILABLE("This interface is unavailable on linux systems")
65-
#else
66-
#define DISPATCH_LINUX_UNAVAILABLE()
6754
#endif
6855

6956
#define DISPATCH_API_VERSION 20160612

src/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const dispatch_block_t _dispatch_data_destructor_none = ^{
108108
DISPATCH_INTERNAL_CRASH(0, "none destructor called");
109109
};
110110

111-
#ifndef __linux__
111+
#if HAVE_MACH
112112
const dispatch_block_t _dispatch_data_destructor_vm_deallocate = ^{
113113
DISPATCH_INTERNAL_CRASH(0, "vmdeallocate destructor called");
114114
};
@@ -249,7 +249,7 @@ dispatch_data_create_f(const void *buffer, size_t size, dispatch_queue_t queue,
249249
if (destructor != DISPATCH_DATA_DESTRUCTOR_DEFAULT &&
250250
destructor != DISPATCH_DATA_DESTRUCTOR_FREE &&
251251
destructor != DISPATCH_DATA_DESTRUCTOR_NONE &&
252-
#ifndef __linux__
252+
#if HAVE_MACH
253253
destructor != DISPATCH_DATA_DESTRUCTOR_VM_DEALLOCATE &&
254254
#endif
255255
destructor != DISPATCH_DATA_DESTRUCTOR_INLINE) {

0 commit comments

Comments
 (0)