29 lines · cpp
1//===---- Darwin implementation of the POSIX clock_gettime function --===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===-----------------------------------------------------------------===//8 9#include "src/time/clock_gettime.h"10 11#include "src/__support/common.h"12#include "src/__support/libc_errno.h"13#include "src/__support/macros/config.h"14#include "src/__support/time/clock_gettime.h"15 16namespace LIBC_NAMESPACE_DECL {17 18LLVM_LIBC_FUNCTION(int, clock_gettime,19 (clockid_t clockid, struct timespec *ts)) {20 auto result = internal::clock_gettime(clockid, ts);21 if (!result.has_value()) {22 libc_errno = result.error();23 return -1;24 }25 return 0;26}27 28} // namespace LIBC_NAMESPACE_DECL29