Path: blob/main/contrib/libfido2/openbsd-compat/clock_gettime.c
39536 views
/*1* Copyright (c) 2020 Yubico AB. All rights reserved.2* Use of this source code is governed by a BSD-style3* license that can be found in the LICENSE file.4* SPDX-License-Identifier: BSD-2-Clause5*/67#include "openbsd-compat.h"89#if !defined(HAVE_CLOCK_GETTIME)1011#if _WIN3212int13clock_gettime(clockid_t clock_id, struct timespec *tp)14{15ULONGLONG ms;1617if (clock_id != CLOCK_MONOTONIC) {18errno = EINVAL;19return (-1);20}2122ms = GetTickCount64();23tp->tv_sec = ms / 1000L;24tp->tv_nsec = (ms % 1000L) * 1000000L;2526return (0);27}28#else29#error "please provide an implementation of clock_gettime() for your platform"30#endif /* _WIN32 */3132#endif /* !defined(HAVE_CLOCK_GETTIME) */333435