mirror of https://github.com/AxioDL/metaforce.git
Windows build fixes
This commit is contained in:
parent
387f8fa864
commit
31caec79dd
|
@ -1 +1 @@
|
||||||
Subproject commit 727f057fa7774cb394f5ee795b2141a930d427ad
|
Subproject commit a9271862dcde58982affda98383e2367e5d205b8
|
|
@ -7,6 +7,42 @@
|
||||||
#define NOMINMAX 1
|
#define NOMINMAX 1
|
||||||
#endif
|
#endif
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
void* memmem(const void* haystack, size_t hlen, const void* needle, size_t nlen);
|
#ifndef DEF_INLINE_MEMMEM
|
||||||
int asprintf(char** buf, const char* format, ...);
|
#define DEF_INLINE_MEMMEM
|
||||||
|
inline void* memmem(const void* haystack, size_t hlen, const void* needle, size_t nlen) {
|
||||||
|
int needle_first;
|
||||||
|
const uint8_t* p = static_cast<const uint8_t*>(haystack);
|
||||||
|
size_t plen = hlen;
|
||||||
|
|
||||||
|
if (!nlen)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
needle_first = *(unsigned char*)needle;
|
||||||
|
|
||||||
|
while (plen >= nlen && (p = static_cast<const uint8_t*>(memchr(p, needle_first, plen - nlen + 1)))) {
|
||||||
|
if (!memcmp(p, needle, nlen))
|
||||||
|
return (void*)p;
|
||||||
|
|
||||||
|
p++;
|
||||||
|
plen = hlen - (p - static_cast<const uint8_t*>(haystack));
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline int asprintf(char** buf, const char* format, ...) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, format);
|
||||||
|
int len = vsnprintf(nullptr, 0, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
*buf = (char*)malloc(len + 1);
|
||||||
|
va_start(ap, format);
|
||||||
|
vsnprintf(*buf, len + 1, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
|
@ -233,9 +233,7 @@ Connection::Connection(int verbosityLevel) {
|
||||||
|
|
||||||
/* Put hecl_blendershell.py in temp dir */
|
/* Put hecl_blendershell.py in temp dir */
|
||||||
const SystemChar* TMPDIR = GetTmpDir();
|
const SystemChar* TMPDIR = GetTmpDir();
|
||||||
#ifdef _WIN32
|
#ifndef _WIN32
|
||||||
m_startupBlend = hecl::WideToUTF8(TMPDIR);
|
|
||||||
#else
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ add_subdirectory(Blender)
|
||||||
add_subdirectory(Runtime)
|
add_subdirectory(Runtime)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND PLAT_SRCS winsupport.cpp ../include/hecl/winsupport.hpp)
|
list(APPEND PLAT_SRCS ../include/hecl/winsupport.hpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
|
||||||
#include "hecl/winsupport.hpp"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The memmem() function finds the start of the first occurrence of the
|
|
||||||
* substring 'needle' of length 'nlen' in the memory area 'haystack' of
|
|
||||||
* length 'hlen'.
|
|
||||||
*
|
|
||||||
* The return value is a pointer to the beginning of the sub-string, or
|
|
||||||
* NULL if the substring is not found.
|
|
||||||
*/
|
|
||||||
void* memmem(const void* haystack, size_t hlen, const void* needle, size_t nlen) {
|
|
||||||
int needle_first;
|
|
||||||
const uint8_t* p = static_cast<const uint8_t*>(haystack);
|
|
||||||
size_t plen = hlen;
|
|
||||||
|
|
||||||
if (!nlen)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
needle_first = *(unsigned char*)needle;
|
|
||||||
|
|
||||||
while (plen >= nlen && (p = static_cast<const uint8_t*>(memchr(p, needle_first, plen - nlen + 1)))) {
|
|
||||||
if (!memcmp(p, needle, nlen))
|
|
||||||
return (void*)p;
|
|
||||||
|
|
||||||
p++;
|
|
||||||
plen = hlen - (p - static_cast<const uint8_t*>(haystack));
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int asprintf(char** buf, const char* format, ...) {
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
int len = vsnprintf(nullptr, 0, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
*buf = (char*)malloc(len + 1);
|
|
||||||
va_start(ap, format);
|
|
||||||
vsnprintf(*buf, len + 1, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return len;
|
|
||||||
}
|
|
Loading…
Reference in New Issue