summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2015-03-19 09:28:31 +0000
committerkrasimir <krasimir@chalmers.se>2015-03-19 09:28:31 +0000
commite72fcb1513024e192eb112005da5e8586f517620 (patch)
treed2561f6008fa2d1535c6d949dde6e06d6474344f /src/runtime
parenta120ed1e22c1fbeb7d8e2245e3b2355b051ce2f2 (diff)
fix the compilation of gu/mem.c on Windows. For now memory mapped pools on Windows are just not supported.
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/c/gu/mem.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/runtime/c/gu/mem.c b/src/runtime/c/gu/mem.c
index ec953854e..0fc315a4f 100644
--- a/src/runtime/c/gu/mem.c
+++ b/src/runtime/c/gu/mem.c
@@ -1,30 +1,13 @@
-/*
- * Copyright 2010 University of Helsinki.
- *
- * This file is part of libgu.
- *
- * Libgu is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version.
- *
- * Libgu is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with libgu. If not, see <http://www.gnu.org/licenses/>.
- */
-
#include <gu/mem.h>
#include <gu/fun.h>
#include <gu/bits.h>
#include <gu/assert.h>
#include <string.h>
#include <stdlib.h>
+#if !defined(_WIN32) && !defined(_WIN64)
#include <sys/mman.h>
#include <sys/stat.h>
+#endif
#include <unistd.h>
#include <fcntl.h>
@@ -197,6 +180,7 @@ gu_new_pool(void)
GuPool*
gu_mmap_pool(char* fpath, void* addr, size_t size, void**pptr)
{
+#if !defined(_WIN32) && !defined(_WIN64)
int prot = PROT_READ;
int fd = open(fpath, O_RDONLY);
if (fd < 0) {
@@ -238,6 +222,9 @@ gu_mmap_pool(char* fpath, void* addr, size_t size, void**pptr)
pool->left_edge = 0;
return pool;
+#else
+ return NULL;
+#endif
}
static void
@@ -373,11 +360,13 @@ gu_pool_free(GuPool* pool)
if (pool->type == GU_POOL_HEAP) {
gu_mem_buf_free(pool);
} else if (pool->type == GU_POOL_MMAP) {
+#if !defined(_WIN32) && !defined(_WIN64)
uint8_t* pfd = pool->init_buf;
int fd = *(pfd);
munmap(pool->curr_buf, pool->curr_size);
close(fd);
+#endif
}
}