Skip to content

Commit fa8bed5

Browse files
committed
[Threading] Put everything through git clang-format.
Just formatting changes. rdar://90776105
1 parent c879a82 commit fa8bed5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+415
-441
lines changed

include/swift/Basic/Compiler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@
165165
// SWIFT_FORMAT(fmt,first) marks a function as taking a format string argument
166166
// at argument `fmt`, with the first argument for the format string as `first`.
167167
#if __has_attribute(format)
168-
#define SWIFT_FORMAT(fmt,first) __attribute__((format(printf, fmt, first)))
168+
#define SWIFT_FORMAT(fmt, first) __attribute__((format(printf, fmt, first)))
169169
#else
170-
#define SWIFT_FORMAT(fmt,first)
170+
#define SWIFT_FORMAT(fmt, first)
171171
#endif
172172

173173
// SWIFT_VFORMAT(fmt) marks a function as taking a format string argument at
174174
// argument `fmt`, with the arguments in a `va_list`.
175175
#if __has_attribute(format)
176-
#define SWIFT_VFORMAT(fmt) __attribute__((format(printf, fmt, 0)))
176+
#define SWIFT_VFORMAT(fmt) __attribute__((format(printf, fmt, 0)))
177177
#else
178178
#define SWIFT_VFORMAT(fmt)
179179
#endif

include/swift/Runtime/Concurrent.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
//===----------------------------------------------------------------------===//
1212
#ifndef SWIFT_RUNTIME_CONCURRENTUTILS_H
1313
#define SWIFT_RUNTIME_CONCURRENTUTILS_H
14-
#include <iterator>
14+
#include "Atomic.h"
15+
#include "Debug.h"
16+
#include "swift/Threading/Mutex.h"
17+
#include "llvm/ADT/Hashing.h"
18+
#include "llvm/Support/Allocator.h"
1519
#include <algorithm>
1620
#include <atomic>
1721
#include <functional>
22+
#include <iterator>
1823
#include <stdint.h>
1924
#include <vector>
20-
#include "llvm/ADT/Hashing.h"
21-
#include "llvm/Support/Allocator.h"
22-
#include "Atomic.h"
23-
#include "Debug.h"
24-
#include "swift/Threading/Mutex.h"
2525

2626
#if defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__HAIKU__)
2727
#include <stdio.h>

include/swift/Runtime/EnvironmentVariables.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ extern swift::once_t initializeToken;
2929
#include "../../../stdlib/public/runtime/EnvironmentVariables.def"
3030

3131
// Define getter functions.
32-
#define VARIABLE(name, type, defaultValue, help) \
33-
inline type name() { \
34-
swift::once(initializeToken, initialize, nullptr); \
35-
return name ## _variable; \
32+
#define VARIABLE(name, type, defaultValue, help) \
33+
inline type name() { \
34+
swift::once(initializeToken, initialize, nullptr); \
35+
return name##_variable; \
3636
}
3737
#include "../../../stdlib/public/runtime/EnvironmentVariables.def"
3838

include/swift/Runtime/VoucherShims.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
// swift-corelibs-libdispatch has os/voucher_private.h but it doesn't work for
2323
// us yet, so only look for it on Apple platforms. We also don't need vouchers
2424
// in the single threaded concurrency runtime.
25-
#if __APPLE__ && !SWIFT_THREADING_NONE \
26-
&& __has_include(<os/voucher_private.h>)
25+
#if __APPLE__ && !SWIFT_THREADING_NONE && __has_include(<os/voucher_private.h>)
2726
#define SWIFT_HAS_VOUCHER_HEADER 1
2827
#include <os/voucher_private.h>
2928
#endif

include/swift/Threading/Errors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SWIFT_ATTRIBUTE_NORETURN
2929
SWIFT_FORMAT(1, 2)
3030
void fatal(const char *msg, ...);
3131

32-
}
33-
}
32+
} // namespace threading
33+
} // namespace swift
3434

3535
#endif // SWIFT_THREADING_ERRORS_H

include/swift/Threading/Impl.h

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,24 @@
1919
#define SWIFT_THREADING_IMPL_H
2020

2121
// Try to autodetect if we aren't told what to do
22-
#if !SWIFT_THREADING_NONE && \
23-
!SWIFT_THREADING_DARWIN && \
24-
!SWIFT_THREADING_LINUX && \
25-
!SWIFT_THREADING_PTHREADS && \
26-
!SWIFT_THREADING_C11 && \
27-
!SWIFT_THREADING_WIN32
28-
#ifdef __APPLE__
29-
#define SWIFT_THREADING_DARWIN 1
30-
#elif defined(__linux__)
31-
#define SWIFT_THREADING_LINUX 1
32-
#elif defined(_WIN32)
33-
#define SWIFT_THREADING_WIN32 1
34-
#elif defined(__wasi__)
35-
#define SWIFT_THREADING_NONE 1
36-
#elif __has_include(<threads.h>)
37-
#define SWIFT_THREADING_C11 1
38-
#elif __has_include(<pthread.h>)
39-
#define SWIFT_THREADING_PTHREADS 1
40-
#else
41-
#error Unable to autodetect threading package. Please define SWIFT_THREADING_x as appropriate for your platform.
42-
#endif
22+
#if !SWIFT_THREADING_NONE && !SWIFT_THREADING_DARWIN && \
23+
!SWIFT_THREADING_LINUX && !SWIFT_THREADING_PTHREADS && \
24+
!SWIFT_THREADING_C11 && !SWIFT_THREADING_WIN32
25+
#ifdef __APPLE__
26+
#define SWIFT_THREADING_DARWIN 1
27+
#elif defined(__linux__)
28+
#define SWIFT_THREADING_LINUX 1
29+
#elif defined(_WIN32)
30+
#define SWIFT_THREADING_WIN32 1
31+
#elif defined(__wasi__)
32+
#define SWIFT_THREADING_NONE 1
33+
#elif __has_include(<threads.h>)
34+
#define SWIFT_THREADING_C11 1
35+
#elif __has_include(<pthread.h>)
36+
#define SWIFT_THREADING_PTHREADS 1
37+
#else
38+
#error Unable to autodetect threading package. Please define SWIFT_THREADING_x as appropriate for your platform.
39+
#endif
4340
#endif
4441

4542
#if SWIFT_THREADING_NONE

include/swift/Threading/Impl/C11.h

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,31 @@
1717
#ifndef SWIFT_THREADING_IMPL_C11_H
1818
#define SWIFT_THREADING_IMPL_C11_H
1919

20-
#include <threads.h>
2120
#include <stdatomic.h>
21+
#include <threads.h>
2222

2323
namespace swift {
2424
namespace threading_impl {
2525

26-
#define SWIFT_C11THREADS_CHECK(expr) \
27-
do { \
28-
int res_ = (expr); \
29-
if (res_ != thrd_success) \
30-
swift::threading::fatal(#expr " failed with error %d\n", res_); \
31-
} while (0)
32-
33-
#define SWIFT_C11THREADS_RETURN_TRUE_OR_FALSE(expr) \
34-
do { \
35-
int res_ = (expr); \
36-
switch (res_) { \
37-
case thrd_success: \
38-
return true; \
39-
case thrd_busy: \
40-
return false; \
41-
default: \
42-
swift::threading::fatal(#expr " failed with error (%d)\n", res_); \
43-
} \
44-
} while (0)
45-
26+
#define SWIFT_C11THREADS_CHECK(expr) \
27+
do { \
28+
int res_ = (expr); \
29+
if (res_ != thrd_success) \
30+
swift::threading::fatal(#expr " failed with error %d\n", res_); \
31+
} while (0)
32+
33+
#define SWIFT_C11THREADS_RETURN_TRUE_OR_FALSE(expr) \
34+
do { \
35+
int res_ = (expr); \
36+
switch (res_) { \
37+
case thrd_success: \
38+
return true; \
39+
case thrd_busy: \
40+
return false; \
41+
default: \
42+
swift::threading::fatal(#expr " failed with error (%d)\n", res_); \
43+
} \
44+
} while (0)
4645

4746
// .. Thread related things ..................................................
4847

@@ -58,7 +57,7 @@ inline bool threads_same(thread_id a, thread_id b) {
5857

5958
using mutex_handle = ::mtx_t;
6059

61-
inline void mutex_init(mutex_handle &handle, bool checked=false) {
60+
inline void mutex_init(mutex_handle &handle, bool checked = false) {
6261
SWIFT_C11THREADS_CHECK(::mtx_init(&handle), ::mtx_plain);
6362
}
6463
inline void mutex_destroy(mutex_handle &handle) {
@@ -83,8 +82,8 @@ inline void mutex_unsafe_unlock(mutex_handle &handle) {
8382
}
8483

8584
struct lazy_mutex_handle {
86-
::mtx_t mutex;
87-
::atomic_int once; // -1 = initialized, 0 = uninitialized, 1 = initializing
85+
::mtx_t mutex;
86+
::atomic_int once; // -1 = initialized, 0 = uninitialized, 1 = initializing
8887
};
8988

9089
inline constexpr lazy_mutex_handle lazy_mutex_initializer() {
@@ -95,9 +94,7 @@ inline void lazy_mutex_init(lazy_mutex_handle &handle) {
9594
if (::atomic_load_explicit(&handle.once, ::memory_order_acquire) < 0)
9695
return;
9796

98-
if (::atomic_compare_exchange_strong_explicit(&handle.once,
99-
&(int){ 0 },
100-
1,
97+
if (::atomic_compare_exchange_strong_explicit(&handle.once, &(int){0}, 1,
10198
::memory_order_relaxed,
10299
::memory_order_relaxed)) {
103100
SWIFT_C11THREADS_CHECK(::mtx_init(&handle.mutex, ::mtx_plain));
@@ -164,13 +161,9 @@ inline bool tls_alloc(tls_key &key, tls_dtor dtor) {
164161
return ::tss_create(&key, dtor) == thrd_success;
165162
}
166163

167-
inline void *tls_get(tls_key key) {
168-
return ::tss_get(key);
169-
}
164+
inline void *tls_get(tls_key key) { return ::tss_get(key); }
170165

171-
inline void tls_set(tls_key key, void *ptr) {
172-
::tss_set(key, ptr);
173-
}
166+
inline void tls_set(tls_key key, void *ptr) { ::tss_set(key, ptr); }
174167

175168
} // namespace threading_impl
176169

include/swift/Threading/Impl/Darwin.h

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#ifndef SWIFT_THREADING_IMPL_DARWIN_H
1818
#define SWIFT_THREADING_IMPL_DARWIN_H
1919

20-
#include <pthread.h>
21-
#include <os/lock.h>
2220
#include <dispatch/dispatch.h>
21+
#include <os/lock.h>
22+
#include <pthread.h>
2323

2424
#include "swift/Threading/Errors.h"
2525

@@ -42,14 +42,12 @@ inline bool threads_same(thread_id a, thread_id b) {
4242

4343
using mutex_handle = ::os_unfair_lock;
4444

45-
inline void mutex_init(mutex_handle &handle, bool checked=false) {
45+
inline void mutex_init(mutex_handle &handle, bool checked = false) {
4646
handle = OS_UNFAIR_LOCK_INIT;
4747
}
48-
inline void mutex_destroy(mutex_handle &handle) { }
48+
inline void mutex_destroy(mutex_handle &handle) {}
4949

50-
inline void mutex_lock(mutex_handle &handle) {
51-
::os_unfair_lock_lock(&handle);
52-
}
50+
inline void mutex_lock(mutex_handle &handle) { ::os_unfair_lock_lock(&handle); }
5351
inline void mutex_unlock(mutex_handle &handle) {
5452
::os_unfair_lock_unlock(&handle);
5553
}
@@ -70,7 +68,7 @@ using lazy_mutex_handle = ::os_unfair_lock;
7068
inline constexpr lazy_mutex_handle lazy_mutex_initializer() {
7169
return OS_UNFAIR_LOCK_INIT;
7270
}
73-
inline void lazy_mutex_destroy(lazy_mutex_handle &handle) { }
71+
inline void lazy_mutex_destroy(lazy_mutex_handle &handle) {}
7472

7573
inline void lazy_mutex_lock(lazy_mutex_handle &handle) {
7674
::os_unfair_lock_lock(&handle);
@@ -118,29 +116,29 @@ inline void once_impl(once_t &predicate, void (*fn)(void *), void *context) {
118116

119117
extern "C" {
120118

121-
extern int pthread_key_init_np(int, void (*)(void *));
122-
123-
inline bool _pthread_has_direct_tsd() { return false; }
124-
inline void *_pthread_getspecific_direct(pthread_key_t k) {
125-
return pthread_getspecific(k);
126-
}
127-
inline void _pthread_setspecific_direct(pthread_key_t k, void *v) {
128-
pthread_setspecific(k, v);
129-
}
119+
extern int pthread_key_init_np(int, void (*)(void *));
130120

121+
inline bool _pthread_has_direct_tsd() { return false; }
122+
inline void *_pthread_getspecific_direct(pthread_key_t k) {
123+
return pthread_getspecific(k);
124+
}
125+
inline void _pthread_setspecific_direct(pthread_key_t k, void *v) {
126+
pthread_setspecific(k, v);
127+
}
131128
}
132129
#endif
133130

134-
#define SWIFT_RUNTIME_TLS_KEY __PTK_FRAMEWORK_SWIFT_KEY0
135-
#define SWIFT_STDLIB_TLS_KEY __PTK_FRAMEWORK_SWIFT_KEY1
136-
#define SWIFT_COMPATIBILITY_50_TLS_KEY __PTK_FRAMEWORK_SWIFT_KEY2
137-
#define SWIFT_CONCURRENCY_TASK_KEY __PTK_FRAMEWORK_SWIFT_KEY3
138-
#define SWIFT_CONCURRENCY_EXECUTOR_TRACKING_INFO_KEY __PTK_FRAMEWORK_SWIFT_KEY4
139-
#define SWIFT_CONCURRENCY_FALLBACK_TASK_LOCAL_STORAGE_KEY __PTK_FRAMEWORK_SWIFT_KEY5
140-
#define SWIFT_RESERVED_TLS_KEY_6 __PTK_FRAMEWORK_SWIFT_KEY6
141-
#define SWIFT_RESERVED_TLS_KEY_7 __PTK_FRAMEWORK_SWIFT_KEY7
142-
#define SWIFT_RESERVED_TLS_KEY_8 __PTK_FRAMEWORK_SWIFT_KEY8
143-
#define SWIFT_RESERVED_TLS_KEY_9 __PTK_FRAMEWORK_SWIFT_KEY9
131+
#define SWIFT_RUNTIME_TLS_KEY __PTK_FRAMEWORK_SWIFT_KEY0
132+
#define SWIFT_STDLIB_TLS_KEY __PTK_FRAMEWORK_SWIFT_KEY1
133+
#define SWIFT_COMPATIBILITY_50_TLS_KEY __PTK_FRAMEWORK_SWIFT_KEY2
134+
#define SWIFT_CONCURRENCY_TASK_KEY __PTK_FRAMEWORK_SWIFT_KEY3
135+
#define SWIFT_CONCURRENCY_EXECUTOR_TRACKING_INFO_KEY __PTK_FRAMEWORK_SWIFT_KEY4
136+
#define SWIFT_CONCURRENCY_FALLBACK_TASK_LOCAL_STORAGE_KEY \
137+
__PTK_FRAMEWORK_SWIFT_KEY5
138+
#define SWIFT_RESERVED_TLS_KEY_6 __PTK_FRAMEWORK_SWIFT_KEY6
139+
#define SWIFT_RESERVED_TLS_KEY_7 __PTK_FRAMEWORK_SWIFT_KEY7
140+
#define SWIFT_RESERVED_TLS_KEY_8 __PTK_FRAMEWORK_SWIFT_KEY8
141+
#define SWIFT_RESERVED_TLS_KEY_9 __PTK_FRAMEWORK_SWIFT_KEY9
144142

145143
#define SWIFT_TLS_DECLARE_DTOR(name) void name(void *)
146144

0 commit comments

Comments
 (0)