Boost C++ Libraries: Ticket #8070: prefer GetTickCount64 over GetTickCount https://svn.boost.org/trac10/ticket/8070 <p> Visual Studio 2012 static analysis issues a warning C28159 (Consider using another function instead), namely for the three calls to <a class="missing wiki">GetTickCount</a> in thread_data.hpp. </p> <p> This should be an almost in-place replacement (with the addition that the variables should be ULONGLONG instead of ULONG). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8070 Trac 1.4.3 viboes Sat, 16 Feb 2013 08:02:38 GMT owner, status, severity changed https://svn.boost.org/trac10/ticket/8070#comment:1 https://svn.boost.org/trac10/ticket/8070#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> </ul> <p> Could you post the exact compiler report here? </p> Ticket alex@… Sat, 16 Feb 2013 16:39:34 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:2</guid> <description> <p> Absolutely: </p> <p> C28159 Consider using another function instead. </p> <p> Consider using 'GetTickCount64' instead of '<a class="missing wiki">GetTickCount</a>'. </p> <p> Reason: <a class="missing wiki">GetTickCount</a> overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 16 Feb 2013 21:42:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:3</guid> <description> <p> Can we check if this function is available using conditional compilation? </p> </description> <category>Ticket</category> </item> <item> <author>alex@…</author> <pubDate>Sat, 16 Feb 2013 22:07:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:4</guid> <description> <p> According to MSDN, this is available for WINNT &gt;= 0x0600 (aka <a class="missing wiki">Vista/Server</a> 2008) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 16 Feb 2013 23:23:46 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8070#comment:5 https://svn.boost.org/trac10/ticket/8070#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> Ticket viboes Sat, 23 Mar 2013 01:54:50 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8070#comment:6 https://svn.boost.org/trac10/ticket/8070#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/83525" title="Thread: merge from trunk. 1.54">[83525]</a>. </p> Ticket anonymous Tue, 02 Jul 2013 15:54:27 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:7</guid> <description> <p> Boost 1.54.0: This is breaking Windows XP compatibility for me: I'm compiling on Windows 7 with MinGW, but my users are on XP and are now seeing" Procedure Entry Point Not Found in Kernel32.dll". I have to revert back to Boost 1.52. </p> <p> Regards, Zenju </p> </description> <category>Ticket</category> </item> <item> <author>schorsch_76@…</author> <pubDate>Wed, 03 Jul 2013 10:00:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:8</guid> <description> <p> Same problem here as Zenju, </p> <p> there seems no compatibility switch in the source. Is there an official statement for boost to not support XP anymore? Have not found anything in the release notes, that XP is no more supported. </p> <p> Regards, Georg </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 03 Jul 2013 21:13:17 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/8070#comment:9 https://svn.boost.org/trac10/ticket/8070#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Sorry for the disturbance. Please could you comment this line </p> <blockquote> <p> 22 #define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 </p> </blockquote> <p> in the following context. </p> <pre class="wiki">branches/release/boost/thread/win32/thread_primitives.hpp r81667 r83525 18 18 #include &lt;algorithm&gt; 19 19 20 #ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 21 #if _WIN32_WINNT &gt;= 0x0600 22 #define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 23 #endif 24 #endif </pre><p> Could someone try using a more restrictive check than </p> <pre class="wiki">_WIN32_WINNT &gt;= 0x0600 </pre><p> ? </p> <p> Maybe something specific to Vista? </p> Ticket viboes Wed, 03 Jul 2013 21:17:30 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:10</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/84946" title="Thread: rollback change in #8070 as this includes a regression on ...">[84946]</a>. Rollback. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 04 Jul 2013 19:53:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:11</guid> <description> <p> Thanks for the quick response! After commenting out BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 and recompiling Boost 1.54, my binaries are running fine on XP again! Currently 30% of my users are still running XP so thanks for supporting this not so small scenario! </p> <p> Regards, Zenju </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 03 Aug 2013 11:22:09 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8070#comment:12 https://svn.boost.org/trac10/ticket/8070#comment:12 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.54.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket viboes Sun, 15 Sep 2013 15:39:35 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:13</guid> <description> <p> Could someone try if </p> <p> branches/release/boost/thread/win32/thread_primitives.hpp </p> <pre class="wiki">#ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 #if _WIN32_WINNT &gt;= 0x0600 &amp;&amp; ! defined _WIN32_WINNT_WS08 #define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 #endif #endif </pre><p> works for Windows XP? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 16 Sep 2013 16:37:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:14</guid> <description> <p> yes it works </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 16 Sep 2013 16:55:55 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8070#comment:15 https://svn.boost.org/trac10/ticket/8070#comment:15 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85701" title="Thread: patch for #8070 to make use of GetTickCount64 when available.">[85701]</a>. Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85714" title="Thread: patch for #8070 to make use of GetTickCount64 when available.">[85714]</a>. </p> Ticket ixSci <beholder@…> Wed, 18 Sep 2013 10:05:43 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:16</guid> <description> <p> Just tested on Win8.1(boost rev. 85771) and it doesn't compile: libs\thread\src\win32\thread.cpp(433) : error C2653: 'win32' : is not a class or namespace name I believe it should be: unsigned long const elapsed_milliseconds=<strong>detail::</strong>win32::<a class="missing wiki">GetTickCount</a>()-target_time.start; </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 18 Sep 2013 10:59:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:17</guid> <description> <p> My bad :( Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85772" title="Thread: add detail:: to access detail::win32::GetTickCount64().">[85772]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 21 Sep 2013 20:45:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:18</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85815" title="Thread: merge from trunk to fix 8070 and possibly 7461.">[85815]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 21 Sep 2013 20:50:01 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8070#comment:19 https://svn.boost.org/trac10/ticket/8070#comment:19 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket anonymous Mon, 18 Nov 2013 17:04:52 GMT status, version, severity changed; resolution deleted https://svn.boost.org/trac10/ticket/8070#comment:20 https://svn.boost.org/trac10/ticket/8070#comment:20 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.52.0</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Cosmetic</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> Hi, </p> <p> the "Procedure Entry Point Not Found" for GetTickCount64 is back or I should better say was not resolved in first place. The </p> <pre class="wiki">#ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 #if _WIN32_WINNT &gt;= 0x0600 &amp;&amp; ! defined _WIN32_WINNT_WS08 #define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 #endif #endif </pre><p> check always enables the GetTickCount64, because _WIN32_WINNT is usually set to 0x0600. This value for _WIN32_WINNT OTOH is *always* required, even when targetting XP in order to have access to Vista and later Win32 structs when the very same executable is supposed to run on later versions of Windows. Commenting out BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 again fixes the issue, but I would very much prefer to use a vanilla version of boost without requiring manual source changes before I can use. </p> <p> Regards, Zenju </p> Ticket viboes Tue, 19 Nov 2013 22:21:23 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:21 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:21</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8070#comment:20" title="Comment 20">anonymous</a>: </p> <blockquote class="citation"> <p> Hi, </p> <p> the "Procedure Entry Point Not Found" for GetTickCount64 is back or I should better say was not resolved in first place. The </p> <pre class="wiki">#ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 #if _WIN32_WINNT &gt;= 0x0600 &amp;&amp; ! defined _WIN32_WINNT_WS08 #define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 #endif #endif </pre><p> check always enables the GetTickCount64, because _WIN32_WINNT is usually set to 0x0600. This value for _WIN32_WINNT OTOH is *always* required, even when targetting XP in order to have access to Vista and later Win32 structs when the very same executable is supposed to run on later versions of Windows. </p> </blockquote> <p> Is _WIN32_WINNT_WS08 defined? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 19 Nov 2013 22:21:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:22 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:22</guid> <description> <p> BTW, what are the android.exe? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>tcourtney</dc:creator> <pubDate>Wed, 04 Dec 2013 19:53:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:23 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:23</guid> <description> <p> I have a question about this issue and the proposed solution. We compile our software on Windows 7 but want the binaries to be compatible for all versions of Windows. It seems that any solution for this issue that relies on #ifdef, #define to determine the OS properties is only valid for the OS that the software was compiled on. I don't see how a solution based on static, compile time #ifdef logic could support both <a class="missing wiki">GetTickCount</a> for XP and GetTickCount64 for Windows 7 using the same binary. This #ifdef fix only makes it possible to compile the code on XP or Windows7. But that doesn't fix the issue for my company because we need to release the same binary for XP and Windows 7. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 04 Dec 2013 22:09:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:24 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:24</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8070#comment:23" title="Comment 23">tcourtney</a>: </p> <blockquote class="citation"> <p> I have a question about this issue and the proposed solution. We compile our software on Windows 7 but want the binaries to be compatible for all versions of Windows. It seems that any solution for this issue that relies on #ifdef, #define to determine the OS properties is only valid for the OS that the software was compiled on. I don't see how a solution based on static, compile time #ifdef logic could support both <a class="missing wiki">GetTickCount</a> for XP and GetTickCount64 for Windows 7 using the same binary. This #ifdef fix only makes it possible to compile the code on XP or Windows7. But that doesn't fix the issue for my company because we need to release the same binary for XP and Windows 7. </p> </blockquote> <p> And you propose ... </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Thu, 19 Dec 2013 11:45:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:25 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:25</guid> <description> <p> _WIN32_WINNT_WS08 is always defined if the windows.h from at least the Windows SDK 6.0 is included before Boost.Thread, so the value of BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 can now vary in different source files depending on include order, which leads to serious bugs. </p> <p> _WIN32_WINNT is the lowest Windows version the software is supposed to run on, so defining it as 0x0600 while still wanting to support Windows XP is incorrect and boost users should fix their code. Boost.Thread is by far not the only library that would drop support for Windows XP when _WIN32_WINNT is defined as 0x0600. </p> <p> So if you want a static check for the minimum required Windows version at compile time, the check for (_WIN32_WINNT &gt;= 0x0600) was absolutely correct. If you want a dynamic check at runtime, you need to call <a class="missing wiki">GetProcAddress</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 28 Jan 2014 20:59:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:26 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:26</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8070#comment:25" title="Comment 25">raad@…</a>: </p> <blockquote class="citation"> <p> _WIN32_WINNT_WS08 is always defined if the windows.h from at least the Windows SDK 6.0 is included before Boost.Thread, so the value of BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64 can now vary in different source files depending on include order, which leads to serious bugs. </p> <p> _WIN32_WINNT is the lowest Windows version the software is supposed to run on, so defining it as 0x0600 while still wanting to support Windows XP is incorrect and boost users should fix their code. Boost.Thread is by far not the only library that would drop support for Windows XP when _WIN32_WINNT is defined as 0x0600. </p> <p> So if you want a static check for the minimum required Windows version at compile time, the check for (_WIN32_WINNT &gt;= 0x0600) was absolutely correct. If you want a dynamic check at runtime, you need to call <a class="missing wiki">GetProcAddress</a>. </p> </blockquote> <p> I have no access to a Windows machine now. I would be grateful of could you provide a patch that works for any windows release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 28 Jan 2014 21:07:35 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8070#comment:27 https://svn.boost.org/trac10/ticket/8070#comment:27 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.55.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket raad@… Sun, 02 Feb 2014 14:40:52 GMT attachment set https://svn.boost.org/trac10/ticket/8070 https://svn.boost.org/trac10/ticket/8070 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gettickcount64.patch</span> </li> </ul> <p> Determine GetTickCount64 support at runtime </p> Ticket raad@… Sun, 02 Feb 2014 14:56:27 GMT <link>https://svn.boost.org/trac10/ticket/8070#comment:28 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:28</guid> <description> <p> Please find attached a patch with a run-time check for GetTickCount64 availability. Please note that ticks_type is always 64-bit with this patch and I don't think it's possible to implement this header-only without a huge run-time overhead, so there is a new cpp file. </p> <p> Alternatively, for the correct compile-time check for the target Windows version, you could just revert commit 3ac48bdd65c4713438779e65a3f5ee4324a03b55 and add a macro like BOOST_THREAD_WIN32_DONT_USE_GET_TICK_COUNT_64 for those who are not willing to set their target Windows version correctly via _WIN32_WINNT. Or only let the user set BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 02 Feb 2014 21:39:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8070#comment:29 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8070#comment:29</guid> <description> <p> Thanks for the patch. I will take a deeper look as soon as I reinstall all the needed tools on my new Windows machine. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 01 Mar 2014 07:52:49 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8070#comment:30 https://svn.boost.org/trac10/ticket/8070#comment:30 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/143adde27d7bf06d972d2ff0c4757f715e6107f2"><span class="icon">​</span>https://github.com/boostorg/thread/commit/143adde27d7bf06d972d2ff0c4757f715e6107f2</a> </p> Ticket viboes Wed, 12 Mar 2014 22:46:26 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8070#comment:31 https://svn.boost.org/trac10/ticket/8070#comment:31 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket