godot/thirdparty/mbedtls/library/mps_trace.h

/*
 *  Copyright The Mbed TLS Contributors
 *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
 */

/**
 * \file mps_trace.h
 *
 * \brief Tracing module for MPS
 */

#ifndef MBEDTLS_MPS_MBEDTLS_MPS_TRACE_H
#define MBEDTLS_MPS_MBEDTLS_MPS_TRACE_H

#include "common.h"
#include "mps_common.h"
#include "mps_trace.h"

#include "mbedtls/platform.h"

#if defined(MBEDTLS_MPS_ENABLE_TRACE)

/*
 * Adapt this to enable/disable tracing output
 * from the various layers of the MPS.
 */

#define MBEDTLS_MPS_TRACE_ENABLE_LAYER_1
#define MBEDTLS_MPS_TRACE_ENABLE_LAYER_2
#define MBEDTLS_MPS_TRACE_ENABLE_LAYER_3
#define MBEDTLS_MPS_TRACE_ENABLE_LAYER_4
#define MBEDTLS_MPS_TRACE_ENABLE_READER
#define MBEDTLS_MPS_TRACE_ENABLE_WRITER

/*
 * To use the existing trace module, only change
 * MBEDTLS_MPS_TRACE_ENABLE_XXX above, but don't modify the
 * rest of this file.
 */

typedef enum {
    MBEDTLS_MPS_TRACE_TYPE_COMMENT,
    MBEDTLS_MPS_TRACE_TYPE_CALL,
    MBEDTLS_MPS_TRACE_TYPE_ERROR,
    MBEDTLS_MPS_TRACE_TYPE_RETURN
} mbedtls_mps_trace_type;

#define MBEDTLS_MPS_TRACE_BIT_LAYER_1
#define MBEDTLS_MPS_TRACE_BIT_LAYER_2
#define MBEDTLS_MPS_TRACE_BIT_LAYER_3
#define MBEDTLS_MPS_TRACE_BIT_LAYER_4
#define MBEDTLS_MPS_TRACE_BIT_WRITER
#define MBEDTLS_MPS_TRACE_BIT_READER

#if defined(MBEDTLS_MPS_TRACE_ENABLE_LAYER_1)
#define MBEDTLS_MPS_TRACE_MASK_LAYER_1
#else
#define MBEDTLS_MPS_TRACE_MASK_LAYER_1
#endif

#if defined(MBEDTLS_MPS_TRACE_ENABLE_LAYER_2)
#define MBEDTLS_MPS_TRACE_MASK_LAYER_2
#else
#define MBEDTLS_MPS_TRACE_MASK_LAYER_2
#endif

#if defined(MBEDTLS_MPS_TRACE_ENABLE_LAYER_3)
#define MBEDTLS_MPS_TRACE_MASK_LAYER_3
#else
#define MBEDTLS_MPS_TRACE_MASK_LAYER_3
#endif

#if defined(MBEDTLS_MPS_TRACE_ENABLE_LAYER_4)
#define MBEDTLS_MPS_TRACE_MASK_LAYER_4
#else
#define MBEDTLS_MPS_TRACE_MASK_LAYER_4
#endif

#if defined(MBEDTLS_MPS_TRACE_ENABLE_READER)
#define MBEDTLS_MPS_TRACE_MASK_READER
#else
#define MBEDTLS_MPS_TRACE_MASK_READER
#endif

#if defined(MBEDTLS_MPS_TRACE_ENABLE_WRITER)
#define MBEDTLS_MPS_TRACE_MASK_WRITER
#else
#define MBEDTLS_MPS_TRACE_MASK_WRITER
#endif

#define MBEDTLS_MPS_TRACE_MASK

/* We have to avoid globals because E-ACSL chokes on them...
 * Wrap everything in stub functions. */
int  mbedtls_mps_trace_get_depth(void);
void mbedtls_mps_trace_inc_depth(void);
void mbedtls_mps_trace_dec_depth(void);

void mbedtls_mps_trace_color(int id);
void mbedtls_mps_trace_indent(int level, mbedtls_mps_trace_type ty);

void mbedtls_mps_trace_print_msg(int id, int line, const char *format, ...);

#define MBEDTLS_MPS_TRACE

#define MBEDTLS_MPS_TRACE_INIT

#define MBEDTLS_MPS_TRACE_END

#define MBEDTLS_MPS_TRACE_RETURN

#else /* MBEDTLS_MPS_TRACE */

#define MBEDTLS_MPS_TRACE(type, ...)
#define MBEDTLS_MPS_TRACE_INIT(...)
#define MBEDTLS_MPS_TRACE_END

#define MBEDTLS_MPS_TRACE_RETURN(val)

#endif /* MBEDTLS_MPS_TRACE */

#endif /* MBEDTLS_MPS_MBEDTLS_MPS_TRACE_H */