ref: ba944527ec029c92d84fb6c815e944c634ea8f0d
parent: 87c9d819a16186785d4e7460b3ab0458efbcb013
author: Antonio Niño Díaz <[email protected]>
date: Sun Dec 31 09:16:36 EST 2017
Replace ULONG by uint32_t All affected `printf` have been fixed. Signed-off-by: Antonio Niño Díaz <[email protected]>
--- a/include/asm/asm.h
+++ b/include/asm/asm.h
@@ -14,24 +14,22 @@
#include <stdio.h>
#include <stdlib.h>
-#include "types.h"
+#include "asm/localasm.h"
#include "asm/symbol.h"
-#include "asm/localasm.h"
-
#define MAXUNIONS 128
#define MAXMACROARGS 256
#define MAXINCPATHS 128
extern int32_t nLineNo;
-extern ULONG nTotalLines;
-extern ULONG nPC;
-extern ULONG nPass;
-extern ULONG nIFDepth;
+extern uint32_t nTotalLines;
+extern uint32_t nPC;
+extern uint32_t nPass;
+extern uint32_t nIFDepth;
extern bool skipElif;
-extern ULONG nUnionDepth;
-extern ULONG unionStart[MAXUNIONS];
-extern ULONG unionSize[MAXUNIONS];
+extern uint32_t nUnionDepth;
+extern uint32_t unionStart[MAXUNIONS];
+extern uint32_t unionSize[MAXUNIONS];
extern char tzCurrentFileName[_MAX_PATH + 1];
extern struct Section *pCurrentSection;
extern struct sSymbol *tHashedSymbols[HASHSIZE];
--- a/include/asm/fstack.h
+++ b/include/asm/fstack.h
@@ -13,9 +13,10 @@
#include <stdio.h>
#include "asm/asm.h"
-#include "types.h"
#include "asm/lexer.h"
+#include "types.h"
+
struct sContext {
YY_BUFFER_STATE FlexHandle;
struct sSymbol *pMacro;
@@ -23,11 +24,11 @@
char tzFileName[_MAX_PATH + 1];
char *tzMacroArgs[MAXMACROARGS + 1];
int32_t nLine;
- ULONG nStatus;
+ uint32_t nStatus;
FILE *pFile;
char *pREPTBlock;
- ULONG nREPTBlockCount;
- ULONG nREPTBlockSize;
+ uint32_t nREPTBlockCount;
+ uint32_t nREPTBlockSize;
};
void
@@ -37,8 +38,8 @@
fstk_Init(char *);
extern void fstk_Dump(void);
extern void fstk_AddIncludePath(char *s);
-extern ULONG fstk_RunMacro(char *s);
-extern void fstk_RunRept(ULONG count);
+extern uint32_t fstk_RunMacro(char *s);
+extern void fstk_RunRept(uint32_t count);
FILE *
fstk_FindFile(char *);
--- a/include/asm/lexer.h
+++ b/include/asm/lexer.h
@@ -4,19 +4,17 @@
#include <stdint.h>
#include <stdio.h>
-#include "types.h"
-
#define LEXHASHSIZE (1 << 11)
#define MAXSTRLEN 255
struct sLexInitString {
char *tzName;
- ULONG nToken;
+ uint32_t nToken;
};
struct sLexFloat {
- ULONG(*Callback) (char *s, ULONG size);
- ULONG nToken;
+ uint32_t(*Callback) (char *s, uint32_t size);
+ uint32_t nToken;
};
struct yy_buffer_state {
@@ -24,8 +22,8 @@
char *pBufferStart; // address where the data is initially written
// after the "safety margin"
char *pBuffer;
- ULONG nBufferSize;
- ULONG oAtLineStart;
+ uint32_t nBufferSize;
+ uint32_t oAtLineStart;
};
enum eLexerState {
@@ -39,24 +37,24 @@
extern void yy_set_state(enum eLexerState i);
extern YY_BUFFER_STATE yy_create_buffer(FILE * f);
-extern YY_BUFFER_STATE yy_scan_bytes(char *mem, ULONG size);
+extern YY_BUFFER_STATE yy_scan_bytes(char *mem, uint32_t size);
extern void yy_delete_buffer(YY_BUFFER_STATE);
extern void yy_switch_to_buffer(YY_BUFFER_STATE);
-extern ULONG lex_FloatAlloc(struct sLexFloat * tok);
-extern void lex_FloatAddRange(ULONG id, uint16_t start, uint16_t end);
-extern void lex_FloatDeleteRange(ULONG id, uint16_t start, uint16_t end);
-extern void lex_FloatAddFirstRange(ULONG id, uint16_t start, uint16_t end);
-extern void lex_FloatDeleteFirstRange(ULONG id, uint16_t start, uint16_t end);
-extern void lex_FloatAddSecondRange(ULONG id, uint16_t start, uint16_t end);
-extern void lex_FloatDeleteSecondRange(ULONG id, uint16_t start, uint16_t end);
+extern uint32_t lex_FloatAlloc(struct sLexFloat * tok);
+extern void lex_FloatAddRange(uint32_t id, uint16_t start, uint16_t end);
+extern void lex_FloatDeleteRange(uint32_t id, uint16_t start, uint16_t end);
+extern void lex_FloatAddFirstRange(uint32_t id, uint16_t start, uint16_t end);
+extern void lex_FloatDeleteFirstRange(uint32_t id, uint16_t start, uint16_t end);
+extern void lex_FloatAddSecondRange(uint32_t id, uint16_t start, uint16_t end);
+extern void lex_FloatDeleteSecondRange(uint32_t id, uint16_t start, uint16_t end);
extern void lex_Init(void);
extern void lex_AddStrings(struct sLexInitString * lex);
-extern void lex_SetBuffer(char *buffer, ULONG len);
-extern ULONG yylex(void);
+extern void lex_SetBuffer(char *buffer, uint32_t len);
+extern uint32_t yylex(void);
extern void yyunput(char c);
extern void yyunputstr(char *s);
-extern void yyskipbytes(ULONG count);
-extern void yyunputbytes(ULONG count);
+extern void yyskipbytes(uint32_t count);
+extern void yyunputbytes(uint32_t count);
extern YY_BUFFER_STATE pCurrentBuffer;
--- a/include/asm/main.h
+++ b/include/asm/main.h
@@ -17,7 +17,7 @@
};
extern char *tzNewMacro;
-extern ULONG ulNewMacroSize;
+extern uint32_t ulNewMacroSize;
extern int32_t nGBGfxID;
extern int32_t nBinaryID;
--- a/include/asm/output.h
+++ b/include/asm/output.h
@@ -4,15 +4,14 @@
#include <stdint.h>
#include "asm/rpn.h"
-#include "types.h"
struct Section {
char *pzName;
uint8_t nType;
- ULONG nPC;
- ULONG nOrg;
- ULONG nBank;
- ULONG nAlign;
+ uint32_t nPC;
+ uint32_t nOrg;
+ uint32_t nBank;
+ uint32_t nAlign;
struct Section *pNext;
struct Patch *pPatches;
struct Charmap *charmap;
@@ -21,9 +20,9 @@
void out_PrepPass2(void);
void out_SetFileName(char *s);
-void out_NewSection(char *pzName, ULONG secttype);
-void out_NewAbsSection(char *pzName, ULONG secttype, int32_t org, int32_t bank);
-void out_NewAlignedSection(char *pzName, ULONG secttype, int32_t alignment, int32_t bank);
+void out_NewSection(char *pzName, uint32_t secttype);
+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_AbsByte(int b);
void out_AbsByteGroup(char *s, int length);
void out_RelByte(struct Expression * expr);
--- a/include/asm/rpn.h
+++ b/include/asm/rpn.h
@@ -4,18 +4,18 @@
#include <stdint.h>
struct Expression {
- int32_t nVal;
- uint8_t tRPN[256];
- ULONG nRPNLength;
- ULONG nRPNOut;
- ULONG isReloc;
- ULONG isPCRel;
+ int32_t nVal;
+ uint8_t tRPN[256];
+ uint32_t nRPNLength;
+ uint32_t nRPNOut;
+ uint32_t isReloc;
+ uint32_t isPCRel;
};
-ULONG rpn_isReloc(struct Expression * expr);
-ULONG rpn_isPCRelative(struct Expression * expr);
+uint32_t rpn_isReloc(struct Expression * expr);
+uint32_t rpn_isPCRelative(struct Expression * expr);
void rpn_Symbol(struct Expression * expr, char *tzSym);
-void rpn_Number(struct Expression * expr, ULONG i);
+void rpn_Number(struct Expression * expr, uint32_t i);
void rpn_LOGNOT(struct Expression * expr, struct Expression * src1);
void
rpn_LOGOR(struct Expression * expr, struct Expression * src1,
--- a/include/asm/symbol.h
+++ b/include/asm/symbol.h
@@ -11,15 +11,15 @@
struct sSymbol {
char tzName[MAXSYMLEN + 1];
int32_t nValue;
- ULONG nType;
+ uint32_t nType;
struct sSymbol *pScope;
struct sSymbol *pNext;
struct Section *pSection;
- ULONG ulMacroSize;
+ uint32_t ulMacroSize;
char *pMacro;
int32_t(*Callback) (struct sSymbol *);
char tzFileName[_MAX_PATH + 1]; /* File where the symbol was defined. */
- ULONG nFileLine; /* Line where the symbol was defined. */
+ uint32_t nFileLine; /* Line where the symbol was defined. */
};
#define SYMF_RELOC 0x001 /* symbol will be reloc'ed during
* linking, it's absolute value is
@@ -39,7 +39,7 @@
#define SYMF_CONST 0x200 /* symbol has a constant value, will
* not be changed during linking */
-ULONG calchash(char *s);
+uint32_t calchash(char *s);
void sym_SetExportAll(uint8_t set);
void sym_PrepPass1(void);
void sym_PrepPass2(void);
@@ -57,23 +57,23 @@
void sym_AddEqu(char *tzSym, int32_t value);
void sym_AddSet(char *tzSym, int32_t value);
void sym_Init(void);
-ULONG sym_GetConstantValue(char *s);
-ULONG sym_isConstant(char *s);
+uint32_t sym_GetConstantValue(char *s);
+uint32_t sym_isConstant(char *s);
struct sSymbol *sym_FindSymbol(char *tzName);
void sym_Global(char *tzSym);
char *sym_FindMacroArg(int32_t i);
char *sym_GetStringValue(char *tzSym);
void sym_UseCurrentMacroArgs(void);
-void sym_SetMacroArgID(ULONG nMacroCount);
-ULONG sym_isString(char *tzSym);
+void sym_SetMacroArgID(uint32_t nMacroCount);
+uint32_t sym_isString(char *tzSym);
void sym_AddMacro(char *tzSym);
void sym_ShiftCurrentMacroArgs(void);
void sym_AddString(char *tzSym, char *tzValue);
-ULONG sym_GetValue(char *s);
-ULONG sym_GetDefinedValue(char *s);
-ULONG sym_isDefined(char *tzName);
+uint32_t sym_GetValue(char *s);
+uint32_t sym_GetDefinedValue(char *s);
+uint32_t sym_isDefined(char *tzName);
void sym_Purge(char *tzName);
-ULONG sym_isConstDefined(char *tzName);
+uint32_t sym_isConstDefined(char *tzName);
int sym_IsRelocDiffDefined(char *tzSym1, char *tzSym2);
#endif
--- a/include/link/assign.h
+++ b/include/link/assign.h
@@ -4,7 +4,6 @@
#include <stdint.h>
#include "mylink.h"
-#include "types.h"
enum eBankCount {
BANK_COUNT_ROM0 = 1,
--- a/include/link/mylink.h
+++ b/include/link/mylink.h
@@ -1,15 +1,10 @@
#ifndef RGBDS_LINK_LINK_H
#define RGBDS_LINK_LINK_H
-#ifndef _MAX_PATH
-#define _MAX_PATH 512
-#endif
-
#include <stdint.h>
-#include "types.h"
-
extern int32_t options;
+
#define OPT_TINY 0x01
#define OPT_SMART_C_LINK 0x02
#define OPT_OVERLAY 0x04
@@ -93,7 +88,7 @@
int32_t nOffset;
char *pzObjFileName; /* Object file where the symbol is located. */
char *pzFileName; /* Source file where the symbol was defined. */
- ULONG nFileLine; /* Line where the symbol was defined. */
+ uint32_t nFileLine; /* Line where the symbol was defined. */
};
enum ePatchType {
--- a/include/link/symbol.h
+++ b/include/link/symbol.h
@@ -3,11 +3,9 @@
#include <stdint.h>
-#include "types.h"
-
void sym_Init(void);
void sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank,
- char *tzObjFileName, char *tzFileName, ULONG nFileLine);
+ char *tzObjFileName, char *tzFileName, uint32_t nFileLine);
int32_t sym_GetValue(char *tzName);
int32_t sym_GetBank(char *tzName);
--- a/include/types.h
+++ b/include/types.h
@@ -2,9 +2,7 @@
#define RGBDS_TYPES_H
#ifndef _MAX_PATH
-#define _MAX_PATH 512
+#define _MAX_PATH 512
#endif
-
-typedef unsigned long ULONG;
#endif
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -18,11 +18,11 @@
#include "asm/main.h"
#include "asm/lexer.h"
-char *tzNewMacro;
-ULONG ulNewMacroSize;
+char *tzNewMacro;
+uint32_t ulNewMacroSize;
void
-bankrangecheck(char *name, ULONG secttype, int32_t org, int32_t bank)
+bankrangecheck(char *name, uint32_t secttype, int32_t org, int32_t bank)
{
int32_t minbank = 0, maxbank = 0;
char *stype = NULL;
@@ -81,8 +81,8 @@
length = i;
} else {
- ULONG value = sym_GetConstantValue(sym);
- int fullLength = snprintf(dest, maxLength + 1, "$%lX", value);
+ uint32_t value = sym_GetConstantValue(sym);
+ int fullLength = snprintf(dest, maxLength + 1, "$%X", value);
if (fullLength < 0) {
fatalerror("snprintf encoding error");
@@ -98,9 +98,9 @@
return length;
}
-ULONG str2int( char *s )
+uint32_t str2int( char *s )
{
- ULONG r=0;
+ uint32_t r=0;
while( *s )
{
r<<=8;
@@ -109,10 +109,10 @@
return( r );
}
-ULONG str2int2( char *s, int length )
+uint32_t str2int2( char *s, int length )
{
int i;
- ULONG r=0;
+ uint32_t r=0;
i = (length - 4 < 0 ? 0 : length - 4);
while(i < length)
{
@@ -123,22 +123,22 @@
return( r );
}
-ULONG isWhiteSpace( char s )
+uint32_t isWhiteSpace( char s )
{
return( s==' ' || s=='\t' || s=='\0' || s=='\n' );
}
-ULONG isRept( char *s )
+uint32_t isRept( char *s )
{
return( (strncasecmp(s,"REPT",4)==0) && isWhiteSpace(*(s-1)) && isWhiteSpace(s[4]) );
}
-ULONG isEndr( char *s )
+uint32_t isEndr( char *s )
{
return( (strncasecmp(s,"Endr",4)==0) && isWhiteSpace(*(s-1)) && isWhiteSpace(s[4]) );
}
-void copyrept( void )
+void copyrept( void )
{
int32_t level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
@@ -193,7 +193,7 @@
ulNewMacroSize=len;
if ((tzNewMacro = malloc(ulNewMacroSize + 1)) != NULL) {
- ULONG i;
+ uint32_t i;
tzNewMacro[ulNewMacroSize]=0;
for( i=0; i<ulNewMacroSize; i+=1 )
@@ -208,17 +208,17 @@
}
-ULONG isMacro( char *s )
+uint32_t isMacro( char *s )
{
return( (strncasecmp(s,"MACRO",4)==0) && isWhiteSpace(*(s-1)) && isWhiteSpace(s[5]) );
}
-ULONG isEndm( char *s )
+uint32_t isEndm( char *s )
{
return( (strncasecmp(s,"Endm",4)==0) && isWhiteSpace(*(s-1)) && isWhiteSpace(s[4]) );
}
-void copymacro( void )
+void copymacro(void)
{
int32_t level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
@@ -274,7 +274,7 @@
if( (tzNewMacro=(char *)malloc(ulNewMacroSize+2))!=NULL )
{
- ULONG i;
+ uint32_t i;
tzNewMacro[ulNewMacroSize]='\n';
tzNewMacro[ulNewMacroSize+1]=0;
@@ -290,22 +290,22 @@
yyskipbytes( ulNewMacroSize+4 );
}
-ULONG isIf(char *s)
+uint32_t isIf(char *s)
{
return((strncasecmp(s,"If",2) == 0) && isWhiteSpace(s[-1]) && isWhiteSpace(s[2]));
}
-ULONG isElif(char *s)
+uint32_t isElif(char *s)
{
return((strncasecmp(s,"Elif",4) == 0) && isWhiteSpace(s[-1]) && isWhiteSpace(s[4]));
}
-ULONG isElse(char *s)
+uint32_t isElse(char *s)
{
return((strncasecmp(s,"Else",4) == 0) && isWhiteSpace(s[-1]) && isWhiteSpace(s[4]));
}
-ULONG isEndc(char *s)
+uint32_t isEndc(char *s)
{
return((strncasecmp(s,"Endc",4) == 0) && isWhiteSpace(s[-1]) && isWhiteSpace(s[4]));
}
@@ -436,25 +436,25 @@
if (!pCurrentSection) {
fatalerror("UNIONs must be inside a SECTION");
}
-
- ULONG unionIndex = nUnionDepth;
+
+ uint32_t unionIndex = nUnionDepth;
nUnionDepth++;
if (nUnionDepth > MAXUNIONS) {
fatalerror("Too many nested UNIONs");
}
-
+
unionStart[unionIndex] = nPC;
unionSize[unionIndex] = 0;
}
void updateUnion() {
- ULONG unionIndex = nUnionDepth - 1;
- ULONG size = nPC - unionStart[unionIndex];
-
+ uint32_t unionIndex = nUnionDepth - 1;
+ uint32_t size = nPC - unionStart[unionIndex];
+
if (size > unionSize[unionIndex]) {
unionSize[unionIndex] = size;
}
-
+
nPC = unionStart[unionIndex];
pCurrentSection->nPC = unionStart[unionIndex];
pPCSymbol->nValue = unionStart[unionIndex];
@@ -794,9 +794,9 @@
if (nUnionDepth <= 0) {
fatalerror("Found ENDU outside of a UNION construct");
}
-
+
updateUnion();
-
+
nUnionDepth--;
nPC = unionStart[nUnionDepth] + unionSize[nUnionDepth];
pCurrentSection->nPC = nPC;
@@ -844,9 +844,8 @@
;
import_list_entry : T_ID {
- /* This is done automatically if
- * the label isn't found in the
- * list of defined symbols. */
+ /* This is done automatically if the label isn't found
+ * in the list of defined symbols. */
if( nPass==1 )
warning("IMPORT is a deprecated keyword with no effect: %s", $1);
}
@@ -1090,7 +1089,14 @@
| T_NUMBER
{ rpn_Number(&$$,$1); $$.nVal = $1; }
| string
- { char *s; int length; ULONG r; s = $1; length = charmap_Convert(&s); r = str2int2(s, length); free(s); rpn_Number(&$$,r); $$.nVal=r; }
+ {
+ char *s = $1;
+ int length = charmap_Convert(&s);
+ uint32_t r = str2int2(s, length);
+ free(s);
+ rpn_Number(&$$,r);
+ $$.nVal=r;
+ }
| T_OP_LOGICNOT relocconst %prec NEG
{ rpn_LOGNOT(&$$,&$2); }
| relocconst T_OP_LOGICOR relocconst
@@ -1791,7 +1797,6 @@
T_MODE_L : T_TOKEN_L
| T_OP_LOW '(' T_MODE_HL ')'
;
-
ccode : T_CC_NZ { $$ = CC_NZ; }
| T_CC_Z { $$ = CC_Z; }
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -9,33 +9,31 @@
#include <stdlib.h>
#include <string.h>
-#include "asm/symbol.h"
#include "asm/fstack.h"
-#include "types.h"
-#include "asm/main.h"
#include "asm/lexer.h"
+#include "asm/main.h"
+#include "asm/symbol.h"
+
#include "extern/err.h"
#include "extern/strl.h"
-#ifndef PATH_MAX
-#define PATH_MAX 256
-#endif
+#include "types.h"
struct sContext *pFileStack;
struct sSymbol *pCurrentMacro;
YY_BUFFER_STATE CurrentFlexHandle;
FILE *pCurrentFile;
-ULONG nCurrentStatus;
+uint32_t nCurrentStatus;
char tzCurrentFileName[_MAX_PATH + 1];
char IncludePaths[MAXINCPATHS][_MAX_PATH + 1];
int32_t NextIncPath = 0;
-ULONG nMacroCount;
+uint32_t nMacroCount;
char *pCurrentREPTBlock;
-ULONG nCurrentREPTBlockSize;
-ULONG nCurrentREPTBlockCount;
+uint32_t nCurrentREPTBlockSize;
+uint32_t nCurrentREPTBlockCount;
-ULONG ulMacroReturnValue;
+uint32_t ulMacroReturnValue;
extern char *tzObjectname;
extern FILE *dependfile;
@@ -228,7 +226,7 @@
FILE *
fstk_FindFile(char *fname)
{
- char path[PATH_MAX];
+ char path[_MAX_PATH];
int i;
FILE *f;
@@ -292,7 +290,7 @@
/*
* Set up a macro for parsing
*/
-ULONG
+uint32_t
fstk_RunMacro(char *s)
{
struct sSymbol *sym;
@@ -362,7 +360,7 @@
* Set up a repeat block for parsing
*/
void
-fstk_RunRept(ULONG count)
+fstk_RunRept(uint32_t count)
{
if (count) {
pushcontext();
--- a/src/asm/globlex.c
+++ b/src/asm/globlex.c
@@ -108,11 +108,10 @@
return (result);
}
-ULONG
-ParseFixedPoint(char *s, ULONG size)
+uint32_t
+ParseFixedPoint(char *s, uint32_t size)
{
- //char dest[256];
- ULONG i = 0, dot = 0;
+ uint32_t i = 0, dot = 0;
while (size && dot != 2) {
if (s[i] == '.')
@@ -119,14 +118,11 @@
dot += 1;
if (dot < 2) {
- //dest[i] = s[i];
size -= 1;
i += 1;
}
}
- //dest[i] = 0;
-
yyunputbytes(size);
yylval.nConstValue = (int32_t) (atof(s) * 65536);
@@ -134,8 +130,8 @@
return (1);
}
-ULONG
-ParseNumber(char *s, ULONG size)
+uint32_t
+ParseNumber(char *s, uint32_t size)
{
char dest[256];
@@ -146,8 +142,8 @@
return (1);
}
-ULONG
-ParseSymbol(char *src, ULONG size)
+uint32_t
+ParseSymbol(char *src, uint32_t size)
{
char dest[MAXSYMLEN + 1];
int copied = 0, size_backup = size;
@@ -204,8 +200,8 @@
}
}
-ULONG
-PutMacroArg(char *src, ULONG size)
+uint32_t
+PutMacroArg(char *src, uint32_t size)
{
char *s;
@@ -222,8 +218,8 @@
return (0);
}
-ULONG
-PutUniqueArg(char *src, ULONG size)
+uint32_t
+PutUniqueArg(char *src, uint32_t size)
{
char *s;
@@ -399,7 +395,7 @@
void
setuplex(void)
{
- ULONG id;
+ uint32_t id;
lex_Init();
lex_AddStrings(staticstrings);
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -6,11 +6,11 @@
#include <ctype.h>
#include "asm/asm.h"
+#include "asm/fstack.h"
#include "asm/lexer.h"
-#include "types.h"
#include "asm/main.h"
#include "asm/rpn.h"
-#include "asm/fstack.h"
+
#include "extern/err.h"
#include "asmy.h"
@@ -17,8 +17,8 @@
struct sLexString {
char *tzName;
- ULONG nToken;
- ULONG nNameLength;
+ uint32_t nToken;
+ uint32_t nNameLength;
struct sLexString *pNext;
};
#define pLexBufferRealStart (pCurrentBuffer->pBufferRealStart)
@@ -32,12 +32,12 @@
struct sLexFloat tLexFloat[32];
struct sLexString *tLexHash[LEXHASHSIZE];
YY_BUFFER_STATE pCurrentBuffer;
-ULONG nLexMaxLength; // max length of all keywords and operators
+uint32_t nLexMaxLength; // max length of all keywords and operators
-ULONG tFloatingSecondChar[256];
-ULONG tFloatingFirstChar[256];
-ULONG tFloatingChars[256];
-ULONG nFloating;
+uint32_t tFloatingSecondChar[256];
+uint32_t tFloatingFirstChar[256];
+uint32_t tFloatingChars[256];
+uint32_t nFloating;
enum eLexerState lexerstate = LEX_STATE_NORMAL;
void
@@ -59,13 +59,13 @@
}
void
-yyskipbytes(ULONG count)
+yyskipbytes(uint32_t count)
{
pLexBuffer += count;
}
void
-yyunputbytes(ULONG count)
+yyunputbytes(uint32_t count)
{
pLexBuffer -= count;
}
@@ -113,7 +113,7 @@
}
YY_BUFFER_STATE
-yy_scan_bytes(char *mem, ULONG size)
+yy_scan_bytes(char *mem, uint32_t size)
{
YY_BUFFER_STATE pBuffer;
@@ -139,7 +139,7 @@
YY_BUFFER_STATE pBuffer;
if ((pBuffer = malloc(sizeof(struct yy_buffer_state))) != NULL) {
- ULONG size;
+ uint32_t size;
fseek(f, 0, SEEK_END);
size = ftell(f);
@@ -148,7 +148,7 @@
if ((pBuffer->pBufferRealStart =
malloc(size + 2 + SAFETYMARGIN)) != NULL) {
char *mem;
- ULONG instring = 0;
+ uint32_t instring = 0;
pBuffer->pBufferStart = pBuffer->pBufferRealStart + SAFETYMARGIN;
pBuffer->pBuffer = pBuffer->pBufferRealStart + SAFETYMARGIN;
@@ -199,7 +199,7 @@
return (NULL);
}
-ULONG
+uint32_t
lex_FloatAlloc(struct sLexFloat *token)
{
tLexFloat[nFloating] = *token;
@@ -221,7 +221,7 @@
}
void
-lex_FloatDeleteRange(ULONG id, uint16_t start, uint16_t end)
+lex_FloatDeleteRange(uint32_t id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -232,7 +232,7 @@
}
void
-lex_FloatAddRange(ULONG id, uint16_t start, uint16_t end)
+lex_FloatAddRange(uint32_t id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -243,7 +243,7 @@
}
void
-lex_FloatDeleteFirstRange(ULONG id, uint16_t start, uint16_t end)
+lex_FloatDeleteFirstRange(uint32_t id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -254,7 +254,7 @@
}
void
-lex_FloatAddFirstRange(ULONG id, uint16_t start, uint16_t end)
+lex_FloatAddFirstRange(uint32_t id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -265,7 +265,7 @@
}
void
-lex_FloatDeleteSecondRange(ULONG id, uint16_t start, uint16_t end)
+lex_FloatDeleteSecondRange(uint32_t id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -276,7 +276,7 @@
}
void
-lex_FloatAddSecondRange(ULONG id, uint16_t start, uint16_t end)
+lex_FloatAddSecondRange(uint32_t id, uint16_t start, uint16_t end)
{
lex_CheckCharacterRange(start, end);
@@ -287,7 +287,7 @@
}
struct sLexFloat *
-lexgetfloat(ULONG nFloatMask)
+lexgetfloat(uint32_t nFloatMask)
{
if (nFloatMask == 0) {
fatalerror("Internal error in lexgetfloat");
@@ -303,10 +303,10 @@
return (&tLexFloat[i]);
}
-ULONG
+uint32_t
lexcalchash(char *s)
{
- ULONG hash = 0;
+ uint32_t hash = 0;
while (*s) {
hash = (hash * 283) ^ toupper(*s++);
@@ -318,7 +318,7 @@
void
lex_Init(void)
{
- ULONG i;
+ uint32_t i;
for (i = 0; i < LEXHASHSIZE; i++) {
tLexHash[i] = NULL;
@@ -339,7 +339,7 @@
{
while (lex->tzName) {
struct sLexString **ppHash;
- ULONG hash;
+ uint32_t hash;
ppHash = &tLexHash[hash = lexcalchash(lex->tzName)];
while (*ppHash)
@@ -377,14 +377,14 @@
* buffer will have their bits set in the float mask.
*/
void
-yylex_GetFloatMaskAndFloatLen(ULONG *pnFloatMask, ULONG *pnFloatLen)
+yylex_GetFloatMaskAndFloatLen(uint32_t *pnFloatMask, uint32_t *pnFloatLen)
{
// Note that '\0' should always have a bit mask of 0 in the "floating"
// tables, so it doesn't need to be checked for separately.
char *s = pLexBuffer;
- ULONG nOldFloatMask = 0;
- ULONG nFloatMask = tFloatingFirstChar[(int)*s];
+ uint32_t nOldFloatMask = 0;
+ uint32_t nFloatMask = tFloatingFirstChar[(int)*s];
if (nFloatMask != 0) {
s++;
@@ -399,7 +399,7 @@
}
*pnFloatMask = nOldFloatMask;
- *pnFloatLen = (ULONG)(s - pLexBuffer);
+ *pnFloatLen = (uint32_t)(s - pLexBuffer);
}
/*
@@ -410,8 +410,8 @@
{
struct sLexString *pLongestFixed = NULL;
char *s = pLexBuffer;
- ULONG hash = 0;
- ULONG length = 0;
+ uint32_t hash = 0;
+ uint32_t length = 0;
while (length < nLexMaxLength && *s) {
hash = (hash * 283) ^ toupper(*s);
@@ -605,12 +605,12 @@
fatalerror("Unterminated string");
}
-ULONG
+uint32_t
yylex_NORMAL()
{
struct sLexString *pLongestFixed = NULL;
- ULONG nFloatMask, nFloatLen;
- ULONG linestart = AtLineStart;
+ uint32_t nFloatMask, nFloatLen;
+ uint32_t linestart = AtLineStart;
AtLineStart = 0;
@@ -682,7 +682,7 @@
return pLongestFixed->nToken;
}
-ULONG
+uint32_t
yylex_MACROARGS()
{
size_t index = 0;
@@ -758,7 +758,7 @@
return 0;
}
-ULONG
+uint32_t
yylex(void)
{
switch (lexerstate) {
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -24,9 +24,9 @@
clock_t nStartClock, nEndClock;
int32_t nLineNo;
-ULONG nTotalLines, nPass, nPC, nIFDepth, nUnionDepth, nErrors;
+uint32_t nTotalLines, nPass, nPC, nIFDepth, nUnionDepth, nErrors;
bool skipElif;
-ULONG unionStart[128], unionSize[128];
+uint32_t unionStart[128], unionSize[128];
extern int yydebug;
@@ -480,7 +480,7 @@
timespent = ((double)(nEndClock - nStartClock))
/ (double)CLOCKS_PER_SEC;
if (CurrentOptions.verbose) {
- printf("Success! %ld lines in %d.%02d seconds ", nTotalLines,
+ printf("Success! %u lines in %d.%02d seconds ", nTotalLines,
(int) timespent, ((int) (timespent * 100.0)) % 100);
if (timespent == 0)
printf("(INFINITY lines/minute)\n");
--- a/src/asm/math.c
+++ b/src/asm/math.c
@@ -6,7 +6,6 @@
#include <stdint.h>
#include <stdio.h>
-#include "types.h"
#include "asm/mymath.h"
#include "asm/symbol.h"
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -23,16 +23,16 @@
struct Patch {
char tzFilename[_MAX_PATH + 1];
- ULONG nLine;
- ULONG nOffset;
+ uint32_t nLine;
+ uint32_t nOffset;
uint8_t nType;
- ULONG nRPNSize;
+ uint32_t nRPNSize;
uint8_t *pRPN;
struct Patch *pNext;
};
struct PatchSymbol {
- ULONG ID;
+ uint32_t ID;
struct sSymbol *pSymbol;
struct PatchSymbol *pNext;
struct PatchSymbol *pBucketNext; // next symbol in hash table bucket
@@ -80,8 +80,8 @@
fatalerror("No entries in the section stack");
}
-ULONG
-getmaxsectionsize(ULONG secttype, char * sectname)
+uint32_t
+getmaxsectionsize(uint32_t secttype, char * sectname)
{
switch (secttype)
{
@@ -101,11 +101,11 @@
/*
* Count the number of symbols used in this object
*/
-ULONG
+uint32_t
countsymbols(void)
{
struct PatchSymbol *pSym;
- ULONG count = 0;
+ uint32_t count = 0;
pSym = pPatchSymbols;
@@ -120,11 +120,11 @@
/*
* Count the number of sections used in this object
*/
-ULONG
+uint32_t
countsections(void)
{
struct Section *pSect;
- ULONG count = 0;
+ uint32_t count = 0;
pSect = pSectionList;
@@ -139,11 +139,11 @@
/*
* Count the number of patches used in this object
*/
-ULONG
+uint32_t
countpatches(struct Section * pSect)
{
struct Patch *pPatch;
- ULONG r = 0;
+ uint32_t r = 0;
pPatch = pSect->pPatches;
while (pPatch) {
@@ -158,7 +158,7 @@
* Write a long to a file (little-endian)
*/
void
-fputlong(ULONG i, FILE * f)
+fputlong(uint32_t i, FILE * f)
{
fputc(i, f);
fputc(i >> 8, f);
@@ -180,11 +180,11 @@
/*
* Return a section's ID
*/
-ULONG
+uint32_t
getsectid(struct Section * pSect)
{
struct Section *sec;
- ULONG ID = 0;
+ uint32_t ID = 0;
sec = pSectionList;
@@ -196,7 +196,7 @@
}
fatalerror("INTERNAL: Unknown section");
- return ((ULONG) - 1);
+ return ((uint32_t) - 1);
}
/*
@@ -251,8 +251,8 @@
writesymbol(struct sSymbol * pSym, FILE * f)
{
char symname[MAXSYMLEN * 2 + 1];
- ULONG type;
- ULONG offset;
+ uint32_t type;
+ uint32_t offset;
int32_t sectid;
if (pSym->nType & SYMF_IMPORT) {
@@ -295,12 +295,12 @@
/*
* Add a symbol to the object
*/
-ULONG
+uint32_t
addsymbol(struct sSymbol * pSym)
{
struct PatchSymbol *pPSym, **ppPSym;
- static ULONG nextID = 0;
- ULONG hash;
+ static uint32_t nextID = 0;
+ uint32_t hash;
hash = calchash(pSym->tzName);
ppPSym = &(tHashedPatchSymbols[hash]);
@@ -369,13 +369,13 @@
* Create a new patch (includes the rpn expr)
*/
void
-createpatch(ULONG type, struct Expression * expr)
+createpatch(uint32_t type, struct Expression * expr)
{
struct Patch *pPatch;
uint16_t rpndata;
uint8_t rpnexpr[2048];
char tzSym[512];
- ULONG rpnptr = 0, symptr;
+ uint32_t rpnptr = 0, symptr;
pPatch = allocpatch();
pPatch->nType = type;
@@ -396,7 +396,7 @@
symptr = 0;
while ((tzSym[symptr++] = rpn_PopByte(expr)) != 0);
if (sym_isConstant(tzSym)) {
- ULONG value;
+ uint32_t value;
value = sym_GetConstantValue(tzSym);
rpnexpr[rpnptr++] = RPN_CONST;
@@ -474,9 +474,9 @@
* Check if the section has grown too much.
*/
void
-checksectionoverflow(ULONG delta_size)
+checksectionoverflow(uint32_t delta_size)
{
- ULONG maxsize = getmaxsectionsize(pCurrentSection->nType,
+ uint32_t maxsize = getmaxsectionsize(pCurrentSection->nType,
pCurrentSection->pzName);
if (pCurrentSection->nPC + delta_size > maxsize) {
@@ -564,7 +564,7 @@
* Find a section by name and type. If it doesn't exist, create it
*/
struct Section *
-out_FindSection(char *pzName, ULONG secttype, int32_t org, int32_t bank, int32_t alignment)
+out_FindSection(char *pzName, uint32_t secttype, int32_t org, int32_t bank, int32_t alignment)
{
struct Section *pSect, **ppSect;
@@ -574,9 +574,9 @@
while (pSect) {
if (strcmp(pzName, pSect->pzName) == 0) {
if (secttype == pSect->nType
- && ((ULONG) org) == pSect->nOrg
- && ((ULONG) bank) == pSect->nBank
- && ((ULONG) alignment == pSect->nAlign)) {
+ && ((uint32_t) org) == pSect->nOrg
+ && ((uint32_t) bank) == pSect->nBank
+ && ((uint32_t) alignment == pSect->nAlign)) {
return (pSect);
} else
fatalerror
@@ -603,7 +603,7 @@
if (secttype == SECT_ROM0 || secttype == SECT_ROMX) {
/* It is only needed to allocate memory for ROM
* sections. */
- ULONG sectsize = getmaxsectionsize(secttype, pzName);
+ uint32_t sectsize = getmaxsectionsize(secttype, pzName);
if ((pSect->tData = malloc(sectsize)) == NULL)
fatalerror("Not enough memory for section");
}
@@ -637,7 +637,7 @@
* Set the current section by name and type
*/
void
-out_NewSection(char *pzName, ULONG secttype)
+out_NewSection(char *pzName, uint32_t secttype)
{
out_SetCurrentSection(out_FindSection(pzName, secttype, -1, -1, 1));
}
@@ -646,7 +646,7 @@
* Set the current section by name and type
*/
void
-out_NewAbsSection(char *pzName, ULONG secttype, int32_t org, int32_t bank)
+out_NewAbsSection(char *pzName, uint32_t secttype, int32_t org, int32_t bank)
{
out_SetCurrentSection(out_FindSection(pzName, secttype, org, bank, 1));
}
@@ -655,7 +655,7 @@
* Set the current section by name and type, using a given byte alignment
*/
void
-out_NewAlignedSection(char *pzName, ULONG secttype, int32_t alignment, int32_t bank)
+out_NewAlignedSection(char *pzName, uint32_t secttype, int32_t alignment, int32_t bank)
{
if (alignment < 0 || alignment > 16) {
yyerror("Alignment must be between 0-16 bits.");
@@ -782,7 +782,7 @@
void
out_RelWord(struct Expression * expr)
{
- ULONG b;
+ uint32_t b;
checkcodesection();
checksectionoverflow(2);
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -6,12 +6,11 @@
#include <stdio.h>
#include <string.h>
-#include "asm/mylink.h"
-#include "types.h"
-#include "asm/symbol.h"
#include "asm/asm.h"
#include "asm/main.h"
+#include "asm/mylink.h"
#include "asm/rpn.h"
+#include "asm/symbol.h"
void
mergetwoexpressions(struct Expression * expr, struct Expression * src1,
@@ -59,7 +58,7 @@
/*
* Determine if the current expression is relocatable
*/
-ULONG
+uint32_t
rpn_isReloc(struct Expression * expr)
{
return (expr->isReloc);
@@ -68,7 +67,7 @@
/*
* Determine if the current expression can be pc-relative
*/
-ULONG
+uint32_t
rpn_isPCRelative(struct Expression * expr)
{
return (expr->isPCRel);
@@ -78,7 +77,7 @@
* Add symbols, constants and operators to expression
*/
void
-rpn_Number(struct Expression * expr, ULONG i)
+rpn_Number(struct Expression * expr, uint32_t i)
{
rpn_Reset(expr);
pushbyte(expr, RPN_CONST);
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -54,7 +54,7 @@
int32_t
Callback_NARG(struct sSymbol * sym)
{
- ULONG i = 0;
+ uint32_t i = 0;
while (currentmacroargs[i] && i < MAXMACROARGS)
i += 1;
@@ -83,10 +83,10 @@
/*
* Calculate the hash value for a string
*/
-ULONG
+uint32_t
calchash(char *s)
{
- ULONG hash = 5381;
+ uint32_t hash = 5381;
while (*s != 0)
hash = (hash * 33) ^ (*s++);
@@ -101,7 +101,7 @@
createsymbol(char *s)
{
struct sSymbol **ppsym;
- ULONG hash;
+ uint32_t hash;
hash = calchash(s);
ppsym = &(tHashedSymbols[hash]);
@@ -232,7 +232,7 @@
/*
* Determine if a symbol has been defined
*/
-ULONG
+uint32_t
sym_isConstDefined(char *tzName)
{
struct sSymbol *psym, *pscope;
@@ -256,7 +256,7 @@
return (0);
}
-ULONG
+uint32_t
sym_isDefined(char *tzName)
{
struct sSymbol *psym, *pscope;
@@ -277,7 +277,7 @@
/*
* Determine if the symbol is a constant
*/
-ULONG
+uint32_t
sym_isConstant(char *s)
{
struct sSymbol *psym, *pscope;
@@ -314,7 +314,7 @@
/*
* Return a constant symbols value
*/
-ULONG
+uint32_t
sym_GetConstantValue(char *s)
{
struct sSymbol *psym, *pscope;
@@ -340,7 +340,7 @@
/*
* Return a symbols value... "estimated" if not defined yet
*/
-ULONG
+uint32_t
sym_GetValue(char *s)
{
struct sSymbol *psym, *pscope;
@@ -379,7 +379,7 @@
/*
* Return a defined symbols value... aborts if not defined yet
*/
-ULONG
+uint32_t
sym_GetDefinedValue(char *s)
{
struct sSymbol *psym, *pscope;
@@ -490,11 +490,11 @@
}
void
-sym_SetMacroArgID(ULONG nMacroCount)
+sym_SetMacroArgID(uint32_t nMacroCount)
{
char s[256];
- sprintf(s, "_%ld", nMacroCount);
+ sprintf(s, "_%u", nMacroCount);
newmacroargs[MAXMACROARGS] = strdup(s);
}
@@ -582,7 +582,7 @@
/*
* check if symbol is a string equated symbol
*/
-ULONG
+uint32_t
sym_isString(char *tzSym)
{
struct sSymbol *pSym;
--- a/src/link/lexer.l
+++ b/src/link/lexer.l
@@ -22,10 +22,13 @@
#include <unistd.h>
#include "extern/err.h"
+
#include "link/mylink.h"
#include "link/script.h"
#include "parser.h"
+
+#include "types.h"
extern int yyparse();
--- a/src/link/library.c
+++ b/src/link/library.c
@@ -4,7 +4,6 @@
#include <string.h>
#include "extern/err.h"
-#include "types.h"
#include "link/mylink.h"
#include "link/main.h"
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -384,7 +384,7 @@
int32_t
file_Length(FILE * f)
{
- ULONG r, p;
+ uint32_t r, p;
p = ftell(f);
fseek(f, 0, SEEK_END);
--- a/src/link/symbol.c
+++ b/src/link/symbol.c
@@ -4,8 +4,10 @@
#include <string.h>
#include "extern/err.h"
+
#include "link/main.h"
#include "link/patch.h"
+
#include "types.h"
#define HASHSIZE 73
@@ -16,7 +18,7 @@
int32_t nBank; /* -1 = constant */
char tzObjFileName[_MAX_PATH + 1]; /* Object file where the symbol was defined. */
char tzFileName[_MAX_PATH + 1]; /* Source file where the symbol was defined. */
- ULONG nFileLine; /* Line where the symbol was defined. */
+ uint32_t nFileLine; /* Line where the symbol was defined. */
struct ISymbol *pNext;
};
@@ -80,7 +82,7 @@
void
sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank, char *tzObjFileName,
- char *tzFileName, ULONG nFileLine)
+ char *tzFileName, uint32_t nFileLine)
{
if (strcmp(tzName, "@") == 0)
return;