mirror of https://github.com/upx/upx.git
src: add boost-pfr
This commit is contained in:
parent
d9657e9831
commit
cd686cb1d9
|
@ -180,7 +180,7 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(t upx)
|
set(t upx)
|
||||||
target_include_directories(${t} PRIVATE vendor)
|
target_include_directories(${t} PRIVATE vendor vendor/boost-pfr/include)
|
||||||
target_compile_definitions(${t} PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
|
target_compile_definitions(${t} PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
|
||||||
if(GITREV_SHORT)
|
if(GITREV_SHORT)
|
||||||
target_compile_definitions(${t} PRIVATE UPX_VERSION_GITREV="${GITREV_SHORT}${GITREV_PLUS}")
|
target_compile_definitions(${t} PRIVATE UPX_VERSION_GITREV="${GITREV_SHORT}${GITREV_PLUS}")
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -120,6 +120,9 @@ build/extra/cross-windows-mingw64/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISA
|
||||||
# check git submodules
|
# check git submodules
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
|
ifeq ($(wildcard ./vendor/boost-pfr/include/.),)
|
||||||
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
|
endif
|
||||||
ifeq ($(wildcard ./vendor/doctest/doctest/.),)
|
ifeq ($(wildcard ./vendor/doctest/doctest/.),)
|
||||||
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
-std=gnu++17
|
-std=gnu++17
|
||||||
-Ivendor
|
-Ivendor
|
||||||
|
-Ivendor/boost-pfr/include
|
||||||
-fno-strict-aliasing
|
-fno-strict-aliasing
|
||||||
-fno-strict-overflow
|
-fno-strict-overflow
|
||||||
-funsigned-char
|
-funsigned-char
|
||||||
|
|
28
src/conf.h
28
src/conf.h
|
@ -778,6 +778,34 @@ unsigned membuffer_get_size(MemBuffer &mb);
|
||||||
//#define DOCTEST_CONFIG_DISABLE 1
|
//#define DOCTEST_CONFIG_DISABLE 1
|
||||||
#include <doctest/doctest/parts/doctest_fwd.h>
|
#include <doctest/doctest/parts/doctest_fwd.h>
|
||||||
|
|
||||||
|
#if WITH_BOOST_PFR
|
||||||
|
#include <boost/pfr/io.hpp>
|
||||||
|
template <class A>
|
||||||
|
__acc_noinline std::string pfr_str(const A &a) {
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << boost::pfr::io(a);
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
template <class A, class B>
|
||||||
|
__acc_noinline std::string pfr_str(const A &a, const B &b) {
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << boost::pfr::io(a);
|
||||||
|
ss << ' ';
|
||||||
|
ss << boost::pfr::io(b);
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
template <class A, class B, class C>
|
||||||
|
__acc_noinline std::string pfr_str(const A &a, const B &b, const C &c) {
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << boost::pfr::io(a);
|
||||||
|
ss << ' ';
|
||||||
|
ss << boost::pfr::io(b);
|
||||||
|
ss << ' ';
|
||||||
|
ss << boost::pfr::io(c);
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
#endif // WITH_BOOST_PFR
|
||||||
|
|
||||||
// util/dt_check.cpp
|
// util/dt_check.cpp
|
||||||
void upx_compiler_sanity_check();
|
void upx_compiler_sanity_check();
|
||||||
int upx_doctest_check();
|
int upx_doctest_check();
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if DEBUG || 1
|
||||||
|
#ifndef WITH_BOOST_PFR
|
||||||
|
#define WITH_BOOST_PFR 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#include "../conf.h"
|
#include "../conf.h"
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -448,4 +453,33 @@ TEST_CASE("libc snprintf") {
|
||||||
CHECK_EQ(strcmp(buf, "-7.0.0.0.0.0.0.0.7.0xffffffffffffffff"), 0);
|
CHECK_EQ(strcmp(buf, "-7.0.0.0.0.0.0.0.7.0xffffffffffffffff"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WITH_BOOST_PFR
|
||||||
|
TEST_CASE("Boost.PFR") {
|
||||||
|
int i = -1;
|
||||||
|
CHECK_EQ(strcmp(pfr_str(i).c_str(), "-1"), 0);
|
||||||
|
BE32 b32;
|
||||||
|
b32 = 1;
|
||||||
|
LE32 l32;
|
||||||
|
l32 = 2;
|
||||||
|
CHECK_EQ(strcmp(pfr_str(b32).c_str(), "1"), 0);
|
||||||
|
CHECK_EQ(strcmp(pfr_str(l32).c_str(), "2"), 0);
|
||||||
|
struct Foo {
|
||||||
|
BE16 b16;
|
||||||
|
BE32 b32;
|
||||||
|
BE64 b64;
|
||||||
|
LE16 l16;
|
||||||
|
LE32 l32;
|
||||||
|
LE64 l64;
|
||||||
|
};
|
||||||
|
Foo foo;
|
||||||
|
foo.b16 = 1;
|
||||||
|
foo.b32 = 2;
|
||||||
|
foo.b64 = 3;
|
||||||
|
foo.l16 = 4;
|
||||||
|
foo.l32 = 5;
|
||||||
|
foo.l64 = 6;
|
||||||
|
CHECK_EQ(strcmp(pfr_str("foo", "=", foo).c_str(), "foo = {1, 2, 3, 4, 5, 6}"), 0);
|
||||||
|
}
|
||||||
|
#endif // WITH_BOOST_PFR
|
||||||
|
|
||||||
/* vim:set ts=4 sw=4 et: */
|
/* vim:set ts=4 sw=4 et: */
|
||||||
|
|
Loading…
Reference in New Issue