From 6cd4612b341b6d5f0df0b604a1f2ee793539a0d9 Mon Sep 17 00:00:00 2001 From: hackyminer Date: Wed, 10 Jun 2020 23:42:38 +0900 Subject: support WIN32 --- common.h | 7 +++++++ libkeccak_generalised_sum_fd.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/common.h b/common.h index e5d9014..3062c14 100644 --- a/common.h +++ b/common.h @@ -3,7 +3,14 @@ #include +#if defined(__GLIBC__) || defined(__sun) || defined(__CYGWIN__) #include +#elif defined(_WIN32) +#include +#if !defined(alloca) +#define alloca _alloca // for clang with MS Codegen +#endif +#endif #include #include diff --git a/libkeccak_generalised_sum_fd.c b/libkeccak_generalised_sum_fd.c index 7c4df54..879371b 100644 --- a/libkeccak_generalised_sum_fd.c +++ b/libkeccak_generalised_sum_fd.c @@ -19,16 +19,20 @@ libkeccak_generalised_sum_fd(int fd, struct libkeccak_state *restrict state, con const char *restrict suffix, void *restrict hashsum) { ssize_t got; +#ifndef _WIN32 struct stat attr; +#endif size_t blksize = 4096; void *restrict chunk; if (libkeccak_state_initialise(state, spec) < 0) return -1; +#ifndef _WIN32 if (fstat(fd, &attr) == 0) if (attr.st_blksize > 0) blksize = (size_t)attr.st_blksize; +#endif chunk = alloca(blksize); -- cgit v1.2.3-70-g09d2