brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 52ace2a Raw
31 lines · cpp
1//===---------- Linux 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#include "src/__support/common.h"11#include "src/__support/libc_errno.h"12#include "src/__support/macros/config.h"13#include "src/__support/time/clock_gettime.h"14 15namespace LIBC_NAMESPACE_DECL {16 17// TODO(michaelrj): Move this into time/linux with the other syscalls.18LLVM_LIBC_FUNCTION(int, clock_gettime, (clockid_t clockid, timespec *ts)) {19  auto result = internal::clock_gettime(clockid, ts);20 21  // A negative return value indicates an error with the magnitude of the22  // value being the error code.23  if (!result.has_value()) {24    libc_errno = result.error();25    return -1;26  }27  return 0;28}29 30} // namespace LIBC_NAMESPACE_DECL31