mirror of https://github.com/AxioDL/kabufuda.git
Windows build fixes
This commit is contained in:
parent
51c7163cfd
commit
8053d1125b
|
@ -9,7 +9,7 @@ unset(KABUFUDA_INCLUDE_DIR CACHE)
|
||||||
|
|
||||||
unset(PLAT_SRCS)
|
unset(PLAT_SRCS)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND PLAT_SRCS lib/kabufuda/winsupport.cpp include/kabufuda/winsupport.hpp lib/kabufuda/AsyncIOWin32.cpp)
|
list(APPEND PLAT_SRCS include/kabufuda/winsupport.hpp lib/kabufuda/AsyncIOWin32.cpp)
|
||||||
else()
|
else()
|
||||||
list(APPEND PLAT_SRCS lib/kabufuda/AsyncIOPosix.cpp)
|
list(APPEND PLAT_SRCS lib/kabufuda/AsyncIOPosix.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -7,5 +7,28 @@
|
||||||
#define NOMINMAX 1
|
#define NOMINMAX 1
|
||||||
#endif
|
#endif
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
void* memmem(const void* haystack, size_t hlen, const void* needle, size_t nlen);
|
#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
|
||||||
|
|
|
@ -1,34 +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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue