1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 /* Augment time.h with trusty-specific functions. */ 20 #include <time.h> 21 22 #include <stdint.h> 23 24 /* Don't use convenience macros here, it will polute the namespace. */ 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* Prefixed with trusty_ because the signatures do not match POSIX. */ 30 int trusty_gettime(clockid_t clock_id, int64_t* time); 31 int trusty_nanosleep(clockid_t clock_id, uint32_t flags, uint64_t sleep_time); 32 33 /* 34 * The trusty_nanosleep() can sleep longer than expected in certain scenarios 35 * (like CPUIdle is enabled). trusty_nanodelay() is less likely to oversleep, 36 * but at the cost of additional CPU usage. Use trusty_nanodelay() when working 37 * with hardware with precise timing requirements. But avoid using 38 * trusty_nanodelay() with large sleep_time values. 39 */ 40 int trusty_nanodelay(clockid_t clock_id, uint32_t flags, uint64_t sleep_time); 41 42 #ifdef __cplusplus 43 } 44 #endif 45