Skip to content

Commit 90ae907

Browse files
authored
Merge pull request #279 from elbeno/usage-test
✨ Add usage test
2 parents 5c6966c + 1c40325 commit 90ae907

File tree

9 files changed

+140
-17
lines changed

9 files changed

+140
-17
lines changed

.github/workflows/usage_test.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Usage Test
2+
permissions: read-all
3+
4+
on:
5+
workflow_dispatch:
6+
merge_group:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
env:
13+
DEBIAN_FRONTEND: noninteractive
14+
USER_LLVM_VERSION: 14
15+
USER_CMAKE_VERSION: 3.25
16+
17+
jobs:
18+
usage_test:
19+
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
cpp_implementation: [FREESTANDING, HOSTED]
24+
25+
steps:
26+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27+
28+
- name: Install compiler
29+
run: sudo apt update && sudo apt-get install -y clang-${{env.USER_LLVM_VERSION}}
30+
31+
- name: Install cmake
32+
run: |
33+
pip3 install --upgrade pip
34+
pip3 install --force cmake==${{env.USER_CMAKE_VERSION}}
35+
36+
- name: Configure CMake
37+
working-directory: ${{github.workspace}}/usage_test
38+
env:
39+
CC: "/usr/lib/llvm-${{env.USER_LLVM_VERSION}}/bin/clang"
40+
CXX: "/usr/lib/llvm-${{env.USER_LLVM_VERSION}}/bin/clang++"
41+
run: ~/.local/bin/cmake -B build -DCPP_IMPLEMENTATION=${{matrix.cpp_implementation}}
42+
43+
- name: Build
44+
working-directory: ${{github.workspace}}/usage_test
45+
run: ~/.local/bin/cmake --build build

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/build
1+
build/
22
/cmake-build-*
33
/venv
44
/.vscode

docs/ct_format.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ provides `ct_format`, a compile-time function for formatting strings.
99
NOTE: Like xref:ct_string.adoc#_ct_string_hpp[`ct_string`], `ct_format` is
1010
available only in C++20 and later.
1111

12+
IMPORTANT: `ct_format` is not yet available on freestanding implementations.
13+
1214
The format string is provided as a template argument, and the arguments to be
1315
formatted as regular function arguments.
1416

docs/for_each_n_args.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ https://github.com/intel/cpp-std-extensions/blob/main/include/stdx/for_each_n_ar
55
provides a method for calling a function (or other callable) with batches of
66
arguments from a parameter pack.
77

8+
IMPORTANT: `for_each_n_args` is not yet available on freestanding implementations.
9+
810
Examples:
911
[source,cpp]
1012
----

docs/function_traits.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ https://github.com/intel/cpp-std-extensions/blob/main/include/stdx/function_trai
55
contains type traits for introspecting function signatures. It works with
66
functions, lambda expressions, and classes with `operator()`.
77

8+
IMPORTANT: Function traits are not yet available on freestanding implementations.
9+
810
Examples:
911
[source,cpp]
1012
----

docs/static_assert.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
`STATIC_ASSERT` is a way to produce compile-time errors using formatted strings.
55

6+
IMPORTANT: `STATIC_ASSERT` is not yet available on freestanding implementations.
7+
68
[source,cpp]
79
----
810
template <typename T>

include/stdx/atomic_bitset.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ template <auto Size,
2525
class atomic_bitset {
2626
constexpr static std::size_t N = to_underlying(Size);
2727

28-
using elem_t = atomic::atomic_type_t<StorageElem>;
29-
constexpr static auto alignment = atomic::alignment_of<StorageElem>;
28+
using elem_t = ::atomic::atomic_type_t<StorageElem>;
29+
constexpr static auto alignment = ::atomic::alignment_of<StorageElem>;
3030

3131
static_assert(std::is_unsigned_v<elem_t>,
3232
"Storage element for atomic_bitset must be an unsigned type");
@@ -39,7 +39,7 @@ class atomic_bitset {
3939

4040
constexpr static auto mask = bit_mask<elem_t, N - 1>();
4141
auto salient_value(std::memory_order order) const -> elem_t {
42-
return atomic::load(storage, order) & mask;
42+
return ::atomic::load(storage, order) & mask;
4343
}
4444

4545
[[nodiscard]] constexpr static auto value_from_string(std::string_view str,
@@ -114,7 +114,7 @@ class atomic_bitset {
114114
}
115115
auto store(bitset_t b,
116116
std::memory_order order = std::memory_order_seq_cst) {
117-
atomic::store(storage, b.template to<elem_t>(), order);
117+
::atomic::store(storage, b.template to<elem_t>(), order);
118118
}
119119

120120
constexpr static std::integral_constant<std::size_t, N> size{};
@@ -128,10 +128,10 @@ class atomic_bitset {
128128
std::memory_order order = std::memory_order_seq_cst) -> bitset_t {
129129
auto const pos = static_cast<std::size_t>(to_underlying(idx));
130130
if (value) {
131-
return bitset_t{atomic::fetch_or(
131+
return bitset_t{::atomic::fetch_or(
132132
storage, static_cast<elem_t>(bit << pos), order)};
133133
}
134-
return bitset_t{atomic::fetch_and(
134+
return bitset_t{::atomic::fetch_and(
135135
storage, static_cast<elem_t>(~(bit << pos)), order)};
136136
}
137137

@@ -141,9 +141,9 @@ class atomic_bitset {
141141
auto const m = to_underlying(msb);
142142
auto const shifted_value = bit_mask<elem_t>(m, l);
143143
if (value) {
144-
return bitset_t{atomic::fetch_or(storage, shifted_value, order)};
144+
return bitset_t{::atomic::fetch_or(storage, shifted_value, order)};
145145
}
146-
return bitset_t{atomic::fetch_and(storage, ~shifted_value, order)};
146+
return bitset_t{::atomic::fetch_and(storage, ~shifted_value, order)};
147147
}
148148

149149
auto set(lsb_t lsb, length_t len, bool value = true,
@@ -155,15 +155,15 @@ class atomic_bitset {
155155

156156
auto set(std::memory_order order = std::memory_order_seq_cst) LIFETIMEBOUND
157157
-> atomic_bitset & {
158-
atomic::store(storage, mask, order);
158+
::atomic::store(storage, mask, order);
159159
return *this;
160160
}
161161

162162
template <typename T>
163163
auto reset(T idx, std::memory_order order = std::memory_order_seq_cst)
164164
-> bitset_t {
165165
auto const pos = static_cast<std::size_t>(to_underlying(idx));
166-
return bitset_t{atomic::fetch_and(
166+
return bitset_t{::atomic::fetch_and(
167167
storage, static_cast<elem_t>(~(bit << pos)), order)};
168168
}
169169

@@ -173,7 +173,7 @@ class atomic_bitset {
173173
auto const l = to_underlying(lsb);
174174
auto const m = to_underlying(msb);
175175
auto const shifted_value = bit_mask<elem_t>(m, l);
176-
return bitset_t{atomic::fetch_and(storage, ~shifted_value, order)};
176+
return bitset_t{::atomic::fetch_and(storage, ~shifted_value, order)};
177177
}
178178

179179
auto reset(lsb_t lsb, length_t len,
@@ -187,24 +187,24 @@ class atomic_bitset {
187187
auto
188188
reset(std::memory_order order = std::memory_order_seq_cst) LIFETIMEBOUND
189189
-> atomic_bitset & {
190-
atomic::store(storage, elem_t{}, order);
190+
::atomic::store(storage, elem_t{}, order);
191191
return *this;
192192
}
193193

194194
template <typename T>
195195
auto flip(T idx, std::memory_order order = std::memory_order_seq_cst)
196196
-> bitset_t {
197197
auto const pos = static_cast<std::size_t>(to_underlying(idx));
198-
return bitset_t{
199-
atomic::fetch_xor(storage, static_cast<elem_t>(bit << pos), order)};
198+
return bitset_t{::atomic::fetch_xor(
199+
storage, static_cast<elem_t>(bit << pos), order)};
200200
}
201201

202202
auto flip(lsb_t lsb, msb_t msb,
203203
std::memory_order order = std::memory_order_seq_cst) -> bitset_t {
204204
auto const l = to_underlying(lsb);
205205
auto const m = to_underlying(msb);
206206
auto const shifted_value = bit_mask<elem_t>(m, l);
207-
return bitset_t{atomic::fetch_xor(storage, shifted_value, order)};
207+
return bitset_t{::atomic::fetch_xor(storage, shifted_value, order)};
208208
}
209209

210210
auto flip(lsb_t lsb, length_t len,
@@ -215,7 +215,7 @@ class atomic_bitset {
215215
}
216216

217217
auto flip(std::memory_order order = std::memory_order_seq_cst) -> bitset_t {
218-
return bitset_t{atomic::fetch_xor(storage, mask, order)};
218+
return bitset_t{::atomic::fetch_xor(storage, mask, order)};
219219
}
220220

221221
[[nodiscard]] auto

usage_test/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if(DEFINED ENV{USER_CMAKE_VERSION})
2+
message(STATUS "Required minimum cmake version: $ENV{USER_CMAKE_VERSION}")
3+
cmake_minimum_required(VERSION $ENV{USER_CMAKE_VERSION})
4+
endif()
5+
message(STATUS "Actual cmake version: ${CMAKE_VERSION}")
6+
7+
project(stdx_usage)
8+
9+
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/get_cpm.cmake)
10+
cpmaddpackage(NAME stdx SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." GIT_TAG HEAD)
11+
12+
add_executable(app main.cpp)
13+
target_link_libraries(app PRIVATE stdx)
14+
if(CPP_IMPLEMENTATION STREQUAL "FREESTANDING")
15+
target_compile_definitions(app PRIVATE SIMULATE_FREESTANDING)
16+
target_compile_options(app PRIVATE -ffreestanding)
17+
endif()

usage_test/main.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <stdx/algorithm.hpp>
2+
#include <stdx/atomic.hpp>
3+
#include <stdx/atomic_bitset.hpp>
4+
#include <stdx/bit.hpp>
5+
#include <stdx/bitset.hpp>
6+
#include <stdx/byterator.hpp>
7+
#include <stdx/cached.hpp>
8+
#include <stdx/compiler.hpp>
9+
#include <stdx/concepts.hpp>
10+
#include <stdx/ct_conversions.hpp>
11+
#ifndef SIMULATE_FREESTANDING
12+
#include <stdx/ct_format.hpp>
13+
#endif
14+
#include <stdx/ct_string.hpp>
15+
#include <stdx/cx_map.hpp>
16+
#include <stdx/cx_multimap.hpp>
17+
#include <stdx/cx_queue.hpp>
18+
#include <stdx/cx_set.hpp>
19+
#include <stdx/cx_vector.hpp>
20+
#include <stdx/env.hpp>
21+
#ifndef SIMULATE_FREESTANDING
22+
#include <stdx/for_each_n_args.hpp>
23+
#include <stdx/function_traits.hpp>
24+
#endif
25+
#include <stdx/functional.hpp>
26+
#include <stdx/intrusive_forward_list.hpp>
27+
#include <stdx/intrusive_list.hpp>
28+
#include <stdx/iterator.hpp>
29+
#include <stdx/latched.hpp>
30+
#include <stdx/memory.hpp>
31+
#include <stdx/numeric.hpp>
32+
#include <stdx/optional.hpp>
33+
#include <stdx/panic.hpp>
34+
#include <stdx/pp_map.hpp>
35+
#include <stdx/priority.hpp>
36+
#include <stdx/ranges.hpp>
37+
#include <stdx/rollover.hpp>
38+
#include <stdx/span.hpp>
39+
#ifndef SIMULATE_FREESTANDING
40+
#include <stdx/static_assert.hpp>
41+
#endif
42+
#include <stdx/tuple.hpp>
43+
#include <stdx/tuple_algorithms.hpp>
44+
#include <stdx/tuple_destructure.hpp>
45+
#include <stdx/type_traits.hpp>
46+
#include <stdx/udls.hpp>
47+
#include <stdx/utility.hpp>
48+
49+
#if __STDC_HOSTED__ == 0
50+
extern "C" auto main() -> int;
51+
#endif
52+
53+
auto main() -> int { return 0; }

0 commit comments

Comments
 (0)