Debian Codegraph @

Utilities/KWSys/kwsysPlatformTestsCXX.cxx

raw
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
3
4 #ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIM
5 # include <sys/types.h>
6
7 # include <sys/stat.h>
8 # include <unistd.h>
9 int main()
10 {
11 struct stat stat1;
12 (void)stat1.st_mtim.tv_sec;
13 (void)stat1.st_mtim.tv_nsec;
14 return 0;
15 }
16 #endif
17
18 #ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
19 # include <sys/types.h>
20
21 # include <sys/stat.h>
22 # include <unistd.h>
23 int main()
24 {
25 struct stat stat1;
26 (void)stat1.st_mtimespec.tv_sec;
27 (void)stat1.st_mtimespec.tv_nsec;
28 return 0;
29 }
30 #endif
31
32 #ifdef TEST_KWSYS_CXX_HAS_SETENV
33 # include <stdlib.h>
34 int main()
35 {
36 return setenv("A", "B", 1);
37 }
38 #endif
39
40 #ifdef TEST_KWSYS_CXX_HAS_UNSETENV
41 # include <stdlib.h>
42 int main()
43 {
44 unsetenv("A");
45 return 0;
46 }
47 #endif
48
49 #ifdef TEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
50 # include <stdlib.h>
51 int main()
52 {
53 char* e = environ[0];
54 return e ? 0 : 1;
55 }
56 #endif
57
58 #ifdef TEST_KWSYS_CXX_HAS_GETLOADAVG
59 // Match feature definitions from SystemInformation.cxx
60 # if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
61 # define _GNU_SOURCE
62 # endif
63 # include <stdlib.h>
64 int main()
65 {
66 double loadavg[3] = { 0.0, 0.0, 0.0 };
67 return getloadavg(loadavg, 3);
68 }
69 #endif
70
71 #ifdef TEST_KWSYS_CXX_HAS_RLIMIT64
72 # include <sys/resource.h>
73 int main()
74 {
75 struct rlimit64 rlim;
76 return getrlimit64(0, &rlim);
77 }
78 #endif
79
80 #ifdef TEST_KWSYS_CXX_HAS_UTIMES
81 # include <sys/time.h>
82 int main()
83 {
84 struct timeval* current_time = 0;
85 return utimes("/example", current_time);
86 }
87 #endif
88
89 #ifdef TEST_KWSYS_CXX_HAS_UTIMENSAT
90 # include <fcntl.h>
91 # include <sys/stat.h>
92 # if defined(__APPLE__)
93 # include <AvailabilityMacros.h>
94 # if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
95 # error "utimensat not available on macOS < 10.13"
96 # endif
97 # endif
98 int main()
99 {
100 struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } };
101 return utimensat(AT_FDCWD, "/example", times, AT_SYMLINK_NOFOLLOW);
102 }
103 #endif
104
105 #ifdef TEST_KWSYS_CXX_HAS_BACKTRACE
106 # if defined(__PATHSCALE__) || defined(__PATHCC__) || \
107 (defined(__LSB_VERSION__) && (__LSB_VERSION__ < 41))
108 backtrace does not work with this compiler or os
109 # endif
110 # if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
111 # define _GNU_SOURCE
112 # endif
113 # include <execinfo.h>
114 int main()
115 {
116 void* stackSymbols[256];
117 backtrace(stackSymbols, 256);
118 backtrace_symbols(&stackSymbols[0], 1);
119 return 0;
120 }
121 #endif
122
123 #ifdef TEST_KWSYS_CXX_HAS_DLADDR
124 # if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
125 # define _GNU_SOURCE
126 # endif
127 # include <dlfcn.h>
128 int main()
129 {
130 Dl_info info;
131 int ierr = dladdr((void*)main, &info);
132 return 0;
133 }
134 #endif
135
136 #ifdef TEST_KWSYS_CXX_HAS_CXXABI
137 # if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
138 # define _GNU_SOURCE
139 # endif
140 # if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5130 && __linux && \
141 __SUNPRO_CC_COMPAT == 'G'
142 # include <iostream>
143 # endif
144 # include <cxxabi.h>
145 int main()
146 {
147 int status = 0;
148 size_t bufferLen = 512;
149 char buffer[512] = { '\0' };
150 const char* function = "_ZN5kwsys17SystemInformation15GetProgramStackEii";
151 char* demangledFunction =
152 abi::__cxa_demangle(function, buffer, &bufferLen, &status);
153 return status;
154 }
155 #endif
156
157 #ifdef TEST_KWSYS_STL_HAS_WSTRING
158 # include <string>
159 void f(std::wstring*)
160 {
161 }
162 int main()
163 {
164 return 0;
165 }
166 #endif
167
168 #ifdef TEST_KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H
169 # include <ext/stdio_filebuf.h>
170 int main()
171 {
172 return 0;
173 }
174 #endif