diff --git a/dmoj/executors/BF.py b/dmoj/executors/BF.py index 47f3dc159..4a6dab717 100644 --- a/dmoj/executors/BF.py +++ b/dmoj/executors/BF.py @@ -11,7 +11,12 @@ #include #include #include -#include +#ifdef WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#else +# include +#endif int main(int argc, char **argv) { char *p; @@ -19,15 +24,23 @@ errno = 0; if (argc != 2 || (size = strtoull(argv[1], NULL, 10), errno)) { - printf("%s \\n", argv[0]); + fprintf(stderr, "%s \\n", argv[0]); return 2; } +#ifdef WIN32 + p = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); + if (!p) { + fprintf(stderr, "Failed to VirtualAlloc with %u\\n", (unsigned) GetLastError()); + return 2; + } +#else p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { perror("mmap"); return 2; } +#endif {code} }