mirror of
https://github.com/Vita3K/Vita3K-Android.git
synced 2024-11-27 07:20:51 +00:00
Update submodules + minor changes (#1137)
* cmake: Add NOMINMAX globally to avoid Windows compilation issues with std::min/std::max * main/net: add missing include files * rtc: Remove convert_filetime/convert_timespec functions as they have been replaced with _wstat/stat * external: Update better-enums to tag "0.11.3" * external: Update CLI11 to tag "v1.9.1" * external: Update elfio to tag "Release_3.8" * external: Update glad to tag "0.1.34" * external: Update googletest to tag "release-1.10.0" * external: Update imgui to tag "v1.80" * external: Update imgui_club * external: Update miniz to tag "2.1.0" * external: Update pugixml to tag "v1.11.4" * external: Update spdlog to tag "v1.8.2" * external: Update stb * external: Update yaml-cpp to tag "yaml-cpp-0.6.3" * external: Switch to vitasdk/vita-toolchain * external: Refactor xxHash integration
This commit is contained in:
parent
2f2fc4430c
commit
5e3a6eb982
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -71,7 +71,7 @@
|
||||
url = https://github.com/Vita3K/unicorn.git
|
||||
[submodule "external/vita-toolchain"]
|
||||
path = external/vita-toolchain
|
||||
url = https://github.com/Vita3K/vita-toolchain
|
||||
url = https://github.com/vitasdk/vita-toolchain.git
|
||||
[submodule "external/VulkanMemoryAllocator"]
|
||||
path = external/VulkanMemoryAllocator
|
||||
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
||||
|
@ -40,7 +40,7 @@ if(NOT CI)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
add_definitions (/D "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS" /D "_CRT_SECURE_NO_WARNINGS")
|
||||
add_definitions (/D "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS" /D "_CRT_SECURE_NO_WARNINGS" /D "NOMINMAX")
|
||||
endif()
|
||||
|
||||
# Allow per-translation-unit parallel builds when using MSVC
|
||||
|
12
external/CMakeLists.txt
vendored
12
external/CMakeLists.txt
vendored
@ -42,11 +42,11 @@ endif()
|
||||
add_library(printf INTERFACE)
|
||||
target_include_directories(printf INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/printf")
|
||||
|
||||
add_library(elfio INTERFACE)
|
||||
target_include_directories(elfio INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/elfio")
|
||||
add_subdirectory(elfio)
|
||||
|
||||
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" ON)
|
||||
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" ON)
|
||||
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
|
||||
target_compile_definitions(spdlog INTERFACE SPDLOG_WCHAR_FILENAMES=1 SPDLOG_NO_THREAD_ID=1 SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
|
||||
|
||||
add_library(stb INTERFACE)
|
||||
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/stb")
|
||||
@ -92,7 +92,7 @@ endif()
|
||||
add_subdirectory(libfat16)
|
||||
|
||||
# The imgui target is including both imgui and imgui_club.
|
||||
add_library(imgui STATIC imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_widgets.cpp imgui/misc/cpp/imgui_stdlib.cpp)
|
||||
add_library(imgui STATIC imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_tables.cpp imgui/imgui_widgets.cpp imgui/misc/cpp/imgui_stdlib.cpp)
|
||||
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/imgui_club/imgui_memory_editor/")
|
||||
|
||||
@ -247,3 +247,7 @@ endif()
|
||||
|
||||
add_subdirectory(ffmpeg)
|
||||
add_subdirectory(psvpfstools)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared library" OFF)
|
||||
option(XXHASH_BUILD_XXHSUM "Build the xxhsum binary" OFF)
|
||||
add_subdirectory(xxHash/cmake_unofficial EXCLUDE_FROM_ALL)
|
||||
|
2
external/better-enums
vendored
2
external/better-enums
vendored
@ -1 +1 @@
|
||||
Subproject commit 1ea7f04bb9afdf7a0c83ba676b9c95b0c4185b4c
|
||||
Subproject commit c35576bed0295689540b39873126129adfa0b4c8
|
369
external/cli11/CLI11.hpp
vendored
369
external/cli11/CLI11.hpp
vendored
File diff suppressed because it is too large
Load Diff
2
external/elfio
vendored
2
external/elfio
vendored
@ -1 +1 @@
|
||||
Subproject commit 580da2467b3d7da4c817d45a99a367e4b0d6d326
|
||||
Subproject commit 1c91bc2bc506ffdb959d045dc45f571980757710
|
2
external/glad/include/KHR/khrplatform.h
vendored
2
external/glad/include/KHR/khrplatform.h
vendored
@ -119,7 +119,7 @@
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC)
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
|
28
external/glad/include/glad/glad.h
vendored
28
external/glad/include/glad/glad.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
OpenGL loader generated by glad 0.1.31 on Sun Jul 28 01:55:08 2019.
|
||||
OpenGL loader generated by glad 0.1.34 on Sun Oct 4 19:21:34 2020.
|
||||
|
||||
Language/Generator: C/C++ Debug
|
||||
Specification: gl
|
||||
@ -1487,6 +1487,18 @@ typedef void (APIENTRY *GLVULKANPROCNV)(void);
|
||||
#define GL_LOSE_CONTEXT_ON_RESET 0x8252
|
||||
#define GL_NO_RESET_NOTIFICATION 0x8261
|
||||
#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004
|
||||
#define GL_COLOR_TABLE 0x80D0
|
||||
#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
|
||||
#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
|
||||
#define GL_PROXY_COLOR_TABLE 0x80D3
|
||||
#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
|
||||
#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
|
||||
#define GL_CONVOLUTION_1D 0x8010
|
||||
#define GL_CONVOLUTION_2D 0x8011
|
||||
#define GL_SEPARABLE_2D 0x8012
|
||||
#define GL_HISTOGRAM 0x8024
|
||||
#define GL_PROXY_HISTOGRAM 0x8025
|
||||
#define GL_MINMAX 0x802E
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC
|
||||
#ifndef GL_VERSION_1_0
|
||||
@ -2764,7 +2776,7 @@ typedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 *data);
|
||||
GLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
|
||||
GLAPI PFNGLGETINTEGER64VPROC glad_debug_glGetInteger64v;
|
||||
#define glGetInteger64v glad_debug_glGetInteger64v
|
||||
typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
|
||||
typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values);
|
||||
GLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv;
|
||||
GLAPI PFNGLGETSYNCIVPROC glad_debug_glGetSynciv;
|
||||
#define glGetSynciv glad_debug_glGetSynciv
|
||||
@ -3148,11 +3160,11 @@ typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, G
|
||||
GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv;
|
||||
GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_debug_glGetActiveSubroutineUniformiv;
|
||||
#define glGetActiveSubroutineUniformiv glad_debug_glGetActiveSubroutineUniformiv
|
||||
typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
|
||||
typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
|
||||
GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName;
|
||||
GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_debug_glGetActiveSubroutineUniformName;
|
||||
#define glGetActiveSubroutineUniformName glad_debug_glGetActiveSubroutineUniformName
|
||||
typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
|
||||
typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
|
||||
GLAPI PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName;
|
||||
GLAPI PFNGLGETACTIVESUBROUTINENAMEPROC glad_debug_glGetActiveSubroutineName;
|
||||
#define glGetActiveSubroutineName glad_debug_glGetActiveSubroutineName
|
||||
@ -3228,7 +3240,7 @@ typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void);
|
||||
GLAPI PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
|
||||
GLAPI PFNGLRELEASESHADERCOMPILERPROC glad_debug_glReleaseShaderCompiler;
|
||||
#define glReleaseShaderCompiler glad_debug_glReleaseShaderCompiler
|
||||
typedef void (APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);
|
||||
typedef void (APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length);
|
||||
GLAPI PFNGLSHADERBINARYPROC glad_glShaderBinary;
|
||||
GLAPI PFNGLSHADERBINARYPROC glad_debug_glShaderBinary;
|
||||
#define glShaderBinary glad_debug_glShaderBinary
|
||||
@ -3592,7 +3604,7 @@ typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)(GL
|
||||
GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance;
|
||||
GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_debug_glDrawElementsInstancedBaseVertexBaseInstance;
|
||||
#define glDrawElementsInstancedBaseVertexBaseInstance glad_debug_glDrawElementsInstancedBaseVertexBaseInstance
|
||||
typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params);
|
||||
GLAPI PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ;
|
||||
GLAPI PFNGLGETINTERNALFORMATIVPROC glad_debug_glGetInternalformativ;
|
||||
#define glGetInternalformativ glad_debug_glGetInternalformativ
|
||||
@ -3660,7 +3672,7 @@ typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenu
|
||||
GLAPI PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv;
|
||||
GLAPI PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_debug_glGetFramebufferParameteriv;
|
||||
#define glGetFramebufferParameteriv glad_debug_glGetFramebufferParameteriv
|
||||
typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);
|
||||
typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params);
|
||||
GLAPI PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v;
|
||||
GLAPI PFNGLGETINTERNALFORMATI64VPROC glad_debug_glGetInternalformati64v;
|
||||
#define glGetInternalformati64v glad_debug_glGetInternalformati64v
|
||||
@ -3708,7 +3720,7 @@ typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC)(GLuint program, GLenum
|
||||
GLAPI PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName;
|
||||
GLAPI PFNGLGETPROGRAMRESOURCENAMEPROC glad_debug_glGetProgramResourceName;
|
||||
#define glGetProgramResourceName glad_debug_glGetProgramResourceName
|
||||
typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params);
|
||||
GLAPI PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv;
|
||||
GLAPI PFNGLGETPROGRAMRESOURCEIVPROC glad_debug_glGetProgramResourceiv;
|
||||
#define glGetProgramResourceiv glad_debug_glGetProgramResourceiv
|
||||
|
5
external/glad/src/glad.c
vendored
5
external/glad/src/glad.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
OpenGL loader generated by glad 0.1.31 on Sun Jul 28 01:55:08 2019.
|
||||
OpenGL loader generated by glad 0.1.34 on Sun Oct 4 19:21:34 2020.
|
||||
|
||||
Language/Generator: C/C++ Debug
|
||||
Specification: gl
|
||||
@ -59,6 +59,9 @@ void glad_set_post_callback(GLADcallback cb) {
|
||||
static void* get_proc(const char *namez);
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#ifndef _WINDOWS_
|
||||
#undef APIENTRY
|
||||
#endif
|
||||
#include <windows.h>
|
||||
static HMODULE libGL;
|
||||
|
||||
|
2
external/googletest
vendored
2
external/googletest
vendored
@ -1 +1 @@
|
||||
Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2
|
||||
Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e
|
2
external/imgui
vendored
2
external/imgui
vendored
@ -1 +1 @@
|
||||
Subproject commit 5503c0a12e0c929e84b3f61b2cb4bb9177ea3da1
|
||||
Subproject commit 58075c4414b985b352d10718b02a8c43f25efd7c
|
2
external/imgui_club
vendored
2
external/imgui_club
vendored
@ -1 +1 @@
|
||||
Subproject commit 50b79d1609c496b67c199aa79de4f7c590d5a5d7
|
||||
Subproject commit 60275e79c3e0b0568ee1e41486233e958eac2e80
|
159
external/miniz/miniz.c
vendored
159
external/miniz/miniz.c
vendored
@ -397,6 +397,32 @@ int mz_inflateInit(mz_streamp pStream)
|
||||
return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS);
|
||||
}
|
||||
|
||||
int mz_inflateReset(mz_streamp pStream)
|
||||
{
|
||||
inflate_state *pDecomp;
|
||||
if (!pStream)
|
||||
return MZ_STREAM_ERROR;
|
||||
|
||||
pStream->data_type = 0;
|
||||
pStream->adler = 0;
|
||||
pStream->msg = NULL;
|
||||
pStream->total_in = 0;
|
||||
pStream->total_out = 0;
|
||||
pStream->reserved = 0;
|
||||
|
||||
pDecomp = (inflate_state *)pStream->state;
|
||||
|
||||
tinfl_init(&pDecomp->m_decomp);
|
||||
pDecomp->m_dict_ofs = 0;
|
||||
pDecomp->m_dict_avail = 0;
|
||||
pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT;
|
||||
pDecomp->m_first_call = 1;
|
||||
pDecomp->m_has_flushed = 0;
|
||||
/* pDecomp->m_window_bits = window_bits */;
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int mz_inflate(mz_streamp pStream, int flush)
|
||||
{
|
||||
inflate_state *pState;
|
||||
@ -1340,13 +1366,13 @@ static int tdefl_flush_block(tdefl_compressor *d, int flush)
|
||||
|
||||
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
|
||||
#ifdef MINIZ_UNALIGNED_USE_MEMCPY
|
||||
static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD(const mz_uint8* p)
|
||||
static mz_uint16 TDEFL_READ_UNALIGNED_WORD(const mz_uint8* p)
|
||||
{
|
||||
mz_uint16 ret;
|
||||
memcpy(&ret, p, sizeof(mz_uint16));
|
||||
return ret;
|
||||
}
|
||||
static inline mz_uint16 TDEFL_READ_UNALIGNED_WORD2(const mz_uint16* p)
|
||||
static mz_uint16 TDEFL_READ_UNALIGNED_WORD2(const mz_uint16* p)
|
||||
{
|
||||
mz_uint16 ret;
|
||||
memcpy(&ret, p, sizeof(mz_uint16));
|
||||
@ -1455,6 +1481,16 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe
|
||||
#endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES */
|
||||
|
||||
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
|
||||
#ifdef MINIZ_UNALIGNED_USE_MEMCPY
|
||||
static mz_uint32 TDEFL_READ_UNALIGNED_WORD32(const mz_uint8* p)
|
||||
{
|
||||
mz_uint32 ret;
|
||||
memcpy(&ret, p, sizeof(mz_uint32));
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#define TDEFL_READ_UNALIGNED_WORD32(p) *(const mz_uint32 *)(p)
|
||||
#endif
|
||||
static mz_bool tdefl_compress_fast(tdefl_compressor *d)
|
||||
{
|
||||
/* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */
|
||||
@ -1489,12 +1525,12 @@ static mz_bool tdefl_compress_fast(tdefl_compressor *d)
|
||||
{
|
||||
mz_uint cur_match_dist, cur_match_len = 1;
|
||||
mz_uint8 *pCur_dict = d->m_dict + cur_pos;
|
||||
mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF;
|
||||
mz_uint first_trigram = TDEFL_READ_UNALIGNED_WORD32(pCur_dict) & 0xFFFFFF;
|
||||
mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK;
|
||||
mz_uint probe_pos = d->m_hash[hash];
|
||||
d->m_hash[hash] = (mz_uint16)lookahead_pos;
|
||||
|
||||
if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram))
|
||||
if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((TDEFL_READ_UNALIGNED_WORD32(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram))
|
||||
{
|
||||
const mz_uint16 *p = (const mz_uint16 *)pCur_dict;
|
||||
const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos);
|
||||
@ -1524,7 +1560,11 @@ static mz_bool tdefl_compress_fast(tdefl_compressor *d)
|
||||
cur_match_dist--;
|
||||
|
||||
pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN);
|
||||
#ifdef MINIZ_UNALIGNED_USE_MEMCPY
|
||||
memcpy(&pLZ_code_buf[1], &cur_match_dist, sizeof(cur_match_dist));
|
||||
#else
|
||||
*(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist;
|
||||
#endif
|
||||
pLZ_code_buf += 3;
|
||||
*pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80);
|
||||
|
||||
@ -2143,6 +2183,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,
|
||||
return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE);
|
||||
}
|
||||
|
||||
#ifndef MINIZ_NO_MALLOC
|
||||
/* Allocate the tdefl_compressor and tinfl_decompressor structures in C so that */
|
||||
/* non-C language bindings to tdefL_ and tinfl_ API don't need to worry about */
|
||||
/* structure size and allocation mechanism. */
|
||||
@ -2155,6 +2196,7 @@ void tdefl_compressor_free(tdefl_compressor *pComp)
|
||||
{
|
||||
MZ_FREE(pComp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
@ -2688,8 +2730,12 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
||||
const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
|
||||
do
|
||||
{
|
||||
#ifdef MINIZ_UNALIGNED_USE_MEMCPY
|
||||
memcpy(pOut_buf_cur, pSrc, sizeof(mz_uint32)*2);
|
||||
#else
|
||||
((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0];
|
||||
((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1];
|
||||
#endif
|
||||
pOut_buf_cur += 8;
|
||||
} while ((pSrc += 8) < pSrc_end);
|
||||
if ((counter &= 7) < 3)
|
||||
@ -2881,6 +2927,7 @@ int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size,
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef MINIZ_NO_MALLOC
|
||||
tinfl_decompressor *tinfl_decompressor_alloc()
|
||||
{
|
||||
tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor));
|
||||
@ -2893,6 +2940,7 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp)
|
||||
{
|
||||
MZ_FREE(pDecomp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -2961,8 +3009,8 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
||||
#define MZ_FWRITE fwrite
|
||||
#define MZ_FTELL64 _ftelli64
|
||||
#define MZ_FSEEK64 _fseeki64
|
||||
#define MZ_FILE_STAT_STRUCT _stat
|
||||
#define MZ_FILE_STAT _stat
|
||||
#define MZ_FILE_STAT_STRUCT _stat64
|
||||
#define MZ_FILE_STAT _stat64
|
||||
#define MZ_FFLUSH fflush
|
||||
#define MZ_FREOPEN mz_freopen
|
||||
#define MZ_DELETE_FILE remove
|
||||
@ -2996,7 +3044,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
||||
#define MZ_FFLUSH fflush
|
||||
#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
|
||||
#define MZ_DELETE_FILE remove
|
||||
#elif defined(__GNUC__) && _LARGEFILE64_SOURCE
|
||||
#elif defined(__GNUC__) && defined(_LARGEFILE64_SOURCE)
|
||||
#ifndef MINIZ_NO_TIME
|
||||
#include <utime.h>
|
||||
#endif
|
||||
@ -3250,7 +3298,8 @@ static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zi
|
||||
size_t orig_size = pArray->m_size;
|
||||
if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE))
|
||||
return MZ_FALSE;
|
||||
memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size);
|
||||
if (n > 0)
|
||||
memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size);
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
@ -3647,21 +3696,47 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flag
|
||||
|
||||
if (extra_size_remaining)
|
||||
{
|
||||
const mz_uint8 *pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size;
|
||||
const mz_uint8 *pExtra_data;
|
||||
void* buf = NULL;
|
||||
|
||||
if (MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + ext_data_size > n)
|
||||
{
|
||||
buf = MZ_MALLOC(ext_data_size);
|
||||
if(buf==NULL)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
|
||||
|
||||
if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size, buf, ext_data_size) != ext_data_size)
|
||||
{
|
||||
MZ_FREE(buf);
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
||||
}
|
||||
|
||||
pExtra_data = (mz_uint8*)buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
mz_uint32 field_id;
|
||||
mz_uint32 field_data_size;
|
||||
|
||||
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
||||
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
|
||||
{
|
||||
MZ_FREE(buf);
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
||||
}
|
||||
|
||||
field_id = MZ_READ_LE16(pExtra_data);
|
||||
field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
|
||||
|
||||
if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
||||
if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
|
||||
{
|
||||
MZ_FREE(buf);
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
||||
}
|
||||
|
||||
if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
|
||||
{
|
||||
@ -3674,6 +3749,8 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flag
|
||||
pExtra_data += sizeof(mz_uint16) * 2 + field_data_size;
|
||||
extra_size_remaining = extra_size_remaining - sizeof(mz_uint16) * 2 - field_data_size;
|
||||
} while (extra_size_remaining);
|
||||
|
||||
MZ_FREE(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4870,7 +4947,7 @@ size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState,
|
||||
if ((pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method))
|
||||
{
|
||||
/* The file is stored or the caller has requested the compressed data, calc amount to return. */
|
||||
copied_to_caller = MZ_MIN( buf_size, pState->comp_remaining );
|
||||
copied_to_caller = (size_t)MZ_MIN( buf_size, pState->comp_remaining );
|
||||
|
||||
/* Zip is in memory....or requires reading from a file? */
|
||||
if (pState->pZip->m_pState->m_pMem)
|
||||
@ -5947,7 +6024,7 @@ static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char
|
||||
if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + user_extra_data_len + comment_size) >= MZ_UINT32_MAX)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
|
||||
|
||||
if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size + user_extra_data_len, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes))
|
||||
if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, (mz_uint16)(extra_size + user_extra_data_len), comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||
|
||||
@ -5971,13 +6048,7 @@ static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name)
|
||||
if (*pArchive_name == '/')
|
||||
return MZ_FALSE;
|
||||
|
||||
while (*pArchive_name)
|
||||
{
|
||||
if ((*pArchive_name == '\\') || (*pArchive_name == ':'))
|
||||
return MZ_FALSE;
|
||||
|
||||
pArchive_name++;
|
||||
}
|
||||
/* Making sure the name does not contain drive letters or DOS style backward slashes is the responsibility of the program using miniz*/
|
||||
|
||||
return MZ_TRUE;
|
||||
}
|
||||
@ -6168,7 +6239,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
||||
}
|
||||
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len), 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
||||
@ -6195,7 +6266,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
{
|
||||
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
||||
@ -6288,7 +6359,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
||||
}
|
||||
|
||||
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment,
|
||||
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, (mz_uint16)extra_size, pComment,
|
||||
comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
|
||||
user_extra_data_central, user_extra_data_central_len))
|
||||
return MZ_FALSE;
|
||||
@ -6299,8 +6370,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
#ifndef MINIZ_NO_STDIO
|
||||
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
||||
mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
||||
const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
|
||||
{
|
||||
mz_uint16 gen_flags = MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
||||
@ -6313,6 +6383,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
mz_uint32 extra_size = 0;
|
||||
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
|
||||
mz_zip_internal_state *pState;
|
||||
mz_uint64 file_ofs = 0;
|
||||
|
||||
if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
|
||||
gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
|
||||
@ -6368,7 +6439,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
if (!pState->m_zip64)
|
||||
{
|
||||
/* Bail early if the archive would obviously become too large */
|
||||
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE
|
||||
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE
|
||||
+ archive_name_size + comment_size + user_extra_data_len + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 1024
|
||||
+ MZ_ZIP_DATA_DESCRIPTER_SIZE32 + user_extra_data_central_len) > 0xFFFFFFFF)
|
||||
{
|
||||
@ -6415,7 +6486,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
||||
}
|
||||
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len), 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
||||
@ -6439,7 +6510,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
{
|
||||
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
||||
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
||||
@ -6477,11 +6548,12 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
while (uncomp_remaining)
|
||||
{
|
||||
mz_uint n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
|
||||
if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
|
||||
if ((read_callback(callback_opaque, file_ofs, pRead_buf, n) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
|
||||
{
|
||||
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
||||
}
|
||||
file_ofs += n;
|
||||
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);
|
||||
uncomp_remaining -= n;
|
||||
cur_archive_file_ofs += n;
|
||||
@ -6516,12 +6588,13 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
tdefl_status status;
|
||||
tdefl_flush flush = TDEFL_NO_FLUSH;
|
||||
|
||||
if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
|
||||
if (read_callback(callback_opaque, file_ofs, pRead_buf, in_buf_size)!= in_buf_size)
|
||||
{
|
||||
mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
||||
break;
|
||||
}
|
||||
|
||||
file_ofs += in_buf_size;
|
||||
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);
|
||||
uncomp_remaining -= in_buf_size;
|
||||
|
||||
@ -6589,7 +6662,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
||||
}
|
||||
|
||||
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment, comment_size,
|
||||
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, (mz_uint16)extra_size, pComment, comment_size,
|
||||
uncomp_size, comp_size, uncomp_crc32, method, gen_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
|
||||
user_extra_data_central, user_extra_data_central_len))
|
||||
return MZ_FALSE;
|
||||
@ -6600,6 +6673,26 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
#ifndef MINIZ_NO_STDIO
|
||||
|
||||
static size_t mz_file_read_func_stdio(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
|
||||
{
|
||||
MZ_FILE *pSrc_file = (MZ_FILE *)pOpaque;
|
||||
mz_int64 cur_ofs = MZ_FTELL64(pSrc_file);
|
||||
|
||||
if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pSrc_file, (mz_int64)file_ofs, SEEK_SET))))
|
||||
return 0;
|
||||
|
||||
return MZ_FREAD(pBuf, 1, n, pSrc_file);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
||||
const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
|
||||
{
|
||||
return mz_zip_writer_add_read_buf_callback(pZip, pArchive_name, mz_file_read_func_stdio, pSrc_file, size_to_add, pFile_time, pComment, comment_size, level_and_flags,
|
||||
user_extra_data, user_extra_data_len, user_extra_data_central, user_extra_data_central_len);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags)
|
||||
{
|
||||
MZ_FILE *pSrc_file = NULL;
|
||||
|
35
external/miniz/miniz.h
vendored
35
external/miniz/miniz.h
vendored
@ -1,4 +1,4 @@
|
||||
/* miniz.c 2.0.8 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
|
||||
/* miniz.c 2.1.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
|
||||
See "unlicense" statement at the end of this file.
|
||||
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
|
||||
Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
|
||||
@ -24,7 +24,7 @@
|
||||
zlib replacement in many apps:
|
||||
The z_stream struct, optional memory allocation callbacks
|
||||
deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound
|
||||
inflateInit/inflateInit2/inflate/inflateEnd
|
||||
inflateInit/inflateInit2/inflate/inflateReset/inflateEnd
|
||||
compress, compress2, compressBound, uncompress
|
||||
CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines.
|
||||
Supports raw deflate streams or standard zlib streams with adler-32 checking.
|
||||
@ -170,12 +170,16 @@
|
||||
#define MINIZ_LITTLE_ENDIAN 0
|
||||
#endif
|
||||
|
||||
/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES only if not set */
|
||||
#if !defined(MINIZ_USE_UNALIGNED_LOADS_AND_STORES)
|
||||
#if MINIZ_X86_OR_X64_CPU
|
||||
/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */
|
||||
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
|
||||
#define MINIZ_UNALIGNED_USE_MEMCPY
|
||||
#else
|
||||
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
|
||||
/* Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). */
|
||||
@ -234,11 +238,11 @@ enum
|
||||
MZ_DEFAULT_COMPRESSION = -1
|
||||
};
|
||||
|
||||
#define MZ_VERSION "10.0.3"
|
||||
#define MZ_VERNUM 0xA030
|
||||
#define MZ_VERSION "10.1.0"
|
||||
#define MZ_VERNUM 0xA100
|
||||
#define MZ_VER_MAJOR 10
|
||||
#define MZ_VER_MINOR 0
|
||||
#define MZ_VER_REVISION 3
|
||||
#define MZ_VER_MINOR 1
|
||||
#define MZ_VER_REVISION 0
|
||||
#define MZ_VER_SUBREVISION 0
|
||||
|
||||
#ifndef MINIZ_NO_ZLIB_APIS
|
||||
@ -361,6 +365,9 @@ int mz_inflateInit(mz_streamp pStream);
|
||||
/* window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). */
|
||||
int mz_inflateInit2(mz_streamp pStream, int window_bits);
|
||||
|
||||
/* Quickly resets a compressor without having to reallocate anything. Same as calling mz_inflateEnd() followed by mz_inflateInit()/mz_inflateInit2(). */
|
||||
int mz_inflateReset(mz_streamp pStream);
|
||||
|
||||
/* Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. */
|
||||
/* Parameters: */
|
||||
/* pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */
|
||||
@ -444,6 +451,7 @@ typedef void *const voidpc;
|
||||
#define compressBound mz_compressBound
|
||||
#define inflateInit mz_inflateInit
|
||||
#define inflateInit2 mz_inflateInit2
|
||||
#define inflateReset mz_inflateReset
|
||||
#define inflate mz_inflate
|
||||
#define inflateEnd mz_inflateEnd
|
||||
#define uncompress mz_uncompress
|
||||
@ -737,11 +745,13 @@ mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
|
||||
/* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */
|
||||
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
|
||||
|
||||
#ifndef MINIZ_NO_MALLOC
|
||||
/* Allocate the tdefl_compressor structure in C so that */
|
||||
/* non-C language bindings to tdefl_ API don't need to worry about */
|
||||
/* structure size and allocation mechanism. */
|
||||
tdefl_compressor *tdefl_compressor_alloc();
|
||||
tdefl_compressor *tdefl_compressor_alloc(void);
|
||||
void tdefl_compressor_free(tdefl_compressor *pComp);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -789,12 +799,13 @@ int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size,
|
||||
struct tinfl_decompressor_tag;
|
||||
typedef struct tinfl_decompressor_tag tinfl_decompressor;
|
||||
|
||||
#ifndef MINIZ_NO_MALLOC
|
||||
/* Allocate the tinfl_decompressor structure in C so that */
|
||||
/* non-C language bindings to tinfl_ API don't need to worry about */
|
||||
/* structure size and allocation mechanism. */
|
||||
|
||||
tinfl_decompressor *tinfl_decompressor_alloc();
|
||||
tinfl_decompressor *tinfl_decompressor_alloc(void);
|
||||
void tinfl_decompressor_free(tinfl_decompressor *pDecomp);
|
||||
#endif
|
||||
|
||||
/* Max size of LZ dictionary. */
|
||||
#define TINFL_LZ_DICT_SIZE 32768
|
||||
@ -1269,6 +1280,12 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
|
||||
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
|
||||
|
||||
/* Adds the contents of a file to an archive. This function also records the disk file's modified time into the archive. */
|
||||
/* File data is supplied via a read callback function. User mz_zip_writer_add_(c)file to add a file directly.*/
|
||||
mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 size_to_add,
|
||||
const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
|
||||
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
|
||||
|
||||
#ifndef MINIZ_NO_STDIO
|
||||
/* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
|
||||
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
|
||||
|
2
external/pugixml
vendored
2
external/pugixml
vendored
@ -1 +1 @@
|
||||
Subproject commit c5752917c72da7cee2271394a827d022ccd4b367
|
||||
Subproject commit 08b3433180727ea2f78fe02e860a08471db1e03c
|
2
external/spdlog
vendored
2
external/spdlog
vendored
@ -1 +1 @@
|
||||
Subproject commit a7148b718ea2fabb8387cb90aee9bf448da63e65
|
||||
Subproject commit de0dbfa3596a18cd70a4619b6a9766847a941276
|
2
external/stb
vendored
2
external/stb
vendored
@ -1 +1 @@
|
||||
Subproject commit c72a95d766b8cbf5514e68d3ddbf6437ac9425b1
|
||||
Subproject commit b42009b3b9d4ca35bc703f5310eedc74f584be58
|
2
external/vita-toolchain
vendored
2
external/vita-toolchain
vendored
@ -1 +1 @@
|
||||
Subproject commit d45a757dd3cf891d3482ee104c36189c2eeb758c
|
||||
Subproject commit 4553ee96482d9ba36b9f6c6dcded465ee5ab6ca5
|
2
external/yaml-cpp
vendored
2
external/yaml-cpp
vendored
@ -1 +1 @@
|
||||
Subproject commit 012269756149ae99745b6dafefd415843d7420bb
|
||||
Subproject commit 9a3624205e8774953ef18f57067b3426c1c5ada6
|
@ -17,10 +17,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/log.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
// clang-format off
|
||||
// Singular options produced in config file
|
||||
// Order is code(option_type, option_name, option_default, member_name)
|
||||
|
@ -52,4 +52,4 @@ add_library(
|
||||
|
||||
target_include_directories(gui PUBLIC include ${CMAKE_SOURCE_DIR}/vita3k)
|
||||
target_link_libraries(gui PUBLIC app host imgui glutil)
|
||||
target_link_libraries(gui PRIVATE nativefiledialog pugixml stb renderer)
|
||||
target_link_libraries(gui PRIVATE nativefiledialog pugixml::pugixml stb renderer)
|
||||
|
@ -142,7 +142,7 @@ void draw_app_selector(GuiState &gui, HostState &host) {
|
||||
gui.live_area.information_bar = true;
|
||||
|
||||
if (!gui.file_menu.pkg_install_dialog) {
|
||||
if (ImGui::IsAnyWindowHovered() || ImGui::IsAnyItemActive() || ImGui::IsAnyItemHovered())
|
||||
if (ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) || ImGui::IsAnyItemActive() || ImGui::IsAnyItemHovered())
|
||||
last_time["start"] = 0;
|
||||
else {
|
||||
if (last_time["start"] == 0)
|
||||
|
@ -100,7 +100,7 @@ static void init_style() {
|
||||
style->Colors[ImGuiCol_PlotHistogram] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f);
|
||||
style->Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f);
|
||||
style->Colors[ImGuiCol_TextSelectedBg] = ImVec4(1.00f, 1.00f, 0.00f, 0.50f);
|
||||
style->Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(1.00f, 0.98f, 0.95f, 0.73f);
|
||||
style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(1.00f, 0.98f, 0.95f, 0.73f);
|
||||
}
|
||||
|
||||
static void init_font(GuiState &gui, HostState &host) {
|
||||
|
@ -23,4 +23,4 @@ target_link_libraries(host PUBLIC psvpfsparser app audio config ctrl dialog io k
|
||||
if(USE_GDBSTUB)
|
||||
target_link_libraries(host PUBLIC gdbstub)
|
||||
endif()
|
||||
target_link_libraries(host PRIVATE elfio FAT16 vita-toolchain)
|
||||
target_link_libraries(host PRIVATE elfio::elfio FAT16 vita-toolchain)
|
||||
|
@ -160,9 +160,9 @@ static bool load_imports(const sce_module_info_raw &module, Ptr<const void> segm
|
||||
const sce_module_imports_raw *const imports_end = reinterpret_cast<const sce_module_imports_raw *>(base + module.import_end);
|
||||
|
||||
for (const sce_module_imports_raw *imports = imports_begin; imports < imports_end; imports = reinterpret_cast<const sce_module_imports_raw *>(reinterpret_cast<const uint8_t *>(imports) + imports->size)) {
|
||||
assert(imports->num_syms_unk == 0);
|
||||
assert(imports->num_syms_tls_vars == 0);
|
||||
|
||||
Address module_name{};
|
||||
Address library_name{};
|
||||
Address func_nid_table{};
|
||||
Address func_entry_table{};
|
||||
Address var_nid_table{};
|
||||
@ -170,14 +170,14 @@ static bool load_imports(const sce_module_info_raw &module, Ptr<const void> segm
|
||||
|
||||
if (imports->size == 0x24) {
|
||||
auto short_imports = reinterpret_cast<const sce_module_imports_short_raw *>(imports);
|
||||
module_name = short_imports->module_name;
|
||||
library_name = short_imports->library_name;
|
||||
func_nid_table = short_imports->func_nid_table;
|
||||
func_entry_table = short_imports->func_entry_table;
|
||||
var_nid_table = short_imports->var_nid_table;
|
||||
var_entry_table = short_imports->var_entry_table;
|
||||
} else if (imports->size == 0x34) {
|
||||
auto long_imports = imports;
|
||||
module_name = long_imports->module_name;
|
||||
library_name = long_imports->library_name;
|
||||
func_nid_table = long_imports->func_nid_table;
|
||||
func_entry_table = long_imports->func_entry_table;
|
||||
var_nid_table = long_imports->var_nid_table;
|
||||
@ -186,7 +186,7 @@ static bool load_imports(const sce_module_info_raw &module, Ptr<const void> segm
|
||||
|
||||
std::string lib_name;
|
||||
if (cfg.log_imports) {
|
||||
lib_name = Ptr<const char>(module_name).get(mem);
|
||||
lib_name = Ptr<const char>(library_name).get(mem);
|
||||
LOG_INFO("Loading func imports from {}", lib_name);
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ static bool load_exports(Ptr<const void> &entry_point, const sce_module_info_raw
|
||||
const sce_module_exports_raw *const exports_end = reinterpret_cast<const sce_module_exports_raw *>(base + module.export_end);
|
||||
|
||||
for (const sce_module_exports_raw *exports = exports_begin; exports < exports_end; exports = reinterpret_cast<const sce_module_exports_raw *>(reinterpret_cast<const uint8_t *>(exports) + exports->size)) {
|
||||
const char *const lib_name = Ptr<const char>(exports->module_name).get(mem);
|
||||
const char *const lib_name = Ptr<const char>(exports->library_name).get(mem);
|
||||
|
||||
if (cfg.log_exports) {
|
||||
LOG_INFO("Loading func exports from {}", lib_name ? lib_name : "unknown");
|
||||
@ -429,7 +429,7 @@ SceUID load_self(Ptr<const void> &entry_point, KernelState &kernel, MemState &me
|
||||
|
||||
for (const auto [seg, infos] : segment_reloc_info) {
|
||||
LOG_INFO("Loaded module segment {} @ [0x{:08X} - 0x{:08X} / 0x{:08X}] (size: 0x{:08X}) of module {}", seg, infos.addr, infos.addr + infos.size, infos.p_vaddr, infos.size, self_path);
|
||||
kernel.module_regions.push_back({ module_info->library_nid,
|
||||
kernel.module_regions.push_back({ module_info->module_nid,
|
||||
module_info->name,
|
||||
infos.addr,
|
||||
static_cast<uint32_t>(infos.size),
|
||||
@ -455,9 +455,9 @@ SceUID load_self(Ptr<const void> &entry_point, KernelState &kernel, MemState &me
|
||||
|
||||
//unk40
|
||||
//unk44
|
||||
sceKernelModuleInfo->tlsInit = Ptr<const void>((!module_info->field_38 ? 0 : (module_info_segment_address.address() + module_info->field_38)));
|
||||
sceKernelModuleInfo->tlsInitSize = module_info->field_3C;
|
||||
sceKernelModuleInfo->tlsAreaSize = module_info->field_40;
|
||||
sceKernelModuleInfo->tlsInit = Ptr<const void>((!module_info->tls_start ? 0 : (module_info_segment_address.address() + module_info->tls_start)));
|
||||
sceKernelModuleInfo->tlsInitSize = module_info->tls_filesz;
|
||||
sceKernelModuleInfo->tlsAreaSize = module_info->tls_memsz;
|
||||
|
||||
if (sceKernelModuleInfo->tlsInit) {
|
||||
kernel.tls_address = sceKernelModuleInfo->tlsInit;
|
||||
|
@ -913,7 +913,7 @@ void make_fself(const std::string &input_file, const std::string &output_file) {
|
||||
control_6.common.type = 6;
|
||||
control_6.common.size = sizeof(control_6);
|
||||
control_6.common.unk = 1;
|
||||
control_6.unk1 = 1;
|
||||
control_6.is_used = 1;
|
||||
SCE_controlinfo_7 control_7 = { 0 };
|
||||
control_7.common.type = 7;
|
||||
control_7.common.size = sizeof(control_7);
|
||||
|
@ -39,7 +39,9 @@
|
||||
#endif
|
||||
|
||||
#include <SDL.h>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <thread>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Root root_paths;
|
||||
|
@ -189,4 +189,5 @@ add_library(modules STATIC
|
||||
SceWlanBt/SceWlan.cpp SceWlanBt/SceWlan.h
|
||||
)
|
||||
target_include_directories(modules PUBLIC include)
|
||||
target_link_libraries(modules PRIVATE xxHash::xxhash)
|
||||
target_link_libraries(modules PUBLIC module)
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <modules/module_parent.h>
|
||||
|
||||
#include "../xxHash/xxh3.h"
|
||||
#include <xxh3.h>
|
||||
|
||||
#include <gxm/functions.h>
|
||||
#include <gxm/types.h>
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include <net/types.h>
|
||||
#include <util/lock_and_find.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
EXPORT(int, sceNetAccept, int sid, SceNetSockaddr *addr, unsigned int *addrlen) {
|
||||
auto sock = lock_and_find(sid, host.net.socks, host.kernel.mutex);
|
||||
if (!sock) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <map>
|
||||
|
||||
#ifdef WIN32
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
#include <Ws2tcpip.h>
|
||||
|
@ -10,4 +10,4 @@ add_library(np
|
||||
|
||||
target_include_directories(np PUBLIC include)
|
||||
target_link_libraries(np PUBLIC yaml-cpp mem)
|
||||
target_link_libraries(np PRIVATE io util pugixml)
|
||||
target_link_libraries(np PRIVATE io util pugixml::pugixml)
|
||||
|
@ -57,5 +57,4 @@ add_library(
|
||||
|
||||
target_include_directories(renderer PUBLIC include)
|
||||
target_link_libraries(renderer PUBLIC crypto stb shader glutil threads config util ${RENDERER_VULKAN_LIBRARIES})
|
||||
target_link_libraries(renderer PRIVATE sdl2 stb ffmpeg)
|
||||
|
||||
target_link_libraries(renderer PRIVATE sdl2 stb ffmpeg xxHash::xxhash)
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include <features/state.h>
|
||||
#include <gxm/functions.h>
|
||||
|
||||
#include <spdlog/fmt/bin_to_hex.h>
|
||||
|
||||
namespace renderer::gl {
|
||||
static GLenum translate_primitive(SceGxmPrimitiveType primType) {
|
||||
R_PROFILE(__func__);
|
||||
@ -72,14 +74,8 @@ void draw(GLState &renderer, GLContext &context, GxmContextState &state, const F
|
||||
const std::string hash_text_v = hex_string(state.vertex_program.get(mem)->renderer_data->hash);
|
||||
|
||||
LOG_DEBUG("\nVertex : {}\nFragment: {}", hash_text_v, hash_text_f);
|
||||
|
||||
std::stringstream vert_ub;
|
||||
dump_hex(context.ubo_data[0], vert_ub);
|
||||
LOG_DEBUG("Vertex default uniform buffer: \n{}", vert_ub.str());
|
||||
|
||||
std::stringstream frag_ub;
|
||||
dump_hex(context.ubo_data[SCE_GXM_REAL_MAX_UNIFORM_BUFFER], frag_ub);
|
||||
LOG_DEBUG("Fragment default uniform buffer: \n{}", frag_ub.str());
|
||||
LOG_DEBUG("Vertex default uniform buffer: {:a}\n", spdlog::to_hex(context.ubo_data[0].begin(), context.ubo_data[0].end(), 16));
|
||||
LOG_DEBUG("Fragment default uniform buffer: {:a}\n", spdlog::to_hex(context.ubo_data[SCE_GXM_REAL_MAX_UNIFORM_BUFFER].begin(), context.ubo_data[SCE_GXM_REAL_MAX_UNIFORM_BUFFER].end(), 16));
|
||||
}
|
||||
|
||||
if (!program_id) {
|
||||
|
@ -6,10 +6,10 @@
|
||||
#include <mem/ptr.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include "../xxHash/xxh3.h"
|
||||
#include <algorithm> // find
|
||||
#include <cstring> // memcmp
|
||||
#include <numeric> // accumulate, reduce
|
||||
#include <xxh3.h>
|
||||
#ifdef WIN32
|
||||
#include <execution>
|
||||
#endif
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
struct _FILETIME;
|
||||
|
||||
// This is the # of microseconds between January 1, 0001 and January 1, 1970.
|
||||
// Grabbed from JPSCP
|
||||
static constexpr auto RTC_OFFSET = 62135596800000000ULL;
|
||||
@ -85,11 +83,6 @@ inline time_t rtc_timegm(struct tm *tm) {
|
||||
|
||||
std::uint64_t rtc_base_ticks();
|
||||
std::uint64_t rtc_get_ticks(uint64_t base_tick);
|
||||
#ifdef WIN32
|
||||
std::uint64_t convert_filetime(const _FILETIME &filetime);
|
||||
#else
|
||||
std::uint64_t convert_timespec(const timespec ×pec);
|
||||
#endif
|
||||
void __RtcPspTimeToTm(tm *val, const SceDateTime *pt);
|
||||
void __RtcTicksToPspTime(SceDateTime *t, std::uint64_t ticks);
|
||||
std::uint64_t __RtcPspTimeToTicks(const SceDateTime *pt);
|
||||
|
@ -33,23 +33,6 @@ std::uint64_t rtc_get_ticks(uint64_t base_ticks) {
|
||||
return base_ticks + rtc_ticks_since_epoch();
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
std::uint64_t convert_filetime(const _FILETIME &filetime) {
|
||||
// Microseconds between 1601-01-01 00:00:00 UTC and 1970-01-01 00:00:00 UTC
|
||||
static const uint64_t EPOCH_DIFFERENCE_MICROS = 11644473600000000ull;
|
||||
|
||||
// First convert 100-ns intervals to microseconds, then adjust for the
|
||||
// epoch difference
|
||||
uint64_t total_us = (((uint64_t)filetime.dwHighDateTime << 32) | (uint64_t)filetime.dwLowDateTime) / 10;
|
||||
total_us -= EPOCH_DIFFERENCE_MICROS;
|
||||
return total_us;
|
||||
}
|
||||
#else
|
||||
std::uint64_t convert_timespec(const timespec ×pec) {
|
||||
return timespec.tv_sec * 1'000'000 + timespec.tv_nsec / 1'000;
|
||||
}
|
||||
#endif
|
||||
|
||||
// The following functions are from PPSSPP
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
|
@ -23,4 +23,4 @@ add_library(
|
||||
)
|
||||
|
||||
target_include_directories(util PUBLIC include)
|
||||
target_link_libraries(util PUBLIC ${Boost_LIBRARIES} spdlog)
|
||||
target_link_libraries(util PUBLIC ${Boost_LIBRARIES} spdlog::spdlog)
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <util/exit_code.h>
|
||||
#include <util/fs.h>
|
||||
@ -69,5 +71,3 @@ std::string log_hex(T val) {
|
||||
using unsigned_type = typename std::make_unsigned<T>::type;
|
||||
return fmt::format("0x{:0X}", static_cast<unsigned_type>(val));
|
||||
}
|
||||
|
||||
void dump_hex(const std::vector<uint8_t> &bytes, std::ostream &stream);
|
@ -56,7 +56,6 @@ ExitCode init(const Root &root_paths, bool use_stdout) {
|
||||
assert(0);
|
||||
});
|
||||
|
||||
spdlog::flush_on(spdlog::level::debug);
|
||||
return Success;
|
||||
}
|
||||
|
||||
@ -282,51 +281,6 @@ std::uint32_t nearest_power_of_two(std::uint32_t num) {
|
||||
return num;
|
||||
}
|
||||
|
||||
// based on https://gist.github.com/shreyasbharath/32a8092666303a916e24a81b18af146b
|
||||
void dump_hex(const std::vector<uint8_t> &bytes, std::ostream &stream) {
|
||||
char buff[17];
|
||||
size_t i = 0;
|
||||
|
||||
stream << std::hex;
|
||||
|
||||
// Process every byte in the data.
|
||||
for (i = 0; i < bytes.size(); i++) {
|
||||
// Multiple of 16 means new line (with line offset).
|
||||
|
||||
if ((i % 16) == 0) {
|
||||
// Just don't print ASCII for the zeroth line.
|
||||
if (i != 0) {
|
||||
stream << " " << buff << std::endl;
|
||||
}
|
||||
|
||||
// Output the offset.
|
||||
stream << " " << std::setw(4) << std::setfill('0') << static_cast<unsigned int>(i);
|
||||
}
|
||||
|
||||
// Now the hex code for the specific character.
|
||||
stream << " " << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(bytes[i]);
|
||||
|
||||
// And store a printable ASCII character for later.
|
||||
if ((bytes[i] < 0x20) || (bytes[i] > 0x7e)) {
|
||||
buff[i % 16] = '.';
|
||||
} else {
|
||||
buff[i % 16] = bytes[i];
|
||||
}
|
||||
buff[(i % 16) + 1] = '\0';
|
||||
}
|
||||
|
||||
stream << std::dec;
|
||||
|
||||
// Pad out last line if not exactly 16 characters.
|
||||
while ((i % 16) != 0) {
|
||||
stream << " ";
|
||||
i++;
|
||||
}
|
||||
|
||||
// And print the final ASCII bit.
|
||||
stream << " " << buff << std::endl;
|
||||
}
|
||||
|
||||
// Encode code taken from https://github.com/yifanlu/UVLoader/blob/master/resolve.c
|
||||
|
||||
uint32_t encode_arm_inst(uint8_t type, uint16_t immed, uint16_t reg) {
|
||||
|
Loading…
Reference in New Issue
Block a user