platform_time.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  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. #if !defined(MBEDTLS_CONFIG_FILE)
  26. #include "config.h"
  27. #else
  28. #include MBEDTLS_CONFIG_FILE
  29. #endif
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /**
  34. * \name SECTION: Module settings
  35. *
  36. * The configuration options you can set for this module are in this section.
  37. * Either change them in config.h or define them on the compiler command line.
  38. * \{
  39. */
  40. /*
  41. * The time_t datatype
  42. */
  43. #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
  44. typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
  45. #else
  46. /* For time_t */
  47. #include <time.h>
  48. typedef time_t mbedtls_time_t;
  49. #endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
  50. /*
  51. * The function pointers for time
  52. */
  53. #if defined(MBEDTLS_PLATFORM_TIME_ALT)
  54. extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
  55. /**
  56. * \brief Set your own time function pointer
  57. *
  58. * \param time_func the time function implementation
  59. *
  60. * \return 0
  61. */
  62. int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
  63. #else
  64. #if defined(MBEDTLS_PLATFORM_TIME_MACRO)
  65. #define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
  66. #else
  67. #define mbedtls_time time
  68. #endif /* MBEDTLS_PLATFORM_TIME_MACRO */
  69. #endif /* MBEDTLS_PLATFORM_TIME_ALT */
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif /* platform_time.h */