Skip to content

Commit 7ce3ac6

Browse files
Merge branch 'b1.1.0'
2 parents 4f3b677 + ef0369f commit 7ce3ac6

File tree

11 files changed

+262
-32
lines changed

11 files changed

+262
-32
lines changed

Benchmark/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.4
1+
// swift-tools-version: 6.0
22
//
33
//===----------------------------------------------------------------------===//
44
//
@@ -21,7 +21,7 @@ import PackageDescription
2121

2222

2323

24-
let swiftSettings: [SwiftSetting] = [ ]
24+
let swiftSettings: [SwiftSetting]? = nil
2525

2626
let package = Package(
2727
name: "kvSimdBenchmark",

Benchmark/Package@swift-5.10.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// swift-tools-version: 5.10
2+
//
3+
//===----------------------------------------------------------------------===//
4+
//
5+
// Copyright (c) 2023 Svyatoslav Popov (info@keyvar.com).
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
8+
// the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
13+
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
14+
// specific language governing permissions and limitations under the License.
15+
//
16+
// SPDX-License-Identifier: Apache-2.0
17+
//
18+
//===----------------------------------------------------------------------===//
19+
20+
import PackageDescription
21+
22+
23+
24+
let swiftSettings: [SwiftSetting]? = nil
25+
26+
let package = Package(
27+
name: "kvSimdBenchmark",
28+
29+
products: [
30+
.executable(name: "kvSimdBenchmark", targets: [ "kvSimdBenchmark" ]),
31+
],
32+
33+
dependencies: [
34+
.package(path: "../"),
35+
.package(url: "https://github.com/keyvariable/kvKit.swift.git", from: "4.1.0"),
36+
],
37+
38+
targets: [
39+
.executableTarget(name: "kvSimdBenchmark",
40+
dependencies: [ .product(name: "kvSIMD.forced", package: "kvSIMD.swift"),
41+
.product(name: "kvKit", package: "kvKit.swift"), ],
42+
swiftSettings: swiftSettings),
43+
]
44+
)

Benchmark/Package@swift-5.9.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// swift-tools-version: 5.9
2+
//
3+
//===----------------------------------------------------------------------===//
4+
//
5+
// Copyright (c) 2023 Svyatoslav Popov (info@keyvar.com).
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
8+
// the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
13+
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
14+
// specific language governing permissions and limitations under the License.
15+
//
16+
// SPDX-License-Identifier: Apache-2.0
17+
//
18+
//===----------------------------------------------------------------------===//
19+
20+
import PackageDescription
21+
22+
23+
24+
let swiftSettings: [SwiftSetting]? = nil
25+
26+
let package = Package(
27+
name: "kvSimdBenchmark",
28+
29+
products: [
30+
.executable(name: "kvSimdBenchmark", targets: [ "kvSimdBenchmark" ]),
31+
],
32+
33+
dependencies: [
34+
.package(path: "../"),
35+
.package(url: "https://github.com/keyvariable/kvKit.swift.git", from: "4.1.0"),
36+
],
37+
38+
targets: [
39+
.executableTarget(name: "kvSimdBenchmark",
40+
dependencies: [ .product(name: "kvSIMD.forced", package: "kvSIMD.swift"),
41+
.product(name: "kvKit", package: "kvKit.swift"), ],
42+
swiftSettings: swiftSettings),
43+
]
44+
)

Benchmark/Packages.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# This script creates copies of Package.swift for versions of Swift 5.9+.
4+
#
5+
6+
set -e # Exit on error
7+
8+
DIR_PATH=$(dirname "$0")
9+
10+
clone()
11+
{
12+
sed "s/swift-tools-version: 6.0/swift-tools-version: $1/" "$DIR_PATH/Package.swift" > "$DIR_PATH/Package@swift-$1.swift"
13+
}
14+
15+
clone "5.10"
16+
clone "5.9"

Benchmark/Sources/kvSimdBenchmark/KvBenchmark.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class KvBenchmark {
185185
var machine: [CChar] = .init(repeating: 0, count: size)
186186
guard sysctlbyname(name, &machine, &size, nil, 0) == 0 else { return nil }
187187

188-
return String(cString: machine)
188+
return String(cString: &machine)
189189
}
190190

191191

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version: 6.0
22
//
33
//===----------------------------------------------------------------------===//
44
//

Package@swift-5.10.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// swift-tools-version: 5.10
2+
//
3+
//===----------------------------------------------------------------------===//
4+
//
5+
// Copyright (c) 2023 Svyatoslav Popov (info@keyvar.com).
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
8+
// the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
13+
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
14+
// specific language governing permissions and limitations under the License.
15+
//
16+
// SPDX-License-Identifier: Apache-2.0
17+
//
18+
//===----------------------------------------------------------------------===//
19+
20+
import PackageDescription
21+
22+
23+
24+
let swiftSettings: [SwiftSetting]? = nil
25+
26+
let isSimdAvailable: Bool
27+
#if canImport(simd)
28+
isSimdAvailable = true
29+
#else // !canImport(simd)
30+
isSimdAvailable = false
31+
#endif // !canImport(simd)
32+
33+
// Module is named "simd" to use `import simd` when the SIMD framework is not available.
34+
// Otherwise it's named "kvSIMD" to prevent collision.
35+
let moduleName = isSimdAvailable ? "kvSIMD" : "simd"
36+
let placeholderModuleName = "kvSIMD_Placeholder"
37+
38+
39+
let package = Package(
40+
name: "kvSIMD.swift",
41+
42+
products: [ .library(name: "kvSIMD", targets: [ !isSimdAvailable ? moduleName : placeholderModuleName ]),
43+
.library(name: "kvSIMD.forced", targets: [ moduleName ])],
44+
45+
targets: Array([
46+
[ .target(name: moduleName, path: "Sources/kvSIMD", swiftSettings: swiftSettings),
47+
.target(name: placeholderModuleName), ],
48+
49+
isSimdAvailable ? [ .testTarget(name: "kvSIMDTests", dependencies: [ .target(name: moduleName) ], swiftSettings: swiftSettings) ] : [ ],
50+
].joined())
51+
)

Package@swift-5.9.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// swift-tools-version: 5.9
2+
//
3+
//===----------------------------------------------------------------------===//
4+
//
5+
// Copyright (c) 2023 Svyatoslav Popov (info@keyvar.com).
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
8+
// the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
13+
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
14+
// specific language governing permissions and limitations under the License.
15+
//
16+
// SPDX-License-Identifier: Apache-2.0
17+
//
18+
//===----------------------------------------------------------------------===//
19+
20+
import PackageDescription
21+
22+
23+
24+
let swiftSettings: [SwiftSetting]? = nil
25+
26+
let isSimdAvailable: Bool
27+
#if canImport(simd)
28+
isSimdAvailable = true
29+
#else // !canImport(simd)
30+
isSimdAvailable = false
31+
#endif // !canImport(simd)
32+
33+
// Module is named "simd" to use `import simd` when the SIMD framework is not available.
34+
// Otherwise it's named "kvSIMD" to prevent collision.
35+
let moduleName = isSimdAvailable ? "kvSIMD" : "simd"
36+
let placeholderModuleName = "kvSIMD_Placeholder"
37+
38+
39+
let package = Package(
40+
name: "kvSIMD.swift",
41+
42+
products: [ .library(name: "kvSIMD", targets: [ !isSimdAvailable ? moduleName : placeholderModuleName ]),
43+
.library(name: "kvSIMD.forced", targets: [ moduleName ])],
44+
45+
targets: Array([
46+
[ .target(name: moduleName, path: "Sources/kvSIMD", swiftSettings: swiftSettings),
47+
.target(name: placeholderModuleName), ],
48+
49+
isSimdAvailable ? [ .testTarget(name: "kvSIMDTests", dependencies: [ .target(name: moduleName) ], swiftSettings: swiftSettings) ] : [ ],
50+
].joined())
51+
)

Packages.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# This script creates copies of Package.swift for versions of Swift 5.9+.
4+
#
5+
6+
set -e # Exit on error
7+
8+
DIR_PATH=$(dirname "$0")
9+
10+
clone()
11+
{
12+
sed "s/swift-tools-version: 6.0/swift-tools-version: $1/" "$DIR_PATH/Package.swift" > "$DIR_PATH/Package@swift-$1.swift"
13+
}
14+
15+
clone "5.10"
16+
clone "5.9"

0 commit comments

Comments
 (0)