Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On Mon, Sep 12, 2011 at 10:45:31PM +0200, CaStarCo wrote:

@Lionel , What is the QuadPart member of the structure? The high
part? the low part? or another thing?

The union is fully described at
http://msdn.microsoft.com/en-us/library/aa383713(v=vs.85).aspx

Are you familiar with the concept of C/C++ union? If not, Google gives
a few hits that don't seem too bad at first sight:

 http://www.cplusplus.com/doc/tutorial/other_data_types/#union
 http://www.go4expert.com/forums/showthread.php?t=15
 http://en.wikipedia.org/wiki/Union_(computer_science)
 http://msdn.microsoft.com/en-us/library/y9zewe0d(v=vs.80).aspx

To get to your question, the QuadPart is the whole 64 bits, that is
the combination of the high part *and* the low part.

Essentially, the paragraph I quoted says that to treat the FILETIME
value as a 64bit integer, one should proceed as such:

__int64     Value;
FILETIME *ft = // some value
ULARGE_INTEGER t;
t.LowPart = ft->dwLowDateTime;
t.HighPart = ft->dwHighDateTime;
// Now, t.QuadPart contains the right 64 bits integer
Value = t.QuadPart; // or use t.QuadPart directly instead of Value

instead of:

Value = *(__int64*)ft;


Do not hesitate to CC to me any additional question you have on this
matter.


2011/9/12 Lionel Elie Mamane <lionel@mamane.lu>

On Sun, Sep 11, 2011 at 10:04:52PM +0200, CaStarCo wrote:
I've created a second (very little too) patch to reduce the scope of a
variable.

--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -60,7 +60,6 @@ extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME 
*pFTime

Thank you for your contribution to LibreOffice, it is most
welcome. Looking at that function in that file, it needs a more
thorough cleanup, and maybe other functions in that file and/or in
other files in the same directory; see
http://msdn.microsoft.com/en-us/library/ms724284%28v=VS.85%29.aspx, in
particular:

 It is not recommended that you add and subtract values from the
 FILETIME structure to obtain relative times. Instead, you should copy
 the low- and high-order parts of the file time to a ULARGE_INTEGER
 structure, perform 64-bit arithmetic on the QuadPart member, and copy
 the LowPart and HighPart members into the FILETIME structure.

 Do not cast a pointer to a FILETIME structure to either a
 ULARGE_INTEGER* or __int64* value because it can cause alignment
 faults on 64-bit Windows.

It would be best to look at every place that FILETIME is used in that
directory.

Just in case you want to volunteer for that cleanup :)

When you send a patch, could you please confirm the patch is licensed
under MPL1.1/LGPLv3+? To make things easier, you can do a one-time
blanket "all my patches" thing if you wish, sort of common to do that.

-- 
Lionel

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.