blob: abb3431420fecc312f0d7d5af42ac99e6a4e6dbc [file] [log] [blame]
Simon Butcher86311432016-07-12 13:11:00 +01001/**
2 * \file platform_time.h
3 *
4 * \brief mbed TLS Platform time abstraction
5 *
6 * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 * This file is part of mbed TLS (https://tls.mbed.org)
22 */
23#ifndef MBEDTLS_PLATFORM_TIME_H
24#define MBEDTLS_PLATFORM_TIME_H
25
26#if !defined(MBEDTLS_CONFIG_FILE)
27#include "config.h"
28#else
29#include MBEDTLS_CONFIG_FILE
30#endif
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/**
37 * \name SECTION: Module settings
38 *
39 * The configuration options you can set for this module are in this section.
40 * Either change them in config.h or define them on the compiler command line.
41 * \{
42 */
43
44/*
45 * The time_t datatype
46 */
47#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
48typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
49#else
50/* For time_t */
51#include <time.h>
52typedef time_t mbedtls_time_t;
53#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
54
55/*
56 * The function pointers for time
57 */
58#if defined(MBEDTLS_PLATFORM_TIME_ALT)
59extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
60
61/**
62 * \brief Set your own time function pointer
63 *
64 * \param time_func the time function implementation
65 *
66 * \return 0
67 */
68int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
69#else
70#if defined(MBEDTLS_PLATFORM_TIME_MACRO)
71#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
72#else
73#define mbedtls_time time
74#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
75#endif /* MBEDTLS_PLATFORM_TIME_ALT */
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* platform_time.h */