Browse Source

try to fix compilation on windows

Corentin Salingue 12 years ago
parent
commit
af625c8de4

+ 10 - 0
src/core/disk_ops/disk_stdio.c

@@ -24,6 +24,10 @@
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>
 
+#if STARPU_HAVE_WINDOWS
+        #include <io.h>
+#endif
+
 #define NITER	64
 
 /* ------------------- use STDIO to write on disk -------------------  */
@@ -58,7 +62,13 @@ starpu_stdio_alloc (void *base, size_t size STARPU_ATTRIBUTE_UNUSED)
 	strcpy(baseCpy, (char *) base);
 	strcat(baseCpy,tmp);
 
+#if STARPU_HAVE_WINDOWS
+        _mktemp_s(baseCpy, size/sizeof(char));
+        id = open(baseCpy, obj->flags);
+#else
 	id = mkstemp(baseCpy);
+
+#endif
 	/* fail */
 	if (id < 0)
 	{

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

@@ -26,6 +26,10 @@
 #include <core/perfmodel/perfmodel.h>
 #include <core/disk_ops/unistd/disk_unistd_global.h>
 
+#if STARPU_HAVE_WINDOWS
+        #include <io.h>
+#endif
+
 #define NITER	64
 #define SIZE_BENCH (4*getpagesize())
 
@@ -33,7 +37,7 @@
 
 /* allocation memory on disk */
  void * 
-starpu_unistd_global_alloc (struct starpu_unistd_global_obj * obj, void *base, size_t size STARPU_ATTRIBUTE_UNUSED)
+starpu_unistd_global_alloc (struct starpu_unistd_global_obj * obj, void *base, size_t size)
 {
 	int id = -1;
 	const char *template = "STARPU_XXXXXX";
@@ -48,6 +52,10 @@ starpu_unistd_global_alloc (struct starpu_unistd_global_obj * obj, void *base, s
 	strcat(baseCpy,template);
 #ifdef STARPU_LINUX_SYS
 	id = mkostemp(baseCpy, obj->flags);
+#elif STARPU_HAVE_WINDOWS
+	/* size in windows is a multiple of char */
+	_mktemp_s(baseCpy, size/sizeof(char));
+	id = open(baseCpy, obj->flags);
 #else
 	STARPU_ASSERT(obj->flags == O_RDWR);
 	id = mkstemp(baseCpy);

+ 13 - 1
tests/disk/disk_compute.c

@@ -27,6 +27,10 @@
 #include <unistd.h>
 #include <math.h>
 
+#if STARPU_HAVE_WINDOWS
+        #include <io.h>
+#endif 
+
 #define NX (1024)
 
 int main(int argc, char **argv)
@@ -99,7 +103,11 @@ int main(int argc, char **argv)
 	fclose(f);
 
 	int descriptor = open(path_file_start, O_RDWR);
+#if STARPU_HAVE_WINDOWS
+	_commit(descriptor);
+#else
 	fsync(descriptor);
+#endif
 	close(descriptor);
 
 	/* create a file to store result */
@@ -114,8 +122,12 @@ int main(int argc, char **argv)
 	fclose(f);
 
         descriptor = open(path_file_end, O_RDWR);
+#if STARPU_HAVE_WINDOWS
+        _commit(descriptor);
+#else
         fsync(descriptor);
-        close(descriptor);
+#endif
+	close(descriptor);
 
 	/* And now, you want to use your datas in StarPU */
 	/* Open the file ON the disk */