| /* A part of the Windows CE C Extra Library (celibc) |
| Copyright 2007-2015 PC GO Ld. |
| |
| This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| */ |
| |
| #include <sys/time.h> |
| #include <windows.h> |
| #include <shared.h> |
| //#include <errno.h> |
| |
| int settimeofday(const struct timeval *tv, const struct timezone *tz) { |
| if(!tv) return 0; |
| |
| /* |
| FILETIME ft = __time_t_to_filetime(tv->tv_sec); |
| if(tv->tv_usec) { |
| if(tv->tv_usec > 1000000) { |
| errno = EINVAL; |
| return -1; |
| } |
| ft.dwLowDateTime += tv->tv_usec * 10; |
| } |
| */ |
| FILETIME ft; |
| SYSTEMTIME st; |
| __timeval_to_filetime(tv, &ft); |
| if(!FileTimeToSystemTime(&ft, &st)) return -1; |
| if(!SetSystemTime(&st)) return -1; |
| return 0; |
| } |