public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: wincap: make capability flags readonly Date: Thu, 12 Jan 2023 09:52:52 +0000 (GMT) [thread overview] Message-ID: <20230112095252.47B413858D35@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e7d0f0eb411f952f708ed12768ad556c136030e6 commit e7d0f0eb411f952f708ed12768ad556c136030e6 Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Thu Jan 12 10:33:52 2023 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Thu Jan 12 10:34:32 2023 +0100 Cygwin: wincap: make capability flags readonly So far the capability bits were stored in the .cygwin_dll_common R/W section because we overwrite the is_server bit. Just don't. Move the bit to class wincapc instead and define all wincaps bitfields const. Fixes: 8937c103ed141 ("* wincap.cc (all wincaps): Store in .cygwin_dll_common section same as wincap. Add comment to explain why.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/local_includes/wincap.h | 6 +++--- winsup/cygwin/wincap.cc | 38 ++++++++++------------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/winsup/cygwin/local_includes/wincap.h b/winsup/cygwin/local_includes/wincap.h index c6dbd2311078..29a7a63de7f6 100644 --- a/winsup/cygwin/local_includes/wincap.h +++ b/winsup/cygwin/local_includes/wincap.h @@ -16,7 +16,6 @@ struct wincaps /* The bitfields must be 8 byte aligned on x86_64, otherwise the bitfield ops generated by gcc are off by 4 bytes. */ struct __attribute__ ((aligned (8))) { - unsigned is_server : 1; unsigned has_new_pebteb_region : 1; unsigned has_unprivileged_createsymlink : 1; unsigned has_precise_interrupt_time : 1; @@ -41,7 +40,8 @@ class wincapc SYSTEM_INFO system_info; RTL_OSVERSIONINFOEXW version; char osnam[40]; - void *caps; + const void *caps; + bool _is_server; public: void init (); @@ -67,7 +67,7 @@ public: { return DEFAULT_GUARD_PAGE_COUNT * page_size (); } - bool IMPLEMENT (is_server) + bool is_server () const { return _is_server; } bool IMPLEMENT (has_new_pebteb_region) bool IMPLEMENT (has_unprivileged_createsymlink) bool IMPLEMENT (has_precise_interrupt_time) diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index cc10e90dccab..91d5d9df8889 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -13,15 +13,8 @@ details. */ #include "ntdll.h" #include "memory_layout.h" -/* CV, 2008-10-23: All wincapc's have to be in the .cygwin_dll_common section, - same as wincap itself. Otherwise the capability changes made in - wincapc::init() are not propagated to any subsequently started process - in the same session. I'm only writing this longish comment because I'm - puzzled that this has never been noticed before... */ - -wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_8_1 = { { - is_server:false, has_new_pebteb_region:false, has_unprivileged_createsymlink:false, has_precise_interrupt_time:false, @@ -41,9 +34,8 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = { }, }; -wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1507 = { { - is_server:false, has_new_pebteb_region:false, has_unprivileged_createsymlink:false, has_precise_interrupt_time:true, @@ -63,9 +55,8 @@ wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared)) }, }; -wincaps wincap_10_1607 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1607 = { { - is_server:false, has_new_pebteb_region:false, has_unprivileged_createsymlink:false, has_precise_interrupt_time:true, @@ -85,9 +76,8 @@ wincaps wincap_10_1607 __attribute__((section (".cygwin_dll_common"), shared)) }, }; -wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1703 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -107,9 +97,8 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) = }, }; -wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1709 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -129,9 +118,8 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) = }, }; -wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1803 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -151,9 +139,8 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) = }, }; -wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1809 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -173,9 +160,8 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) = }, }; -wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_1903 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -195,9 +181,8 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) = }, }; -wincaps wincap_10_2004 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_10_2004 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -217,9 +202,8 @@ wincaps wincap_10_2004 __attribute__((section (".cygwin_dll_common"), shared)) = }, }; -wincaps wincap_11 __attribute__((section (".cygwin_dll_common"), shared)) = { +static const wincaps wincap_11 = { { - is_server:false, has_new_pebteb_region:true, has_unprivileged_createsymlink:true, has_precise_interrupt_time:true, @@ -284,7 +268,7 @@ wincapc::init () caps = & wincap_10_1507; } - ((wincaps *)caps)->is_server = (version.wProductType != VER_NT_WORKSTATION); + _is_server = (version.wProductType != VER_NT_WORKSTATION); __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion, version.dwMinorVersion);
reply other threads:[~2023-01-12 9:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230112095252.47B413858D35@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).