Add doxygen docs

This commit is contained in:
Henrik Stickann
2022-05-10 15:36:48 +02:00
parent 8efed8802d
commit f4e3a0ae1c
8 changed files with 339 additions and 160 deletions

View File

@@ -1,34 +1,66 @@
/**
* @file
* @brief Helper for useful compiler features.
*/
#ifndef STA_LANG_HPP
#define STA_LANG_HPP
/**
* @defgroup staCoreLang Lang
* @ingroup staCore
* @brief Compiler instructions.
* @{
*/
/**
* @brief Assembler instruction.
*/
#ifndef STA_ASM
# define STA_ASM __asm
#endif // STA_ASM
/**
* @brief Mark as deprecated.
*/
#ifndef STA_DEPRECATED
# define STA_DEPRECATED __attribute__((deprecated))
#endif // STA_DEPRECATED
/**
* @brief Mark as weak definition.
*/
#ifndef STA_WEAK
# define STA_WEAK __attribute__((weak))
#endif // STA_WEAK
/**
* @brief Mark as field w/o added padding.
*/
#ifndef STA_PACKED
# define STA_PACKED __attribute__((packed))
#endif // STA_PACKED
/**
* @brief Mark as struct w/o added padding.
*/
#ifndef STA_PACKED_STRUCT
# define STA_PACKED_STRUCT struct STA_PACKED
#endif // STA_PACKED_STRUCT
/**
* @brief Mark as union w/o added padding.
*/
#ifndef STA_PACKED_UNION
# define STA_PACKED_UNION union STA_PACKED
#endif // STA_PACKED_UNION
/**
* @brief Add breakpoint.
*
* @param value Additional uint16_t data for debugger
*/
#ifndef STA_BKPT
# define STA_BKPT(value) STA_ASM volatile ("bkpt "#value)
#endif // STA_BKPT
@@ -37,17 +69,48 @@
// TODO Check for GCC
/**
* @brief Helper for silencing compiler warnings in unreachable code locations.
* @brief Silencing compiler warnings in unreachable code locations.
*
* Example: Default of switch handling all cases of enum class
* Example:
* @code
* enum class E { A };
*
* E val = A;
*
* switch (val)
* {
* case E::A:
* break;
*
* default:
* // All enum values already handled
* STA_UNREACHABLE();
* }
* @endcode
*/
#ifndef STA_UNREACHABLE
# define STA_UNREACHABLE() __builtin_unreachable()
#endif // !STA_UNREACHABLE
/**
* @brief Silencing compiler warnings for intended switch case fallthrough.
*
* Example:
* @code
* switch (val)
* {
* case A: STA_FALLTHROUGH();
* case B:
* do();
* break;
* }
* @endcode
*/
#ifndef STA_FALLTRHOUGH
# define STA_FALLTHROUGH() __attribute__((fallthrough))
#endif // !STA_FALLTRHOUGH
/** @} */
#endif // STA_LANG_HPP