2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 | Index | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | RE: _WIN32_WINNT defines in EPICS base |
From: | Freddie Akeroyd - UKRI STFC via Core-talk <[email protected]> |
To: | "EPICS core-talk ([email protected])" <[email protected]> |
Date: | Fri, 17 May 2019 22:47:21 +0000 |
Hi Andrew, Setting _WIN32_WINNT should just be restricting the available windows API functions you are prepared to access from the windows SDK you are compiling against. It doesn’t (ususally) trigger a change in behaviour
of an existing function, but that is something I have double checked. Certainly the documentation for the windows functions called in these files do not mention any change in behaviour between version, other than a caveat on GetVersionEx() that it is being
deprecated because it may not return quite what you think for later versions of windows. The current check for “thisIsNT” will return true for windows 2000 and above, so given the intended support targets of base this check could now be dropped and the code
simplified too. When re-checking the original files my only area of concern is with SetThreadName.cpp . The code here says it was taken from a visual c++ example, I located a newer version of this example at
https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code?view=vs-2019 which seems to have added pack pragmas and use sizeof(ULONG_PTR) rather than sizeof(DWORD) which makes me think the existing implementation in base
may not be 64bit safe. The original base code also only defines _WIN32_WINNT to be 0x400 on 64bit windows, which seems odd as windows that far back wasn’t 64bit! It may be that this is a trick that makes it work on 64bit windows? Given this slight oddness
it is probably best to update the code in this file to that from the link, and also to look at using the mentioned SetThreadDescription() function on more recent windows versions. I am happy to look at this and submit a patch.
The only other change that would happen with removing the _WIN32_WINNT defines is that there is a call to GetModuleHandleEx() in osdThread.c that is protected by “if _WIN32_WINNT >= 0x0501” and so would previously
never been used with _WIN32_WINNT being set to 0x0400. If base will now only support XP / 2003 and later, the second part of this conditional could be removed too. Given I’ve removed the _WIN32_WINNT defines from our code here already, maybe the best thing is for me to report back in a few weeks time as to whether I’ve had any problems. The code in SetThreadName.cpp is
only ever used on debug builds so would not affect any deployments here, I’ll test it separately and also conditionally enable a SetThreadDescription() option on newer windows builds Regards, Freddie From:
[email protected] [mailto:[email protected]] On Behalf Of
Johnson, Andrew N. via Core-talk Hi Freddie, On 5/15/19 5:28 AM, Freddie Akeroyd - UKRI STFC via Core-talk wrote:
If you think we can safely remove all those tests and definitions from libCom/osi/os/WIN32 for the "recent-enough" versions of Windows we should
support I'd be fine with doing that. -- Complexity comes for free, Simplicity you have to work for. |