Cygwin: (mostly) drop NT4 and Samba < 3.0 support
[newlib-cygwin.git] / winsup / cygwin / wincap.cc
blob30d9c14e8d3b1efaa8e7c46df101dd4ff32b9748
1 /* wincap.cc -- figure out on which OS we're running. Set the
2 capability class to the appropriate values.
4 This file is part of Cygwin.
6 This software is a copyrighted work licensed under the terms of the
7 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
8 details. */
10 #include "winsup.h"
11 #include "miscfuncs.h"
12 #include "security.h"
13 #include "ntdll.h"
14 #include "memory_layout.h"
16 static const wincaps wincap_8_1 = {
18 has_new_pebteb_region:false,
19 has_unprivileged_createsymlink:false,
20 has_precise_interrupt_time:false,
21 has_posix_unlink_semantics:false,
22 has_posix_unlink_semantics_with_ignore_readonly:false,
23 has_case_sensitive_dirs:false,
24 has_posix_rename_semantics:false,
25 has_con_24bit_colors:false,
26 has_con_broken_csi3j:false,
27 has_con_broken_il_dl:false,
28 has_con_esc_rep:false,
29 has_extended_mem_api:false,
30 has_tcp_fastopen:false,
31 has_linux_tcp_keepalive_sockopts:false,
32 has_tcp_maxrtms:false,
33 has_con_broken_tabs:false,
34 has_user_shstk:false,
38 static const wincaps wincap_10_1507 = {
40 has_new_pebteb_region:false,
41 has_unprivileged_createsymlink:false,
42 has_precise_interrupt_time:true,
43 has_posix_unlink_semantics:false,
44 has_posix_unlink_semantics_with_ignore_readonly:false,
45 has_case_sensitive_dirs:false,
46 has_posix_rename_semantics:false,
47 has_con_24bit_colors:false,
48 has_con_broken_csi3j:false,
49 has_con_broken_il_dl:false,
50 has_con_esc_rep:false,
51 has_extended_mem_api:false,
52 has_tcp_fastopen:false,
53 has_linux_tcp_keepalive_sockopts:false,
54 has_tcp_maxrtms:false,
55 has_con_broken_tabs:false,
56 has_user_shstk:false,
60 static const wincaps wincap_10_1607 = {
62 has_new_pebteb_region:false,
63 has_unprivileged_createsymlink:false,
64 has_precise_interrupt_time:true,
65 has_posix_unlink_semantics:false,
66 has_posix_unlink_semantics_with_ignore_readonly:false,
67 has_case_sensitive_dirs:false,
68 has_posix_rename_semantics:false,
69 has_con_24bit_colors:false,
70 has_con_broken_csi3j:false,
71 has_con_broken_il_dl:false,
72 has_con_esc_rep:false,
73 has_extended_mem_api:false,
74 has_tcp_fastopen:true,
75 has_linux_tcp_keepalive_sockopts:false,
76 has_tcp_maxrtms:true,
77 has_con_broken_tabs:false,
78 has_user_shstk:false,
82 static const wincaps wincap_10_1703 = {
84 has_new_pebteb_region:true,
85 has_unprivileged_createsymlink:true,
86 has_precise_interrupt_time:true,
87 has_posix_unlink_semantics:false,
88 has_posix_unlink_semantics_with_ignore_readonly:false,
89 has_case_sensitive_dirs:false,
90 has_posix_rename_semantics:false,
91 has_con_24bit_colors:true,
92 has_con_broken_csi3j:false,
93 has_con_broken_il_dl:false,
94 has_con_esc_rep:false,
95 has_extended_mem_api:false,
96 has_tcp_fastopen:true,
97 has_linux_tcp_keepalive_sockopts:false,
98 has_tcp_maxrtms:true,
99 has_con_broken_tabs:true,
100 has_user_shstk:false,
104 static const wincaps wincap_10_1709 = {
106 has_new_pebteb_region:true,
107 has_unprivileged_createsymlink:true,
108 has_precise_interrupt_time:true,
109 has_posix_unlink_semantics:true,
110 has_posix_unlink_semantics_with_ignore_readonly:false,
111 has_case_sensitive_dirs:false,
112 has_posix_rename_semantics:false,
113 has_con_24bit_colors:true,
114 has_con_broken_csi3j:false,
115 has_con_broken_il_dl:false,
116 has_con_esc_rep:false,
117 has_extended_mem_api:false,
118 has_tcp_fastopen:true,
119 has_linux_tcp_keepalive_sockopts:true,
120 has_tcp_maxrtms:true,
121 has_con_broken_tabs:true,
122 has_user_shstk:false,
126 static const wincaps wincap_10_1803 = {
128 has_new_pebteb_region:true,
129 has_unprivileged_createsymlink:true,
130 has_precise_interrupt_time:true,
131 has_posix_unlink_semantics:true,
132 has_posix_unlink_semantics_with_ignore_readonly:false,
133 has_case_sensitive_dirs:true,
134 has_posix_rename_semantics:false,
135 has_con_24bit_colors:true,
136 has_con_broken_csi3j:false,
137 has_con_broken_il_dl:false,
138 has_con_esc_rep:false,
139 has_extended_mem_api:true,
140 has_tcp_fastopen:true,
141 has_linux_tcp_keepalive_sockopts:true,
142 has_tcp_maxrtms:true,
143 has_con_broken_tabs:true,
144 has_user_shstk:false,
148 static const wincaps wincap_10_1809 = {
150 has_new_pebteb_region:true,
151 has_unprivileged_createsymlink:true,
152 has_precise_interrupt_time:true,
153 has_posix_unlink_semantics:true,
154 has_posix_unlink_semantics_with_ignore_readonly:true,
155 has_case_sensitive_dirs:true,
156 has_posix_rename_semantics:true,
157 has_con_24bit_colors:true,
158 has_con_broken_csi3j:true,
159 has_con_broken_il_dl:false,
160 has_con_esc_rep:false,
161 has_extended_mem_api:true,
162 has_tcp_fastopen:true,
163 has_linux_tcp_keepalive_sockopts:true,
164 has_tcp_maxrtms:true,
165 has_con_broken_tabs:true,
166 has_user_shstk:false,
170 static const wincaps wincap_10_1903 = {
172 has_new_pebteb_region:true,
173 has_unprivileged_createsymlink:true,
174 has_precise_interrupt_time:true,
175 has_posix_unlink_semantics:true,
176 has_posix_unlink_semantics_with_ignore_readonly:true,
177 has_case_sensitive_dirs:true,
178 has_posix_rename_semantics:true,
179 has_con_24bit_colors:true,
180 has_con_broken_csi3j:false,
181 has_con_broken_il_dl:true,
182 has_con_esc_rep:true,
183 has_extended_mem_api:true,
184 has_tcp_fastopen:true,
185 has_linux_tcp_keepalive_sockopts:true,
186 has_tcp_maxrtms:true,
187 has_con_broken_tabs:true,
188 has_user_shstk:false,
192 static const wincaps wincap_10_2004 = {
194 has_new_pebteb_region:true,
195 has_unprivileged_createsymlink:true,
196 has_precise_interrupt_time:true,
197 has_posix_unlink_semantics:true,
198 has_posix_unlink_semantics_with_ignore_readonly:true,
199 has_case_sensitive_dirs:true,
200 has_posix_rename_semantics:true,
201 has_con_24bit_colors:true,
202 has_con_broken_csi3j:false,
203 has_con_broken_il_dl:false,
204 has_con_esc_rep:true,
205 has_extended_mem_api:true,
206 has_tcp_fastopen:true,
207 has_linux_tcp_keepalive_sockopts:true,
208 has_tcp_maxrtms:true,
209 has_con_broken_tabs:true,
210 has_user_shstk:true,
214 static const wincaps wincap_11 = {
216 has_new_pebteb_region:true,
217 has_unprivileged_createsymlink:true,
218 has_precise_interrupt_time:true,
219 has_posix_unlink_semantics:true,
220 has_posix_unlink_semantics_with_ignore_readonly:true,
221 has_case_sensitive_dirs:true,
222 has_posix_rename_semantics:true,
223 has_con_24bit_colors:true,
224 has_con_broken_csi3j:false,
225 has_con_broken_il_dl:false,
226 has_con_esc_rep:true,
227 has_extended_mem_api:true,
228 has_tcp_fastopen:true,
229 has_linux_tcp_keepalive_sockopts:true,
230 has_tcp_maxrtms:true,
231 has_con_broken_tabs:false,
232 has_user_shstk:true,
236 wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
238 void
239 wincapc::init ()
241 if (caps)
242 return; // already initialized
244 GetSystemInfo (&system_info);
245 version.dwOSVersionInfoSize = sizeof (RTL_OSVERSIONINFOEXW);
246 RtlGetVersion (&version);
247 /* Overwrite unreliable kernel version with correct values returned by
248 RtlGetNtVersionNumbers. See git log of this change for a description. */
249 RtlGetNtVersionNumbers (&version.dwMajorVersion,
250 &version.dwMinorVersion,
251 &version.dwBuildNumber);
252 version.dwBuildNumber &= 0xffff;
254 switch (version.dwMajorVersion)
256 case 6:
257 caps = &wincap_8_1;
258 break;
259 case 10:
260 default:
261 if (likely (version.dwBuildNumber >= 22000))
262 caps = &wincap_11;
263 else if (version.dwBuildNumber >= 19041)
264 caps = &wincap_10_2004;
265 else if (version.dwBuildNumber >= 18362)
266 caps = &wincap_10_1903;
267 else if (version.dwBuildNumber >= 17763)
268 caps = &wincap_10_1809;
269 else if (version.dwBuildNumber >= 17134)
270 caps = &wincap_10_1803;
271 else if (version.dwBuildNumber >= 16299)
272 caps = &wincap_10_1709;
273 else if (version.dwBuildNumber >= 15063)
274 caps = &wincap_10_1703;
275 else if (version.dwBuildNumber >= 14393)
276 caps = &wincap_10_1607;
277 else
278 caps = & wincap_10_1507;
281 _is_server = (version.wProductType != VER_NT_WORKSTATION);
283 __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
284 version.dwMinorVersion);