| /* 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 <time.h> |
| #include <errno.h> |
| #include <windows.h> |
| #include <shared.h> |
| |
| int clock_settime(clockid_t clock_id, const struct timespec *tp) { |
| if(!tp) { |
| errno = EFAULT; |
| return -1; |
| } |
| switch(clock_id) { |
| case CLOCK_REALTIME: { |
| FILETIME ft; |
| SYSTEMTIME st; |
| __timespec_to_filetime(tp, &ft); |
| if(!FileTimeToSystemTime(&ft, &st)) return -1; |
| if(!SetSystemTime(&st)) return -1; |
| return 0; |
| } |
| case CLOCK_MONOTONIC: |
| errno = EPERM; |
| return -1; |
| default: |
| errno = EINVAL; |
| return -1; |
| } |
| } |