Skip to content

[cxx-interop] Fix check to include std::span #76370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions benchmark/utils/CxxTests/CxxStdlibPerformance.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,25 @@
#include <set>

// FIXME swift-ci linux tests do not support std::span
#if defined(__has_include) && __has_include(<span>)
#ifndef __linux__
#include <span>
#define SPAN_DEFINED 1
#else
#define SPAN_DEFINED 0
#endif
#endif // __linux__

static const size_t spanSize = 50000;

using VectorOfU32 = std::vector<uint32_t>;
using SetOfU32 = std::set<uint32_t>;
#if SPAN_DEFINED
#ifndef __linux__
using ArrayOfU32 = uint32_t[spanSize];
using SpanOfU32 = std::span<uint32_t>;
#endif
#endif // __linux__

static inline VectorOfU32 vec;
static inline SetOfU32 set;
#if SPAN_DEFINED
#ifndef __linux__
static inline ArrayOfU32 array;
static inline SpanOfU32 span;
#endif
#endif // __linux__

inline void initVector(size_t size) {
if (!vec.empty()) {
Expand All @@ -47,7 +44,7 @@ inline void initSet(size_t size) {
}
}

#if SPAN_DEFINED
#ifndef __linux__
inline void initSpan() {
if (!span.empty()) {
return;
Expand All @@ -57,7 +54,7 @@ inline void initSpan() {
}
span = SpanOfU32(array);
}
#endif
#endif // __linux__

inline VectorOfU32 makeVector32(size_t size) {
initVector(size);
Expand Down