Replace SLONG by int32_t

All affected `printf` have been fixed.

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 13:59:17 +01:00
parent 13c0684497
commit 87c9d819a1
28 changed files with 247 additions and 232 deletions

View File

@@ -22,9 +22,9 @@ char *tzNewMacro;
ULONG ulNewMacroSize;
void
bankrangecheck(char *name, ULONG secttype, SLONG org, SLONG bank)
bankrangecheck(char *name, ULONG secttype, int32_t org, int32_t bank)
{
SLONG minbank = 0, maxbank = 0;
int32_t minbank = 0, maxbank = 0;
char *stype = NULL;
switch (secttype) {
case SECT_ROMX:
@@ -140,7 +140,7 @@ ULONG isEndr( char *s )
void copyrept( void )
{
SLONG level=1, len, instring=0;
int32_t level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
@@ -220,7 +220,7 @@ ULONG isEndm( char *s )
void copymacro( void )
{
SLONG level=1, len, instring=0;
int32_t level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer;
char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
@@ -312,7 +312,7 @@ ULONG isEndc(char *s)
void if_skip_to_else()
{
SLONG level = 1;
int32_t level = 1;
bool inString = false;
char *src=pCurrentBuffer->pBuffer;
@@ -367,7 +367,7 @@ void if_skip_to_else()
fatalerror("Unterminated IF construct");
}
SLONG len = src - pCurrentBuffer->pBuffer;
int32_t len = src - pCurrentBuffer->pBuffer;
yyskipbytes(len);
yyunput('\n');
@@ -376,7 +376,7 @@ void if_skip_to_else()
void if_skip_to_endc()
{
SLONG level = 1;
int32_t level = 1;
bool inString = false;
char *src=pCurrentBuffer->pBuffer;
@@ -425,7 +425,7 @@ void if_skip_to_endc()
fatalerror("Unterminated IF construct");
}
SLONG len = src - pCurrentBuffer->pBuffer;
int32_t len = src - pCurrentBuffer->pBuffer;
yyskipbytes(len);
yyunput('\n');
@@ -467,7 +467,7 @@ void updateUnion() {
char tzSym[MAXSYMLEN + 1];
char tzString[MAXSTRLEN + 1];
struct Expression sVal;
SLONG nConstValue;
int32_t nConstValue;
}
%type <sVal> relocconst
@@ -922,7 +922,7 @@ printt : T_POP_PRINTT string
printv : T_POP_PRINTV const
{
if( nPass==1 )
printf( "$%lX", $2 );
printf( "$%X", $2 );
}
;

View File

@@ -28,7 +28,7 @@ FILE *pCurrentFile;
ULONG nCurrentStatus;
char tzCurrentFileName[_MAX_PATH + 1];
char IncludePaths[MAXINCPATHS][_MAX_PATH + 1];
SLONG NextIncPath = 0;
int32_t NextIncPath = 0;
ULONG nMacroCount;
char *pCurrentREPTBlock;
@@ -200,12 +200,12 @@ fstk_Dump(void)
pLastFile = pFileStack;
while (pLastFile) {
fprintf(stderr, "%s(%ld) -> ", pLastFile->tzFileName,
pLastFile->nLine);
fprintf(stderr, "%s(%d) -> ", pLastFile->tzFileName,
pLastFile->nLine);
pLastFile = pLastFile->pNext;
}
fprintf(stderr, "%s(%ld)", tzCurrentFileName, nLineNo);
fprintf(stderr, "%s(%d)", tzCurrentFileName, nLineNo);
}
/*
@@ -320,7 +320,7 @@ fstk_RunMacro(char *s)
* Set up a macroargument for parsing
*/
void
fstk_RunMacroArg(SLONG s)
fstk_RunMacroArg(int32_t s)
{
char *sym;

View File

@@ -8,19 +8,20 @@
#include "asmy.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
bool oDontExpandStrings = false;
SLONG nGBGfxID = -1;
SLONG nBinaryID = -1;
int32_t nGBGfxID = -1;
int32_t nBinaryID = -1;
SLONG
int32_t
gbgfx2bin(char ch)
{
SLONG i;
int32_t i;
for (i = 0; i <= 3; i += 1) {
if (CurrentOptions.gbgfx[i] == ch) {
@@ -31,10 +32,10 @@ gbgfx2bin(char ch)
return (0);
}
SLONG
int32_t
binary2bin(char ch)
{
SLONG i;
int32_t i;
for (i = 0; i <= 1; i += 1) {
if (CurrentOptions.binary[i] == ch) {
@@ -45,7 +46,7 @@ binary2bin(char ch)
return (0);
}
SLONG
int32_t
char2bin(char ch)
{
if (ch >= 'a' && ch <= 'f')
@@ -60,13 +61,13 @@ char2bin(char ch)
return (0);
}
typedef SLONG(*x2bin) (char ch);
typedef int32_t(*x2bin) (char ch);
SLONG
int32_t
ascii2bin(char *s)
{
SLONG radix = 10;
SLONG result = 0;
int32_t radix = 10;
int32_t result = 0;
x2bin convertfunc = char2bin;
switch (*s) {
@@ -93,7 +94,7 @@ ascii2bin(char *s)
}
if (radix == 4) {
SLONG c;
int32_t c;
while (*s != '\0') {
c = convertfunc(*s++);
@@ -128,7 +129,7 @@ ParseFixedPoint(char *s, ULONG size)
yyunputbytes(size);
yylval.nConstValue = (SLONG) (atof(s) * 65536);
yylval.nConstValue = (int32_t) (atof(s) * 65536);
return (1);
}

View File

@@ -1,6 +1,7 @@
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -22,7 +23,7 @@ int cldefines_size;
char **cldefines;
clock_t nStartClock, nEndClock;
SLONG nLineNo;
int32_t nLineNo;
ULONG nTotalLines, nPass, nPC, nIFDepth, nUnionDepth, nErrors;
bool skipElif;
ULONG unionStart[128], unionSize[128];
@@ -141,7 +142,7 @@ opt_Parse(char *s)
if (strlen(&s[1]) <= 2) {
int result;
result = sscanf(&s[1], "%lx", &newopt.fillchar);
result = sscanf(&s[1], "%x", &newopt.fillchar);
if (!((result == EOF) || (result == 1))) {
errx(1, "Invalid argument for option 'z'");
}

View File

@@ -3,6 +3,7 @@
*/
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include "types.h"
@@ -10,7 +11,7 @@
#include "asm/symbol.h"
#define fix2double(i) ((double)(i/65536.0))
#define double2fix(d) ((SLONG)(d*65536.0))
#define double2fix(d) ((int32_t)(d*65536.0))
#ifndef PI
#define PI (acos(-1))
#endif
@@ -28,21 +29,21 @@ math_DefinePI(void)
* Print a fixed point value
*/
void
math_Print(SLONG i)
math_Print(int32_t i)
{
if (i >= 0)
printf("%ld.%05ld", i >> 16,
((SLONG) (fix2double(i) * 100000 + 0.5)) % 100000);
printf("%d.%05d", i >> 16,
((int32_t) (fix2double(i) * 100000 + 0.5)) % 100000);
else
printf("-%ld.%05ld", (-i) >> 16,
((SLONG) (fix2double(-i) * 100000 + 0.5)) % 100000);
printf("-%d.%05d", (-i) >> 16,
((int32_t) (fix2double(-i) * 100000 + 0.5)) % 100000);
}
/*
* Calculate sine
*/
SLONG
math_Sin(SLONG i)
int32_t
math_Sin(int32_t i)
{
return (double2fix(sin(fix2double(i) * 2 * PI / 65536)));
}
@@ -50,8 +51,8 @@ math_Sin(SLONG i)
/*
* Calculate cosine
*/
SLONG
math_Cos(SLONG i)
int32_t
math_Cos(int32_t i)
{
return (double2fix(cos(fix2double(i) * 2 * PI / 65536)));
}
@@ -59,8 +60,8 @@ math_Cos(SLONG i)
/*
* Calculate tangent
*/
SLONG
math_Tan(SLONG i)
int32_t
math_Tan(int32_t i)
{
return (double2fix(tan(fix2double(i) * 2 * PI / 65536)));
}
@@ -68,8 +69,8 @@ math_Tan(SLONG i)
/*
* Calculate arcsine
*/
SLONG
math_ASin(SLONG i)
int32_t
math_ASin(int32_t i)
{
return (double2fix(asin(fix2double(i)) / 2 / PI * 65536));
}
@@ -77,8 +78,8 @@ math_ASin(SLONG i)
/*
* Calculate arccosine
*/
SLONG
math_ACos(SLONG i)
int32_t
math_ACos(int32_t i)
{
return (double2fix(acos(fix2double(i)) / 2 / PI * 65536));
}
@@ -86,8 +87,8 @@ math_ACos(SLONG i)
/*
* Calculate arctangent
*/
SLONG
math_ATan(SLONG i)
int32_t
math_ATan(int32_t i)
{
return (double2fix(atan(fix2double(i)) / 2 / PI * 65536));
}
@@ -95,8 +96,8 @@ math_ATan(SLONG i)
/*
* Calculate atan2
*/
SLONG
math_ATan2(SLONG i, SLONG j)
int32_t
math_ATan2(int32_t i, int32_t j)
{
return (double2fix
(atan2(fix2double(i), fix2double(j)) / 2 / PI * 65536));
@@ -105,8 +106,8 @@ math_ATan2(SLONG i, SLONG j)
/*
* Multiplication
*/
SLONG
math_Mul(SLONG i, SLONG j)
int32_t
math_Mul(int32_t i, int32_t j)
{
return (double2fix(fix2double(i) * fix2double(j)));
}
@@ -114,8 +115,8 @@ math_Mul(SLONG i, SLONG j)
/*
* Division
*/
SLONG
math_Div(SLONG i, SLONG j)
int32_t
math_Div(int32_t i, int32_t j)
{
return (double2fix(fix2double(i) / fix2double(j)));
}
@@ -123,8 +124,8 @@ math_Div(SLONG i, SLONG j)
/*
* Round
*/
SLONG
math_Round(SLONG i)
int32_t
math_Round(int32_t i)
{
return double2fix(round(fix2double(i)));
}
@@ -132,8 +133,8 @@ math_Round(SLONG i)
/*
* Ceil
*/
SLONG
math_Ceil(SLONG i)
int32_t
math_Ceil(int32_t i)
{
return double2fix(ceil(fix2double(i)));
}
@@ -141,8 +142,8 @@ math_Ceil(SLONG i)
/*
* Floor
*/
SLONG
math_Floor(SLONG i)
int32_t
math_Floor(int32_t i)
{
return double2fix(floor(fix2double(i)));
}

View File

@@ -253,7 +253,7 @@ writesymbol(struct sSymbol * pSym, FILE * f)
char symname[MAXSYMLEN * 2 + 1];
ULONG type;
ULONG offset;
SLONG sectid;
int32_t sectid;
if (pSym->nType & SYMF_IMPORT) {
/* Symbol should be imported */
@@ -564,7 +564,7 @@ out_SetFileName(char *s)
* Find a section by name and type. If it doesn't exist, create it
*/
struct Section *
out_FindSection(char *pzName, ULONG secttype, SLONG org, SLONG bank, SLONG alignment)
out_FindSection(char *pzName, ULONG secttype, int32_t org, int32_t bank, int32_t alignment)
{
struct Section *pSect, **ppSect;
@@ -646,7 +646,7 @@ out_NewSection(char *pzName, ULONG secttype)
* Set the current section by name and type
*/
void
out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank)
out_NewAbsSection(char *pzName, ULONG secttype, int32_t org, int32_t bank)
{
out_SetCurrentSection(out_FindSection(pzName, secttype, org, bank, 1));
}
@@ -655,7 +655,7 @@ out_NewAbsSection(char *pzName, ULONG secttype, SLONG org, SLONG bank)
* Set the current section by name and type, using a given byte alignment
*/
void
out_NewAlignedSection(char *pzName, ULONG secttype, SLONG alignment, SLONG bank)
out_NewAlignedSection(char *pzName, ULONG secttype, int32_t alignment, int32_t bank)
{
if (alignment < 0 || alignment > 16) {
yyerror("Alignment must be between 0-16 bits.");
@@ -805,10 +805,10 @@ out_RelWord(struct Expression * expr)
* Output an absolute longword
*/
void
out_AbsLong(SLONG b)
out_AbsLong(int32_t b)
{
checkcodesection();
checksectionoverflow(sizeof(SLONG));
checksectionoverflow(sizeof(int32_t));
if (nPass == 2) {
pCurrentSection->tData[nPC] = b & 0xFF;
pCurrentSection->tData[nPC + 1] = b >> 8;
@@ -827,7 +827,7 @@ out_AbsLong(SLONG b)
void
out_RelLong(struct Expression * expr)
{
SLONG b;
int32_t b;
checkcodesection();
checksectionoverflow(4);
@@ -854,7 +854,7 @@ out_RelLong(struct Expression * expr)
void
out_PCRelByte(struct Expression * expr)
{
SLONG b = expr->nVal;
int32_t b = expr->nVal;
checkcodesection();
checksectionoverflow(1);
@@ -879,7 +879,7 @@ out_BinaryFile(char *s)
err(1, "Unable to open incbin file '%s'", s);
}
SLONG fsize;
int32_t fsize;
fseek(f, 0, SEEK_END);
fsize = ftell(f);
@@ -889,8 +889,8 @@ out_BinaryFile(char *s)
checksectionoverflow(fsize);
if (nPass == 2) {
SLONG dest = nPC;
SLONG todo = fsize;
int32_t dest = nPC;
int32_t todo = fsize;
while (todo--)
pCurrentSection->tData[dest++] = fgetc(f);
@@ -902,7 +902,7 @@ out_BinaryFile(char *s)
}
void
out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
out_BinaryFileSlice(char *s, int32_t start_pos, int32_t length)
{
FILE *f;
@@ -917,7 +917,7 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
err(1, "Unable to open included file '%s'", s);
}
SLONG fsize;
int32_t fsize;
fseek(f, 0, SEEK_END);
fsize = ftell(f);
@@ -934,8 +934,8 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
checksectionoverflow(length);
if (nPass == 2) {
SLONG dest = nPC;
SLONG todo = length;
int32_t dest = nPC;
int32_t todo = length;
while (todo--)
pCurrentSection->tData[dest++] = fgetc(f);

View File

@@ -51,7 +51,7 @@ void helper_RemoveLeadingZeros(char * string){
memmove(string, new_beginning, strlen(new_beginning) + 1);
}
SLONG
int32_t
Callback_NARG(struct sSymbol * sym)
{
ULONG i = 0;
@@ -62,7 +62,7 @@ Callback_NARG(struct sSymbol * sym)
return (i);
}
SLONG
int32_t
Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
{
return (nLineNo);
@@ -71,7 +71,7 @@ Callback__LINE__(struct sSymbol __attribute__((unused)) * sym)
/*
* Get the nValue field of a symbol
*/
SLONG
int32_t
getvaluefield(struct sSymbol * sym)
{
if (sym->Callback) {
@@ -145,7 +145,7 @@ struct sSymbol **
findpsymbol(char *s, struct sSymbol * scope)
{
struct sSymbol **ppsym;
SLONG hash;
int32_t hash;
char fullname[MAXSYMLEN + 1];
if (s[0] == '.' && scope) {
@@ -411,7 +411,7 @@ sym_GetDefinedValue(char *s)
void
sym_ShiftCurrentMacroArgs(void)
{
SLONG i;
int32_t i;
free(currentmacroargs[0]);
for (i = 0; i < MAXMACROARGS - 1; i += 1) {
@@ -421,7 +421,7 @@ sym_ShiftCurrentMacroArgs(void)
}
char *
sym_FindMacroArg(SLONG i)
sym_FindMacroArg(int32_t i)
{
if (i == -1)
i = MAXMACROARGS + 1;
@@ -435,7 +435,7 @@ sym_FindMacroArg(SLONG i)
void
sym_UseNewMacroArgs(void)
{
SLONG i;
int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) {
currentmacroargs[i] = newmacroargs[i];
@@ -446,7 +446,7 @@ sym_UseNewMacroArgs(void)
void
sym_SaveCurrentMacroArgs(char *save[])
{
SLONG i;
int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1)
save[i] = currentmacroargs[i];
@@ -455,7 +455,7 @@ sym_SaveCurrentMacroArgs(char *save[])
void
sym_RestoreCurrentMacroArgs(char *save[])
{
SLONG i;
int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1)
currentmacroargs[i] = save[i];
@@ -464,7 +464,7 @@ sym_RestoreCurrentMacroArgs(char *save[])
void
sym_FreeCurrentMacroArgs(void)
{
SLONG i;
int32_t i;
for (i = 0; i <= MAXMACROARGS; i += 1) {
free(currentmacroargs[i]);
@@ -475,7 +475,7 @@ sym_FreeCurrentMacroArgs(void)
void
sym_AddNewMacroArg(char *s)
{
SLONG i = 0;
int32_t i = 0;
while (i < MAXMACROARGS && newmacroargs[i] != NULL)
i += 1;
@@ -501,7 +501,7 @@ sym_SetMacroArgID(ULONG nMacroCount)
void
sym_UseCurrentMacroArgs(void)
{
SLONG i;
int32_t i;
for (i = 1; i <= MAXMACROARGS; i += 1)
sym_AddNewMacroArg(sym_FindMacroArg(i));
@@ -520,7 +520,7 @@ sym_FindMacro(char *s)
* Add an equated symbol
*/
void
sym_AddEqu(char *tzSym, SLONG value)
sym_AddEqu(char *tzSym, int32_t value)
{
if ((nPass == 1)
|| ((nPass == 2) && (sym_isDefined(tzSym) == 0))) {
@@ -598,7 +598,7 @@ sym_isString(char *tzSym)
* Alter a SET symbols value
*/
void
sym_AddSet(char *tzSym, SLONG value)
sym_AddSet(char *tzSym, int32_t value)
{
struct sSymbol *nsym;
@@ -834,7 +834,7 @@ sym_PrepPass1(void)
void
sym_PrepPass2(void)
{
SLONG i;
int32_t i;
for (i = 0; i < HASHSIZE; i += 1) {
struct sSymbol **ppSym = &(tHashedSymbols[i]);
@@ -885,7 +885,7 @@ sym_PrepPass2(void)
void
sym_Init(void)
{
SLONG i;
int32_t i;
time_t now;
for (i = 0; i < MAXMACROARGS; i += 1) {