2022-10-12 01:31:33 +02:00
|
|
|
#ifndef TYPES_H
|
|
|
|
#define TYPES_H
|
|
|
|
// ****************************************************************************
|
|
|
|
// types.h DB48X project
|
|
|
|
// ****************************************************************************
|
|
|
|
//
|
|
|
|
// File Description:
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// ****************************************************************************
|
|
|
|
// (C) 2022 Christophe de Dinechin <christophe@dinechin.org>
|
|
|
|
// This software is licensed under the terms outlined in LICENSE.txt
|
|
|
|
// ****************************************************************************
|
|
|
|
// This file is part of DB48X.
|
|
|
|
//
|
|
|
|
// DB48X is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms outlined in the LICENSE.txt file
|
|
|
|
//
|
|
|
|
// DB48X is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// ****************************************************************************
|
|
|
|
|
2022-10-14 09:03:35 +02:00
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
2022-10-12 01:31:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
//
|
|
|
|
// Basic data types
|
|
|
|
//
|
|
|
|
// ============================================================================
|
|
|
|
|
2022-10-12 09:17:59 +02:00
|
|
|
typedef unsigned uint;
|
|
|
|
typedef uint8_t byte;
|
2022-10-18 00:32:05 +02:00
|
|
|
typedef const byte *byte_p;
|
2022-10-18 09:51:25 +02:00
|
|
|
typedef uint64_t ularge;
|
|
|
|
typedef int64_t large;
|
2022-10-12 09:17:59 +02:00
|
|
|
typedef const char *cstring;
|
2022-10-24 20:08:03 +02:00
|
|
|
typedef const byte *utf8;
|
2022-10-29 14:46:41 +02:00
|
|
|
typedef unsigned unicode;
|
2022-10-12 01:31:33 +02:00
|
|
|
|
2022-10-14 13:21:24 +02:00
|
|
|
// Indicate that an argument may be unused
|
2022-10-14 13:20:07 +02:00
|
|
|
#define UNUSED __attribute__((unused))
|
2022-10-12 23:44:22 +02:00
|
|
|
|
2023-11-03 19:42:12 +01:00
|
|
|
#define COMPILE_TIME_ASSERT(x) extern int CompileTimeAssert(int[!!(x)-1])
|
2023-07-18 19:43:10 +02:00
|
|
|
|
2023-11-03 19:42:12 +01:00
|
|
|
#define INLINE __attribute__((always_inline))
|
2023-08-26 14:28:59 +02:00
|
|
|
|
|
|
|
template <typename value_type>
|
|
|
|
struct save
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Save a value and reset it to what it was on scope exit
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
{
|
2024-02-22 19:20:12 +01:00
|
|
|
save(value_type &ref, value_type value): ref(ref), saved(ref)
|
2023-08-26 14:28:59 +02:00
|
|
|
{
|
|
|
|
ref = value;
|
|
|
|
}
|
|
|
|
~save()
|
|
|
|
{
|
2024-02-22 19:20:12 +01:00
|
|
|
ref = saved;
|
2023-08-26 14:28:59 +02:00
|
|
|
}
|
|
|
|
value_type &ref;
|
2024-02-22 19:20:12 +01:00
|
|
|
value_type saved;
|
2023-08-26 14:28:59 +02:00
|
|
|
};
|
|
|
|
|
2023-11-04 20:26:55 +01:00
|
|
|
extern void debug_printf(int row, cstring format, ...);
|
|
|
|
extern void debug_wait(int delay);
|
|
|
|
|
2022-10-12 01:31:33 +02:00
|
|
|
#endif // TYPES_H
|