Replace C types by stdint.h types

Not all occurrences have been replaced, in some cases they have been
left as they were before (like in rgbgfx and when they are in the
interface of a C standard library function).

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2017-12-31 15:46:22 +01:00
parent 71961a88a0
commit ec76431c51
25 changed files with 125 additions and 157 deletions

View File

@@ -7,14 +7,14 @@
#define CHARMAPLENGTH 16 #define CHARMAPLENGTH 16
struct Charmap { struct Charmap {
int count; int32_t count;
char input[MAXCHARMAPS][CHARMAPLENGTH + 1]; char input[MAXCHARMAPS][CHARMAPLENGTH + 1];
char output[MAXCHARMAPS]; char output[MAXCHARMAPS];
}; };
int readUTF8Char(char *destination, char *source); int32_t readUTF8Char(char *destination, char *source);
void charmap_Sort(); void charmap_Sort();
int charmap_Add(char *input, uint8_t output); int32_t charmap_Add(char *input, uint8_t output);
int charmap_Convert(char **input); int32_t charmap_Convert(char **input);
#endif #endif

View File

@@ -31,19 +31,15 @@ struct sContext {
uint32_t nREPTBlockSize; uint32_t nREPTBlockSize;
}; };
void void fstk_RunInclude(char *);
fstk_RunInclude(char *);
extern void fstk_RunMacroArg(int32_t s); extern void fstk_RunMacroArg(int32_t s);
void void fstk_Init(char *);
fstk_Init(char *);
extern void fstk_Dump(void); extern void fstk_Dump(void);
extern void fstk_AddIncludePath(char *s); extern void fstk_AddIncludePath(char *s);
extern uint32_t fstk_RunMacro(char *s); extern uint32_t fstk_RunMacro(char *s);
extern void fstk_RunRept(uint32_t count); extern void fstk_RunRept(uint32_t count);
FILE * FILE * fstk_FindFile(char *);
fstk_FindFile(char *); int32_t fstk_GetLine(void);
int fstk_GetLine(void);
extern int yywrap(void); extern int yywrap(void);

View File

@@ -23,13 +23,13 @@ void out_SetFileName(char *s);
void out_NewSection(char *pzName, uint32_t secttype); void out_NewSection(char *pzName, uint32_t secttype);
void out_NewAbsSection(char *pzName, uint32_t secttype, int32_t org, int32_t bank); void out_NewAbsSection(char *pzName, uint32_t secttype, int32_t org, int32_t bank);
void out_NewAlignedSection(char *pzName, uint32_t secttype, int32_t alignment, int32_t bank); void out_NewAlignedSection(char *pzName, uint32_t secttype, int32_t alignment, int32_t bank);
void out_AbsByte(int b); void out_AbsByte(int32_t b);
void out_AbsByteGroup(char *s, int length); void out_AbsByteGroup(char *s, int32_t length);
void out_RelByte(struct Expression * expr); void out_RelByte(struct Expression * expr);
void out_RelWord(struct Expression * expr); void out_RelWord(struct Expression * expr);
void out_PCRelByte(struct Expression * expr); void out_PCRelByte(struct Expression * expr);
void out_WriteObject(void); void out_WriteObject(void);
void out_Skip(int skip); void out_Skip(int32_t skip);
void out_BinaryFile(char *s); void out_BinaryFile(char *s);
void out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length); void out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length);
void out_String(char *s); void out_String(char *s);

View File

@@ -17,60 +17,24 @@ uint32_t rpn_isPCRelative(struct Expression * expr);
void rpn_Symbol(struct Expression * expr, char *tzSym); void rpn_Symbol(struct Expression * expr, char *tzSym);
void rpn_Number(struct Expression * expr, uint32_t i); void rpn_Number(struct Expression * expr, uint32_t i);
void rpn_LOGNOT(struct Expression * expr, struct Expression * src1); void rpn_LOGNOT(struct Expression * expr, struct Expression * src1);
void void rpn_LOGOR(struct Expression * expr, struct Expression * src1, struct Expression * src2);
rpn_LOGOR(struct Expression * expr, struct Expression * src1, void rpn_LOGAND(struct Expression * expr, struct Expression * src1, struct Expression * src2);
struct Expression * src2); void rpn_LOGEQU(struct Expression * expr, struct Expression * src1, struct Expression * src2);
void void rpn_LOGGT(struct Expression * expr, struct Expression * src1, struct Expression * src2);
rpn_LOGAND(struct Expression * expr, struct Expression * src1, void rpn_LOGLT(struct Expression * expr, struct Expression * src1, struct Expression * src2);
struct Expression * src2); void rpn_LOGGE(struct Expression * expr, struct Expression * src1, struct Expression * src2);
void void rpn_LOGLE(struct Expression * expr, struct Expression * src1, struct Expression * src2);
rpn_LOGEQU(struct Expression * expr, struct Expression * src1, void rpn_LOGNE(struct Expression * expr, struct Expression * src1, struct Expression * src2);
struct Expression * src2); void rpn_ADD(struct Expression * expr, struct Expression * src1, struct Expression * src2);
void void rpn_SUB(struct Expression * expr, struct Expression * src1, struct Expression * src2);
rpn_LOGGT(struct Expression * expr, struct Expression * src1, void rpn_XOR(struct Expression * expr, struct Expression * src1, struct Expression * src2);
struct Expression * src2); void rpn_OR(struct Expression * expr, struct Expression * src1, struct Expression * src2);
void void rpn_AND(struct Expression * expr, struct Expression * src1, struct Expression * src2);
rpn_LOGLT(struct Expression * expr, struct Expression * src1, void rpn_SHL(struct Expression * expr, struct Expression * src1, struct Expression * src2);
struct Expression * src2); void rpn_SHR(struct Expression * expr, struct Expression * src1, struct Expression * src2);
void void rpn_MUL(struct Expression * expr, struct Expression * src1, struct Expression * src2);
rpn_LOGGE(struct Expression * expr, struct Expression * src1, void rpn_DIV(struct Expression * expr, struct Expression * src1, struct Expression * src2);
struct Expression * src2); void rpn_MOD(struct Expression * expr, struct Expression * src1, struct Expression * src2);
void
rpn_LOGLE(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_LOGNE(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_ADD(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_SUB(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_XOR(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_OR(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_AND(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_SHL(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_SHR(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_MUL(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_DIV(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void
rpn_MOD(struct Expression * expr, struct Expression * src1,
struct Expression * src2);
void rpn_HIGH(struct Expression * expr, struct Expression * src); void rpn_HIGH(struct Expression * expr, struct Expression * src);
void rpn_LOW(struct Expression * expr, struct Expression * src); void rpn_LOW(struct Expression * expr, struct Expression * src);
void rpn_UNNEG(struct Expression * expr, struct Expression * src); void rpn_UNNEG(struct Expression * expr, struct Expression * src);

View File

@@ -74,6 +74,6 @@ uint32_t sym_GetDefinedValue(char *s);
uint32_t sym_isDefined(char *tzName); uint32_t sym_isDefined(char *tzName);
void sym_Purge(char *tzName); void sym_Purge(char *tzName);
uint32_t sym_isConstDefined(char *tzName); uint32_t sym_isConstDefined(char *tzName);
int sym_IsRelocDiffDefined(char *tzSym1, char *tzSym2); int32_t sym_IsRelocDiffDefined(char *tzSym1, char *tzSym2);
#endif #endif

View File

@@ -30,22 +30,23 @@ enum eBankDefine {
#define MAXBANKS (BANK_COUNT_ROM0 + BANK_COUNT_ROMX + BANK_COUNT_WRAM0 + BANK_COUNT_WRAMX \ #define MAXBANKS (BANK_COUNT_ROM0 + BANK_COUNT_ROMX + BANK_COUNT_WRAM0 + BANK_COUNT_WRAMX \
+ BANK_COUNT_VRAM + BANK_COUNT_OAM + BANK_COUNT_HRAM + BANK_COUNT_SRAM) + BANK_COUNT_VRAM + BANK_COUNT_OAM + BANK_COUNT_HRAM + BANK_COUNT_SRAM)
extern int32_t area_Avail(int32_t bank);
extern void AssignSections(void);
extern void CreateSymbolTable(void);
extern int32_t MaxBankUsed; extern int32_t MaxBankUsed;
extern int32_t MaxAvail[MAXBANKS]; extern int32_t MaxAvail[MAXBANKS];
int int32_t area_Avail(int32_t bank);
void AssignSections(void);
void CreateSymbolTable(void);
int32_t
IsSectionNameInUse(const char *name); IsSectionNameInUse(const char *name);
void void
SetLinkerscriptName(char *tzLinkerscriptFile); SetLinkerscriptName(char *tzLinkerscriptFile);
int int32_t
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank); IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int32_t bank);
unsigned int uint32_t
AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank); AssignSectionAddressAndBankByName(const char *name, uint32_t address, int32_t bank);
#endif #endif

View File

@@ -1,6 +1,6 @@
#ifndef RGBDS_LINK_LIBRARY_H #ifndef RGBDS_LINK_LIBRARY_H
#define RGBDS_LINK_LIBRARY_H #define RGBDS_LINK_LIBRARY_H
extern void AddNeededModules(void); void AddNeededModules(void);
#endif #endif

View File

@@ -3,11 +3,11 @@
#include <stdint.h> #include <stdint.h>
extern void SetMapfileName(char *name); void SetMapfileName(char *name);
extern void SetSymfileName(char *name); void SetSymfileName(char *name);
extern void CloseMapfile(void); void CloseMapfile(void);
extern void MapfileWriteSection(struct sSection * pSect); void MapfileWriteSection(struct sSection * pSect);
extern void MapfileInitBank(int32_t bank); void MapfileInitBank(int32_t bank);
extern void MapfileCloseBank(int32_t slack); void MapfileCloseBank(int32_t slack);
#endif #endif

View File

@@ -1,6 +1,6 @@
#ifndef RGBDS_LINK_OBJECT_H #ifndef RGBDS_LINK_OBJECT_H
#define RGBDS_LINK_OBJECT_H #define RGBDS_LINK_OBJECT_H
extern void obj_Readfile(char *tzObjectfile); void obj_Readfile(char *tzObjectfile);
#endif #endif

View File

@@ -17,6 +17,8 @@
#ifndef RGBDS_LINK_SCRIPT_H #ifndef RGBDS_LINK_SCRIPT_H
#define RGBDS_LINK_SCRIPT_H #define RGBDS_LINK_SCRIPT_H
#include <stdint.h>
#include "extern/stdnoreturn.h" #include "extern/stdnoreturn.h"
noreturn void script_fatalerror(const char *fmt, ...); noreturn void script_fatalerror(const char *fmt, ...);
@@ -24,13 +26,13 @@ noreturn void script_fatalerror(const char *fmt, ...);
void script_Parse(const char *path); void script_Parse(const char *path);
void script_IncludeFile(const char *path); void script_IncludeFile(const char *path);
int script_IncludeDepthGet(void); int32_t script_IncludeDepthGet(void);
void script_IncludePop(void); void script_IncludePop(void);
void script_InitSections(void); void script_InitSections(void);
void script_SetCurrentSectionType(const char *type, unsigned int bank); void script_SetCurrentSectionType(const char *type, uint32_t bank);
void script_SetAddress(unsigned int addr); void script_SetAddress(uint32_t addr);
void script_SetAlignment(unsigned int alignment); void script_SetAlignment(uint32_t alignment);
void script_OutputSection(const char *section_name); void script_OutputSection(const char *section_name);
#endif #endif

View File

@@ -82,7 +82,7 @@ size_t symvaluetostring(char *dest, size_t maxLength, char *sym)
length = i; length = i;
} else { } else {
uint32_t value = sym_GetConstantValue(sym); uint32_t value = sym_GetConstantValue(sym);
int fullLength = snprintf(dest, maxLength + 1, "$%X", value); int32_t fullLength = snprintf(dest, maxLength + 1, "$%X", value);
if (fullLength < 0) { if (fullLength < 0) {
fatalerror("snprintf encoding error"); fatalerror("snprintf encoding error");
@@ -109,9 +109,9 @@ uint32_t str2int( char *s )
return( r ); return( r );
} }
uint32_t str2int2( char *s, int length ) uint32_t str2int2( char *s, int32_t length )
{ {
int i; int32_t i;
uint32_t r=0; uint32_t r=0;
i = (length - 4 < 0 ? 0 : length - 4); i = (length - 4 < 0 ? 0 : length - 4);
while(i < length) while(i < length)
@@ -997,7 +997,7 @@ constlist_8bit_entry : /* empty */ {
out_RelByte( &$1 ); out_RelByte( &$1 );
} | string { } | string {
char *s = $1; char *s = $1;
int length = charmap_Convert(&s); int32_t length = charmap_Convert(&s);
out_AbsByteGroup(s, length); out_AbsByteGroup(s, length);
free(s); free(s);
} }
@@ -1009,7 +1009,7 @@ constlist_8bit_entry_single : /* empty */ {
out_RelByte( &$1 ); out_RelByte( &$1 );
} | string { } | string {
char *s = $1; char *s = $1;
int length = charmap_Convert(&s); int32_t length = charmap_Convert(&s);
out_AbsByteGroup(s, length); out_AbsByteGroup(s, length);
free(s); free(s);
} }
@@ -1091,7 +1091,7 @@ relocconst : T_ID
| string | string
{ {
char *s = $1; char *s = $1;
int length = charmap_Convert(&s); int32_t length = charmap_Convert(&s);
uint32_t r = str2int2(s, length); uint32_t r = str2int2(s, length);
free(s); free(s);
rpn_Number(&$$,r); rpn_Number(&$$,r);

View File

@@ -81,12 +81,12 @@ struct Charmap globalCharmap = {0};
extern struct Section *pCurrentSection; extern struct Section *pCurrentSection;
int int32_t
readUTF8Char(char *dest, char *src) readUTF8Char(char *dest, char *src)
{ {
uint32_t state; uint32_t state;
uint32_t codep; uint32_t codep;
int i; int32_t i;
for (i = 0, state = 0;; i++) { for (i = 0, state = 0;; i++) {
if (decode(&state, &codep, (uint8_t)src[i]) == 1) { if (decode(&state, &codep, (uint8_t)src[i]) == 1) {
@@ -104,10 +104,10 @@ readUTF8Char(char *dest, char *src)
} }
} }
int int32_t
charmap_Add(char *input, uint8_t output) charmap_Add(char *input, uint8_t output)
{ {
int i; int32_t i;
size_t input_length; size_t input_length;
char temp1i[CHARMAPLENGTH + 1], temp2i[CHARMAPLENGTH + 1], temp1o = 0, char temp1i[CHARMAPLENGTH + 1], temp2i[CHARMAPLENGTH + 1], temp1o = 0,
temp2o = 0; temp2o = 0;
@@ -170,14 +170,14 @@ charmap_Add(char *input, uint8_t output)
return ++charmap->count; return ++charmap->count;
} }
int int32_t
charmap_Convert(char **input) charmap_Convert(char **input)
{ {
struct Charmap *charmap; struct Charmap *charmap;
char outchar[CHARMAPLENGTH + 1]; char outchar[CHARMAPLENGTH + 1];
char *buffer; char *buffer;
int i, j, length; int32_t i, j, length;
if (pCurrentSection && pCurrentSection->charmap) { if (pCurrentSection && pCurrentSection->charmap) {
charmap = pCurrentSection->charmap; charmap = pCurrentSection->charmap;

View File

@@ -86,7 +86,7 @@ pushcontext(void)
fatalerror("No memory for context"); fatalerror("No memory for context");
} }
int static int32_t
popcontext(void) popcontext(void)
{ {
struct sContext *pLastFile, **ppLastFile; struct sContext *pLastFile, **ppLastFile;
@@ -150,7 +150,7 @@ popcontext(void)
return (1); return (1);
} }
int int32_t
fstk_GetLine(void) fstk_GetLine(void)
{ {
struct sContext *pLastFile, **ppLastFile; struct sContext *pLastFile, **ppLastFile;
@@ -227,7 +227,7 @@ FILE *
fstk_FindFile(char *fname) fstk_FindFile(char *fname)
{ {
char path[_MAX_PATH]; char path[_MAX_PATH];
int i; int32_t i;
FILE *f; FILE *f;
if ((f = fopen(fname, "rb")) != NULL || errno != ENOENT) { if ((f = fopen(fname, "rb")) != NULL || errno != ENOENT) {

View File

@@ -146,7 +146,7 @@ uint32_t
ParseSymbol(char *src, uint32_t size) ParseSymbol(char *src, uint32_t size)
{ {
char dest[MAXSYMLEN + 1]; char dest[MAXSYMLEN + 1];
int copied = 0, size_backup = size; int32_t copied = 0, size_backup = size;
while (size && copied < MAXSYMLEN) { while (size && copied < MAXSYMLEN) {
if (*src == '\\') { if (*src == '\\') {

View File

@@ -82,7 +82,7 @@ yyunput(char c)
void void
yyunputstr(char *s) yyunputstr(char *s)
{ {
int i, len; int32_t i, len;
len = strlen(s); len = strlen(s);
@@ -293,7 +293,7 @@ lexgetfloat(uint32_t nFloatMask)
fatalerror("Internal error in lexgetfloat"); fatalerror("Internal error in lexgetfloat");
} }
int i = 0; int32_t i = 0;
while ((nFloatMask & 1) == 0) { while ((nFloatMask & 1) == 0) {
nFloatMask >>= 1; nFloatMask >>= 1;
@@ -384,17 +384,17 @@ yylex_GetFloatMaskAndFloatLen(uint32_t *pnFloatMask, uint32_t *pnFloatLen)
char *s = pLexBuffer; char *s = pLexBuffer;
uint32_t nOldFloatMask = 0; uint32_t nOldFloatMask = 0;
uint32_t nFloatMask = tFloatingFirstChar[(int)*s]; uint32_t nFloatMask = tFloatingFirstChar[(int32_t)*s];
if (nFloatMask != 0) { if (nFloatMask != 0) {
s++; s++;
nOldFloatMask = nFloatMask; nOldFloatMask = nFloatMask;
nFloatMask &= tFloatingSecondChar[(int)*s]; nFloatMask &= tFloatingSecondChar[(int32_t)*s];
while (nFloatMask != 0) { while (nFloatMask != 0) {
s++; s++;
nOldFloatMask = nFloatMask; nOldFloatMask = nFloatMask;
nFloatMask &= tFloatingChars[(int)*s]; nFloatMask &= tFloatingChars[(int32_t)*s];
} }
} }
@@ -438,7 +438,7 @@ CopyMacroArg(char *dest, size_t maxLength, char c)
{ {
size_t i; size_t i;
char *s; char *s;
int argNum; int32_t argNum;
switch (c) { switch (c) {
case '1': case '1':
@@ -498,9 +498,9 @@ yylex_SymbolWriteChar(char *s, size_t index, char c)
*/ */
void yylex_TrimEnd(char *s, size_t index) void yylex_TrimEnd(char *s, size_t index)
{ {
int i; int32_t i;
for (i = (int)index - 1; i >= 0 && (s[i] == ' ' || s[i] == '\t'); i--) for (i = (int32_t)index - 1; i >= 0 && (s[i] == ' ' || s[i] == '\t'); i--)
s[i] = 0; s[i] = 0;
} }
@@ -663,7 +663,7 @@ scanagain:
struct sLexFloat *token = lexgetfloat(nFloatMask); struct sLexFloat *token = lexgetfloat(nFloatMask);
if (token->Callback) { if (token->Callback) {
int done = token->Callback(pLexBuffer, nFloatLen); int32_t done = token->Callback(pLexBuffer, nFloatLen);
if (!done) if (!done)
goto scanagain; goto scanagain;
} }

View File

@@ -18,8 +18,8 @@
int yyparse(void); int yyparse(void);
void setuplex(void); void setuplex(void);
int cldefines_index; int32_t cldefines_index;
int cldefines_size; int32_t cldefines_size;
char **cldefines; char **cldefines;
clock_t nStartClock, nEndClock; clock_t nStartClock, nEndClock;
@@ -140,7 +140,7 @@ opt_Parse(char *s)
break; break;
case 'z': case 'z':
if (strlen(&s[1]) <= 2) { if (strlen(&s[1]) <= 2) {
int result; int32_t result;
result = sscanf(&s[1], "%x", &newopt.fillchar); result = sscanf(&s[1], "%x", &newopt.fillchar);
if (!((result == EOF) || (result == 1))) { if (!((result == EOF) || (result == 1))) {
@@ -217,7 +217,7 @@ opt_AddDefine(char *s)
void void
opt_ParseDefines() opt_ParseDefines()
{ {
int i; int32_t i;
for(i = 0; i < cldefines_index; i += 2) for(i = 0; i < cldefines_index; i += 2)
{ {

View File

@@ -331,7 +331,7 @@ addsymbol(struct sSymbol * pSym)
void void
addexports(void) addexports(void)
{ {
int i; int32_t i;
for (i = 0; i < HASHSIZE; i += 1) { for (i = 0; i < HASHSIZE; i += 1) {
struct sSymbol *pSym; struct sSymbol *pSym;
@@ -667,7 +667,7 @@ out_NewAlignedSection(char *pzName, uint32_t secttype, int32_t alignment, int32_
* Output an absolute byte (bypassing ROM/union checks) * Output an absolute byte (bypassing ROM/union checks)
*/ */
void void
out_AbsByteBypassCheck(int b) out_AbsByteBypassCheck(int32_t b)
{ {
checksectionoverflow(1); checksectionoverflow(1);
b &= 0xFF; b &= 0xFF;
@@ -683,14 +683,14 @@ out_AbsByteBypassCheck(int b)
* Output an absolute byte * Output an absolute byte
*/ */
void void
out_AbsByte(int b) out_AbsByte(int32_t b)
{ {
checkcodesection(); checkcodesection();
out_AbsByteBypassCheck(b); out_AbsByteBypassCheck(b);
} }
void void
out_AbsByteGroup(char *s, int length) out_AbsByteGroup(char *s, int32_t length)
{ {
checkcodesection(); checkcodesection();
checksectionoverflow(length); checksectionoverflow(length);
@@ -702,7 +702,7 @@ out_AbsByteGroup(char *s, int length)
* Skip this many bytes * Skip this many bytes
*/ */
void void
out_Skip(int skip) out_Skip(int32_t skip)
{ {
checksection(); checksection();
checksectionoverflow(skip); checksectionoverflow(skip);
@@ -761,7 +761,7 @@ out_RelByte(struct Expression * expr)
* Output an absolute word * Output an absolute word
*/ */
void void
out_AbsWord(int b) out_AbsWord(int32_t b)
{ {
checkcodesection(); checkcodesection();
checksectionoverflow(2); checksectionoverflow(2);

View File

@@ -653,7 +653,7 @@ sym_AddReloc(char *tzSym)
} }
struct sSymbol *parent = pScope->pScope ? pScope->pScope : pScope; struct sSymbol *parent = pScope->pScope ? pScope->pScope : pScope;
int parentLen = localPtr - tzSym; int32_t parentLen = localPtr - tzSym;
if (strchr(localPtr + 1, '.') != NULL) { if (strchr(localPtr + 1, '.') != NULL) {
fatalerror("'%s' is a nonsensical reference to a nested local symbol", tzSym); fatalerror("'%s' is a nonsensical reference to a nested local symbol", tzSym);
@@ -695,7 +695,7 @@ sym_AddReloc(char *tzSym)
* *
* It returns 1 if the difference is defined, 0 if not. * It returns 1 if the difference is defined, 0 if not.
*/ */
int int32_t
sym_IsRelocDiffDefined(char *tzSym1, char *tzSym2) sym_IsRelocDiffDefined(char *tzSym1, char *tzSym2)
{ {
/* Do nothing the first pass. */ /* Do nothing the first pass. */
@@ -710,8 +710,8 @@ sym_IsRelocDiffDefined(char *tzSym1, char *tzSym2)
if ((nsym2 = sym_FindSymbol(tzSym2)) == NULL) if ((nsym2 = sym_FindSymbol(tzSym2)) == NULL)
fatalerror("Symbol \"%s\" isn't defined.", tzSym2); fatalerror("Symbol \"%s\" isn't defined.", tzSym2);
int s1reloc = (nsym1->nType & SYMF_RELOC) != 0; int32_t s1reloc = (nsym1->nType & SYMF_RELOC) != 0;
int s2reloc = (nsym2->nType & SYMF_RELOC) != 0; int32_t s2reloc = (nsym2->nType & SYMF_RELOC) != 0;
/* Both are non-relocatable */ /* Both are non-relocatable */
if (!s1reloc && !s2reloc) return 1; if (!s1reloc && !s2reloc) return 1;

View File

@@ -142,7 +142,7 @@ area_AllocAbsAnyBank(int32_t org, int32_t size, enum eSectionType type)
int32_t startBank = SECT_ATTRIBUTES[type].bank; int32_t startBank = SECT_ATTRIBUTES[type].bank;
int32_t bankCount = SECT_ATTRIBUTES[type].bankCount; int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) { for (int32_t i = 0; i < bankCount; i++) {
if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) { if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) {
return startBank + i; return startBank + i;
} }
@@ -185,7 +185,7 @@ area_AllocAnyBank(int32_t size, int32_t alignment, enum eSectionType type) {
int32_t startBank = SECT_ATTRIBUTES[type].bank; int32_t startBank = SECT_ATTRIBUTES[type].bank;
int32_t bankCount = SECT_ATTRIBUTES[type].bankCount; int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) { for (int32_t i = 0; i < bankCount; i++) {
int32_t org = area_Alloc(&BankFree[startBank + i], size, alignment); int32_t org = area_Alloc(&BankFree[startBank + i], size, alignment);
if (org != -1) { if (org != -1) {
return ((startBank + i) << 16) | org; return ((startBank + i) << 16) | org;
@@ -217,7 +217,7 @@ FindLargestSection(enum eSectionType type, bool bankFixed)
return r; return r;
} }
int int32_t
IsSectionNameInUse(const char *name) IsSectionNameInUse(const char *name)
{ {
struct sSection *pSection; struct sSection *pSection;
@@ -234,8 +234,8 @@ IsSectionNameInUse(const char *name)
} }
int int32_t
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank) IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int32_t bank)
{ {
struct sSection *pSection; struct sSection *pSection;
@@ -261,8 +261,8 @@ IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int b
errx(1, "Section \"%s\" not found (or already used).\n", name); errx(1, "Section \"%s\" not found (or already used).\n", name);
} }
unsigned int uint32_t
AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank) AssignSectionAddressAndBankByName(const char *name, uint32_t address, int32_t bank)
{ {
struct sSection *pSection; struct sSection *pSection;

View File

@@ -19,6 +19,7 @@
%{ %{
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include "extern/err.h" #include "extern/err.h"
@@ -36,11 +37,11 @@ extern int yyparse();
#define MAX_INCLUDE_DEPTH 8 #define MAX_INCLUDE_DEPTH 8
static int include_stack_ptr = 0; static int32_t include_stack_ptr = 0;
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
static char include_path[MAX_INCLUDE_DEPTH][_MAX_PATH + 1]; static char include_path[MAX_INCLUDE_DEPTH][_MAX_PATH + 1];
static int include_line[MAX_INCLUDE_DEPTH]; static int32_t include_line[MAX_INCLUDE_DEPTH];
static char linkerscript_path[_MAX_PATH + 1]; /* Base file */ static char linkerscript_path[_MAX_PATH + 1]; /* Base file */
%} %}
@@ -151,7 +152,7 @@ void script_IncludeFile(const char * path)
unput('\n'); unput('\n');
} }
int script_IncludeDepthGet(void) int32_t script_IncludeDepthGet(void)
{ {
return include_stack_ptr; return include_stack_ptr;
} }
@@ -169,7 +170,7 @@ void script_IncludePop(void)
void script_PrintFileStack(void) void script_PrintFileStack(void)
{ {
int i = include_stack_ptr; int32_t i = include_stack_ptr;
include_line[i] = yylineno; include_line[i] = yylineno;

View File

@@ -15,7 +15,7 @@ symboldefined(char *name)
pSect = pSections; pSect = pSections;
while (pSect) { while (pSect) {
int i; int32_t i;
for (i = 0; i < pSect->nNumberOfSymbols; i += 1) { for (i = 0; i < pSect->nNumberOfSymbols; i += 1) {
if ((pSect->tSymbols[i]->Type == SYM_EXPORT) if ((pSect->tSymbols[i]->Type == SYM_EXPORT)
@@ -39,7 +39,7 @@ addmodulecontaining(char *name)
ppLSect = &pLibSections; ppLSect = &pLibSections;
while (*ppLSect) { while (*ppLSect) {
int i; int32_t i;
for (i = 0; i < (*ppLSect)->nNumberOfSymbols; i += 1) { for (i = 0; i < (*ppLSect)->nNumberOfSymbols; i += 1) {
if (((*ppLSect)->tSymbols[i]->Type == SYM_EXPORT) if (((*ppLSect)->tSymbols[i]->Type == SYM_EXPORT)
@@ -101,7 +101,7 @@ AddNeededModules(void)
pSect = pSections; pSect = pSections;
while (pSect) { while (pSect) {
int i; int32_t i;
for (i = 0; i < pSect->nNumberOfSymbols; i += 1) { for (i = 0; i < pSect->nNumberOfSymbols; i += 1) {
if ((pSect->tSymbols[i]->Type == SYM_IMPORT) if ((pSect->tSymbols[i]->Type == SYM_IMPORT)

View File

@@ -121,7 +121,7 @@ main(int argc, char *argv[])
if (argc == 0) if (argc == 0)
usage(); usage();
for (int i = 0; i < argc; ++i) for (int32_t i = 0; i < argc; ++i)
obj_Readfile(argv[i]); obj_Readfile(argv[i]);
AddNeededModules(); AddNeededModules();

View File

@@ -179,7 +179,7 @@ obj_ReadRGBSection(FILE * f)
} }
} }
unsigned int maxsize = 0; uint32_t maxsize = 0;
/* Verify that the section isn't too big */ /* Verify that the section isn't too big */
switch (pSection->Type) switch (pSection->Type)
@@ -353,7 +353,7 @@ obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
strlen(RGBDS_OBJECT_VERSION_STRING)) == 0) { strlen(RGBDS_OBJECT_VERSION_STRING)) == 0) {
obj_ReadRGB(pObjfile, tzObjectfile); obj_ReadRGB(pObjfile, tzObjectfile);
} else { } else {
for (int i = 0; i < strlen(RGBDS_OBJECT_VERSION_STRING); i++) for (int32_t i = 0; i < strlen(RGBDS_OBJECT_VERSION_STRING); i++)
if (!isprint(tzHeader[i])) if (!isprint(tzHeader[i]))
tzHeader[i] = '?'; tzHeader[i] = '?';
errx(1, "%s: Invalid file or object file version [%s]", errx(1, "%s: Invalid file or object file version [%s]",

View File

@@ -15,6 +15,7 @@
*/ */
%{ %{
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include "extern/err.h" #include "extern/err.h"
@@ -26,7 +27,7 @@ void yyerror(char *);
extern int yylineno; extern int yylineno;
%} %}
%union { int i; char s[512]; } %union { int32_t i; char s[512]; }
%token<i> INTEGER %token<i> INTEGER
%token<s> STRING %token<s> STRING

View File

@@ -14,23 +14,26 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include <stdint.h>
#include <string.h> #include <string.h>
#include "extern/err.h" #include "extern/err.h"
#include "link/assign.h" #include "link/assign.h"
#include "link/mylink.h" #include "link/mylink.h"
static struct { static struct {
unsigned int address; /* current address to write sections to */ uint32_t address; /* current address to write sections to */
unsigned int top_address; /* not inclusive */ uint32_t top_address; /* not inclusive */
enum eSectionType type; enum eSectionType type;
} bank[MAXBANKS]; } bank[MAXBANKS];
static int current_bank = -1; /* Bank as seen by the bank array */ static int32_t current_bank = -1; /* Bank as seen by the bank array */
static int current_real_bank = -1; /* bank as seen by the GB */ static int32_t current_real_bank = -1; /* bank as seen by the GB */
void script_InitSections(void) void script_InitSections(void)
{ {
int i; int32_t i;
for (i = 0; i < MAXBANKS; i++) { for (i = 0; i < MAXBANKS; i++) {
if (i == BANK_ROM0) { if (i == BANK_ROM0) {
/* ROM0 bank */ /* ROM0 bank */
@@ -91,7 +94,7 @@ void script_InitSections(void)
} }
} }
void script_SetCurrentSectionType(const char *type, unsigned int bank) void script_SetCurrentSectionType(const char *type, uint32_t bank)
{ {
if (strcmp(type, "ROM0") == 0) { if (strcmp(type, "ROM0") == 0) {
if (bank != 0) if (bank != 0)
@@ -150,7 +153,7 @@ void script_SetCurrentSectionType(const char *type, unsigned int bank)
errx(1, "(Internal) Unknown section type \"%s\".\n", type); errx(1, "(Internal) Unknown section type \"%s\".\n", type);
} }
void script_SetAddress(unsigned int addr) void script_SetAddress(uint32_t addr)
{ {
if (current_bank == -1) { if (current_bank == -1) {
errx(1, "Trying to set an address without assigned bank\n"); errx(1, "Trying to set an address without assigned bank\n");
@@ -171,7 +174,7 @@ void script_SetAddress(unsigned int addr)
} }
} }
void script_SetAlignment(unsigned int alignment) void script_SetAlignment(uint32_t alignment)
{ {
if (current_bank == -1) { if (current_bank == -1) {
errx(1, "Trying to set an alignment without assigned bank\n"); errx(1, "Trying to set an alignment without assigned bank\n");
@@ -181,8 +184,8 @@ void script_SetAlignment(unsigned int alignment)
errx(1, "Trying to set an alignment too big: %d\n", alignment); errx(1, "Trying to set an alignment too big: %d\n", alignment);
} }
unsigned int size = 1 << alignment; uint32_t size = 1 << alignment;
unsigned int mask = size - 1; uint32_t mask = size - 1;
if (bank[current_bank].address & mask) { if (bank[current_bank].address & mask) {
bank[current_bank].address &= ~mask; bank[current_bank].address &= ~mask;