Mbed TLS v3.5.2
Loading...
Searching...
No Matches
platform_util.h
Go to the documentation of this file.
1
7/*
8 * Copyright The Mbed TLS Contributors
9 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
10 */
11#ifndef MBEDTLS_PLATFORM_UTIL_H
12#define MBEDTLS_PLATFORM_UTIL_H
13
14#include "mbedtls/build_info.h"
15
16#include <stddef.h>
17#if defined(MBEDTLS_HAVE_TIME_DATE)
19#include <time.h>
20#endif /* MBEDTLS_HAVE_TIME_DATE */
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* Internal macros meant to be called only from within the library. */
27#define MBEDTLS_INTERNAL_VALIDATE_RET(cond, ret) do { } while (0)
28#define MBEDTLS_INTERNAL_VALIDATE(cond) do { } while (0)
29
30/* Internal helper macros for deprecating API constants. */
31#if !defined(MBEDTLS_DEPRECATED_REMOVED)
32#if defined(MBEDTLS_DEPRECATED_WARNING)
33#define MBEDTLS_DEPRECATED __attribute__((deprecated))
34MBEDTLS_DEPRECATED typedef char const *mbedtls_deprecated_string_constant_t;
35#define MBEDTLS_DEPRECATED_STRING_CONSTANT(VAL) \
36 ((mbedtls_deprecated_string_constant_t) (VAL))
37MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t;
38#define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(VAL) \
39 ((mbedtls_deprecated_numeric_constant_t) (VAL))
40#else /* MBEDTLS_DEPRECATED_WARNING */
41#define MBEDTLS_DEPRECATED
42#define MBEDTLS_DEPRECATED_STRING_CONSTANT(VAL) VAL
43#define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(VAL) VAL
44#endif /* MBEDTLS_DEPRECATED_WARNING */
45#endif /* MBEDTLS_DEPRECATED_REMOVED */
46
47/* Implementation of the check-return facility.
48 * See the user documentation in mbedtls_config.h.
49 *
50 * Do not use this macro directly to annotate function: instead,
51 * use one of MBEDTLS_CHECK_RETURN_CRITICAL or MBEDTLS_CHECK_RETURN_TYPICAL
52 * depending on how important it is to check the return value.
53 */
54#if !defined(MBEDTLS_CHECK_RETURN)
55#if defined(__GNUC__)
56#define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__))
57#elif defined(_MSC_VER) && _MSC_VER >= 1700
58#include <sal.h>
59#define MBEDTLS_CHECK_RETURN _Check_return_
60#else
61#define MBEDTLS_CHECK_RETURN
62#endif
63#endif
64
81#define MBEDTLS_CHECK_RETURN_CRITICAL MBEDTLS_CHECK_RETURN
82
100#if defined(MBEDTLS_CHECK_RETURN_WARNING)
101#define MBEDTLS_CHECK_RETURN_TYPICAL MBEDTLS_CHECK_RETURN
102#else
103#define MBEDTLS_CHECK_RETURN_TYPICAL
104#endif
105
117#define MBEDTLS_CHECK_RETURN_OPTIONAL
118
124#if !defined(MBEDTLS_IGNORE_RETURN)
125/* GCC doesn't silence the warning with just (void)(result).
126 * (void)!(result) is known to work up at least up to GCC 10, as well
127 * as with Clang and MSVC.
128 *
129 * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Non_002dbugs.html
130 * https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result
131 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34
132 */
133#define MBEDTLS_IGNORE_RETURN(result) ((void) !(result))
134#endif
135
136/* If the following macro is defined, the library is being built by the test
137 * framework, and the framework is going to provide a replacement
138 * mbedtls_platform_zeroize() using a preprocessor macro, so the function
139 * declaration should be omitted. */
140#if !defined(MBEDTLS_TEST_DEFINES_ZEROIZE) //no-check-names
163void mbedtls_platform_zeroize(void *buf, size_t len);
164#endif
165
166#if defined(MBEDTLS_HAVE_TIME_DATE)
194 struct tm *tm_buf);
195#endif /* MBEDTLS_HAVE_TIME_DATE */
196
197#ifdef __cplusplus
198}
199#endif
200
201#endif /* MBEDTLS_PLATFORM_UTIL_H */
Build-time configuration info.
Mbed TLS Platform time abstraction.
time_t mbedtls_time_t
#define MBEDTLS_DEPRECATED
struct tm * mbedtls_platform_gmtime_r(const mbedtls_time_t *tt, struct tm *tm_buf)
Platform-specific implementation of gmtime_r()