void Viewport3D::ApplyRotationMatrix(const MR_2DCoordinate & pSrc, MR_2DCoordinate & pDest) const { MR_3DCoordinate lPos; lPos.mX = pSrc.mX - mPosition.mX; lPos.mY = pSrc.mY - mPosition.mY; pDest.mX = (MR_Int32) Int64ShraMod32(Int32x32To64(lPos.mX, mRotationMatrix[0][0]) + Int32x32To64(lPos.mY, mRotationMatrix[0][1]), MR_TRIGO_SHIFT); pDest.mY = (MR_Int32) Int64ShraMod32(Int32x32To64(lPos.mX, mRotationMatrix[1][0]) + Int32x32To64(lPos.mY, mRotationMatrix[1][1]), MR_TRIGO_SHIFT); }
void Viewport3D::ApplyPositionMatrix(const PositionMatrix & pMatrix, const MR_3DCoordinate & pSrc, MR_3DCoordinate & pDest) const { MR_2DCoordinate lPos; lPos.mX = (MR_Int32) Int64ShraMod32(Int32x32To64(pSrc.mX, pMatrix.mRotation[0][0]) + Int32x32To64(pSrc.mY, pMatrix.mRotation[0][1]), MR_TRIGO_SHIFT) + pMatrix.mDisplacement.mX; lPos.mY = (MR_Int32) Int64ShraMod32(Int32x32To64(pSrc.mX, pMatrix.mRotation[1][0]) + Int32x32To64(pSrc.mY, pMatrix.mRotation[1][1]), MR_TRIGO_SHIFT) + pMatrix.mDisplacement.mY; ApplyRotationMatrix(lPos, pDest); pDest.mZ = pSrc.mZ + pMatrix.mDisplacement.mZ - mPosition.mZ; }
ULONG HalSetProfileInterval ( IN ULONG Interval ) /*++ Routine Description: This routine sets the profile interrupt interval. Arguments: Interval - Supplies the desired profile interval in 100ns units. Return Value: The actual profile interval. --*/ { LARGE_INTEGER TempValue; // // If the specified profile interval is less that the minimum profile // interval or greater than the maximum profile interval, then set the // profile interval to the minimum or maximum as appropriate. // if (Interval < MINIMUM_PROFILE_INTERVAL) { Interval = MINIMUM_PROFILE_INTERVAL; } else if (Interval > MAXIMUM_PROFILE_INTERVAL) { Interval = MAXIMUM_PROFILE_INTERVAL; } // // First compute the profile count value and then back calculate the // actual profile interval. // TempValue.QuadPart = Int32x32To64(HalpProfileCountRate, Interval); TempValue.QuadPart += ROUND_VALUE; TempValue = RtlExtendedLargeIntegerDivide(TempValue, ONE_SECOND, NULL); TempValue.QuadPart = Int32x32To64(TempValue.LowPart, ONE_SECOND); TempValue = RtlExtendedLargeIntegerDivide(TempValue, HalpProfileCountRate, NULL); HalpProfileInterval = TempValue.LowPart; return HalpProfileInterval; }
static int filefind_index_write_FILETIME_helper(lua_State* L, struct FileFindInfo* info) { #if defined(WIN32) return _filefind_push_FILETIME(L, &info->fd.ftLastWriteTime); #else return _filefind_push_FILETIME(L, Int32x32To64(info->attr.st_mtime, 10000000) + 116444736000000000); #endif }
static void TT_to_FILETIME( time_t t, FILETIME& ft ) { LONGLONG ll; ll = Int32x32To64( t, 10000000 ) + 116444736000000000ll; ft.dwLowDateTime = ( DWORD )ll; ft.dwHighDateTime = ll >> 32; }
//after Microsoft KB167296 static void UnixTimevalToFileTime(struct timeval t, LPFILETIME pft) { LONGLONG ll; ll = Int32x32To64(t.tv_sec, CSYNC_USEC_IN_SEC*10) + t.tv_usec*10 + CSYNC_SECONDS_SINCE_1601*CSYNC_USEC_IN_SEC*10; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = ll >> 32; }
void UnixTimeToFileTime(time_t t, LPFILETIME pft){ LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = ll >> 32; }
static void format_timestamp(uint64_t seconds, int microseconds, char *buffer, int length, char *date_separator, char *date_time_separator, char *time_separator) { ULONGLONG timestamp = 0; ULONGLONG offset_to_1970 = 116444736000000000; SYSTEMTIME st; FILETIME ft, ft_local; timestamp = Int32x32To64(seconds, 10000000) + offset_to_1970; ft.dwHighDateTime = (DWORD)((timestamp >> 32) & 0xFFFFFFFF); ft.dwLowDateTime = (DWORD)(timestamp & 0xFFFFFFFF); FileTimeToLocalFileTime(&ft, &ft_local); FileTimeToSystemTime(&ft_local, &st); if (microseconds < 0) { _snprintf(buffer, length, "%d%s%02d%s%02d%s%02d%s%02d%s%02d", st.wYear, date_separator, st.wMonth, date_separator, st.wDay, date_time_separator, st.wHour, time_separator, st.wMinute, time_separator, st.wSecond); } else { _snprintf(buffer, length, "%d%s%02d%s%02d%s%02d%s%02d%s%02d.%06d", st.wYear, date_separator, st.wMonth, date_separator, st.wDay, date_time_separator, st.wHour, time_separator, st.wMinute, time_separator, st.wSecond, microseconds); } }
bool CArchiverUNARJ::InspectArchiveGetWriteTime(FILETIME &FileTime) { if(!m_hInspectArchive){ ASSERT(!"Open an Archive First!!!\n"); return false; } //拡張版関数で時刻取得 if(ArchiverGetWriteTimeEx){ FILETIME TempTime; if(!ArchiverGetWriteTimeEx(m_hInspectArchive,&TempTime))return false; if(!LocalFileTimeToFileTime(&TempTime,&FileTime))return false; return true; } //通常版関数で時刻取得 else if(ArchiverGetWriteTime){ DWORD UnixTime=ArchiverGetWriteTime(m_hInspectArchive); if(-1==UnixTime){ return false; } //time_tからFileTimeへ変換 LONGLONG ll = Int32x32To64(UnixTime, 10000000) + 116444736000000000; FileTime.dwLowDateTime = (DWORD) ll; FileTime.dwHighDateTime = (DWORD)(ll >>32); return true; } else{
/* This starts the timer */ NFCSTATUS phOsalNfc_Timer_Start(uint32_t TimerId, uint32_t dueTimeMsec, ppCallBck_t pCallback, void *pContext) { uint32_t uIndex; LONGLONG DueTime; uint32_t uWindow = (dueTimeMsec < 50) ? 0 : (dueTimeMsec / 4); if (NULL == gpphOsalNfc_Context || PH_OSALNFC_TIMER_ID_INVALID == TimerId) { return PHNFCSTVAL(CID_NFC_OSAL, NFCSTATUS_INVALID_PARAMETER); } uIndex = TimerId - PH_OSAL_TIMER_BASE_ADDRESS; // Convert dueTimeMsec to relative filetime units (100ns) DueTime = Int32x32To64(dueTimeMsec, -10000); EnterCriticalSection(&gpphOsalNfc_Context->TimerLock); SetThreadpoolTimer(gpphOsalNfc_Context->TimerList[uIndex].pTimer, (FILETIME*)&DueTime, 0, uWindow); gpphOsalNfc_Context->TimerList[uIndex].pCallback = pCallback; gpphOsalNfc_Context->TimerList[uIndex].pContext = pContext; LeaveCriticalSection(&gpphOsalNfc_Context->TimerLock); return NFCSTATUS_SUCCESS; }
void CFileSystem::TimestampToFiletime(const time_t t, _FILETIME& pft) { LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; pft.dwLowDateTime = (DWORD)ll; pft.dwHighDateTime = ll >> 32; }
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) { LARGE_INTEGER LargeTimeout, PreWaitTime, PostWaitTime; UINT64 TimeDiff; NTSTATUS Status; PVOID Message; PLWIP_MESSAGE_CONTAINER Container; PLIST_ENTRY Entry; KIRQL OldIrql; PVOID WaitObjects[] = {&mbox->Event, &TerminationEvent}; LargeTimeout.QuadPart = Int32x32To64(timeout, -10000); KeQuerySystemTime(&PreWaitTime); Status = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, Executive, KernelMode, FALSE, timeout != 0 ? &LargeTimeout : NULL, NULL); if (Status == STATUS_WAIT_0) { KeAcquireSpinLock(&mbox->Lock, &OldIrql); Entry = RemoveHeadList(&mbox->ListHead); ASSERT(Entry); if (IsListEmpty(&mbox->ListHead)) KeClearEvent(&mbox->Event); KeReleaseSpinLock(&mbox->Lock, OldIrql); Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry); Message = Container->Message; ExFreePool(Container); if (msg) *msg = Message; KeQuerySystemTime(&PostWaitTime); TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart; TimeDiff /= 10000; return TimeDiff; } else if (Status == STATUS_WAIT_1) { /* DON'T remove ourselves from the thread list! */ PsTerminateSystemThread(STATUS_SUCCESS); /* We should never get here! */ ASSERT(FALSE); return 0; } return SYS_ARCH_TIMEOUT; }
bool UnixTimeToFileTime(unsigned long mtime, LPFILETIME ft) { // Note that LONGLONG is a 64-bit value LONGLONG ll = Int32x32To64(mtime, 10000000) + 116444736000000000; ft->dwLowDateTime = (DWORD)ll; ft->dwHighDateTime = ll >> 32; return true; }
void touchmind::util::TimeUtil::UnixTimeToFileTime(time_t t, FILETIME* fileTime) { LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; fileTime->dwLowDateTime = (DWORD) ll; fileTime->dwHighDateTime = ll >> 32; }
FILETIME UnixTimeToFileTime(const time_t t) { FILETIME ft; const LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = static_cast<DWORD>(ll); ft.dwHighDateTime = ll >> 32; return ft; }
void UnixTimeToFileTime(const time_t t, LPFILETIME pft) { // Note that LONGLONG is a 64-bit value LONGLONG ll; ll = Int32x32To64(t, SECS_TO_100NS) + SECS_BETWEEN_EPOCHS * SECS_TO_100NS; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = ll >> 32; }
AREXPORT bool ArUtil::changeFileTimestamp(const char *fileName, time_t timestamp) { if (ArUtil::isStrEmpty(fileName)) { ArLog::log(ArLog::Normal, "Cannot change date on file with empty name"); return false; } #ifdef WIN32 FILETIME fileTime; HANDLE hFile = CreateFile(fileName, GENERIC_READ | GENERIC_WRITE, 0,NULL, OPEN_EXISTING, 0,NULL); if (hFile == NULL) { return false; } // The following is extracted from the MSDN article "Converting a time_t Value // to a File Time". LONGLONG temp = Int32x32To64(timestamp, 10000000) + 116444736000000000; fileTime.dwLowDateTime = (DWORD) temp; fileTime.dwHighDateTime = temp >> 32; SetFileTime(hFile, &fileTime, (LPFILETIME) NULL, // don't change last access time (?) &fileTime); CloseHandle(hFile); #else // unix char timeBuf[500]; strftime(timeBuf, sizeof(timeBuf), "%c", ::localtime(×tamp)); ArLog::log(ArLog::Normal, "Changing file %s modified time to %s", fileName, timeBuf); // time_t newTime = mktime(×tamp); struct utimbuf fileTime; fileTime.actime = timestamp; fileTime.modtime = timestamp; utime(fileName, &fileTime); #endif // else unix return true; } // end method changeFileTimestamp
void UnixTimeToFileTime(time_t t, LPFILETIME pft) { // Note that LONGLONG is a 64-bit value LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = (DWORD)(ll >> 32); }
static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */ { // Note that LONGLONG is a 64-bit value LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = ll >> 32; }
VOID HalStartProfileInterrupt ( KPROFILE_SOURCE ProfileSource ) /*++ Routine Description: This routine computes the profile count value, writes the compare register, clears the count register, and updates the performance counter. N.B. This routine must be called at PROFILE_LEVEL while holding the profile lock. Arguments: Source - Supplies the profile source. Return Value: None. --*/ { PKPRCB Prcb; ULONG PreviousCount; LARGE_INTEGER TempValue; // // Compute the profile count from the current profile interval. // TempValue.QuadPart = Int32x32To64(HalpProfileCountRate, HalpProfileInterval); TempValue.QuadPart += ROUND_VALUE; TempValue = RtlExtendedLargeIntegerDivide(TempValue, ONE_SECOND, NULL); // // Write the compare register and clear the count register. // PreviousCount = HalpWriteCompareRegisterAndClear(TempValue.LowPart); // // Update the performance counter by adding in the previous count value. // Prcb = KeGetCurrentPrcb(); HalpPerformanceCounter[Prcb->Number].QuadPart += PreviousCount; return; }
FILETIME unixTimeToFiletime(time_t t) { // Note that LONGLONG is a 64-bit value LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000LL; FILETIME res; res.dwLowDateTime = (DWORD)ll; res.dwHighDateTime = (DWORD)(ll >> 32); return res; }
void UnixTimeToFileTime(time_t const t, LPFILETIME const pft) { int64_t const ll = Int32x32To64(t, SECS_TO_100NS) + SECS_BETWEEN_EPOCHS * SECS_TO_100NS; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = (DWORD)(ll >> 32); }
/** * Convert Unix time_t to FILETIME */ void Time_tToFileTime(time_t t, FILETIME &ft) { // Note that LONGLONG is a 64-bit value. From MS article // http://support.microsoft.com/default.aspx?scid=KB;en-us;q167296 LONGLONG ll; ll = Int32x32To64(t, 10000000) + 116444736000000000; ft.dwLowDateTime = (DWORD)ll; ft.dwHighDateTime = (DWORD)(ll >> 32); }
/*! \brief converts unix time to windows time * * based on microsoft kb 167296 * \param ftime pointer to place where is windows time stored * \param ztime unix time representation */ static void zfstime_to_filetime(PFILETIME ftime, zfs_time ztime) { if (ftime == NULL || ztime == ((zfs_time) - 1)) return; // based on microsoft kb 167296 LONGLONG ll; ll = Int32x32To64(ztime, 10000000) + 116444736000000000; ftime->dwLowDateTime = (DWORD) ll; ftime->dwHighDateTime = ll >> 32; }
//--------------------------------------- GetSystemTimeAsFileTime -------------------------------------------- void WINAPI _GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { auto replacementSeed = BWAPI::BroodwarImpl.seedOverride; if (lpSystemTimeAsFileTime != nullptr && replacementSeed != std::numeric_limits<decltype(replacementSeed)>::max()) { // https://support.microsoft.com/kb/167296 auto ll = Int32x32To64(replacementSeed, 10000000) + 116444736000000000; lpSystemTimeAsFileTime->dwLowDateTime = (DWORD)ll; lpSystemTimeAsFileTime->dwHighDateTime = ll >> 32; return; }
static SYSTEMTIME TimeToSystemTime(std::time_t timestamp) { LONGLONG ll = Int32x32To64(timestamp, 10000000) + 116444736000000000; FILETIME ft; ft.dwLowDateTime = (DWORD)ll; ft.dwHighDateTime = ll >> 32; SYSTEMTIME st; FileTimeToSystemTime(&ft, &st); return st; }
DateTime fromCTime(time_t t){ // adapted from: https://docs.microsoft.com/en-us/windows/desktop/sysinfo/converting-a-time-t-value-to-a-file-time DateTime dt; FILETIME* ftime = (FILETIME*)&dt._data; LONGLONG t_val = Int32x32To64(t, 10000000) + 116444736000000000; ftime->dwLowDateTime = (DWORD) t_val; ftime->dwHighDateTime = t_val >>32; return dt; }
static int l_filefind_FILETIME_to_unix_time_UTC(lua_State* L) { time_t unixTime = (time_t)luaL_checknumber(L, 1); #if _MSC_VER __int64 ll; // 64 bit value #else signed long long ll; #endif ll = Int32x32To64(unixTime, 10000000) + 116444736000000000ui64; lua_pushnumber(L, (DWORD)ll); lua_pushnumber(L, (DWORD)(ll >> 32)); return 2; }
iStringT FormatDate(uint32 timestamp, bool bShowTime) { FILETIME ft; SYSTEMTIME st; LONGLONG ll; ll = Int32x32To64(timestamp, 600000000); ft.dwLowDateTime = (DWORD)ll; ft.dwHighDateTime = ll >> 32; FileTimeToSystemTime(&ft, &st); if (bShowTime) return iFormat(_T("%d %s %d (%d:%02d)"), st.wDay, gTextMgr[TRID_MONTH_JAN+st.wMonth-1], st.wYear, st.wHour, st.wMinute); else return iFormat(_T("%d %s %d"), st.wDay, gTextMgr[TRID_MONTH_JAN+st.wMonth-1], st.wYear); }
// Convert from time_t to FILETIME // Uses 3 static entries so that we can convert 3 concurrent values at the same time static LPFILETIME __inline to_filetime(time_t t) { static int i = 0; static FILETIME ft[3], *r; LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000; r = &ft[i]; r->dwLowDateTime = (DWORD)ll; r->dwHighDateTime = (DWORD)(ll >> 32); i = (i + 1) % ARRAYSIZE(ft); return r; }