Skip to content

Commit

Permalink
chore: use attributes that will not be expanded by doxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
marcluque committed Oct 23, 2022
1 parent 3f5edfb commit b115d70
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void UNKNOWN_OPCODE(void) {

#else

_Noreturn static void UNKNOWN_OPCODE(void) {
ATTR_NORETURN static void UNKNOWN_OPCODE(void) {
YOBEMAG_EXIT("An unsupported instruction was encountered: 0x%x", cpu.opcode);
}

Expand All @@ -48,11 +48,11 @@ CPU cpu = {
0,
};

__attribute((always_inline)) inline static void clear_flag_register(void) {
ATTR_ALWAYS_INLINE inline static void clear_flag_register(void) {
CPU_REG_F = 0;
}

__attribute__((always_inline)) inline static void LD_REG_REG(uint8_t *register_one, uint8_t register_two) {
ATTR_ALWAYS_INLINE inline static void LD_REG_REG(uint8_t *register_one, uint8_t register_two) {
*register_one = register_two;
}

Expand Down
11 changes: 5 additions & 6 deletions src/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#define YOBEMAG_CPU_H

#include <stdint.h>
#include "attributes.h"

/**
* Encodes bit positions for flag register A
*/
typedef enum flag {
typedef enum Flag {
/**
* @brief Carry flag
*/
Expand Down Expand Up @@ -70,15 +71,15 @@ void cpu_step(void);

void cpu_print_registers(void);

__attribute((always_inline)) inline uint8_t get_flag(Flag f) {
ATTR_ALWAYS_INLINE inline uint8_t get_flag(Flag f) {
return (CPU_REG_F >> f) & 1;
}

__attribute((always_inline)) inline void set_flag(uint8_t bit, Flag f) {
ATTR_ALWAYS_INLINE inline void set_flag(uint8_t bit, Flag f) {
CPU_REG_F |= bit << f;
}

__attribute((always_inline)) inline void clear_flag(Flag f) {
ATTR_ALWAYS_INLINE inline void clear_flag(Flag f) {
CPU_REG_F &= (uint8_t) ~(1 << f);
}

Expand Down Expand Up @@ -165,8 +166,6 @@ void OPC_LD_A_HL(void);
void OPC_LD_A_A(void);
void OPC_LD_A_d8(void);

uint16_t cpu_get_two_bytes(uint16_t addr);

/******************************************************
*** 8-BIT ALU ***
******************************************************/
Expand Down
10 changes: 5 additions & 5 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <stdio.h>

#include "attributes.h"

typedef enum LoggingLevel {
DEBUG = -1,
INFO,
Expand Down Expand Up @@ -34,8 +36,7 @@ void log_teardown(void);
* @param msg Format string for the log message
* @param ... Parameters for format string
*/
_Noreturn __attribute__((format(printf, 3, 4))) void log_exit(char const *file_path, int line_number,
char const *msg, ...);
ATTR_NORETURN ATTR_FORMAT3 void log_exit(char const *file_path, int line_number, char const *msg, ...);

/**
* @brief Log a string to @p stream with logging level @p dbg_lvl, (printed as @p log_lvl_str),
Expand All @@ -47,15 +48,14 @@ _Noreturn __attribute__((format(printf, 3, 4))) void log_exit(char const *file_p
* @param msg Format string for the log message
* @param ... Parameters for format string
*/
__attribute__((format(printf, 4, 5))) void log_str(LoggingLevel log_lvl, char const *log_lvl_str, FILE *stream,
char const *msg, ...);
ATTR_FORMAT4 void log_str(LoggingLevel log_lvl, char const *log_lvl_str, FILE *stream, char const *msg, ...);

/*
* This is necessary, since __VA_ARGS__ is a C GNU extension.
* clang will not compile with -Werror, if this warning is not ignored here.
* Ignoring is fine, since clang can handle this GNU extension.
*
* The second ignored diagnostic surpresses "Macro not used" messages.
* The second ignored diagnostic suppresses "Macro not used" messages.
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
Expand Down
5 changes: 3 additions & 2 deletions src/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "attributes.h"

#define ROM_LIMIT (0x8000)
#define BOOT_ROM_SIZE (256)
#define MEM_SIZE (65536)

void mmu_init(void);
__attribute__((pure)) uint8_t mmu_get_byte(uint16_t addr);
ATTR_PURE uint8_t mmu_get_byte(uint16_t addr);
void mmu_write_byte(uint16_t dest_addr, uint8_t value);
__attribute__((pure)) uint16_t mmu_get_two_bytes(uint16_t addr);
ATTR_PURE uint16_t mmu_get_two_bytes(uint16_t addr);
void mmu_write_two_bytes(uint16_t dest_addr, uint16_t value);
void mmu_destroy(void);

Expand Down
3 changes: 2 additions & 1 deletion src/rom.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#define YOBEMAG_ROM_H

#include <stdint.h>
#include "attributes.h"

void rom_init(char const *file_name);
void rom_destroy(void);
__attribute__((pure)) uint8_t *get_rom_bytes(void);
ATTR_PURE uint8_t *get_rom_bytes(void);

#endif // YOBEMAG_ROM_H

0 comments on commit b115d70

Please sign in to comment.