#ifndef INCLUDE_GENERAL_H
#define INCLUDE_GENERAL_H
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#if !defined(__USE_MINGW_ANSI_STDIO)
#define __USE_MINGW_ANSI_STDIO 1
#endif
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <sys/types.h>
#include "maths_utils.h"
#include "timing.h"
#include "platform_support.h"
#include "align.h"
#ifndef ARRAY_LENGTH
#define ARRAY_LENGTH(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
#define FREQ_FIXED 0xffffffffU
#if PC_HOSTED == 0
#if !defined(PLATFORM_PRINTF)
#define PLATFORM_PRINTF printf
#endif
#define PRINT_NOOP(...) \
do { \
} while (false)
#if defined(ENABLE_DEBUG)
#define DEBUG_ERROR(...) PLATFORM_PRINTF(__VA_ARGS__)
#define DEBUG_WARN(...) PLATFORM_PRINTF(__VA_ARGS__)
#define DEBUG_INFO(...) PLATFORM_PRINTF(__VA_ARGS__)
#else
#define DEBUG_ERROR(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_WARN(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_INFO(...) PRINT_NOOP(__VA_ARGS__)
#endif
#define DEBUG_GDB(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_TARGET(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_PROTO(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_PROBE(...) PRINT_NOOP(__VA_ARGS__)
#define DEBUG_WIRE(...) PRINT_NOOP(__VA_ARGS__)
void debug_serial_send_stdout(const uint8_t *data, size_t len);
#else
#include "debug.h"
#define DEBUG_ERROR(...) debug_error(__VA_ARGS__)
#define DEBUG_WARN(...) debug_warning(__VA_ARGS__)
#define DEBUG_INFO(...) debug_info(__VA_ARGS__)
#define DEBUG_GDB(...) debug_gdb(__VA_ARGS__)
#define DEBUG_TARGET(...) debug_target(__VA_ARGS__)
#define DEBUG_PROTO(...) debug_protocol(__VA_ARGS__)
#define DEBUG_PROBE(...) debug_probe(__VA_ARGS__)
#define DEBUG_WIRE(...) debug_wire(__VA_ARGS__)
#endif
#undef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#undef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif