Skip to content

Commit 56a6b79

Browse files
authored
Mark earlyCWD (OpenBSD-only) constinit and fix some comments/style. (#1396)
See title. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 55ff51e commit 56a6b79

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/_TestingInternals/ExecutablePath.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// This source file is part of the Swift.org open source project
33
//
4-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
4+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
55
// Licensed under Apache License v2.0 with Runtime Library Exception
66
//
77
// See https://swift.org/LICENSE.txt for license information
@@ -13,7 +13,8 @@
1313
#include <atomic>
1414

1515
#if defined(__OpenBSD__)
16-
static std::atomic<const char *> earlyCWD { nullptr };
16+
/// Storage for ``swt_getEarlyCWD()``.
17+
static constinit std::atomic<const char *> earlyCWD { nullptr };
1718

1819
/// At process start (before `main()` is called), capture the current working
1920
/// directory.
@@ -22,7 +23,7 @@ static std::atomic<const char *> earlyCWD { nullptr };
2223
/// possible) resolve the executable path when the first argument is a relative
2324
/// path (which can occur when manually invoking the test executable.)
2425
__attribute__((__constructor__(101), __used__))
25-
static void swt_captureEarlyCWD(void) {
26+
static void captureEarlyCWD(void) {
2627
static char buffer[PATH_MAX * 2];
2728
if (getcwd(buffer, sizeof(buffer))) {
2829
earlyCWD.store(buffer);

0 commit comments

Comments
 (0)