Skip to content

Commit

Permalink
Add conditional to avoid building std::assume_aligned for android
Browse files Browse the repository at this point in the history
b/309847996

Change-Id: I538fa194d1a76c447ae328e320dd3f1d6c24613b
  • Loading branch information
niranjanyardi committed Mar 23, 2024
1 parent 9ff9f31 commit 1068c35
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion starboard/nplb/compiler_compliance/cpp20_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include <numeric>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <version>

namespace starboard {
namespace nplb {
Expand All @@ -34,17 +36,22 @@ void test_string_ends_with() {
bool result = std::string("foobar").ends_with("bar");
}

#if __cpp_lib_assume_aligned >= 201811L
// Test std::assume_aligned support
void test_assume_aligned(int* p) {
int* p1 = std::assume_aligned<256>(p);
}
#else
// Fallback implementation if std::assume_aligned is not supported
// Currently android platform is incapable of building std::assume_aligned.
#endif

// Test std::erase_if support
void test_erase_if() {
std::vector<char> cnt(10);
std::iota(cnt.begin(), cnt.end(), '0');
std::erase(cnt, '3');
auto erased = std::erase_if(cnt, [](char x) { return (x - '0') % 2 == 0; });
std::erase_if(cnt, [](char x) { return (x - '0') % 2 == 0; });
}

// Test std::midpoint support
Expand Down

0 comments on commit 1068c35

Please sign in to comment.