⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gettimeofday.c

📁 加密认证联合模式的源代码
💻 C
字号:

#include <windows.h>
#include <errno.h>

static unsigned long long filetime_to_unix_epoch( const FILETIME *ft )
{
    unsigned long long res = (unsigned long long) ft->dwHighDateTime << 32;
    res |= ft->dwLowDateTime;
    res /= 10;
    res -= 11644473600000000ULL;	/* from Win epoch to Unix epoch */
    return res;
}

int gettimeofday( struct timeval *tv, void *tz )
{
    FILETIME  ft;
    unsigned long long tim;

    if(!tv)
    {
        errno = EINVAL; return -1;
    }

    GetSystemTimeAsFileTime (&ft);
    tim = filetime_to_unix_epoch (&ft);
    tv->tv_sec  = (long) (tim / 1000000L);
    tv->tv_usec = (long) (tim % 1000000L);
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -