Explorar o código

try to resolve bug compilation on windows

Corentin Salingue %!s(int64=12) %!d(string=hai) anos
pai
achega
bc52051032

+ 14 - 2
src/core/disk_ops/disk_stdio.c

@@ -63,8 +63,8 @@ starpu_stdio_alloc (void *base, size_t size)
 	strcat(baseCpy,tmp);
 	strcat(baseCpy,tmp);
 
 
 #ifdef STARPU_HAVE_WINDOWS
 #ifdef STARPU_HAVE_WINDOWS
-        _mktemp_s(baseCpy, size/sizeof(char));
-        id = open(baseCpy, obj->flags);
+        _mktemp(baseCpy, size/sizeof(char));
+        id = open(baseCpy, "rb+");
 #else
 #else
 	id = mkstemp(baseCpy);
 	id = mkstemp(baseCpy);
 
 
@@ -88,7 +88,11 @@ starpu_stdio_alloc (void *base, size_t size)
 		return NULL;
 		return NULL;
 	}
 	}
 
 
+#ifdef STARPU_HAVE_WINDOWS
+	int val = _chsize(id, size);
+#else
 	int val = ftruncate(id,size);
 	int val = ftruncate(id,size);
+#endif
 	/* fail */
 	/* fail */
 	if (val < 0)
 	if (val < 0)
 	{
 	{
@@ -256,7 +260,11 @@ get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 		int res = fflush (tmp->file);
 		int res = fflush (tmp->file);
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
 
 
+#ifdef STARPU_HAVE_WINDOWS
+		res = _commit(tmp->descriptor);
+#else
 		res = fsync(tmp->descriptor);
 		res = fsync(tmp->descriptor);
+#endif
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
 	}
 	}
 	gettimeofday(&end, NULL);
 	gettimeofday(&end, NULL);
@@ -278,7 +286,11 @@ get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 		int res = fflush (tmp->file);
 		int res = fflush (tmp->file);
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 
 
+#ifdef STARPU_HAVE_WINDOWS
+		res = _commit(tmp->descriptor);
+#else
 		res = fsync(tmp->descriptor);
 		res = fsync(tmp->descriptor);
+#endif
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 	}
 	}
 	gettimeofday(&end, NULL);
 	gettimeofday(&end, NULL);

+ 5 - 1
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -54,7 +54,7 @@ starpu_unistd_global_alloc (struct starpu_unistd_global_obj * obj, void *base, s
 	id = mkostemp(baseCpy, obj->flags);
 	id = mkostemp(baseCpy, obj->flags);
 #elif STARPU_HAVE_WINDOWS
 #elif STARPU_HAVE_WINDOWS
 	/* size in windows is a multiple of char */
 	/* size in windows is a multiple of char */
-	_mktemp_s(baseCpy, size/sizeof(char));
+	_mktemp(baseCpy, size/sizeof(char));
 	id = open(baseCpy, obj->flags);
 	id = open(baseCpy, obj->flags);
 #else
 #else
 	STARPU_ASSERT(obj->flags == O_RDWR);
 	STARPU_ASSERT(obj->flags == O_RDWR);
@@ -69,7 +69,11 @@ starpu_unistd_global_alloc (struct starpu_unistd_global_obj * obj, void *base, s
 		return NULL;
 		return NULL;
 	}
 	}
 	
 	
+#ifdef STARPU_HAVE_WINDOWS
+	int val = _chsize(id, size);
+#else 
 	int val = ftruncate(id,size);
 	int val = ftruncate(id,size);
+#endif
 	/* fail */
 	/* fail */
 	if (val < 0)
 	if (val < 0)
 	{
 	{