blob: eee61d695a3c03bbe82c592d0c15bec9a3621cb6 [file] [log] [blame]
Simon Butcher86311432016-07-12 13:11:00 +01001/**
2 * \file platform_time.h
3 *
4 * \brief mbed TLS Platform time abstraction
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02007 * Copyright The Mbed TLS Contributors
Simon Butcher86311432016-07-12 13:11:00 +01008 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
Simon Butcher86311432016-07-12 13:11:00 +010021 */
22#ifndef MBEDTLS_PLATFORM_TIME_H
23#define MBEDTLS_PLATFORM_TIME_H
24
25#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010026#include "mbedtls/config.h"
Simon Butcher86311432016-07-12 13:11:00 +010027#else
28#include MBEDTLS_CONFIG_FILE
29#endif
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
Simon Butcher86311432016-07-12 13:11:00 +010035/*
36 * The time_t datatype
37 */
38#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
39typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
40#else
41/* For time_t */
42#include <time.h>
43typedef time_t mbedtls_time_t;
44#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
45
46/*
47 * The function pointers for time
48 */
49#if defined(MBEDTLS_PLATFORM_TIME_ALT)
David Horstmannceeaeb92023-01-05 15:44:23 +000050extern mbedtls_time_t (*mbedtls_time)(mbedtls_time_t *time);
Simon Butcher86311432016-07-12 13:11:00 +010051
52/**
53 * \brief Set your own time function pointer
54 *
55 * \param time_func the time function implementation
56 *
57 * \return 0
58 */
David Horstmannceeaeb92023-01-05 15:44:23 +000059int mbedtls_platform_set_time(mbedtls_time_t (*time_func)(mbedtls_time_t *time));
Simon Butcher86311432016-07-12 13:11:00 +010060#else
61#if defined(MBEDTLS_PLATFORM_TIME_MACRO)
62#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
63#else
64#define mbedtls_time time
65#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
66#endif /* MBEDTLS_PLATFORM_TIME_ALT */
67
68#ifdef __cplusplus
69}
70#endif
71
Simon Butcher86311432016-07-12 13:11:00 +010072#endif /* platform_time.h */