Skip to content

Commit 490bf1d

Browse files
authored
Merge pull request #3630 from swiftwasm/maxd/5.5-merge
Resolve conflicts with upstream 5.5 branch
2 parents 9bbe441 + 3f9d907 commit 490bf1d

File tree

16 files changed

+141
-19
lines changed

16 files changed

+141
-19
lines changed

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
5959
CheckedContinuation.swift
6060
GlobalExecutor.cpp
6161
Errors.swift
62+
Error.cpp
6263
Executor.swift
6364
AsyncCompactMapSequence.swift
6465
AsyncDropFirstSequence.swift

stdlib/public/Concurrency/Error.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===--- Error.cpp - Error handling support code --------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "Error.h"
14+
15+
// swift::fatalError is not exported from libswiftCore and not shared, so define another
16+
// internal function instead.
17+
SWIFT_NORETURN void swift::swift_Concurrency_fatalError(uint32_t flags, const char *format, ...) {
18+
abort();
19+
}

stdlib/public/Concurrency/Error.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===--- Error.h - Swift Concurrency error helpers --------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Error handling support.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_CONCURRENCY_ERRORS_H
18+
#define SWIFT_CONCURRENCY_ERRORS_H
19+
20+
#include "../SwiftShims/Visibility.h"
21+
#include <cstdint>
22+
#include <stdlib.h>
23+
24+
namespace swift {
25+
26+
SWIFT_NORETURN void swift_Concurrency_fatalError(uint32_t flags, const char *format, ...);
27+
28+
} // namespace swift
29+
30+
#endif

stdlib/public/Concurrency/GlobalExecutor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "swift/Runtime/Concurrency.h"
5858
#include "swift/Runtime/EnvironmentVariables.h"
5959
#include "TaskPrivate.h"
60+
#include "Error.h"
6061

6162
#if !SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
6263
#include <dispatch/dispatch.h>
@@ -275,7 +276,7 @@ extern "C" void dispatch_queue_set_width(dispatch_queue_t dq, long width);
275276
static dispatch_queue_t getGlobalQueue(JobPriority priority) {
276277
size_t numericPriority = static_cast<size_t>(priority);
277278
if (numericPriority >= globalQueueCacheCount)
278-
fatalError(0, "invalid job priority %#zx");
279+
swift_Concurrency_fatalError(0, "invalid job priority %#zx");
279280

280281
#ifdef SWIFT_CONCURRENCY_BACK_DEPLOYMENT
281282
std::memory_order loadOrder = std::memory_order_acquire;

stdlib/public/Concurrency/Mutex.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "Error.h"
14+
15+
#define SWIFT_FATAL_ERROR swift_Concurrency_fatalError
16+
1317
// Include the runtime's mutex support code.
1418
// FIXME: figure out some reasonable way to share this stuff
1519

@@ -18,8 +22,3 @@
1822
#ifdef SWIFT_STDLIB_SINGLE_THREADED_RUNTIME
1923
#include "swift/Runtime/MutexSingleThreaded.h"
2024
#endif
21-
22-
__attribute__ ((weak))
23-
SWIFT_NORETURN void swift::fatalError(uint32_t flags, const char *format, ...) {
24-
abort();
25-
}

stdlib/public/Concurrency/Task.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "TaskPrivate.h"
2727
#include "AsyncCall.h"
2828
#include "Debug.h"
29+
#include "Error.h"
2930

3031
#if !SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
3132
#include <dispatch/dispatch.h>
@@ -787,7 +788,7 @@ static void swift_task_future_waitImpl(
787788
}
788789

789790
case FutureFragment::Status::Error:
790-
fatalError(0, "future reported an error, but wait cannot throw");
791+
swift_Concurrency_fatalError(0, "future reported an error, but wait cannot throw");
791792
}
792793
}
793794

stdlib/public/Concurrency/TaskAlloc.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "swift/Runtime/Concurrency.h"
2121
#include "swift/ABI/Task.h"
2222
#include "TaskPrivate.h"
23-
2423
#include <stdlib.h>
2524

2625
using namespace swift;

stdlib/public/Concurrency/TaskPrivate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include "swift/Runtime/Exclusivity.h"
2626
#include "swift/Runtime/HeapObject.h"
2727

28+
#include "Error.h"
29+
30+
#define SWIFT_FATAL_ERROR swift_Concurrency_fatalError
2831
#include "../runtime/StackAllocator.h"
2932

3033
#if HAVE_PTHREAD_H

stdlib/public/runtime/MutexPThread.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
#endif
2121

2222
#if defined(_POSIX_THREADS) && !defined(SWIFT_STDLIB_SINGLE_THREADED_RUNTIME)
23+
24+
// Notes: swift::fatalError is not shared between libswiftCore and libswift_Concurrency
25+
// and libswift_Concurrency uses swift_Concurrency_fatalError instead.
26+
#ifndef SWIFT_FATAL_ERROR
27+
#define SWIFT_FATAL_ERROR swift::fatalError
28+
#endif
29+
2330
#include "swift/Runtime/Mutex.h"
2431

2532
#include "swift/Runtime/Debug.h"
@@ -32,8 +39,8 @@ using namespace swift;
3239
do { \
3340
int errorcode = PThreadFunction; \
3441
if (errorcode != 0) { \
35-
fatalError(/* flags = */ 0, "'%s' failed with error '%s'(%d)\n", \
36-
#PThreadFunction, errorName(errorcode), errorcode); \
42+
SWIFT_FATAL_ERROR(/* flags = */ 0, "'%s' failed with error '%s'(%d)\n", \
43+
#PThreadFunction, errorName(errorcode), errorcode); \
3744
} \
3845
} while (false)
3946

@@ -44,8 +51,8 @@ using namespace swift;
4451
return true; \
4552
if (returnFalseOnEBUSY && errorcode == EBUSY) \
4653
return false; \
47-
fatalError(/* flags = */ 0, "'%s' failed with error '%s'(%d)\n", \
48-
#PThreadFunction, errorName(errorcode), errorcode); \
54+
SWIFT_FATAL_ERROR(/* flags = */ 0, "'%s' failed with error '%s'(%d)\n", \
55+
#PThreadFunction, errorName(errorcode), errorcode); \
4956
} while (false)
5057

5158
static const char *errorName(int errorcode) {

stdlib/public/runtime/MutexWin32.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#if defined(_WIN32)
19+
20+
// Notes: swift::fatalError is not shared between libswiftCore and libswift_Concurrency
21+
// and libswift_Concurrency uses swift_Concurrency_fatalError instead.
22+
#ifndef SWIFT_FATAL_ERROR
23+
#define SWIFT_FATAL_ERROR swift::fatalError
24+
#endif
25+
1926
#include "swift/Runtime/Mutex.h"
2027
#include "swift/Runtime/Debug.h"
2128

@@ -26,9 +33,9 @@ void ConditionPlatformHelper::wait(CONDITION_VARIABLE &condition,
2633
BOOL result = SleepConditionVariableSRW(&condition, &mutex, INFINITE, 0);
2734
if (!result) {
2835
DWORD errorcode = GetLastError();
29-
fatalError(/* flags = */ 0,
30-
"'SleepConditionVariableSRW()' failed with error code %d\n",
31-
errorcode);
36+
SWIFT_FATAL_ERROR(/* flags = */ 0,
37+
"'SleepConditionVariableSRW()' failed with error code %d\n",
38+
errorcode);
3239
}
3340
}
3441
#endif

0 commit comments

Comments
 (0)