Browse Source

Make sure we don't unconditionnally include unistd.h, which is not available on windows

Samuel Thibault 10 years ago
parent
commit
a92760f1c6

+ 12 - 0
configure.ac

@@ -2491,6 +2491,18 @@ AC_SUBST(SOCL_VENDORS)
 AC_CONFIG_FILES(tests/regression/regression.sh tests/regression/profiles tests/regression/profiles.build.only)
 AC_CONFIG_HEADER(src/common/config.h include/starpu_config.h gcc-plugin/include/starpu-gcc/config.h starpu-top/config.h)
 
+AH_BOTTOM([
+#if defined(STARPU_DEVEL) && defined(BUILDING_STARPU)
+#  ifndef STARPU_CHECKED_UNISTD_H
+#    define STARPU_CHECKED_UNISTD_H
+#    ifdef _UNISTD_H
+#      define _UNISTD_H PLEASE_DONT_INCLUDE_IT
+#      error Please do not unconditionally include unistd.h, it is not available on Windows, include config.h and test for HAVE_UNISTD_H
+#    endif
+#  endif
+#endif
+])
+
 AC_OUTPUT([
 	Makefile
 	src/Makefile

+ 3 - 2
src/common/fxt.h

@@ -23,12 +23,13 @@
 #define _GNU_SOURCE  /* ou _BSD_SOURCE ou _SVID_SOURCE */
 #endif
 
-#include <unistd.h>
-
 #include <string.h>
 #include <sys/types.h>
 #include <stdlib.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <common/utils.h>
 #include <starpu.h>
 

+ 3 - 1
src/common/timing.h

@@ -23,9 +23,11 @@
  * functions.
  */
 
-#include <unistd.h>
 #include <stdint.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <starpu_util.h>
 

+ 2 - 0
src/common/utils.c

@@ -19,7 +19,9 @@
 #include <common/config.h>
 #include <common/utils.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <fcntl.h>
 
 #if defined(_WIN32) && !defined(__CYGWIN__)

+ 4 - 1
src/core/disk_ops/disk_unistd.c

@@ -15,11 +15,14 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <stdint.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>

+ 4 - 1
src/core/disk_ops/disk_unistd_o_direct.c

@@ -15,11 +15,14 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <stdint.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>

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

@@ -15,7 +15,6 @@
  */
 
 #include <fcntl.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <stdint.h>
@@ -24,6 +23,10 @@
 #endif
 #include <errno.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu.h>
 #include <core/disk.h>
 #include <core/perfmodel/perfmodel.h>

+ 3 - 1
src/core/jobs.h

@@ -24,10 +24,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
-#include <unistd.h>
 #include <string.h>
 #include <stdarg.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <common/timing.h>
 #include <common/list.h>
 #include <common/fxt.h>

+ 2 - 0
src/core/perfmodel/perfmodel.c

@@ -20,7 +20,9 @@
 #include <starpu_profiling.h>
 #include <common/config.h>
 #include <common/utils.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <sys/stat.h>
 #include <core/perfmodel/perfmodel.h>
 #include <core/jobs.h>

+ 3 - 1
src/core/perfmodel/perfmodel_bus.c

@@ -22,7 +22,6 @@
 #endif
 #include <sched.h>
 #endif
-#include <unistd.h>
 #include <stdlib.h>
 #include <math.h>
 
@@ -30,6 +29,9 @@
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <core/workers.h>
 #include <core/perfmodel/perfmodel.h>
 #include <core/simgrid.h>

+ 3 - 1
src/core/perfmodel/perfmodel_history.c

@@ -16,13 +16,15 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <unistd.h>
 #if !defined(_WIN32) || defined(__MINGW__) || defined(__CYGWIN__)
 #include <dirent.h>
 #include <sys/stat.h>
 #endif
 #include <errno.h>
 #include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <common/utils.h>
 #include <core/perfmodel/perfmodel.h>
 #include <core/jobs.h>

+ 3 - 0
src/core/simgrid.c

@@ -16,7 +16,10 @@
 
 #include <starpu.h>
 #include <datawizard/memory_nodes.h>
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <core/perfmodel/perfmodel.h>
 #include <core/workers.h>
 #include <core/simgrid.h>

+ 5 - 2
src/drivers/opencl/driver_opencl_utils.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
- * Copyright (C) 2010-2013  Université de Bordeaux 1
+ * Copyright (C) 2010-2014  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,9 +20,12 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/types.h>
 
+#include <common/config.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <starpu_opencl.h>
 #include <starpu_profiling.h>
 #include <core/workers.h>

+ 2 - 0
src/top/starpu_top_connection.c

@@ -40,7 +40,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 const char *STARPU_TOP_PORT = "2011";
 const int STARPU_TOP_BUFFER_SIZE=1024;