Skip to content

Commit b464562

Browse files
committed
compat : rebase and build for windows xp.
1 parent e937066 commit b464562

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ggml.c

+7
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ void ggml_print_backtrace(void) {
190190
#endif
191191

192192
#if defined(_MSC_VER) || defined(__MINGW32__)
193+
193194
#define GGML_ALIGNED_MALLOC(size) _aligned_malloc(size, GGML_MEM_ALIGN)
194195
#define GGML_ALIGNED_FREE(ptr) _aligned_free(ptr)
196+
197+
#if defined(__MINGW32__) && !defined(_aligned_malloc)
198+
_CRTIMP void __cdecl _aligned_free(void *_Memory);
199+
_CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment);
200+
#endif
201+
195202
#else
196203
inline static void * ggml_aligned_malloc(size_t size) {
197204
if (size == 0) {

llama.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ struct llama_mmap {
904904
}
905905

906906
if (prefetch) {
907+
#if WINVER >= 0x0602 // Windows 8 or higher define this function.
907908
// PrefetchVirtualMemory is only present on Windows 8 and above, so we dynamically load it
908909
BOOL (WINAPI *pPrefetchVirtualMemory) (HANDLE, ULONG_PTR, PWIN32_MEMORY_RANGE_ENTRY, ULONG);
909910
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
@@ -921,6 +922,9 @@ struct llama_mmap {
921922
llama_format_win_err(GetLastError()).c_str());
922923
}
923924
}
925+
#else
926+
throw std::runtime_error("PrefetchVirtualMemory unavailable");
927+
#endif
924928
}
925929
}
926930

0 commit comments

Comments
 (0)