Windows build fixes

This commit is contained in:
Jack Andersen 2019-06-12 15:29:52 -10:00
parent 387f8fa864
commit 31caec79dd
5 changed files with 41 additions and 53 deletions

2
hecl/extern/athena vendored

@ -1 +1 @@
Subproject commit 727f057fa7774cb394f5ee795b2141a930d427ad
Subproject commit a9271862dcde58982affda98383e2367e5d205b8

View File

@ -7,6 +7,42 @@
#define NOMINMAX 1
#endif
#include "windows.h"
#include <cstdint>
#include <cstdio>
#include <cstdlib>
void* memmem(const void* haystack, size_t hlen, const void* needle, size_t nlen);
int asprintf(char** buf, const char* format, ...);
#ifndef DEF_INLINE_MEMMEM
#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;
}

View File

@ -233,9 +233,7 @@ Connection::Connection(int verbosityLevel) {
/* Put hecl_blendershell.py in temp dir */
const SystemChar* TMPDIR = GetTmpDir();
#ifdef _WIN32
m_startupBlend = hecl::WideToUTF8(TMPDIR);
#else
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
#endif

View File

@ -10,7 +10,7 @@ add_subdirectory(Blender)
add_subdirectory(Runtime)
if(WIN32)
list(APPEND PLAT_SRCS winsupport.cpp ../include/hecl/winsupport.hpp)
list(APPEND PLAT_SRCS ../include/hecl/winsupport.hpp)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")

View File

@ -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;
}