1 /* 2 * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "mbedtls/build_info.h" 8 #include "mbedtls/platform_time.h" 9 10 #ifdef MBEDTLS_PLATFORM_MS_TIME_ALT mbedtls_ms_time()11mbedtls_ms_time_t mbedtls_ms_time() 12 { 13 int ret; 14 struct timespec tv = {}; 15 mbedtls_ms_time_t current_ms; 16 17 ret = clock_gettime(CLOCK_MONOTONIC, &tv); 18 if (ret) { 19 return time(NULL) * 1000L; 20 } 21 22 current_ms = tv.tv_sec; 23 return current_ms * 1000L + tv.tv_nsec / 1000000L; 24 } 25 #endif // MBEDTLS_PLATFORM_MS_TIME_ALT 26