platform_time.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: GPL-2.0
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. *
  23. * This file is part of mbed TLS (https://tls.mbed.org)
  24. */
  25. #ifndef MBEDTLS_PLATFORM_TIME_H
  26. #define MBEDTLS_PLATFORM_TIME_H
  27. #if !defined(MBEDTLS_CONFIG_FILE)
  28. #include "config.h"
  29. #else
  30. #include MBEDTLS_CONFIG_FILE
  31. #endif
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. * \name SECTION: Module settings
  37. *
  38. * The configuration options you can set for this module are in this section.
  39. * Either change them in config.h or define them on the compiler command line.
  40. * \{
  41. */
  42. /*
  43. * The time_t datatype
  44. */
  45. #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
  46. typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
  47. #else
  48. /* For time_t */
  49. #include <time.h>
  50. typedef time_t mbedtls_time_t;
  51. #endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
  52. /*
  53. * The function pointers for time
  54. */
  55. #if defined(MBEDTLS_PLATFORM_TIME_ALT)
  56. extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
  57. /**
  58. * \brief Set your own time function pointer
  59. *
  60. * \param time_func the time function implementation
  61. *
  62. * \return 0
  63. */
  64. int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
  65. #else
  66. #if defined(MBEDTLS_PLATFORM_TIME_MACRO)
  67. #define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
  68. #else
  69. #define mbedtls_time time
  70. #endif /* MBEDTLS_PLATFORM_TIME_MACRO */
  71. #endif /* MBEDTLS_PLATFORM_TIME_ALT */
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif /* platform_time.h */