xref: /freebsd/contrib/llvm-project/libc/include/llvm-libc-macros/baremetal/time-macros.h (revision bb722a7d0f1642bff6487f943ad0427799a6e5bf)
1 //===-- Definition of macros from time.h ---------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_MACROS_BAREMETAL_TIME_MACROS_H
10 #define LLVM_LIBC_MACROS_BAREMETAL_TIME_MACROS_H
11 
12 #ifdef __CLK_TCK
13 #define CLOCKS_PER_SEC __CLK_TCK
14 #else
15 #if defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) ||             \
16     defined(__arm64__) || defined(_M_ARM64)
17 // This default implementation of this function shall use semihosting
18 // Semihosting measures time in centiseconds
19 // https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst#sys-clock-0x10
20 #define CLOCKS_PER_SEC 100
21 #else
22 #define CLOCKS_PER_SEC 1000000
23 #endif
24 #endif
25 
26 #endif // LLVM_LIBC_MACROS_BAREMETAL_TIME_MACROS_H
27