Skip to content

Commit 6e875da

Browse files
committed
[Threading] Remove thread_get_main().
Removing thread_get_main() means we don't need a static initializer on Darwin, which means we can delete Darwin.cpp as well. We can also delete Nothreads.cpp while we're about it, because there's nothing in that file. rdar://90776105
1 parent dadd23e commit 6e875da

File tree

15 files changed

+11
-118
lines changed

15 files changed

+11
-118
lines changed

include/swift/Threading/Impl/C11.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ do { \
4949
using thread_id = ::thrd_t;
5050

5151
inline thread_id thread_get_current() { return ::thrd_current(); }
52-
thread_id thread_get_main();
5352
bool thread_is_main();
5453
inline bool threads_same(thread_id a, thread_id b) {
5554
return ::thrd_equal(a, b);

include/swift/Threading/Impl/Darwin.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ using thread_id = ::pthread_t;
3232

3333
inline thread_id thread_get_current() { return ::pthread_self(); }
3434

35-
thread_id thread_get_main();
36-
bool thread_is_main();
35+
inline bool thread_is_main() { return pthread_main_np(); }
3736

3837
inline bool threads_same(thread_id a, thread_id b) {
3938
return ::pthread_equal(a, b);

include/swift/Threading/Impl/Linux.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ using thread_id = ::pthread_t;
5555

5656
inline thread_id thread_get_current() { return ::pthread_self(); }
5757

58-
thread_id thread_get_main();
5958
bool thread_is_main();
6059

6160
inline bool threads_same(thread_id a, thread_id b) {

include/swift/Threading/Impl/Nothreads.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace threading_impl {
2525
using thread_id = unsigned;
2626

2727
inline thread_id thread_get_current() { return 0; }
28-
inline thread_id thread_get_main() { return 0; }
2928
inline bool thread_is_main() { return true; }
3029
inline bool threads_same(thread_id a, thread_id b) { return a == b; }
3130

include/swift/Threading/Impl/Pthreads.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ using thread_id = ::pthread_t;
5454

5555
inline thread_id thread_get_current() { return ::pthread_self(); }
5656

57-
thread_id thread_get_main();
5857
bool thread_is_main();
5958

6059
inline bool threads_same(thread_id a, thread_id b) {

include/swift/Threading/Impl/Win32.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ namespace threading_impl {
2929
using thread_id = ::DWORD;
3030

3131
inline thread_id thread_get_current() { return ::GetCurrentThreadId(); }
32-
thread_id thread_get_main();
3332
bool thread_is_main();
3433
inline bool threads_same(thread_id a, thread_id b) { return a == b; }
3534

include/swift/Threading/Thread.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ class Thread {
5555
return Thread(threading_impl::thread_get_current());
5656
}
5757

58-
/// Returns the main thread in this program
59-
static Thread main() {
60-
return Thread(threading_impl::thread_get_main());
61-
}
62-
6358
/// Returns true iff executed on the main thread
6459
static bool onMainThread() {
6560
return threading_impl::thread_is_main();

lib/Threading/C11.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,9 @@ C11ThreadingHelper helper;
6464
using namespace swift;
6565
using namespace threading_impl;
6666

67-
thread_id
68-
swift::threading_impl::thread_get_main() {
69-
return helper.main_thread();
70-
}
71-
7267
bool
7368
swift::threading_impl::thread_is_main() {
74-
return thrd_equal(thrd_current(), thread_get_main());
69+
return thrd_equal(thrd_current(), helper.main_thread());
7570
}
7671

7772
void

lib/Threading/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
# If you update this, you also need to update the CMakeLists.txt file in
2+
# stdlib/public/Threading
3+
14
add_swift_host_library(swiftThreading STATIC
25
C11.cpp
3-
Darwin.cpp
46
Linux.cpp
5-
Nothreads.cpp
67
Pthreads.cpp
78
Win32.cpp)

lib/Threading/Darwin.cpp

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)