]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/wincap.cc
Cygwin: tcp: Support TCP_USER_TIMEOUT
[newlib-cygwin.git] / winsup / cygwin / wincap.cc
1 /* wincap.cc -- figure out on which OS we're running. Set the
2 capability class to the appropriate values.
3
4 This file is part of Cygwin.
5
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. */
9
10 #include "winsup.h"
11 #include "miscfuncs.h"
12 #include "security.h"
13 #include "ntdll.h"
14
15 /* CV, 2008-10-23: All wincapc's have to be in the .cygwin_dll_common section,
16 same as wincap itself. Otherwise the capability changes made in
17 wincapc::init() are not propagated to any subsequently started process
18 in the same session. I'm only writing this longish comment because I'm
19 puzzled that this has never been noticed before... */
20
21 wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
22 def_guard_pages:1,
23 mmap_storage_high:0x070000000000LL,
24 {
25 is_server:false,
26 needs_count_in_si_lpres2:true,
27 needs_query_information:true,
28 has_gaa_largeaddress_bug:true,
29 has_broken_alloc_console:false,
30 has_console_logon_sid:false,
31 has_precise_system_time:false,
32 has_microsoft_accounts:false,
33 has_processor_groups:false,
34 has_broken_prefetchvm:false,
35 has_new_pebteb_region:false,
36 has_broken_whoami:true,
37 has_unprivileged_createsymlink:false,
38 has_unbiased_interrupt_time:false,
39 has_precise_interrupt_time:false,
40 has_posix_unlink_semantics:false,
41 has_case_sensitive_dirs:false,
42 has_posix_rename_semantics:false,
43 no_msv1_0_s4u_logon_in_wow64:true,
44 has_con_24bit_colors:false,
45 has_con_broken_csi3j:false,
46 has_con_broken_il_dl:false,
47 has_con_esc_rep:false,
48 has_extended_mem_api:false,
49 has_tcp_fastopen:false,
50 has_linux_tcp_keepalive_sockopts:false,
51 has_tcp_maxrtms:false,
52 },
53 };
54
55 wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
56 def_guard_pages:1,
57 mmap_storage_high:0x070000000000LL,
58 {
59 is_server:false,
60 needs_count_in_si_lpres2:false,
61 needs_query_information:true,
62 has_gaa_largeaddress_bug:true,
63 has_broken_alloc_console:true,
64 has_console_logon_sid:true,
65 has_precise_system_time:false,
66 has_microsoft_accounts:false,
67 has_processor_groups:true,
68 has_broken_prefetchvm:false,
69 has_new_pebteb_region:false,
70 has_broken_whoami:true,
71 has_unprivileged_createsymlink:false,
72 has_unbiased_interrupt_time:true,
73 has_precise_interrupt_time:false,
74 has_posix_unlink_semantics:false,
75 has_case_sensitive_dirs:false,
76 has_posix_rename_semantics:false,
77 no_msv1_0_s4u_logon_in_wow64:true,
78 has_con_24bit_colors:false,
79 has_con_broken_csi3j:false,
80 has_con_broken_il_dl:false,
81 has_con_esc_rep:false,
82 has_extended_mem_api:false,
83 has_tcp_fastopen:false,
84 has_linux_tcp_keepalive_sockopts:false,
85 has_tcp_maxrtms:false,
86 },
87 };
88
89 wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
90 def_guard_pages:2,
91 mmap_storage_high:0x070000000000LL,
92 {
93 is_server:false,
94 needs_count_in_si_lpres2:false,
95 needs_query_information:true,
96 has_gaa_largeaddress_bug:false,
97 has_broken_alloc_console:true,
98 has_console_logon_sid:true,
99 has_precise_system_time:true,
100 has_microsoft_accounts:true,
101 has_processor_groups:true,
102 has_broken_prefetchvm:false,
103 has_new_pebteb_region:false,
104 has_broken_whoami:false,
105 has_unprivileged_createsymlink:false,
106 has_unbiased_interrupt_time:true,
107 has_precise_interrupt_time:false,
108 has_posix_unlink_semantics:false,
109 has_case_sensitive_dirs:false,
110 has_posix_rename_semantics:false,
111 no_msv1_0_s4u_logon_in_wow64:false,
112 has_con_24bit_colors:false,
113 has_con_broken_csi3j:false,
114 has_con_broken_il_dl:false,
115 has_con_esc_rep:false,
116 has_extended_mem_api:false,
117 has_tcp_fastopen:false,
118 has_linux_tcp_keepalive_sockopts:false,
119 has_tcp_maxrtms:false,
120 },
121 };
122
123 wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
124 def_guard_pages:2,
125 mmap_storage_high:0x700000000000LL,
126 {
127 is_server:false,
128 needs_count_in_si_lpres2:false,
129 needs_query_information:false,
130 has_gaa_largeaddress_bug:false,
131 has_broken_alloc_console:true,
132 has_console_logon_sid:true,
133 has_precise_system_time:true,
134 has_microsoft_accounts:true,
135 has_processor_groups:true,
136 has_broken_prefetchvm:false,
137 has_new_pebteb_region:false,
138 has_broken_whoami:false,
139 has_unprivileged_createsymlink:false,
140 has_unbiased_interrupt_time:true,
141 has_precise_interrupt_time:false,
142 has_posix_unlink_semantics:false,
143 has_case_sensitive_dirs:false,
144 has_posix_rename_semantics:false,
145 no_msv1_0_s4u_logon_in_wow64:false,
146 has_con_24bit_colors:false,
147 has_con_broken_csi3j:false,
148 has_con_broken_il_dl:false,
149 has_con_esc_rep:false,
150 has_extended_mem_api:false,
151 has_tcp_fastopen:false,
152 has_linux_tcp_keepalive_sockopts:false,
153 has_tcp_maxrtms:false,
154 },
155 };
156
157 wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared)) = {
158 def_guard_pages:2,
159 mmap_storage_high:0x700000000000LL,
160 {
161 is_server:false,
162 needs_count_in_si_lpres2:false,
163 needs_query_information:false,
164 has_gaa_largeaddress_bug:false,
165 has_broken_alloc_console:true,
166 has_console_logon_sid:true,
167 has_precise_system_time:true,
168 has_microsoft_accounts:true,
169 has_processor_groups:true,
170 has_broken_prefetchvm:true,
171 has_new_pebteb_region:false,
172 has_broken_whoami:false,
173 has_unprivileged_createsymlink:false,
174 has_unbiased_interrupt_time:true,
175 has_precise_interrupt_time:true,
176 has_posix_unlink_semantics:false,
177 has_case_sensitive_dirs:false,
178 has_posix_rename_semantics:false,
179 no_msv1_0_s4u_logon_in_wow64:false,
180 has_con_24bit_colors:false,
181 has_con_broken_csi3j:false,
182 has_con_broken_il_dl:false,
183 has_con_esc_rep:false,
184 has_extended_mem_api:false,
185 has_tcp_fastopen:false,
186 has_linux_tcp_keepalive_sockopts:false,
187 has_tcp_maxrtms:false,
188 },
189 };
190
191 wincaps wincap_10_1607 __attribute__((section (".cygwin_dll_common"), shared)) = {
192 def_guard_pages:2,
193 mmap_storage_high:0x700000000000LL,
194 {
195 is_server:false,
196 needs_count_in_si_lpres2:false,
197 needs_query_information:false,
198 has_gaa_largeaddress_bug:false,
199 has_broken_alloc_console:true,
200 has_console_logon_sid:true,
201 has_precise_system_time:true,
202 has_microsoft_accounts:true,
203 has_processor_groups:true,
204 has_broken_prefetchvm:true,
205 has_new_pebteb_region:false,
206 has_broken_whoami:false,
207 has_unprivileged_createsymlink:false,
208 has_unbiased_interrupt_time:true,
209 has_precise_interrupt_time:true,
210 has_posix_unlink_semantics:false,
211 has_case_sensitive_dirs:false,
212 has_posix_rename_semantics:false,
213 no_msv1_0_s4u_logon_in_wow64:false,
214 has_con_24bit_colors:false,
215 has_con_broken_csi3j:false,
216 has_con_broken_il_dl:false,
217 has_con_esc_rep:false,
218 has_extended_mem_api:false,
219 has_tcp_fastopen:true,
220 has_linux_tcp_keepalive_sockopts:false,
221 has_tcp_maxrtms:true,
222 },
223 };
224
225 wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) = {
226 def_guard_pages:2,
227 mmap_storage_high:0x700000000000LL,
228 {
229 is_server:false,
230 needs_count_in_si_lpres2:false,
231 needs_query_information:false,
232 has_gaa_largeaddress_bug:false,
233 has_broken_alloc_console:true,
234 has_console_logon_sid:true,
235 has_precise_system_time:true,
236 has_microsoft_accounts:true,
237 has_processor_groups:true,
238 has_broken_prefetchvm:false,
239 has_new_pebteb_region:true,
240 has_broken_whoami:false,
241 has_unprivileged_createsymlink:true,
242 has_unbiased_interrupt_time:true,
243 has_precise_interrupt_time:true,
244 has_posix_unlink_semantics:false,
245 has_case_sensitive_dirs:false,
246 has_posix_rename_semantics:false,
247 no_msv1_0_s4u_logon_in_wow64:false,
248 has_con_24bit_colors:true,
249 has_con_broken_csi3j:false,
250 has_con_broken_il_dl:false,
251 has_con_esc_rep:false,
252 has_extended_mem_api:false,
253 has_tcp_fastopen:true,
254 has_linux_tcp_keepalive_sockopts:false,
255 has_tcp_maxrtms:true,
256 },
257 };
258
259 wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) = {
260 def_guard_pages:2,
261 mmap_storage_high:0x700000000000LL,
262 {
263 is_server:false,
264 needs_count_in_si_lpres2:false,
265 needs_query_information:false,
266 has_gaa_largeaddress_bug:false,
267 has_broken_alloc_console:true,
268 has_console_logon_sid:true,
269 has_precise_system_time:true,
270 has_microsoft_accounts:true,
271 has_processor_groups:true,
272 has_broken_prefetchvm:false,
273 has_new_pebteb_region:true,
274 has_broken_whoami:false,
275 has_unprivileged_createsymlink:true,
276 has_unbiased_interrupt_time:true,
277 has_precise_interrupt_time:true,
278 has_posix_unlink_semantics:true,
279 has_case_sensitive_dirs:false,
280 has_posix_rename_semantics:false,
281 no_msv1_0_s4u_logon_in_wow64:false,
282 has_con_24bit_colors:true,
283 has_con_broken_csi3j:false,
284 has_con_broken_il_dl:false,
285 has_con_esc_rep:false,
286 has_extended_mem_api:false,
287 has_tcp_fastopen:true,
288 has_linux_tcp_keepalive_sockopts:true,
289 has_tcp_maxrtms:true,
290 },
291 };
292
293 wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) = {
294 def_guard_pages:2,
295 mmap_storage_high:0x700000000000LL,
296 {
297 is_server:false,
298 needs_count_in_si_lpres2:false,
299 needs_query_information:false,
300 has_gaa_largeaddress_bug:false,
301 has_broken_alloc_console:true,
302 has_console_logon_sid:true,
303 has_precise_system_time:true,
304 has_microsoft_accounts:true,
305 has_processor_groups:true,
306 has_broken_prefetchvm:false,
307 has_new_pebteb_region:true,
308 has_broken_whoami:false,
309 has_unprivileged_createsymlink:true,
310 has_unbiased_interrupt_time:true,
311 has_precise_interrupt_time:true,
312 has_posix_unlink_semantics:true,
313 has_case_sensitive_dirs:true,
314 has_posix_rename_semantics:false,
315 no_msv1_0_s4u_logon_in_wow64:false,
316 has_con_24bit_colors:true,
317 has_con_broken_csi3j:false,
318 has_con_broken_il_dl:false,
319 has_con_esc_rep:false,
320 has_extended_mem_api:true,
321 has_tcp_fastopen:true,
322 has_linux_tcp_keepalive_sockopts:true,
323 has_tcp_maxrtms:true,
324 },
325 };
326
327 wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) = {
328 def_guard_pages:2,
329 mmap_storage_high:0x700000000000LL,
330 {
331 is_server:false,
332 needs_count_in_si_lpres2:false,
333 needs_query_information:false,
334 has_gaa_largeaddress_bug:false,
335 has_broken_alloc_console:true,
336 has_console_logon_sid:true,
337 has_precise_system_time:true,
338 has_microsoft_accounts:true,
339 has_processor_groups:true,
340 has_broken_prefetchvm:false,
341 has_new_pebteb_region:true,
342 has_broken_whoami:false,
343 has_unprivileged_createsymlink:true,
344 has_unbiased_interrupt_time:true,
345 has_precise_interrupt_time:true,
346 has_posix_unlink_semantics:true,
347 has_case_sensitive_dirs:true,
348 has_posix_rename_semantics:true,
349 no_msv1_0_s4u_logon_in_wow64:false,
350 has_con_24bit_colors:true,
351 has_con_broken_csi3j:true,
352 has_con_broken_il_dl:false,
353 has_con_esc_rep:false,
354 has_extended_mem_api:true,
355 has_tcp_fastopen:true,
356 has_linux_tcp_keepalive_sockopts:true,
357 has_tcp_maxrtms:true,
358 },
359 };
360
361 wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) = {
362 def_guard_pages:2,
363 mmap_storage_high:0x700000000000LL,
364 {
365 is_server:false,
366 needs_count_in_si_lpres2:false,
367 needs_query_information:false,
368 has_gaa_largeaddress_bug:false,
369 has_broken_alloc_console:true,
370 has_console_logon_sid:true,
371 has_precise_system_time:true,
372 has_microsoft_accounts:true,
373 has_processor_groups:true,
374 has_broken_prefetchvm:false,
375 has_new_pebteb_region:true,
376 has_broken_whoami:false,
377 has_unprivileged_createsymlink:true,
378 has_unbiased_interrupt_time:true,
379 has_precise_interrupt_time:true,
380 has_posix_unlink_semantics:true,
381 has_case_sensitive_dirs:true,
382 has_posix_rename_semantics:true,
383 no_msv1_0_s4u_logon_in_wow64:false,
384 has_con_24bit_colors:true,
385 has_con_broken_csi3j:false,
386 has_con_broken_il_dl:true,
387 has_con_esc_rep:true,
388 has_extended_mem_api:true,
389 has_tcp_fastopen:true,
390 has_linux_tcp_keepalive_sockopts:true,
391 has_tcp_maxrtms:true,
392 },
393 };
394
395 wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
396
397 void
398 wincapc::init ()
399 {
400 if (caps)
401 return; // already initialized
402
403 GetSystemInfo (&system_info);
404 version.dwOSVersionInfoSize = sizeof (RTL_OSVERSIONINFOEXW);
405 RtlGetVersion (&version);
406 /* Overwrite unreliable kernel version with correct values returned by
407 RtlGetNtVersionNumbers. See git log of this change for a description. */
408 RtlGetNtVersionNumbers (&version.dwMajorVersion,
409 &version.dwMinorVersion,
410 &version.dwBuildNumber);
411 version.dwBuildNumber &= 0xffff;
412
413 switch (version.dwMajorVersion)
414 {
415 case 6:
416 switch (version.dwMinorVersion)
417 {
418 case 0:
419 caps = &wincap_vista;
420 break;
421 case 1:
422 caps = &wincap_7;
423 break;
424 case 2:
425 caps = &wincap_8;
426 break;
427 case 3:
428 default:
429 caps = &wincap_8_1;
430 break;
431 }
432 break;
433 case 10:
434 default:
435 if (likely (version.dwBuildNumber >= 18362))
436 caps = &wincap_10_1903;
437 else if (version.dwBuildNumber >= 17763)
438 caps = &wincap_10_1809;
439 else if (version.dwBuildNumber >= 17134)
440 caps = &wincap_10_1803;
441 else if (version.dwBuildNumber >= 16299)
442 caps = &wincap_10_1709;
443 else if (version.dwBuildNumber >= 15063)
444 caps = &wincap_10_1703;
445 else if (version.dwBuildNumber >= 14393)
446 caps = &wincap_10_1607;
447 else
448 caps = & wincap_10_1507;
449 }
450
451 ((wincaps *)caps)->is_server = (version.wProductType != VER_NT_WORKSTATION);
452 #ifdef __x86_64__
453 wow64 = 0;
454 /* 64 bit systems have one more guard page than their 32 bit counterpart. */
455 ++((wincaps *)caps)->def_guard_pages;
456 #else
457 if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
458 ProcessWow64Information,
459 &wow64, sizeof wow64, NULL))
460 && !wow64)
461 #endif
462 {
463 ((wincaps *)caps)->needs_count_in_si_lpres2 = false;
464 ((wincaps *)caps)->has_gaa_largeaddress_bug = false;
465 ((wincaps *)caps)->has_broken_prefetchvm = false;
466 ((wincaps *)caps)->no_msv1_0_s4u_logon_in_wow64 = false;
467 }
468
469 __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
470 version.dwMinorVersion);
471 }
This page took 0.05681 seconds and 5 git commands to generate.