mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-11-05 09:36:52 +00:00
Implement system polyfill for win32 / posix.1
I don't have access to Microsoft Visual Studio right now (aside from the the Github Actions CI system) but I think this code should come close to what we want in terms of polyfilling UNIX functionality.
This commit is contained in:
23
main.cpp
23
main.cpp
@@ -1,9 +1,9 @@
|
||||
#include "ggml.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "mmap.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -207,27 +207,6 @@ void *memalign(size_t a, size_t n) {
|
||||
return p;
|
||||
}
|
||||
|
||||
int posix_memalign(void **pp, size_t a, size_t n) {
|
||||
int e;
|
||||
void *m;
|
||||
size_t q, r;
|
||||
q = a / sizeof(void *);
|
||||
r = a % sizeof(void *);
|
||||
if (!r && q && IS2POW(q)) {
|
||||
e = errno;
|
||||
m = memalign(a, n);
|
||||
if (m) {
|
||||
*pp = m;
|
||||
return 0;
|
||||
} else {
|
||||
errno = e;
|
||||
return ENOMEM;
|
||||
}
|
||||
} else {
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
void *malloc(size_t n) {
|
||||
return memalign(MAGIC_ALGN, n);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user