mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Make comments more consistent
- Changes most `/* comments */` to `// comments` - Changes `/**` block comments consistently to `/*` - Adds consistent license comments to all files Also renames `T_POP_SET` to `T_Z80_SET`
This commit is contained in:
@@ -20,4 +20,4 @@ void charmap_Add(char *mapping, uint8_t value);
|
||||
size_t charmap_Convert(char const *input, uint8_t *output);
|
||||
size_t charmap_ConvertNext(char const **input, uint8_t **output);
|
||||
|
||||
#endif /* RGBDS_ASM_CHARMAP_H */
|
||||
#endif // RGBDS_ASM_CHARMAP_H
|
||||
|
||||
@@ -28,4 +28,4 @@ int32_t fix_Round(int32_t i);
|
||||
int32_t fix_Ceil(int32_t i);
|
||||
int32_t fix_Floor(int32_t i);
|
||||
|
||||
#endif /* RGBDS_ASM_FIXPOINT_H */
|
||||
#endif // RGBDS_ASM_FIXPOINT_H
|
||||
|
||||
@@ -60,4 +60,4 @@ void fmt_FinishCharacters(struct FormatSpec *fmt);
|
||||
void fmt_PrintString(char *buf, size_t bufLen, struct FormatSpec const *fmt, char const *value);
|
||||
void fmt_PrintNumber(char *buf, size_t bufLen, struct FormatSpec const *fmt, uint32_t value);
|
||||
|
||||
#endif /* RGBDS_FORMAT_SPEC_H */
|
||||
#endif // RGBDS_FORMAT_SPEC_H
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/*
|
||||
* Contains some assembler-wide defines and externs
|
||||
*/
|
||||
// Contains some assembler-wide defines and externs
|
||||
|
||||
#ifndef RGBDS_ASM_FSTACK_H
|
||||
#define RGBDS_ASM_FSTACK_H
|
||||
@@ -21,13 +19,13 @@
|
||||
|
||||
|
||||
struct FileStackNode {
|
||||
struct FileStackNode *parent; /* Pointer to parent node, for error reporting */
|
||||
/* Line at which the parent context was exited; meaningless for the root level */
|
||||
struct FileStackNode *parent; // Pointer to parent node, for error reporting
|
||||
// Line at which the parent context was exited; meaningless for the root level
|
||||
uint32_t lineNo;
|
||||
|
||||
struct FileStackNode *next; /* Next node in the output linked list */
|
||||
bool referenced; /* If referenced, don't free! */
|
||||
uint32_t ID; /* Set only if referenced: ID within the object file, -1 if not output yet */
|
||||
struct FileStackNode *next; // Next node in the output linked list
|
||||
bool referenced; // If referenced, don't free!
|
||||
uint32_t ID; // Set only if referenced: ID within the object file, -1 if not output yet
|
||||
|
||||
enum {
|
||||
NODE_REPT,
|
||||
@@ -36,16 +34,16 @@ struct FileStackNode {
|
||||
} type;
|
||||
};
|
||||
|
||||
struct FileStackReptNode { /* NODE_REPT */
|
||||
struct FileStackReptNode { // NODE_REPT
|
||||
struct FileStackNode node;
|
||||
uint32_t reptDepth;
|
||||
/* WARNING: if changing this type, change overflow check in `fstk_Init` */
|
||||
uint32_t iters[]; /* REPT iteration counts since last named node, in reverse depth order */
|
||||
// WARNING: if changing this type, change overflow check in `fstk_Init`
|
||||
uint32_t iters[]; // REPT iteration counts since last named node, in reverse depth order
|
||||
};
|
||||
|
||||
struct FileStackNamedNode { /* NODE_FILE, NODE_MACRO */
|
||||
struct FileStackNamedNode { // NODE_FILE, NODE_MACRO
|
||||
struct FileStackNode node;
|
||||
char name[]; /* File name for files, file::macro name for macros */
|
||||
char name[]; // File name for files, file::macro name for macros
|
||||
};
|
||||
|
||||
#define DEFAULT_MAX_DEPTH 64
|
||||
@@ -56,11 +54,11 @@ struct MacroArgs;
|
||||
void fstk_Dump(struct FileStackNode const *node, uint32_t lineNo);
|
||||
void fstk_DumpCurrent(void);
|
||||
struct FileStackNode *fstk_GetFileStack(void);
|
||||
/* The lifetime of the returned chars is until reaching the end of that file */
|
||||
// The lifetime of the returned chars is until reaching the end of that file
|
||||
char const *fstk_GetFileName(void);
|
||||
|
||||
void fstk_AddIncludePath(char const *s);
|
||||
/**
|
||||
/*
|
||||
* @param path The user-provided file name
|
||||
* @param fullPath The address of a pointer, which will be made to point at the full path
|
||||
* The pointer's value must be a valid argument to `realloc`, including NULL
|
||||
@@ -81,4 +79,4 @@ bool fstk_Break(void);
|
||||
void fstk_NewRecursionDepth(size_t newDepth);
|
||||
void fstk_Init(char const *mainPath, size_t maxDepth);
|
||||
|
||||
#endif /* RGBDS_ASM_FSTACK_H */
|
||||
#endif // RGBDS_ASM_FSTACK_H
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAXSTRLEN 255
|
||||
#define MAXSTRLEN 255
|
||||
|
||||
struct LexerState;
|
||||
extern struct LexerState *lexerState;
|
||||
@@ -49,9 +49,7 @@ static inline void lexer_SetGfxDigits(char const digits[4])
|
||||
gfxDigits[3] = digits[3];
|
||||
}
|
||||
|
||||
/*
|
||||
* `path` is referenced, but not held onto..!
|
||||
*/
|
||||
// `path` is referenced, but not held onto..!
|
||||
struct LexerState *lexer_OpenFile(char const *path);
|
||||
struct LexerState *lexer_OpenFileView(char const *path, char *buf, size_t size, uint32_t lineNo);
|
||||
void lexer_RestartRept(uint32_t lineNo);
|
||||
@@ -99,4 +97,4 @@ struct DsArgList {
|
||||
struct Expression *args;
|
||||
};
|
||||
|
||||
#endif /* RGBDS_ASM_LEXER_H */
|
||||
#endif // RGBDS_ASM_LEXER_H
|
||||
|
||||
@@ -34,4 +34,4 @@ uint32_t macro_UseNewUniqueID(void);
|
||||
void macro_ShiftCurrentArgs(int32_t count);
|
||||
uint32_t macro_NbArgs(void);
|
||||
|
||||
#endif
|
||||
#endif // RGBDS_MACRO_H
|
||||
|
||||
@@ -20,7 +20,7 @@ extern bool warnOnHaltNop;
|
||||
extern bool optimizeLoads;
|
||||
extern bool warnOnLdOpt;
|
||||
extern bool verbose;
|
||||
extern bool warnings; /* True to enable warnings, false to disable them. */
|
||||
extern bool warnings; // True to enable warnings, false to disable them.
|
||||
|
||||
extern FILE *dependfile;
|
||||
extern char *targetFileName;
|
||||
@@ -28,4 +28,4 @@ extern bool generatedMissingIncludes;
|
||||
extern bool failedOnMissingInclude;
|
||||
extern bool generatePhonyDeps;
|
||||
|
||||
#endif /* RGBDS_MAIN_H */
|
||||
#endif // RGBDS_MAIN_H
|
||||
|
||||
@@ -22,4 +22,4 @@ void opt_Parse(char const *option);
|
||||
void opt_Push(void);
|
||||
void opt_Pop(void);
|
||||
|
||||
#endif
|
||||
#endif // RGBDS_OPT_H
|
||||
|
||||
@@ -27,4 +27,4 @@ bool out_CreateAssert(enum AssertionType type, struct Expression const *expr,
|
||||
char const *message, uint32_t ofs);
|
||||
void out_WriteObject(void);
|
||||
|
||||
#endif /* RGBDS_ASM_OUTPUT_H */
|
||||
#endif // RGBDS_ASM_OUTPUT_H
|
||||
|
||||
@@ -27,17 +27,13 @@ struct Expression {
|
||||
uint32_t rpnPatchSize; // Size the expression will take in the object file
|
||||
};
|
||||
|
||||
/*
|
||||
* Determines if an expression is known at assembly time
|
||||
*/
|
||||
// Determines if an expression is known at assembly time
|
||||
static inline bool rpn_isKnown(struct Expression const *expr)
|
||||
{
|
||||
return expr->isKnown;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines if an expression is a symbol suitable for const diffing
|
||||
*/
|
||||
// Determines if an expression is a symbol suitable for const diffing
|
||||
static inline bool rpn_isSymbol(const struct Expression *expr)
|
||||
{
|
||||
return expr->isSymbol;
|
||||
@@ -67,4 +63,4 @@ void rpn_CheckRST(struct Expression *expr, const struct Expression *src);
|
||||
void rpn_CheckNBit(struct Expression const *expr, uint8_t n);
|
||||
int32_t rpn_GetConstVal(struct Expression const *expr);
|
||||
|
||||
#endif /* RGBDS_ASM_RPN_H */
|
||||
#endif // RGBDS_ASM_RPN_H
|
||||
|
||||
@@ -23,8 +23,8 @@ struct Section {
|
||||
char *name;
|
||||
enum SectionType type;
|
||||
enum SectionModifier modifier;
|
||||
struct FileStackNode *src; /* Where the section was defined */
|
||||
uint32_t fileLine; /* Line where the section was defined */
|
||||
struct FileStackNode *src; // Where the section was defined
|
||||
uint32_t fileLine; // Line where the section was defined
|
||||
uint32_t size;
|
||||
uint32_t org;
|
||||
uint32_t bank;
|
||||
@@ -79,4 +79,4 @@ void sect_PopSection(void);
|
||||
|
||||
bool sect_IsSizeKnown(struct Section const NONNULL(name));
|
||||
|
||||
#endif
|
||||
#endif // RGBDS_SECTION_H
|
||||
|
||||
@@ -32,28 +32,28 @@ enum SymbolType {
|
||||
struct Symbol {
|
||||
char name[MAXSYMLEN + 1];
|
||||
enum SymbolType type;
|
||||
bool isExported; /* Whether the symbol is to be exported */
|
||||
bool isBuiltin; /* Whether the symbol is a built-in */
|
||||
bool isExported; // Whether the symbol is to be exported
|
||||
bool isBuiltin; // Whether the symbol is a built-in
|
||||
struct Section *section;
|
||||
struct FileStackNode *src; /* Where the symbol was defined */
|
||||
uint32_t fileLine; /* Line where the symbol was defined */
|
||||
struct FileStackNode *src; // Where the symbol was defined
|
||||
uint32_t fileLine; // Line where the symbol was defined
|
||||
|
||||
bool hasCallback;
|
||||
union {
|
||||
/* If sym_IsNumeric */
|
||||
// If sym_IsNumeric
|
||||
int32_t value;
|
||||
int32_t (*numCallback)(void);
|
||||
/* For SYM_MACRO and SYM_EQUS; TODO: have separate fields */
|
||||
// For SYM_MACRO and SYM_EQUS; TODO: have separate fields
|
||||
struct {
|
||||
size_t macroSize;
|
||||
char *macro;
|
||||
};
|
||||
/* For SYM_EQUS */
|
||||
// For SYM_EQUS
|
||||
char const *(*strCallback)(void);
|
||||
};
|
||||
|
||||
uint32_t ID; /* ID of the symbol in the object file (-1 if none) */
|
||||
struct Symbol *next; /* Next object to output in the object file */
|
||||
uint32_t ID; // ID of the symbol in the object file (-1 if none)
|
||||
struct Symbol *next; // Next object to output in the object file
|
||||
};
|
||||
|
||||
bool sym_IsPC(struct Symbol const *sym);
|
||||
@@ -98,9 +98,7 @@ static inline bool sym_IsExported(struct Symbol const *sym)
|
||||
return sym->isExported;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a string equate's value
|
||||
*/
|
||||
// Get a string equate's value
|
||||
static inline char const *sym_GetStringValue(struct Symbol const *sym)
|
||||
{
|
||||
if (sym->hasCallback)
|
||||
@@ -123,17 +121,11 @@ struct Symbol *sym_AddVar(char const *symName, int32_t value);
|
||||
uint32_t sym_GetPCValue(void);
|
||||
uint32_t sym_GetConstantSymValue(struct Symbol const *sym);
|
||||
uint32_t sym_GetConstantValue(char const *symName);
|
||||
/*
|
||||
* Find a symbol by exact name, bypassing expansion checks
|
||||
*/
|
||||
// Find a symbol by exact name, bypassing expansion checks
|
||||
struct Symbol *sym_FindExactSymbol(char const *symName);
|
||||
/*
|
||||
* Find a symbol by exact name; may not be scoped, produces an error if it is
|
||||
*/
|
||||
// Find a symbol by exact name; may not be scoped, produces an error if it is
|
||||
struct Symbol *sym_FindUnscopedSymbol(char const *symName);
|
||||
/*
|
||||
* Find a symbol, possibly scoped, by name
|
||||
*/
|
||||
// Find a symbol, possibly scoped, by name
|
||||
struct Symbol *sym_FindScopedSymbol(char const *symName);
|
||||
struct Symbol const *sym_GetPC(void);
|
||||
struct Symbol *sym_AddMacro(char const *symName, int32_t defLineNo, char *body, size_t size);
|
||||
@@ -143,8 +135,8 @@ struct Symbol *sym_RedefString(char const *symName, char const *value);
|
||||
void sym_Purge(char const *symName);
|
||||
void sym_Init(time_t now);
|
||||
|
||||
/* Functions to save and restore the current symbol scope. */
|
||||
// Functions to save and restore the current symbol scope.
|
||||
char const *sym_GetCurrentSymbolScope(void);
|
||||
void sym_SetCurrentSymbolScope(char const *newScope);
|
||||
|
||||
#endif /* RGBDS_SYMBOL_H */
|
||||
#endif // RGBDS_SYMBOL_H
|
||||
|
||||
@@ -18,4 +18,4 @@ char const *printChar(int c);
|
||||
*/
|
||||
size_t readUTF8Char(uint8_t *dest, char const *src);
|
||||
|
||||
#endif /* RGBDS_UTIL_H */
|
||||
#endif // RGBDS_UTIL_H
|
||||
|
||||
@@ -91,4 +91,4 @@ _Noreturn void fatalerror(char const *fmt, ...) format_(printf, 1, 2);
|
||||
*/
|
||||
void error(char const *fmt, ...) format_(printf, 1, 2);
|
||||
|
||||
#endif
|
||||
#endif // WARNING_H
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Allocator adaptor that interposes construct() calls to convert value-initialization
|
||||
* (which is what you get with e.g. `vector::resize`) into default-initialization (which does not
|
||||
* zero out non-class types).
|
||||
@@ -36,4 +36,4 @@ public:
|
||||
template<typename T>
|
||||
using DefaultInitVec = std::vector<T, default_init_allocator<T>>;
|
||||
|
||||
#endif
|
||||
#endif // DEFAULT_INIT_ALLOC_H
|
||||
|
||||
@@ -26,4 +26,4 @@ _Noreturn void errx(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RGBDS_ERROR_H */
|
||||
#endif // RGBDS_ERROR_H
|
||||
|
||||
2
include/extern/utf8decoder.h
vendored
2
include/extern/utf8decoder.h
vendored
@@ -11,4 +11,4 @@
|
||||
|
||||
uint32_t decode(uint32_t *state, uint32_t *codep, uint8_t byte);
|
||||
|
||||
#endif /* EXTERN_UTF8DECODER_H */
|
||||
#endif // EXTERN_UTF8DECODER_H
|
||||
|
||||
@@ -71,19 +71,19 @@ struct Options {
|
||||
|
||||
extern Options options;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Prints the error count, and exits with failure
|
||||
*/
|
||||
[[noreturn]] void giveUp();
|
||||
/**
|
||||
/*
|
||||
* Prints a warning, and does not change the error count
|
||||
*/
|
||||
void warning(char const *fmt, ...);
|
||||
/**
|
||||
/*
|
||||
* Prints an error, and increments the error count
|
||||
*/
|
||||
void error(char const *fmt, ...);
|
||||
/**
|
||||
/*
|
||||
* Prints a fatal error, increments the error count, and gives up
|
||||
*/
|
||||
[[noreturn]] void fatal(char const *fmt, ...);
|
||||
@@ -120,4 +120,4 @@ static constexpr auto flipTable(std::integer_sequence<T, i...>) {
|
||||
// Flipping tends to happen fairly often, so take a bite out of dcache to speed it up
|
||||
static constexpr auto flipTable = detail::flipTable(std::make_integer_sequence<uint16_t, 256>());
|
||||
|
||||
#endif /* RGBDS_GFX_MAIN_HPP */
|
||||
#endif // RGBDS_GFX_MAIN_HPP
|
||||
|
||||
@@ -21,7 +21,7 @@ class ProtoPalette;
|
||||
|
||||
namespace packing {
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns which palette each proto-palette maps to, and how many palettes are necessary
|
||||
*/
|
||||
std::tuple<DefaultInitVec<size_t>, size_t>
|
||||
@@ -29,4 +29,4 @@ std::tuple<DefaultInitVec<size_t>, size_t>
|
||||
|
||||
}
|
||||
|
||||
#endif /* RGBDS_GFX_PAL_PACKING_HPP */
|
||||
#endif // RGBDS_GFX_PAL_PACKING_HPP
|
||||
|
||||
@@ -29,4 +29,4 @@ void rgb(std::vector<Palette> &palettes);
|
||||
|
||||
}
|
||||
|
||||
#endif /* RGBDS_GFX_PAL_SORTING_HPP */
|
||||
#endif // RGBDS_GFX_PAL_SORTING_HPP
|
||||
|
||||
@@ -12,4 +12,4 @@
|
||||
void parseInlinePalSpec(char const * const arg);
|
||||
void parseExternalPalSpec(char const *arg);
|
||||
|
||||
#endif /* RGBDS_GFX_PAL_SPEC_HPP */
|
||||
#endif // RGBDS_GFX_PAL_SPEC_HPP
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
|
||||
void process();
|
||||
|
||||
#endif /* RGBDS_GFX_CONVERT_HPP */
|
||||
#endif // RGBDS_GFX_CONVERT_HPP
|
||||
|
||||
@@ -21,7 +21,7 @@ class ProtoPalette {
|
||||
std::array<uint16_t, 4> _colorIndices{UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX};
|
||||
|
||||
public:
|
||||
/**
|
||||
/*
|
||||
* Adds the specified color to the set
|
||||
* Returns false if the set is full
|
||||
*/
|
||||
@@ -41,4 +41,4 @@ public:
|
||||
decltype(_colorIndices)::const_iterator end() const;
|
||||
};
|
||||
|
||||
#endif /* RGBDS_GFX_PROTO_PALETTE_HPP */
|
||||
#endif // RGBDS_GFX_PROTO_PALETTE_HPP
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
|
||||
void reverse();
|
||||
|
||||
#endif /* RGBDS_GFX_REVERSE_HPP */
|
||||
#endif // RGBDS_GFX_REVERSE_HPP
|
||||
|
||||
@@ -20,7 +20,7 @@ struct Rgba {
|
||||
|
||||
constexpr Rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
: red(r), green(g), blue(b), alpha(a) {}
|
||||
/**
|
||||
/*
|
||||
* Constructs the color from a "packed" RGBA representation (0xRRGGBBAA)
|
||||
*/
|
||||
explicit constexpr Rgba(uint32_t rgba = 0)
|
||||
@@ -35,7 +35,7 @@ struct Rgba {
|
||||
(uint8_t)(cgbColor & 0x8000 ? 0x00 : 0xFF)};
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns this RGBA as a 32-bit number that can be printed in hex (`%08x`) to yield its CSS
|
||||
* representation
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ struct Rgba {
|
||||
}
|
||||
friend bool operator!=(Rgba const &lhs, Rgba const &rhs) { return lhs.toCSS() != rhs.toCSS(); }
|
||||
|
||||
/**
|
||||
/*
|
||||
* CGB colors are RGB555, so we use bit 15 to signify that the color is transparent instead
|
||||
* Since the rest of the bits don't matter then, we return 0x8000 exactly.
|
||||
*/
|
||||
@@ -55,7 +55,7 @@ struct Rgba {
|
||||
bool isTransparent() const { return alpha < transparency_threshold; }
|
||||
static constexpr uint8_t opacity_threshold = 0xF0;
|
||||
bool isOpaque() const { return alpha >= opacity_threshold; }
|
||||
/**
|
||||
/*
|
||||
* Computes the equivalent CGB color, respects the color curve depending on options
|
||||
*/
|
||||
uint16_t cgbColor() const;
|
||||
@@ -64,4 +64,4 @@ struct Rgba {
|
||||
uint8_t grayIndex() const;
|
||||
};
|
||||
|
||||
#endif /* RGBDS_GFX_RGBA_HPP */
|
||||
#endif // RGBDS_GFX_RGBA_HPP
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Generic hashmap implementation (C++ templates are calling...) */
|
||||
// Generic hashmap implementation (C++ templates are calling...)
|
||||
#ifndef RGBDS_LINK_HASHMAP_H
|
||||
#define RGBDS_LINK_HASHMAP_H
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
static_assert(HALF_HASH_NB_BITS * 2 == HASH_NB_BITS, "");
|
||||
#define HASHMAP_NB_BUCKETS (1 << HALF_HASH_NB_BITS)
|
||||
|
||||
/* HashMapEntry is internal, please do not attempt to use it */
|
||||
// HashMapEntry is internal, please do not attempt to use it
|
||||
typedef struct HashMapEntry *HashMap[HASHMAP_NB_BUCKETS];
|
||||
|
||||
/**
|
||||
/*
|
||||
* Adds an element to a hashmap.
|
||||
* @warning Adding a new element with an already-present key will not cause an
|
||||
* error, this must be handled externally.
|
||||
@@ -33,7 +33,7 @@ typedef struct HashMapEntry *HashMap[HASHMAP_NB_BUCKETS];
|
||||
*/
|
||||
void **hash_AddElement(HashMap map, char const *key, void *element);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Removes an element from a hashmap.
|
||||
* @param map The HashMap to remove the element from
|
||||
* @param key The key to search the element with
|
||||
@@ -41,7 +41,7 @@ void **hash_AddElement(HashMap map, char const *key, void *element);
|
||||
*/
|
||||
bool hash_RemoveElement(HashMap map, char const *key);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Finds an element in a hashmap, and returns a pointer to its value field.
|
||||
* @param map The map to consider the elements of
|
||||
* @param key The key to search an element for
|
||||
@@ -49,7 +49,7 @@ bool hash_RemoveElement(HashMap map, char const *key);
|
||||
*/
|
||||
void **hash_GetNode(HashMap const map, char const *key);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Finds an element in a hashmap.
|
||||
* @param map The map to consider the elements of
|
||||
* @param key The key to search an element for
|
||||
@@ -58,7 +58,7 @@ void **hash_GetNode(HashMap const map, char const *key);
|
||||
*/
|
||||
void *hash_GetElement(HashMap const map, char const *key);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Executes a function on each element in a hashmap.
|
||||
* @param map The map to consider the elements of
|
||||
* @param func The function to run. The first argument will be the element,
|
||||
@@ -67,11 +67,11 @@ void *hash_GetElement(HashMap const map, char const *key);
|
||||
*/
|
||||
void hash_ForEach(HashMap const map, void (*func)(void *, void *), void *arg);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Cleanly empties a hashmap from its contents.
|
||||
* This does not `free` the data structure itself!
|
||||
* @param map The map to empty
|
||||
*/
|
||||
void hash_EmptyMap(HashMap map);
|
||||
|
||||
#endif /* RGBDS_LINK_HASHMAP_H */
|
||||
#endif // RGBDS_LINK_HASHMAP_H
|
||||
|
||||
@@ -93,4 +93,4 @@
|
||||
// (Having two instances of `arr` is OK because the contents of `sizeof` are not evaluated.)
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof *(arr))
|
||||
|
||||
#endif /* HELPERS_H */
|
||||
#endif // HELPERS_H
|
||||
|
||||
@@ -79,12 +79,10 @@ using Holder = std::conditional_t<std::is_lvalue_reference_v<T>, T,
|
||||
std::remove_cv_t<std::remove_reference_t<T>>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the same number of iterations as the first container's iterator!
|
||||
*/
|
||||
// Does the same number of iterations as the first container's iterator!
|
||||
template<typename... Containers>
|
||||
static constexpr auto zip(Containers &&...cs) {
|
||||
return detail::ZipContainer<detail::Holder<Containers>...>(std::forward<Containers>(cs)...);
|
||||
}
|
||||
|
||||
#endif /* RGBDS_ITERTOOLS_HPP */
|
||||
#endif // RGBDS_ITERTOOLS_HPP
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Assigning all sections a place */
|
||||
// Assigning all sections a place
|
||||
#ifndef RGBDS_LINK_ASSIGN_H
|
||||
#define RGBDS_LINK_ASSIGN_H
|
||||
|
||||
@@ -14,14 +14,10 @@
|
||||
|
||||
extern uint64_t nbSectionsToAssign;
|
||||
|
||||
/**
|
||||
* Assigns all sections a slice of the address space
|
||||
*/
|
||||
// Assigns all sections a slice of the address space
|
||||
void assign_AssignSections(void);
|
||||
|
||||
/**
|
||||
* `free`s all assignment memory that was allocated.
|
||||
*/
|
||||
// `free`s all assignment memory that was allocated
|
||||
void assign_Cleanup(void);
|
||||
|
||||
#endif /* RGBDS_LINK_ASSIGN_H */
|
||||
#endif // RGBDS_LINK_ASSIGN_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Declarations that all modules use, as well as `main` and related */
|
||||
// Declarations that all modules use, as well as `main` and related
|
||||
#ifndef RGBDS_LINK_MAIN_H
|
||||
#define RGBDS_LINK_MAIN_H
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
/* Variables related to CLI options */
|
||||
// Variables related to CLI options
|
||||
extern bool isDmgMode;
|
||||
extern char *linkerScriptName;
|
||||
extern char const *mapFileName;
|
||||
@@ -35,7 +35,7 @@ extern bool disablePadding;
|
||||
|
||||
struct FileStackNode {
|
||||
struct FileStackNode *parent;
|
||||
/* Line at which the parent context was exited; meaningless for the root level */
|
||||
// Line at which the parent context was exited; meaningless for the root level
|
||||
uint32_t lineNo;
|
||||
|
||||
enum {
|
||||
@@ -44,21 +44,21 @@ struct FileStackNode {
|
||||
NODE_MACRO,
|
||||
} type;
|
||||
union {
|
||||
char *name; /* NODE_FILE, NODE_MACRO */
|
||||
struct { /* NODE_REPT */
|
||||
char *name; // NODE_FILE, NODE_MACRO
|
||||
struct { // NODE_REPT
|
||||
uint32_t reptDepth;
|
||||
uint32_t *iters;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* Helper macro for printing verbose-mode messages */
|
||||
// Helper macro for printing verbose-mode messages
|
||||
#define verbosePrint(...) do { \
|
||||
if (beVerbose) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
/*
|
||||
* Dump a file stack to stderr
|
||||
* @param node The leaf node to dump the context of
|
||||
*/
|
||||
@@ -73,7 +73,7 @@ void error(struct FileStackNode const *where, uint32_t lineNo,
|
||||
_Noreturn void fatal(struct FileStackNode const *where, uint32_t lineNo,
|
||||
char const *fmt, ...) format_(printf, 3, 4);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Opens a file if specified, and aborts on error.
|
||||
* @param fileName The name of the file to open; if NULL, no file will be opened
|
||||
* @param mode The mode to open the file with
|
||||
@@ -87,4 +87,4 @@ FILE *openFile(char const *fileName, char const *mode);
|
||||
fclose(tmp); \
|
||||
} while (0)
|
||||
|
||||
#endif /* RGBDS_LINK_MAIN_H */
|
||||
#endif // RGBDS_LINK_MAIN_H
|
||||
|
||||
@@ -6,37 +6,37 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Declarations related to processing of object (.o) files */
|
||||
// Declarations related to processing of object (.o) files
|
||||
|
||||
#ifndef RGBDS_LINK_OBJECT_H
|
||||
#define RGBDS_LINK_OBJECT_H
|
||||
|
||||
/**
|
||||
/*
|
||||
* Read an object (.o) file, and add its info to the data structures.
|
||||
* @param fileName A path to the object file to be read
|
||||
* @param i The ID of the file
|
||||
*/
|
||||
void obj_ReadFile(char const *fileName, unsigned int i);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Perform validation on the object files' contents
|
||||
*/
|
||||
void obj_DoSanityChecks(void);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Evaluate all assertions
|
||||
*/
|
||||
void obj_CheckAssertions(void);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Sets up object file reading
|
||||
* @param nbFiles The number of object files that will be read
|
||||
*/
|
||||
void obj_Setup(unsigned int nbFiles);
|
||||
|
||||
/**
|
||||
/*
|
||||
* `free`s all object memory that was allocated.
|
||||
*/
|
||||
void obj_Cleanup(void);
|
||||
|
||||
#endif /* RGBDS_LINK_OBJECT_H */
|
||||
#endif // RGBDS_LINK_OBJECT_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Outputting the result of linking */
|
||||
// Outputting the result of linking
|
||||
#ifndef RGBDS_LINK_OUTPUT_H
|
||||
#define RGBDS_LINK_OUTPUT_H
|
||||
|
||||
@@ -14,22 +14,22 @@
|
||||
|
||||
#include "link/section.h"
|
||||
|
||||
/**
|
||||
/*
|
||||
* Registers a section for output.
|
||||
* @param section The section to add
|
||||
*/
|
||||
void out_AddSection(struct Section const *section);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Finds an assigned section overlapping another one.
|
||||
* @param section The section that is being overlapped
|
||||
* @return A section overlapping it
|
||||
*/
|
||||
struct Section const *out_OverlappingSection(struct Section const *section);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Writes all output (bin, sym, map) files.
|
||||
*/
|
||||
void out_WriteFiles(void);
|
||||
|
||||
#endif /* RGBDS_LINK_OUTPUT_H */
|
||||
#endif // RGBDS_LINK_OUTPUT_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Applying patches to SECTIONs */
|
||||
// Applying patches to SECTIONs
|
||||
#ifndef RGBDS_LINK_PATCH_H
|
||||
#define RGBDS_LINK_PATCH_H
|
||||
|
||||
@@ -27,15 +27,15 @@ struct Assertion {
|
||||
struct Assertion *next;
|
||||
};
|
||||
|
||||
/**
|
||||
/*
|
||||
* Checks all assertions
|
||||
* @return true if assertion failed
|
||||
*/
|
||||
void patch_CheckAssertions(struct Assertion *assertion);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Applies all SECTIONs' patches to them
|
||||
*/
|
||||
void patch_ApplyPatches(void);
|
||||
|
||||
#endif /* RGBDS_LINK_PATCH_H */
|
||||
#endif // RGBDS_LINK_PATCH_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Parsing a linker script */
|
||||
// Parsing a linker script
|
||||
#ifndef RGBDS_LINK_SCRIPT_H
|
||||
#define RGBDS_LINK_SCRIPT_H
|
||||
|
||||
@@ -24,15 +24,15 @@ struct SectionPlacement {
|
||||
|
||||
extern uint64_t script_lineNo;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Parses the linker script to return the next section constraint
|
||||
* @return A pointer to a struct, or NULL on EOF. The pointer shouldn't be freed
|
||||
*/
|
||||
struct SectionPlacement *script_NextSection(void);
|
||||
|
||||
/**
|
||||
/*
|
||||
* `free`s all assignment memory that was allocated.
|
||||
*/
|
||||
void script_Cleanup(void);
|
||||
|
||||
#endif /* RGBDS_LINK_SCRIPT_H */
|
||||
#endif // RGBDS_LINK_SCRIPT_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Assigning all sections a place */
|
||||
// Assigning all sections a place
|
||||
#ifndef RGBDS_LINK_SDAS_OBJ_H
|
||||
#define RGBDS_LINK_SDAS_OBJ_H
|
||||
|
||||
@@ -16,4 +16,4 @@ struct FileStackNode;
|
||||
|
||||
void sdobj_ReadFile(struct FileStackNode const *fileName, FILE *file);
|
||||
|
||||
#endif /* RGBDS_LINK_SDAS_OBJ_H */
|
||||
#endif // RGBDS_LINK_SDAS_OBJ_H
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Declarations manipulating symbols */
|
||||
// Declarations manipulating symbols
|
||||
#ifndef RGBDS_LINK_SECTION_H
|
||||
#define RGBDS_LINK_SECTION_H
|
||||
|
||||
/* GUIDELINE: external code MUST NOT BE AWARE of the data structure used!! */
|
||||
// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!!
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -41,7 +41,7 @@ struct Patch {
|
||||
};
|
||||
|
||||
struct Section {
|
||||
/* Info contained in the object files */
|
||||
// Info contained in the object files
|
||||
char *name;
|
||||
uint16_t size;
|
||||
uint16_t offset;
|
||||
@@ -56,14 +56,14 @@ struct Section {
|
||||
bool isAlignFixed;
|
||||
uint16_t alignMask;
|
||||
uint16_t alignOfs;
|
||||
uint8_t *data; /* Array of size `size`*/
|
||||
uint8_t *data; // Array of size `size`
|
||||
uint32_t nbPatches;
|
||||
struct Patch *patches;
|
||||
/* Extra info computed during linking */
|
||||
// Extra info computed during linking
|
||||
struct Symbol **fileSymbols;
|
||||
uint32_t nbSymbols;
|
||||
struct Symbol **symbols;
|
||||
struct Section *nextu; /* The next "component" of this unionized sect */
|
||||
struct Section *nextu; // The next "component" of this unionized sect
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -76,27 +76,27 @@ struct Section {
|
||||
*/
|
||||
void sect_ForEach(void (*callback)(struct Section *, void *), void *arg);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Registers a section to be processed.
|
||||
* @param section The section to register.
|
||||
*/
|
||||
void sect_AddSection(struct Section *section);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Finds a section by its name.
|
||||
* @param name The name of the section to look for
|
||||
* @return A pointer to the section, or NULL if it wasn't found
|
||||
*/
|
||||
struct Section *sect_GetSection(char const *name);
|
||||
|
||||
/**
|
||||
/*
|
||||
* `free`s all section memory that was allocated.
|
||||
*/
|
||||
void sect_CleanupSections(void);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Checks if all sections meet reasonable criteria, such as max size
|
||||
*/
|
||||
void sect_DoSanityChecks(void);
|
||||
|
||||
#endif /* RGBDS_LINK_SECTION_H */
|
||||
#endif // RGBDS_LINK_SECTION_H
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* Declarations manipulating symbols */
|
||||
// Declarations manipulating symbols
|
||||
#ifndef RGBDS_LINK_SYMBOL_H
|
||||
#define RGBDS_LINK_SYMBOL_H
|
||||
|
||||
/* GUIDELINE: external code MUST NOT BE AWARE of the data structure used!! */
|
||||
// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!!
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
struct FileStackNode;
|
||||
|
||||
struct Symbol {
|
||||
/* Info contained in the object files */
|
||||
// Info contained in the object files
|
||||
char *name;
|
||||
enum ExportLevel type;
|
||||
char const *objFileName;
|
||||
@@ -31,7 +31,7 @@ struct Symbol {
|
||||
int32_t offset;
|
||||
int32_t value;
|
||||
};
|
||||
/* Extra info computed during linking */
|
||||
// Extra info computed during linking
|
||||
struct Section *section;
|
||||
};
|
||||
|
||||
@@ -47,16 +47,16 @@ void sym_ForEach(void (*callback)(struct Symbol *, void *), void *arg);
|
||||
|
||||
void sym_AddSymbol(struct Symbol *symbol);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Finds a symbol in all the defined symbols.
|
||||
* @param name The name of the symbol to look for
|
||||
* @return A pointer to the symbol, or NULL if not found.
|
||||
*/
|
||||
struct Symbol *sym_GetSymbol(char const *name);
|
||||
|
||||
/**
|
||||
/*
|
||||
* `free`s all symbol memory that was allocated.
|
||||
*/
|
||||
void sym_CleanupSymbols(void);
|
||||
|
||||
#endif /* RGBDS_LINK_SYMBOL_H */
|
||||
#endif // RGBDS_LINK_SYMBOL_H
|
||||
|
||||
@@ -88,7 +88,7 @@ extern struct SectionTypeInfo {
|
||||
uint32_t lastBank;
|
||||
} sectionTypeInfo[SECTTYPE_INVALID];
|
||||
|
||||
/**
|
||||
/*
|
||||
* Tells whether a section has data in its object file definition,
|
||||
* depending on type.
|
||||
* @param type The section's type
|
||||
@@ -100,7 +100,7 @@ static inline bool sect_HasData(enum SectionType type)
|
||||
return type == SECTTYPE_ROM0 || type == SECTTYPE_ROMX;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Computes a memory region's end address (last byte), eg. 0x7FFF
|
||||
* @return The address of the last byte in that memory region
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ static inline uint16_t endaddr(enum SectionType type)
|
||||
return sectionTypeInfo[type].startAddr + sectionTypeInfo[type].size - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Computes a memory region's number of banks
|
||||
* @return The number of banks, 1 for regions without banking
|
||||
*/
|
||||
@@ -141,4 +141,4 @@ enum PatchType {
|
||||
PATCHTYPE_INVALID
|
||||
};
|
||||
|
||||
#endif /* RGBDS_LINKDEFS_H */
|
||||
#endif // RGBDS_LINKDEFS_H
|
||||
|
||||
@@ -18,4 +18,4 @@ int32_t op_shift_left(int32_t value, int32_t amount);
|
||||
int32_t op_shift_right(int32_t value, int32_t amount);
|
||||
int32_t op_shift_right_unsigned(int32_t value, int32_t amount);
|
||||
|
||||
#endif /* RGBDS_OP_MATH_H */
|
||||
#endif // RGBDS_OP_MATH_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/* platform-specific hacks */
|
||||
// platform-specific hacks
|
||||
|
||||
#ifndef RGBDS_PLATFORM_H
|
||||
#define RGBDS_PLATFORM_H
|
||||
@@ -20,20 +20,20 @@
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
/* MSVC has deprecated strdup in favor of _strdup */
|
||||
// MSVC has deprecated strdup in favor of _strdup
|
||||
#ifdef _MSC_VER
|
||||
# define strdup _strdup
|
||||
#endif
|
||||
|
||||
/* MSVC prefixes the names of S_* macros with underscores,
|
||||
and doesn't define any S_IS* macros. Define them ourselves */
|
||||
// MSVC prefixes the names of S_* macros with underscores,
|
||||
// and doesn't define any S_IS* macros; define them ourselves
|
||||
#ifdef _MSC_VER
|
||||
# define S_IFMT _S_IFMT
|
||||
# define S_IFDIR _S_IFDIR
|
||||
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* MSVC doesn't use POSIX types or defines for `read` */
|
||||
// MSVC doesn't use POSIX types or defines for `read`
|
||||
#ifdef _MSC_VER
|
||||
# include <io.h>
|
||||
# define STDIN_FILENO 0
|
||||
@@ -46,7 +46,7 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* MSVC doesn't support `[static N]` for array arguments from C99 or C11 */
|
||||
// MSVC doesn't support `[static N]` for array arguments from C99 or C11
|
||||
#ifdef _MSC_VER
|
||||
# define MIN_NB_ELMS(N)
|
||||
# define ARR_QUALS(...)
|
||||
@@ -75,4 +75,4 @@
|
||||
# define setmode(fd, mode) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* RGBDS_PLATFORM_H */
|
||||
#endif // RGBDS_PLATFORM_H
|
||||
|
||||
@@ -24,4 +24,4 @@ char const *get_package_version_string(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EXTERN_VERSION_H */
|
||||
#endif // EXTERN_VERSION_H
|
||||
|
||||
Reference in New Issue
Block a user