31 lines · cpp
1//===---------- Linux implementation of the POSIX clock_settime 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_settime.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_settime.h"14 15namespace LIBC_NAMESPACE_DECL {16 17LLVM_LIBC_FUNCTION(int, clock_settime,18 (clockid_t clockid, const timespec *ts)) {19 auto result = internal::clock_settime(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