Skip to content

Commit 1589ca1

Browse files
committed
[SDK] Use an extra shims header to remove _silgen_name from the XPC overlay.
1 parent 26e24f7 commit 1589ca1

File tree

5 files changed

+59
-118
lines changed

5 files changed

+59
-118
lines changed

stdlib/public/SDK/XPC/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_swift_library(swiftXPC ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
22
XPC.swift
3-
XPC.mm
43

54
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
65
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

stdlib/public/SDK/XPC/XPC.swift

Lines changed: 18 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,76 +11,77 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import XPC
14+
import _SwiftXPCOverlayShims
1415

1516
//===----------------------------------------------------------------------===//
1617
// XPC Types
1718
//===----------------------------------------------------------------------===//
1819
public var XPC_TYPE_CONNECTION: xpc_type_t {
19-
return _swift_xpc_type_connection()
20+
return _swift_xpc_type_CONNECTION()
2021
}
2122

2223
public var XPC_TYPE_ENDPOINT: xpc_type_t {
23-
return _swift_xpc_type_endpoint()
24+
return _swift_xpc_type_ENDPOINT()
2425
}
2526

2627
public var XPC_TYPE_NULL: xpc_type_t {
27-
return _swift_xpc_type_null()
28+
return _swift_xpc_type_NULL()
2829
}
2930

3031
public var XPC_TYPE_BOOL: xpc_type_t {
31-
return _swift_xpc_type_bool()
32+
return _swift_xpc_type_BOOL()
3233
}
3334

3435
public var XPC_TYPE_INT64: xpc_type_t {
35-
return _swift_xpc_type_int64()
36+
return _swift_xpc_type_INT64()
3637
}
3738

3839
public var XPC_TYPE_UINT64: xpc_type_t {
39-
return _swift_xpc_type_uint64()
40+
return _swift_xpc_type_UINT64()
4041
}
4142

4243
public var XPC_TYPE_DOUBLE: xpc_type_t {
43-
return _swift_xpc_type_double()
44+
return _swift_xpc_type_DOUBLE()
4445
}
4546

4647
public var XPC_TYPE_DATE: xpc_type_t {
47-
return _swift_xpc_type_date()
48+
return _swift_xpc_type_DATE()
4849
}
4950

5051
public var XPC_TYPE_DATA: xpc_type_t {
51-
return _swift_xpc_type_data()
52+
return _swift_xpc_type_DATA()
5253
}
5354

5455
public var XPC_TYPE_STRING: xpc_type_t {
55-
return _swift_xpc_type_string()
56+
return _swift_xpc_type_STRING()
5657
}
5758

5859
public var XPC_TYPE_UUID: xpc_type_t {
59-
return _swift_xpc_type_uuid()
60+
return _swift_xpc_type_UUID()
6061
}
6162

6263
public var XPC_TYPE_FD: xpc_type_t {
63-
return _swift_xpc_type_fd()
64+
return _swift_xpc_type_FD()
6465
}
6566

6667
public var XPC_TYPE_SHMEM: xpc_type_t {
67-
return _swift_xpc_type_shmem()
68+
return _swift_xpc_type_SHMEM()
6869
}
6970

7071
public var XPC_TYPE_ARRAY: xpc_type_t {
71-
return _swift_xpc_type_array()
72+
return _swift_xpc_type_ARRAY()
7273
}
7374

7475
public var XPC_TYPE_DICTIONARY: xpc_type_t {
75-
return _swift_xpc_type_dictionary()
76+
return _swift_xpc_type_DICTIONARY()
7677
}
7778

7879
public var XPC_TYPE_ERROR: xpc_type_t {
79-
return _swift_xpc_type_error()
80+
return _swift_xpc_type_ERROR()
8081
}
8182

8283
public var XPC_TYPE_ACTIVITY: xpc_type_t {
83-
return _swift_xpc_type_activity()
84+
return _swift_xpc_type_ACTIVITY()
8485
}
8586

8687
//===----------------------------------------------------------------------===//
@@ -103,63 +104,6 @@ public var XPC_ARRAY_APPEND: size_t {
103104
return -1
104105
}
105106

106-
@_silgen_name("_swift_xpc_bool_true")
107-
internal func _swift_xpc_bool_true() -> xpc_object_t
108-
109-
@_silgen_name("_swift_xpc_bool_false")
110-
internal func _swift_xpc_bool_false() -> xpc_object_t
111-
112-
@_silgen_name("_swift_xpc_type_CONNECTION")
113-
internal func _swift_xpc_type_connection() -> xpc_type_t
114-
115-
@_silgen_name("_swift_xpc_type_ENDPOINT")
116-
internal func _swift_xpc_type_endpoint() -> xpc_type_t
117-
118-
@_silgen_name("_swift_xpc_type_NULL")
119-
internal func _swift_xpc_type_null() -> xpc_type_t
120-
121-
@_silgen_name("_swift_xpc_type_BOOL")
122-
internal func _swift_xpc_type_bool() -> xpc_type_t
123-
124-
@_silgen_name("_swift_xpc_type_INT64")
125-
internal func _swift_xpc_type_int64() -> xpc_type_t
126-
127-
@_silgen_name("_swift_xpc_type_UINT64")
128-
internal func _swift_xpc_type_uint64() -> xpc_type_t
129-
130-
@_silgen_name("_swift_xpc_type_DOUBLE")
131-
internal func _swift_xpc_type_double() -> xpc_type_t
132-
133-
@_silgen_name("_swift_xpc_type_DATE")
134-
internal func _swift_xpc_type_date() -> xpc_type_t
135-
136-
@_silgen_name("_swift_xpc_type_DATA")
137-
internal func _swift_xpc_type_data() -> xpc_type_t
138-
139-
@_silgen_name("_swift_xpc_type_STRING")
140-
internal func _swift_xpc_type_string() -> xpc_type_t
141-
142-
@_silgen_name("_swift_xpc_type_UUID")
143-
internal func _swift_xpc_type_uuid() -> xpc_type_t
144-
145-
@_silgen_name("_swift_xpc_type_FD")
146-
internal func _swift_xpc_type_fd() -> xpc_type_t
147-
148-
@_silgen_name("_swift_xpc_type_SHMEM")
149-
internal func _swift_xpc_type_shmem() -> xpc_type_t
150-
151-
@_silgen_name("_swift_xpc_type_ARRAY")
152-
internal func _swift_xpc_type_array() -> xpc_type_t
153-
154-
@_silgen_name("_swift_xpc_type_DICTIONARY")
155-
internal func _swift_xpc_type_dictionary() -> xpc_type_t
156-
157-
@_silgen_name("_swift_xpc_type_ERROR")
158-
internal func _swift_xpc_type_error() -> xpc_type_t
159-
160-
@_silgen_name("_swift_xpc_type_ACTIVITY")
161-
internal func _swift_xpc_type_activity() -> xpc_type_t
162-
163107
// xpc/connection.h
164108

165109
public var XPC_ERROR_CONNECTION_INTERRUPTED: xpc_object_t {
@@ -173,12 +117,3 @@ public var XPC_ERROR_CONNECTION_INVALID: xpc_object_t {
173117
public var XPC_ERROR_TERMINATION_IMMINENT: xpc_object_t {
174118
return _swift_xpc_connection_termination_imminent()
175119
}
176-
177-
@_silgen_name("_swift_xpc_connection_interrupted")
178-
internal func _swift_xpc_connection_interrupted() -> xpc_object_t
179-
180-
@_silgen_name("_swift_xpc_connection_invalid")
181-
internal func _swift_xpc_connection_invalid() -> xpc_object_t
182-
183-
@_silgen_name("_swift_xpc_connection_termination_imminent")
184-
internal func _swift_xpc_connection_termination_imminent() -> xpc_object_t

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set(sources
1919
OSOverlayShims.h
2020
SafariServicesOverlayShims.h
2121
XCTestOverlayShims.h
22+
XPCOverlayShims.h
2223

2324
module.modulemap
2425
)
Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===----------------------------------------------------------------------===//
1+
//===--- XPCOverlayShims.h --------------------------------------*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -10,65 +10,66 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include <xpc/xpc.h>
13+
#ifndef SWIFT_STDLIB_SHIMS_XPC_OVERLAY_H
14+
#define SWIFT_STDLIB_SHIMS_XPC_OVERLAY_H
15+
16+
@import XPC;
1417

15-
__attribute__((visibility("hidden")))
16-
extern "C" xpc_type_t
18+
static inline xpc_type_t
1719
_swift_xpc_get_type(xpc_object_t object) {
1820
return xpc_get_type(object);
1921
}
2022

21-
__attribute__((visibility("hidden")))
22-
extern "C" xpc_object_t
23+
static inline xpc_object_t
2324
_swift_xpc_bool_true() {
2425
return XPC_BOOL_TRUE;
2526
}
2627

27-
__attribute__((visibility("hidden")))
28-
extern "C" xpc_object_t
28+
static inline xpc_object_t
2929
_swift_xpc_bool_false() {
3030
return XPC_BOOL_FALSE;
3131
}
3232

33-
#define TYPE(t) \
34-
__attribute__((visibility("hidden"))) \
35-
extern "C" xpc_type_t \
33+
#define SWIFT_XPC_TYPE(t) \
34+
static inline xpc_type_t \
3635
_swift_xpc_type_##t(void) { \
3736
return XPC_TYPE_##t; \
3837
}
3938

40-
TYPE(CONNECTION)
41-
TYPE(ENDPOINT)
42-
TYPE(NULL)
43-
TYPE(BOOL)
44-
TYPE(INT64)
45-
TYPE(UINT64)
46-
TYPE(DOUBLE)
47-
TYPE(DATE)
48-
TYPE(DATA)
49-
TYPE(STRING)
50-
TYPE(UUID)
51-
TYPE(FD)
52-
TYPE(SHMEM)
53-
TYPE(ARRAY)
54-
TYPE(DICTIONARY)
55-
TYPE(ERROR)
56-
TYPE(ACTIVITY)
39+
SWIFT_XPC_TYPE(CONNECTION)
40+
SWIFT_XPC_TYPE(ENDPOINT)
41+
SWIFT_XPC_TYPE(NULL)
42+
SWIFT_XPC_TYPE(BOOL)
43+
SWIFT_XPC_TYPE(INT64)
44+
SWIFT_XPC_TYPE(UINT64)
45+
SWIFT_XPC_TYPE(DOUBLE)
46+
SWIFT_XPC_TYPE(DATE)
47+
SWIFT_XPC_TYPE(DATA)
48+
SWIFT_XPC_TYPE(STRING)
49+
SWIFT_XPC_TYPE(UUID)
50+
SWIFT_XPC_TYPE(FD)
51+
SWIFT_XPC_TYPE(SHMEM)
52+
SWIFT_XPC_TYPE(ARRAY)
53+
SWIFT_XPC_TYPE(DICTIONARY)
54+
SWIFT_XPC_TYPE(ERROR)
55+
SWIFT_XPC_TYPE(ACTIVITY)
56+
57+
#undef SWIFT_XPC_TYPE
5758

58-
__attribute__((visibility("hidden")))
59-
extern "C" xpc_object_t
59+
static inline xpc_object_t
6060
_swift_xpc_connection_interrupted(void) {
6161
return XPC_ERROR_CONNECTION_INTERRUPTED;
6262
}
6363

64-
__attribute__((visibility("hidden")))
65-
extern "C" xpc_object_t
64+
static inline xpc_object_t
6665
_swift_xpc_connection_invalid(void) {
6766
return XPC_ERROR_CONNECTION_INVALID;
6867
}
6968

70-
__attribute__((visibility("hidden")))
71-
extern "C" xpc_object_t
69+
static inline xpc_object_t
7270
_swift_xpc_connection_termination_imminent(void) {
7371
return XPC_ERROR_TERMINATION_IMMINENT;
7472
}
73+
74+
#endif // SWIFT_STDLIB_SHIMS_XPC_OVERLAY_H
75+

stdlib/public/SwiftShims/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ module _SwiftXCTestOverlayShims {
3636
header "XCTestOverlayShims.h"
3737
export *
3838
}
39+
40+
module _SwiftXPCOverlayShims {
41+
header "XPCOverlayShims.h"
42+
export *
43+
}

0 commit comments

Comments
 (0)