-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ New ztd::tests::keep_process_awake type for preventing benchmark sleep
- Loading branch information
Showing
16 changed files
with
586 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.. ============================================================================= | ||
.. | ||
.. ztd.idk | ||
.. Copyright © 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC | ||
.. Contact: opensource@soasis.org | ||
.. | ||
.. Commercial License Usage | ||
.. Licensees holding valid commercial ztd.idk licenses may use this file in | ||
.. accordance with the commercial license agreement provided with the | ||
.. Software or, alternatively, in accordance with the terms contained in | ||
.. a written agreement between you and Shepherd's Oasis, LLC. | ||
.. For licensing terms and conditions see your agreement. For | ||
.. further information contact opensource@soasis.org. | ||
.. | ||
.. Apache License Version 2 Usage | ||
.. Alternatively, this file may be used under the terms of Apache License | ||
.. Version 2.0 (the "License") for non-commercial use; you may not use this | ||
.. file except in compliance with the License. You may obtain a copy of the | ||
.. License at | ||
.. | ||
.. https://www.apache.org/licenses/LICENSE-2.0 | ||
.. | ||
.. Unless required by applicable law or agreed to in writing, software | ||
.. distributed under the License is distributed on an "AS IS" BASIS, | ||
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
.. See the License for the specific language governing permissions and | ||
.. limitations under the License. | ||
.. | ||
.. =============================================================================> | ||
tag | ||
=== | ||
|
||
.. doxygenclass:: ztd::tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// ============================================================================= | ||
// | ||
// ztd.idk | ||
// Copyright © 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC | ||
// Contact: opensource@soasis.org | ||
// | ||
// Commercial License Usage | ||
// Licensees holding valid commercial ztd.idk licenses may use this file in | ||
// accordance with the commercial license agreement provided with the | ||
// Software or, alternatively, in accordance with the terms contained in | ||
// a written agreement between you and Shepherd's Oasis, LLC. | ||
// For licensing terms and conditions see your agreement. For | ||
// further information contact opensource@soasis.org. | ||
// | ||
// Apache License Version 2 Usage | ||
// Alternatively, this file may be used under the terms of Apache License | ||
// Version 2.0 (the "License") for non-commercial use; you may not use this | ||
// file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ============================================================================ // | ||
|
||
#pragma once | ||
|
||
#ifndef ZTD_IDK_ALIGN_H | ||
#define ZTD_IDK_ALIGN_H | ||
|
||
#include <ztd/idk/version.h> | ||
|
||
#if ZTD_IS_ON(ZTD_C) | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#else | ||
#include <cstddef> | ||
#include <cstdint> | ||
#endif | ||
|
||
////// | ||
/// @addtogroup ztd_idk_align Align | ||
/// @{ | ||
|
||
////// | ||
/// @brief A structure containing a pointer, the size required by the object at the givne pointer offset, and the amount | ||
/// of space leftover from a ztdc_align call. | ||
typedef struct ztdc_aligned_const_pointer { | ||
////// | ||
/// @brief The pointer that was aligned. If the ztdc_aligned call failed, this member will be a null pointer | ||
/// constant. | ||
const void* ptr; | ||
////// | ||
/// @brief The amount of space required at the offset of the passed-in pointer. | ||
size_t required_space; | ||
////// | ||
/// @brief The amount of space leftover from the space after adjusting the pointer to its new offset, if ztdc_align | ||
/// succeeded. | ||
size_t leftover_space; | ||
} ztdc_aligned_const_pointer; | ||
|
||
////// | ||
/// @brief A structure containing a pointer, the size required by the object at the givne pointer offset, and the amount | ||
/// of space leftover from a ztdc_align call. | ||
typedef struct ztdc_aligned_mutable_pointer { | ||
////// | ||
/// @brief The pointer that was aligned. If the ztdc_aligned call failed, this member will be a null pointer | ||
/// constant. | ||
void* ptr; | ||
////// | ||
/// @brief The amount of space required at the offset of the passed-in pointer. | ||
size_t required_space; | ||
////// | ||
/// @brief The amount of space leftover from the space after adjusting the pointer to its new offset, if ztdc_align | ||
/// succeeded. | ||
size_t leftover_space; | ||
} ztdc_aligned_mutable_pointer; | ||
|
||
////// | ||
/// @brief Aligns a pointer according to the given `alignment` and `size`, within the available `space` bytes. | ||
/// | ||
/// @param alignment The desired alignment for object that will be put at the (new aligned) pointer's location. | ||
/// @param size The size of the object that will be put at the (newly aligned) pointer's location, in bytes. | ||
/// @param ptr The pointer to align. | ||
/// @param space The amount of available space within which this alignment pay be performed, in bytes. | ||
ZTD_C_LANGUAGE_LINKAGE_I_ ZTD_IDK_API_LINKAGE_I_ inline ztdc_aligned_const_pointer ztdc_align_const( | ||
size_t alignment, size_t size, const void* ptr, size_t space) ZTD_NOEXCEPT_IF_CXX_I_ { | ||
const uintptr_t initial = (uintptr_t)(ptr); | ||
const uintptr_t offby = (uintptr_t)(initial % alignment); | ||
const uintptr_t padding = (alignment - offby) % alignment; | ||
const size_t required_space = size + padding; | ||
if (space < required_space) { | ||
return { nullptr, required_space, space }; | ||
} | ||
const void* const aligned_ptr = (const void*)((const char*)(ptr) + padding); | ||
const size_t leftover_space = space - padding; | ||
return { aligned_ptr, required_space, leftover_space }; | ||
} | ||
|
||
////// | ||
/// @brief Aligns a pointer according to the given `alignment` and `size`, within the available `space` bytes. | ||
/// | ||
/// @param alignment The desired alignment for object that will be put at the (new aligned) pointer's location. | ||
/// @param size The size of the object that will be put at the (newly aligned) pointer's location, in bytes. | ||
/// @param ptr The pointer to align. | ||
/// @param space The amount of available space within which this alignment pay be performed, in bytes. | ||
ZTD_C_LANGUAGE_LINKAGE_I_ ZTD_IDK_API_LINKAGE_I_ inline ztdc_aligned_mutable_pointer ztdc_align_mutable( | ||
size_t alignment, size_t size, void* ptr, size_t space) ZTD_NOEXCEPT_IF_CXX_I_ { | ||
const uintptr_t initial = (uintptr_t)(ptr); | ||
const uintptr_t offby = (uintptr_t)(initial % alignment); | ||
const uintptr_t padding = (alignment - offby) % alignment; | ||
const size_t required_space = size + padding; | ||
if (space < required_space) { | ||
return { nullptr, required_space, space }; | ||
} | ||
void* const aligned_ptr = (void*)((char*)(ptr) + padding); | ||
const size_t leftover_space = space - padding; | ||
return { aligned_ptr, required_space, leftover_space }; | ||
} | ||
|
||
////// | ||
/// @brief Aligns a pointer according to the given `alignment` and `size`, within the available `space` bytes. | ||
/// | ||
/// @param _ALIGN The desired alignment for object that will be put at the (new aligned) pointer's location. | ||
/// @param _SIZE The size of the object that will be put at the (newly aligned) pointer's location, in bytes. | ||
/// @param _PTR The pointer to align. | ||
/// @param _SPACE The amount of available space within which this alignment pay be performed, in bytes. | ||
#define ztdc_align(_ALIGN, _SIZE, _PTR, _SPACE) \ | ||
_Generic(_PTR, const void* : ztdc_align_const, void* : ztdc_align_mutable)(_ALIGN, _SIZE, _PTR, _SPACE) | ||
|
||
////// | ||
/// @} | ||
|
||
#endif // ZTD_IDK_ALIGN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ============================================================================= | ||
// | ||
// ztd.idk | ||
// Copyright © 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC | ||
// Contact: opensource@soasis.org | ||
// | ||
// Commercial License Usage | ||
// Licensees holding valid commercial ztd.idk licenses may use this file in | ||
// accordance with the commercial license agreement provided with the | ||
// Software or, alternatively, in accordance with the terms contained in | ||
// a written agreement between you and Shepherd's Oasis, LLC. | ||
// For licensing terms and conditions see your agreement. For | ||
// further information contact opensource@soasis.org. | ||
// | ||
// Apache License Version 2 Usage | ||
// Alternatively, this file may be used under the terms of Apache License | ||
// Version 2.0 (the "License") for non-commercial use; you may not use this | ||
// file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ============================================================================ // | ||
|
||
#pragma once | ||
|
||
#ifndef ZTD_IDK_CKD_INT_H | ||
#define ZTD_IDK_CKD_INT_H | ||
|
||
#include <ztd/idk/version.h> | ||
|
||
#include <ztd/prologue.hpp> | ||
|
||
#define ZTD_DIV_OVERFLOW(_LEFT, _RIGHT, _PTR) | ||
|
||
|
||
#if ZTD_IS_ON(ZTD_COMPILER_CLANG) || ZTD_IS_ON(ZTD_COMPILER_GC) | ||
#define ztdc_ckd_add(_PTR, _LEFT, _RIGHT) __builtin_add_overflow(_LEFT, _RIGHT, _PTR) | ||
#define ztdc_ckd_sub(_PTR, _LEFT, _RIGHT) __builtin_sub_overflow(_LEFT, _RIGHT, _PTR) | ||
#define ztdc_ckd_mul(_PTR, _LEFT, _RIGHT) __builtin_mul_overflow(_LEFT, _RIGHT, _PTR) | ||
#else | ||
#define ztdc_ckd_add(_PTR, _LEFT, _RIGHT) | ||
#define ztdc_ckd_add(_PTR, _LEFT, _RIGHT) | ||
#define ztdc_ckd_add(_PTR, _LEFT, _RIGHT) | ||
#endif | ||
|
||
#include <ztd/epilogue.hpp> | ||
|
||
#endif // ZTD_IDK_CKD_INT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// ============================================================================= | ||
// | ||
// ztd.idk | ||
// Copyright © 2022 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC | ||
// Contact: opensource@soasis.org | ||
// | ||
// Commercial License Usage | ||
// Licensees holding valid commercial ztd.idk licenses may use this file in | ||
// accordance with the commercial license agreement provided with the | ||
// Software or, alternatively, in accordance with the terms contained in | ||
// a written agreement between you and Shepherd's Oasis, LLC. | ||
// For licensing terms and conditions see your agreement. For | ||
// further information contact opensource@soasis.org. | ||
// | ||
// Apache License Version 2 Usage | ||
// Alternatively, this file may be used under the terms of Apache License | ||
// Version 2.0 (the "License") for non-commercial use; you may not use this | ||
// file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ============================================================================ // | ||
|
||
#pragma once | ||
|
||
#ifndef ZTD_IDK_TAG_HPP | ||
#define ZTD_IDK_TAG_HPP | ||
|
||
#include <ztd/idk/version.hpp> | ||
|
||
#include <ztd/prologue.hpp> | ||
|
||
////// | ||
/// @addtogroup ztd_idk_tags Tags | ||
/// @{ | ||
////// | ||
|
||
namespace ztd { | ||
|
||
////// | ||
/// @brief A tag type which can hold arbitrarily many types. Useful as an anchor for overload resolution on | ||
/// specific entities, extension point anchors, and more. Not related to the ztd::tag_invoke infrastructure. | ||
////// | ||
template <typename...> | ||
class tag { }; | ||
|
||
} // namespace ztd | ||
|
||
/// @} | ||
////// | ||
|
||
|
||
#include <ztd/epilogue.hpp> | ||
|
||
#endif // ZTD_IDK_TAG_HPP |
Oops, something went wrong.