all: cosmetic cleanups
This commit is contained in:
+4
-4
@@ -1,4 +1,4 @@
|
||||
/* cxxlib.h --
|
||||
/* cxxlib.h -- C++ support library
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace upx {
|
||||
// type_traits
|
||||
**************************************************************************/
|
||||
|
||||
// <type_traits> is_bounded_array: same as C++20 std::is_bounded_array
|
||||
// is_bounded_array: identical to C++20 std::is_bounded_array
|
||||
template <class T>
|
||||
struct is_bounded_array : public std::false_type {};
|
||||
template <class T, size_t N>
|
||||
@@ -43,7 +43,7 @@ struct is_bounded_array<T[N]> : public std::true_type {};
|
||||
template <class T>
|
||||
inline constexpr bool is_bounded_array_v = is_bounded_array<T>::value;
|
||||
|
||||
// <type_traits> util: is_same_all and is_same_any means std::is_same for multiple types
|
||||
// is_same_all and is_same_any: std::is_same for multiple types
|
||||
template <class T, class... Ts>
|
||||
struct is_same_all : public std::conjunction<std::is_same<T, Ts>...> {};
|
||||
template <class T, class... Ts>
|
||||
@@ -125,7 +125,7 @@ struct TriBool final {
|
||||
return value == TriBool(other).value;
|
||||
}
|
||||
|
||||
// "Third" can mean many things, depending on usage context, so provide some alternative names:
|
||||
// "Third" can mean many things - depending on usage context, so provide some alternate names:
|
||||
// constexpr bool isDefault() const noexcept { return isThird(); } // might be misleading
|
||||
constexpr bool isIndeterminate() const noexcept { return isThird(); }
|
||||
constexpr bool isOther() const noexcept { return isThird(); }
|
||||
|
||||
+1
-1
@@ -388,7 +388,7 @@ void upx_std_stable_sort(void *array, size_t n, upx_compare_func_t compare) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UPX_QSORT_IS_STABLE_SORT
|
||||
#if UPX_CONFIG_USE_STABLE_SORT
|
||||
// instantiate function templates for all element sizes we need
|
||||
// efficient, but code size bloat
|
||||
template void upx_std_stable_sort<1>(void *, size_t, upx_compare_func_t);
|
||||
|
||||
+5
-5
@@ -138,13 +138,13 @@ void upx_shellsort_memcpy(void *array, size_t n, size_t element_size, upx_compar
|
||||
template <size_t ElementSize>
|
||||
void upx_std_stable_sort(void *array, size_t n, upx_compare_func_t compare);
|
||||
|
||||
#if 1
|
||||
// #define UPX_CONFIG_USE_STABLE_SORT 1
|
||||
#if UPX_CONFIG_USE_STABLE_SORT
|
||||
// use std::stable_sort(); requires that "element_size" is constexpr!
|
||||
#define upx_qsort(a, n, element_size, compare) upx_std_stable_sort<(element_size)>(a, n, compare)
|
||||
#else
|
||||
// use libc qsort()
|
||||
#define upx_qsort qsort
|
||||
#else
|
||||
// use std::stable_sort()
|
||||
#define upx_qsort(a, b, c, d) upx_std_stable_sort<(c)>(a, b, d)
|
||||
#define UPX_QSORT_IS_STABLE_SORT 1
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@
|
||||
#include "xspan_impl.h"
|
||||
|
||||
#ifdef XSPAN_NAMESPACE_NAME
|
||||
// help constructor to distinguish between number of elements and bytes
|
||||
// types to help the constructor to distinguish between number of elements and bytes
|
||||
using XSPAN_NAMESPACE_NAME::XSpanCount;
|
||||
using XSPAN_NAMESPACE_NAME::XSpanSizeInBytes;
|
||||
// actual classes
|
||||
@@ -59,7 +59,7 @@ using XSPAN_NAMESPACE_NAME::Ptr;
|
||||
using XSPAN_NAMESPACE_NAME::PtrOrSpan;
|
||||
using XSPAN_NAMESPACE_NAME::PtrOrSpanOrNull;
|
||||
using XSPAN_NAMESPACE_NAME::Span;
|
||||
// util
|
||||
// support functions
|
||||
using XSPAN_NAMESPACE_NAME::raw_bytes; // overloaded for all classes
|
||||
using XSPAN_NAMESPACE_NAME::raw_index_bytes; // overloaded for all classes
|
||||
#endif
|
||||
|
||||
@@ -204,8 +204,6 @@ struct XSpanInternalDummyArg {
|
||||
#define XSpanInternalDummyArgInit (XSPAN_NS(XSpanInternalDummyArg)(0, nullptr))
|
||||
#endif
|
||||
|
||||
XSPAN_NAMESPACE_END
|
||||
|
||||
// poison a pointer: point to a non-null invalid address
|
||||
// - resulting pointer should crash on dereference
|
||||
// - this should be efficient (so no mmap() guard page etc.)
|
||||
@@ -216,6 +214,8 @@ static forceinline void *XSPAN_GET_POISON_VOID_PTR() {
|
||||
return (void *) 251;
|
||||
}
|
||||
|
||||
XSPAN_NAMESPACE_END
|
||||
|
||||
#ifndef XSPAN_DELETED_FUNCTION
|
||||
#define XSPAN_DELETED_FUNCTION = delete
|
||||
#endif
|
||||
|
||||
@@ -443,7 +443,7 @@ public: // raw access
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// like C++ std::span
|
||||
// like C++20 std::span
|
||||
pointer data() const noexcept { return ptr; }
|
||||
pointer data(size_t bytes) const { return raw_bytes(bytes); } // UPX extra
|
||||
// size_type size() const { return size_bytes() / sizeof(element_type); } // NOT USED
|
||||
|
||||
Reference in New Issue
Block a user