VirtualBox

Changeset 3060 in kBuild for trunk/src/kmk/kmkbuiltin/mscfakes.c


Ignore:
Timestamp:
Sep 21, 2017 3:11:07 PM (7 years ago)
Author:
bird
Message:

kmk,lib: ported kmk_touch to windows (nt).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/mscfakes.c

    r2901 r3060  
    3737#include <fcntl.h>
    3838#include <sys/stat.h>
     39#include <sys/timeb.h>
    3940#include "err.h"
    4041#include "mscfakes.h"
     42
     43#include "nt/ntutimes.h"
     44#undef utimes
     45#undef lutimes
    4146
    4247#define timeval windows_timeval
    4348#include <Windows.h>
    4449#undef timeval
     50
    4551
    4652/*******************************************************************************
     
    460466
    461467
    462 int utimes(const char *pszPath, const struct timeval *paTimes)
    463 {
    464     /** @todo implement me! */
    465     return 0;
    466 }
    467 
    468 
    469468/* We override the libc write function (in our modules only, unfortunately) so
    470469   we can kludge our way around a ENOSPC problem observed on build servers
     
    651650
    652651
     652int utimes(const char *pszPath, const struct timeval *paTimes)
     653{
     654    BirdTimeVal_T aTimes[2];
     655    aTimes[0].tv_sec  = paTimes[0].tv_sec;
     656    aTimes[0].tv_usec = paTimes[0].tv_usec;
     657    aTimes[1].tv_sec  = paTimes[1].tv_sec;
     658    aTimes[1].tv_usec = paTimes[1].tv_usec;
     659    return birdUtimes(pszPath, aTimes);
     660}
     661
     662
     663int lutimes(const char *pszPath, const struct timeval *paTimes)
     664{
     665    BirdTimeVal_T aTimes[2];
     666    aTimes[0].tv_sec  = paTimes[0].tv_sec;
     667    aTimes[0].tv_usec = paTimes[0].tv_usec;
     668    aTimes[1].tv_sec  = paTimes[1].tv_sec;
     669    aTimes[1].tv_usec = paTimes[1].tv_usec;
     670    return birdUtimes(pszPath, aTimes);
     671}
     672
     673
     674int gettimeofday(struct timeval *pNow, void *pvIgnored)
     675{
     676    struct __timeb64 Now;
     677    int rc = _ftime64_s(&Now);
     678    if (rc == 0)
     679    {
     680        pNow->tv_sec  = Now.time;
     681        pNow->tv_usec = Now.millitm * 1000;
     682        return 0;
     683    }
     684    errno = rc;
     685    return -1;
     686}
     687
     688
     689struct tm *localtime_r(const __time64_t *pNow, struct tm *pResult)
     690{
     691    int rc = _localtime64_s(pResult, pNow);
     692    if (rc == 0)
     693        return pResult;
     694    errno = rc;
     695    return NULL;
     696}
     697
     698
     699__time64_t timegm(struct tm *pNow)
     700{
     701    return _mkgmtime64(pNow);
     702}
     703
     704
    653705/**
    654706 * Checks if the given file descriptor is a pipe or not.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette