| 80 | */ |
| 81 | |
| 82 | void timestamp_from_filetime( timestamp * const t, FILETIME const * const ft ) |
| 83 | { |
| 84 | /* Seconds between 1.1.1601 and 1.1.1970 */ |
| 85 | static __int64 const secs_between_epochs = 11644473600; |
| 86 | |
| 87 | /* We can not simply cast and dereference a FILETIME, since it might not be |
| 88 | * aligned properly. __int64 type variables are expected to be aligned to an |
| 89 | * 8 byte boundary while FILETIME structures may be aligned to any 4 byte |
| 90 | * boundary. Using an incorrectly aligned __int64 variable may cause a |
| 91 | * performance penalty on some platforms or even exceptions on others |
| 92 | * (documented on MSDN). |
| 93 | */ |
| 94 | __int64 in; |
| 95 | memcpy( &in, ft, sizeof( in ) ); |
| 96 | |
| 97 | /* FILETIME resolution: 100ns. */ |
| 98 | timestamp_init( t, (time_t)( ( in / 10000000 ) - secs_between_epochs ), |
| 99 | (int)( in % 10000000 ) * 100 ); |
| 100 | } |
| 101 | #endif /* OS_NT */ |
| 102 | |
| 103 |
no test coverage detected