hardcode value of filetime epoch

avoid unnecessary calls to SystemTimeToFileTime() in get_file_epoch() by hardcoding the FILETIME value of jan_1_1970

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2011-09-15 14:34:55 -04:00 committed by unknown
parent 5880a8bb1d
commit 3a115a39fa
2 changed files with 22 additions and 39 deletions

View file

@ -177,40 +177,6 @@ void nfs_to_standard_info(
TRUE : FALSE;
}
/* http://msdn.microsoft.com/en-us/library/ms724290%28VS.85%29.aspx:
* A file time is a 64-bit value that represents the number of
* 100-nanosecond intervals that have elapsed since 12:00 A.M.
* January 1, 1601 Coordinated Universal Time (UTC). */
static __inline void get_file_epoch(
OUT PLARGE_INTEGER time_out)
{
static const SYSTEMTIME jan_1_1970 = {1970, 1, 4, 1, 0, 0, 0, 0};
SystemTimeToFileTime(&jan_1_1970, (LPFILETIME)time_out);
}
void file_time_to_nfs_time(
IN const PLARGE_INTEGER file_time,
OUT nfstime4 *nfs_time)
{
LARGE_INTEGER diff;
get_file_epoch(&diff);
diff.QuadPart = file_time->QuadPart - diff.QuadPart;
nfs_time->seconds = diff.QuadPart / 10000000;
nfs_time->nseconds = (uint32_t)((diff.QuadPart % 10000000)*100);
}
void nfs_time_to_file_time(
IN const nfstime4 *nfs_time,
OUT PLARGE_INTEGER file_time)
{
LARGE_INTEGER diff;
get_file_epoch(&diff);
file_time->QuadPart = diff.QuadPart +
nfs_time->seconds * 10000000 +
nfs_time->nseconds / 100;
}
void get_file_time(
OUT PLARGE_INTEGER file_time)
{

View file

@ -94,13 +94,30 @@ void nfs_to_standard_info(
IN const nfs41_file_info *info,
OUT PFILE_STANDARD_INFO std_out);
/* nfstime4 */
void file_time_to_nfs_time(
/* http://msdn.microsoft.com/en-us/library/ms724290%28VS.85%29.aspx:
* A file time is a 64-bit value that represents the number of
* 100-nanosecond intervals that have elapsed since 12:00 A.M.
* January 1, 1601 Coordinated Universal Time (UTC). */
#define FILETIME_EPOCH 116444736000000000LL
static __inline void file_time_to_nfs_time(
IN const PLARGE_INTEGER file_time,
OUT nfstime4 *nfs_time);
void nfs_time_to_file_time(
OUT nfstime4 *nfs_time)
{
LONGLONG diff = file_time->QuadPart - FILETIME_EPOCH;
nfs_time->seconds = diff / 10000000;
nfs_time->nseconds = (uint32_t)((diff % 10000000)*100);
}
static __inline void nfs_time_to_file_time(
IN const nfstime4 *nfs_time,
OUT PLARGE_INTEGER file_time);
OUT PLARGE_INTEGER file_time)
{
file_time->QuadPart = FILETIME_EPOCH +
nfs_time->seconds * 10000000 +
nfs_time->nseconds / 100;
}
void get_file_time(
OUT PLARGE_INTEGER file_time);
void get_nfs_time(