platform_time.h 2.0 KB

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