coco_platform.h
Go to the documentation of this file.
1 
13 #ifndef __COCO_PLATFORM__
14 #define __COCO_PLATFORM__
15 
16 #include <stddef.h>
17 
18 /* Definitions of COCO_PATH_MAX, coco_path_separator, HAVE_GFA and HAVE_STAT heavily used by functions in
19  * coco_utilities.c */
20 #if defined(_WIN32) || defined(_WIN64) || defined(__MINGW64__) || defined(__CYGWIN__)
21 #include <windows.h>
22 static const char *coco_path_separator = "\\";
23 #define COCO_PATH_MAX MAX_PATH
24 #define HAVE_GFA 1
25 #elif defined(__gnu_linux__)
26 #include <sys/stat.h>
27 #include <sys/types.h>
28 #include <linux/limits.h>
29 static const char *coco_path_separator = "/";
30 #define HAVE_STAT 1
31 #define COCO_PATH_MAX PATH_MAX
32 #elif defined(__APPLE__)
33 #include <sys/stat.h>
34 #include <sys/types.h>
35 #include <sys/syslimits.h>
36 static const char *coco_path_separator = "/";
37 #define HAVE_STAT 1
38 #define COCO_PATH_MAX PATH_MAX
39 #elif defined(__FreeBSD__)
40 #include <sys/stat.h>
41 #include <sys/types.h>
42 #include <limits.h>
43 static const char *coco_path_separator = "/";
44 #define HAVE_STAT 1
45 #define COCO_PATH_MAX PATH_MAX
46 #elif (defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__))
47 /* Solaris */
48 #include <sys/stat.h>
49 #include <sys/types.h>
50 #include <limits.h>
51 static const char *coco_path_separator = "/";
52 #define HAVE_STAT 1
53 #define COCO_PATH_MAX PATH_MAX
54 #else
55 #error Unknown platform
56 #endif
57 #if !defined(COCO_PATH_MAX)
58 #error COCO_PATH_MAX undefined
59 #endif
60 
61 /* Definitions needed for creating and removing directories */
62 /* Separately handle the special case of Microsoft Visual Studio 2008 with x86_64-w64-mingw32-gcc */
63 #if _MSC_VER
64 #include <direct.h>
65 #elif defined(__MINGW32__) || defined(__MINGW64__)
66 #include <dirent.h>
67 #else
68 #include <dirent.h>
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 /* To silence the compiler (implicit-function-declaration warning). */
76 int rmdir(const char *pathname);
77 int unlink(const char *file_name);
78 int mkdir(const char *pathname, mode_t mode);
80 #endif
81 
82 /* Definition of the S_IRWXU constant needed to set file permissions */
83 #if defined(HAVE_GFA)
84 #define S_IRWXU 0700
85 #endif
86 
87 /* To silence the Visual Studio compiler (C4996 warnings in the python build). */
88 #ifdef _MSC_VER
89 #pragma warning(disable:4996)
90 #endif
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif