mirror of
https://github.com/upx/upx.git
synced 2025-08-11 22:52:30 +08:00
all: minor cleanups
This commit is contained in:
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -384,8 +384,8 @@ jobs:
|
||||
- { zig_target: x86_64-macos.13-none }
|
||||
- { zig_target: x86_64-windows-gnu }
|
||||
env:
|
||||
# 2023-05-12
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.3097+7f7bd206d
|
||||
# 2023-05-14
|
||||
ZIG_DIST_VERSION: 0.11.0-dev.3123+6f418c11e
|
||||
# for zig-cc wrapper scripts (see below):
|
||||
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
||||
ZIG_FLAGS: ${{ matrix.zig_flags }}
|
||||
@ -459,5 +459,10 @@ jobs:
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
if: ${{ contains(matrix.zig_target, '-linux-') }}
|
||||
run: |
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
|
||||
# vim:set ts=2 sw=2 et:
|
||||
|
@ -190,17 +190,21 @@ else()
|
||||
endif()
|
||||
|
||||
# compile a target with -O2 even in Debug build
|
||||
function(upx_compile_target_debug_with_O2 t)
|
||||
if(MSVC_FRONTEND)
|
||||
# MSVC uses some Debug compile options like -RTC1 that are incompatible with -O2
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-O2>)
|
||||
endif()
|
||||
function(upx_compile_target_debug_with_O2)
|
||||
foreach(t ${ARGV})
|
||||
if(MSVC_FRONTEND)
|
||||
# MSVC uses some Debug compilation options like -RTC1 that are incompatible with -O2
|
||||
else()
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-O2>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(upx_sanitize_target t)
|
||||
if(NOT UPX_CONFIG_DISABLE_SANITIZE)
|
||||
if(MSVC_FRONTEND)
|
||||
function(upx_sanitize_target)
|
||||
foreach(t ${ARGV})
|
||||
if(UPX_CONFIG_DISABLE_SANITIZE)
|
||||
# no-op
|
||||
elseif(MSVC_FRONTEND)
|
||||
# MSVC uses -GS (similar to -fstack-protector) by default
|
||||
elseif(CMAKE_C_PLATFORM_ID MATCHES "^MinGW" OR MINGW OR CYGWIN)
|
||||
# avoid link errors with current MinGW-w64 versions
|
||||
@ -211,7 +215,7 @@ function(upx_sanitize_target t)
|
||||
# default sanitizer for Release builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(t upx_vendor_ucl)
|
||||
|
@ -49,6 +49,8 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
if (e && e[0]) {
|
||||
if (strcmp(e, "0") == 0) {
|
||||
minimal = true;
|
||||
} else if (strcmp(e, "1") == 0) {
|
||||
minimal = false;
|
||||
} else if (strcmp(e, "2") == 0) {
|
||||
minimal = false;
|
||||
duration = true;
|
||||
@ -185,6 +187,12 @@ struct CheckIntegral {
|
||||
COMPILE_TIME_ASSERT(upx_is_integral_v<U>)
|
||||
}
|
||||
static void check(void) {
|
||||
T a = {};
|
||||
const T b = {};
|
||||
constexpr T c = {};
|
||||
assert(a == 0);
|
||||
assert(b == 0);
|
||||
assert(c == 0);
|
||||
checkU<T>();
|
||||
checkU<typename std::add_const<T>::type>();
|
||||
#if !defined(__GNUC__)
|
||||
|
@ -112,7 +112,7 @@ inline constexpr bool upx_is_integral_v = upx_is_integral<T>::value;
|
||||
// horrible hack for broken compiler
|
||||
#define upx_fake_alignas_1 __attribute__((__aligned__(1),__packed__))
|
||||
#define upx_fake_alignas_16 __attribute__((__aligned__(2))) // object file maximum 2 ???
|
||||
#define upx_fake_alignas__(a) upx_fake_alignas_ ## a
|
||||
#define upx_fake_alignas__(x) upx_fake_alignas_ ## x
|
||||
#define alignas(x) upx_fake_alignas__(x)
|
||||
#endif
|
||||
|
||||
@ -555,7 +555,7 @@ constexpr bool string_ge(const char *a, const char *b) {
|
||||
#define M_IS_ZSTD(x) ((x) == M_ZSTD)
|
||||
|
||||
|
||||
// filters
|
||||
// filters internal usage
|
||||
#define FT_END (-1)
|
||||
#define FT_NONE (-2)
|
||||
#define FT_SKIP (-3)
|
||||
|
@ -25,6 +25,9 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
// A MemBuffer allocates memory on the heap, and automatically
|
||||
// gets destructed when leaving scope or on exceptions.
|
||||
|
||||
#include "../conf.h"
|
||||
#include "membuffer.h"
|
||||
|
||||
@ -256,7 +259,7 @@ void MemBuffer::dealloc() noexcept {
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("MemBuffer") {
|
||||
TEST_CASE("MemBuffer core") {
|
||||
MemBuffer mb;
|
||||
CHECK_THROWS(mb.checkState());
|
||||
CHECK_THROWS(mb.alloc(0x30000000 + 1));
|
||||
|
@ -119,17 +119,15 @@ inline typename MemBufferBase<T>::pointer raw_index_bytes(const MemBufferBase<T>
|
||||
return mbb.raw_bytes(mem_size(sizeof(element_type), index, size_in_bytes)) + index;
|
||||
}
|
||||
|
||||
#if 1
|
||||
// some more global overloads using a checked raw_bytes() call
|
||||
#define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \
|
||||
typename std::enable_if<std::is_same<A, B>::value, RType>::type
|
||||
#define XSPAN_FWD_C_IS_MEMBUFFER 1
|
||||
#define C MemBufferBase
|
||||
#define XSPAN_FWD_C_IS_MEMBUFFER 1
|
||||
#include "xspan_fwd.h"
|
||||
#undef C
|
||||
#undef XSPAN_FWD_C_IS_MEMBUFFER
|
||||
#undef C
|
||||
#undef XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
|
@ -76,10 +76,10 @@ void xspan_check_range(const void *p, const void *base, ptrdiff_t size_in_bytes)
|
||||
if very_unlikely (base == nullptr)
|
||||
xspan_fail_range_nullbase();
|
||||
ptrdiff_t off = (const charptr) p - (const charptr) base;
|
||||
if very_unlikely (off < 0 || off > size_in_bytes)
|
||||
if very_unlikely (off < 0 || off > size_in_bytes || size_in_bytes > UPX_RSIZE_MAX)
|
||||
xspan_fail_range_range();
|
||||
xspan_stats.check_range_counter += 1;
|
||||
// fprintf(stderr, "xspan_check_range done\n");
|
||||
NO_fprintf(stderr, "xspan_check_range done\n");
|
||||
}
|
||||
|
||||
XSPAN_NAMESPACE_END
|
||||
|
Reference in New Issue
Block a user