Changeset 3060 for trunk/src/kmk
- Timestamp:
- Sep 21, 2017, 5:11:07 PM (8 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/mscfakes.c
r2901 r3060 37 37 #include <fcntl.h> 38 38 #include <sys/stat.h> 39 #include <sys/timeb.h> 39 40 #include "err.h" 40 41 #include "mscfakes.h" 42 43 #include "nt/ntutimes.h" 44 #undef utimes 45 #undef lutimes 41 46 42 47 #define timeval windows_timeval 43 48 #include <Windows.h> 44 49 #undef timeval 50 45 51 46 52 /******************************************************************************* … … 460 466 461 467 462 int utimes(const char *pszPath, const struct timeval *paTimes)463 {464 /** @todo implement me! */465 return 0;466 }467 468 469 468 /* We override the libc write function (in our modules only, unfortunately) so 470 469 we can kludge our way around a ENOSPC problem observed on build servers … … 651 650 652 651 652 int 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 663 int 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 674 int 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 689 struct 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 653 705 /** 654 706 * Checks if the given file descriptor is a pipe or not. -
trunk/src/kmk/kmkbuiltin/mscfakes.h
r2766 r3060 28 28 #ifdef _MSC_VER 29 29 30 #define timeval windows_timeval 31 30 32 /* Include the config file (kmk's) so we don't need to duplicate stuff from it here. */ 31 33 #include "config.h" … … 50 52 # define lseek _lseeki64 51 53 #endif 54 55 #undef timeval 52 56 53 57 #undef PATH_MAX … … 104 108 #endif 105 109 106 #if !defined(timerisset) && defined(MSCFAKES_NO_WINDOWS_H)107 110 struct timeval 108 111 { 109 longtv_sec;112 __time64_t tv_sec; 110 113 long tv_usec; 111 114 }; 112 #endif113 115 114 116 struct iovec … … 134 136 #define chmod msc_chmod 135 137 #define lchown(path, uid, gid) chown(path, uid, gid) 136 #define lutimes(path, tvs) utimes(path, tvs)137 138 int link(const char *pszDst, const char *pszLink); 138 139 int mkdir_msc(const char *path, mode_t mode); … … 158 159 int symlink(const char *pszDst, const char *pszLink); 159 160 int utimes(const char *pszPath, const struct timeval *paTimes); 161 int lutimes(const char *pszPath, const struct timeval *paTimes); 160 162 ssize_t writev(int fd, const struct iovec *vector, int count); 163 164 int gettimeofday(struct timeval *pNow, void *pvIgnored); 165 struct tm *localtime_r(const __time64_t *pNow, struct tm *pResult); 166 __time64_t timegm(struct tm *pNow); 167 #undef mktime 168 #define mktime _mktime64 161 169 162 170 /* bird write ENOSPC hacks. */ -
trunk/src/kmk/kmkbuiltin/touch.c
r3059 r3060 38 38 # include <ctype.h> 39 39 # include <io.h> 40 # include <sys/timeb.h> 40 41 #else 41 42 # include <unistd.h> … … 47 48 #include "kbuild_version.h" 48 49 #include "kmkbuiltin.h" 50 51 #ifdef _MSC_VER 52 # include "nt/ntstat.h" 53 # undef FILE_TIMESTAMP_HI_RES 54 # define FILE_TIMESTAMP_HI_RES 1 55 #endif 56 49 57 50 58 /********************************************************************************************************************************* … … 99 107 int cFiles; 100 108 /** The specified files. */ 101 c onst char**papszFiles;109 char **papszFiles; 102 110 } KMKTOUCHOPTS; 103 111 typedef KMKTOUCHOPTS *PKMKTOUCHOPTS; 112 104 113 105 114 … … 217 226 { 218 227 const char * const pszTsIn = pszTs; 219 KBOOL fIsZulu = K_FALSE;220 228 struct tm ExpTime; 221 229 … … 244 252 return touch_error("Malformed timestamp '%s' given to -d: expected to two digit month at position 6 followed by a dash", 245 253 pszTsIn); 246 ExpTime.tm_mon = TWO_CHARS_TO_INT(pszTs[0], pszTs[1]) ;254 ExpTime.tm_mon = TWO_CHARS_TO_INT(pszTs[0], pszTs[1]) - 1; 247 255 pszTs += 3; 248 256 … … 301 309 302 310 /* zulu time indicator */ 311 ExpTime.tm_isdst = -1; 303 312 if (*pszTs == 'Z' || *pszTs == 'z') 304 313 { 305 fIsZulu = K_TRUE;314 ExpTime.tm_isdst = 0; 306 315 pszTs++; 307 316 if (*pszTs != '\0') … … 315 324 * Convert to UTC seconds using either timegm or mktime. 316 325 */ 317 ExpTime.tm_isdst = fIsZulu ? 0 : -1;318 326 ExpTime.tm_yday = -1; 319 327 ExpTime.tm_wday = -1; 320 pDst->tv_sec = fIsZulu ? timegm(&ExpTime) : mktime(&ExpTime); 321 if (pDst->tv_sec != -1) 322 return 0; 323 return touch_error("%s failed on '%s': %s", fIsZulu ? "timegm" : "mktime", pszTs, strerror(errno)); 328 if (ExpTime.tm_isdst == 0) 329 { 330 pDst->tv_sec = timegm(&ExpTime); 331 if (pDst->tv_sec == -1) 332 return touch_error("timegm failed on '%s': %s", pszTs, strerror(errno)); 333 } 334 else 335 { 336 pDst->tv_sec = mktime(&ExpTime); 337 if (pDst->tv_sec == -1) 338 return touch_error("mktime failed on '%s': %s", pszTs, strerror(errno)); 339 } 340 return 0; 324 341 } 325 342 … … 421 438 } 422 439 423 pExpTime->tm_mon = TWO_CHARS_TO_INT(pszTs[cchTsNoSec - 8], pszTs[cchTsNoSec - 7]) ;440 pExpTime->tm_mon = TWO_CHARS_TO_INT(pszTs[cchTsNoSec - 8], pszTs[cchTsNoSec - 7]) - 1; 424 441 pExpTime->tm_mday = TWO_CHARS_TO_INT(pszTs[cchTsNoSec - 6], pszTs[cchTsNoSec - 5]); 425 442 pExpTime->tm_hour = TWO_CHARS_TO_INT(pszTs[cchTsNoSec - 4], pszTs[cchTsNoSec - 3]); … … 894 911 Opts.fDereference = K_TRUE; 895 912 Opts.cFiles = 0; 896 Opts.papszFiles = (c onst char **)calloc(argc, sizeof(constchar *));913 Opts.papszFiles = (char **)calloc(argc, sizeof(char *)); 897 914 if (Opts.papszFiles) 898 915 { -
trunk/src/kmk/w32/pathstuff.c
r2849 r3060 16 16 this program. If not, see <http://www.gnu.org/licenses/>. */ 17 17 18 #include <Windows.h> /* bird */19 18 #include "make.h" 20 19 #include <string.h>
Note:
See TracChangeset
for help on using the changeset viewer.