CI updates

This commit is contained in:
Markus F.X.J. Oberhumer
2023-12-21 23:01:52 +01:00
parent 636cefb9f3
commit 778663ae69
12 changed files with 142 additions and 37 deletions
+3 -3
View File
@@ -84,7 +84,7 @@ private:
AbstractPolicy(AbstractPolicy &&) noexcept DELETED_FUNCTION;
AbstractPolicy &operator=(AbstractPolicy &&) noexcept DELETED_FUNCTION;
// disable dynamic allocation
ACC_CXX_DISABLE_NEW_DELETE
UPX_CXX_DISABLE_NEW_DELETE
};
#endif
@@ -152,7 +152,7 @@ private:
BEPolicy(BEPolicy &&) noexcept DELETED_FUNCTION;
BEPolicy &operator=(BEPolicy &&) noexcept DELETED_FUNCTION;
// disable dynamic allocation
ACC_CXX_DISABLE_NEW_DELETE
UPX_CXX_DISABLE_NEW_DELETE
};
struct LEPolicy
@@ -214,7 +214,7 @@ private:
LEPolicy(LEPolicy &&) noexcept DELETED_FUNCTION;
LEPolicy &operator=(LEPolicy &&) noexcept DELETED_FUNCTION;
// disable dynamic allocation
ACC_CXX_DISABLE_NEW_DELETE
UPX_CXX_DISABLE_NEW_DELETE
};
// Native Endianness policy (aka host policy)
+72
View File
@@ -97,6 +97,78 @@ ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_gt("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_ge("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_le("abc", "abz"))
/*************************************************************************
// UPX_CXX_DISABLE_NEW_DELETE
**************************************************************************/
namespace test_disable_new_delete {
struct A1 {
int a;
};
struct A2 {
int a;
UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL
};
struct B1_A1 : public A1 {
int b;
};
struct B1_A2 : public A2 {
int b;
};
struct B2_A1 : public A1 {
int b;
UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL
};
struct B2_A2 : public A2 {
int b;
UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL
};
struct X1 {
virtual ~X1() noexcept {}
int x;
};
struct X2 {
virtual ~X2() noexcept {}
int x;
UPX_CXX_DISABLE_NEW_DELETE
};
struct Y1_X1 : public X1 {
int y;
};
struct Y1_X2 : public X2 {
int y;
};
struct Y2_X1 : public X1 {
int y;
UPX_CXX_DISABLE_NEW_DELETE
};
struct Y2_X2 : public X2 {
int y;
UPX_CXX_DISABLE_NEW_DELETE
};
struct Z1_X1 : public X1 {
virtual ~Z1_X1() noexcept {}
int z;
};
struct Z1_X2 : public X2 {
virtual ~Z1_X2() noexcept {}
int z;
};
struct Z2_X1 : public X1 {
virtual ~Z2_X1() noexcept {}
int z;
UPX_CXX_DISABLE_NEW_DELETE
};
struct Z2_X2 : public X2 {
virtual ~Z2_X2() noexcept {}
int z;
UPX_CXX_DISABLE_NEW_DELETE
};
} // namespace test_disable_new_delete
/*************************************************************************
// util
**************************************************************************/
+1 -1
View File
@@ -61,7 +61,7 @@ private:
Throwable(Throwable &&) noexcept DELETED_FUNCTION;
Throwable &operator=(Throwable &&) noexcept DELETED_FUNCTION;
// disable dynamic allocation => force throwing by value
ACC_CXX_DISABLE_NEW_DELETE
UPX_CXX_DISABLE_NEW_DELETE
// disable taking the address => force passing by reference
// [I'm not too sure about this design decision, but we can always allow it if needed]
Throwable *operator&() const noexcept DELETED_FUNCTION;
+56 -27
View File
@@ -26,11 +26,63 @@
#pragma once
// #include <stddef.h>
// #include <cstddef>
// #include <new>
// #include <type_traits>
namespace upx {
/*************************************************************************
// core
**************************************************************************/
// fun with C++: disable common "new" and ALL "delete" operators
#define UPX_CXX_DISABLE_NEW_DELETE_COMMON__ \
private: \
/* common allocation functions (4) */ \
static void *operator new(std::size_t) = delete; \
static void *operator new[](std::size_t) = delete; \
static void *operator new(std::size_t, void *) = delete; \
static void *operator new[](std::size_t, void *) = delete; \
/* replaceable placement deallocation functions (4) */ \
static void operator delete(void *, const std::nothrow_t &) noexcept = delete; \
static void operator delete[](void *, const std::nothrow_t &) noexcept = delete; \
static void operator delete(void *, std::align_val_t, const std::nothrow_t &) noexcept = \
delete; \
static void operator delete[](void *, std::align_val_t, const std::nothrow_t &) noexcept = \
delete; \
/* non-allocating placement deallocation functions (2) */ \
static void operator delete(void *, void *) noexcept = delete; \
static void operator delete[](void *, void *) noexcept = delete;
// for classes with virtual methods
#define UPX_CXX_DISABLE_NEW_DELETE \
UPX_CXX_DISABLE_NEW_DELETE_COMMON__ \
/* replaceable usual deallocation functions (8) */ \
protected: \
static void operator delete(void *) noexcept {} \
static void operator delete[](void *) noexcept = delete; \
static void operator delete(void *, std::align_val_t) {} \
static void operator delete[](void *, std::align_val_t) noexcept = delete; \
static void operator delete(void *, std::size_t) {} \
static void operator delete[](void *, std::size_t) noexcept = delete; \
static void operator delete(void *, std::size_t, std::align_val_t) {} \
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept = delete; \
private:
// for classes WITHOUT any virtual methods
#define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL \
UPX_CXX_DISABLE_NEW_DELETE_COMMON__ \
/* replaceable usual deallocation functions (8) */ \
static void operator delete(void *) noexcept = delete; \
static void operator delete[](void *) noexcept = delete; \
static void operator delete(void *, std::align_val_t) = delete; \
static void operator delete[](void *, std::align_val_t) noexcept = delete; \
static void operator delete(void *, std::size_t) = delete; \
static void operator delete[](void *, std::size_t) noexcept = delete; \
static void operator delete(void *, std::size_t, std::align_val_t) = delete; \
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept = delete;
/*************************************************************************
// type_traits
**************************************************************************/
@@ -162,7 +214,8 @@ struct TriBool final {
#endif
private:
value_type value = False; // the actual value of this type
value_type value = False; // the actual value of this type
UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL // UPX convention
};
typedef TriBool<> tribool;
@@ -261,31 +314,7 @@ private:
pointer ptr;
reference operator[](std::ptrdiff_t) noexcept = delete;
const_reference operator[](std::ptrdiff_t) const noexcept = delete;
#if 0 // fun with C++
// disable common "new" and ALL "delete" operators
static void *operator new(std::size_t) = delete;
static void *operator new[](std::size_t) = delete;
static void *operator new(std::size_t, void *) = delete;
static void *operator new[](std::size_t, void *) = delete;
// replaceable usual deallocation functions (8)
static void operator delete(void *) noexcept = delete;
static void operator delete[](void *) noexcept = delete;
static void operator delete(void *, std::align_val_t) noexcept = delete;
static void operator delete[](void *, std::align_val_t) noexcept = delete;
static void operator delete(void *, std::size_t) noexcept = delete;
static void operator delete[](void *, std::size_t) noexcept = delete;
static void operator delete(void *, std::size_t, std::align_val_t) noexcept = delete;
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept = delete;
// replaceable placement deallocation functions (4)
static void operator delete(void *, const std::nothrow_t &) noexcept = delete;
static void operator delete[](void *, const std::nothrow_t &) noexcept = delete;
static void operator delete(void *, std::align_val_t, const std::nothrow_t &) noexcept = delete;
static void operator delete[](void *, std::align_val_t,
const std::nothrow_t &) noexcept = delete;
// non-allocating placement deallocation functions (2)
static void operator delete(void *, void *) noexcept = delete;
static void operator delete[](void *, void *) noexcept = delete;
#endif
UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL // UPX convention
};
// must overload mem_clear()
template <class T>
+1 -1
View File
@@ -217,7 +217,7 @@ private:
MemBuffer &operator=(MemBuffer &&) noexcept DELETED_FUNCTION;
#endif
// disable dynamic allocation
ACC_CXX_DISABLE_NEW_DELETE
UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL
};
/* vim:set ts=4 sw=4 et: */