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

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
@@ -11,25 +12,25 @@
#include "link/symbol.h"
struct sFreeArea {
SLONG nOrg;
SLONG nSize;
int32_t nOrg;
int32_t nSize;
struct sFreeArea *pPrev, *pNext;
};
struct sSectionAttributes {
const char *name;
SLONG bank;
SLONG offset; // bank + offset = bank originally stored in a section struct
SLONG minBank;
SLONG bankCount;
int32_t bank;
int32_t offset; // bank + offset = bank originally stored in a section struct
int32_t minBank;
int32_t bankCount;
};
struct sFreeArea *BankFree[MAXBANKS];
SLONG MaxAvail[MAXBANKS];
SLONG MaxBankUsed;
SLONG MaxWBankUsed;
SLONG MaxSBankUsed;
SLONG MaxVBankUsed;
int32_t MaxAvail[MAXBANKS];
int32_t MaxBankUsed;
int32_t MaxWBankUsed;
int32_t MaxSBankUsed;
int32_t MaxVBankUsed;
const enum eSectionType SECT_MIN = SECT_WRAM0;
const enum eSectionType SECT_MAX = SECT_OAM;
@@ -63,10 +64,10 @@ ensureSectionTypeIsValid(enum eSectionType type)
}
}
SLONG
area_Avail(SLONG bank)
int32_t
area_Avail(int32_t bank)
{
SLONG r;
int32_t r;
struct sFreeArea *pArea;
r = 0;
@@ -80,8 +81,8 @@ area_Avail(SLONG bank)
return (r);
}
SLONG
area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size)
int32_t
area_doAlloc(struct sFreeArea *pArea, int32_t org, int32_t size)
{
if (org >= pArea->nOrg && (org + size) <= (pArea->nOrg + pArea->nSize)) {
if (org == pArea->nOrg) {
@@ -114,14 +115,14 @@ area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size)
return -1;
}
SLONG
area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
int32_t
area_AllocAbs(struct sFreeArea ** ppArea, int32_t org, int32_t size)
{
struct sFreeArea *pArea;
pArea = *ppArea;
while (pArea) {
SLONG result = area_doAlloc(pArea, org, size);
int32_t result = area_doAlloc(pArea, org, size);
if (result != -1) {
return result;
}
@@ -133,13 +134,13 @@ area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
return -1;
}
SLONG
area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
int32_t
area_AllocAbsAnyBank(int32_t org, int32_t size, enum eSectionType type)
{
ensureSectionTypeIsValid(type);
SLONG startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
int32_t startBank = SECT_ATTRIBUTES[type].bank;
int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) {
if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) {
@@ -150,8 +151,8 @@ area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
return -1;
}
SLONG
area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
int32_t
area_Alloc(struct sFreeArea ** ppArea, int32_t size, int32_t alignment) {
struct sFreeArea *pArea;
if (alignment < 1) {
alignment = 1;
@@ -159,13 +160,13 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
pArea = *ppArea;
while (pArea) {
SLONG org = pArea->nOrg;
int32_t org = pArea->nOrg;
if (org % alignment) {
org += alignment;
}
org -= org % alignment;
SLONG result = area_doAlloc(pArea, org, size);
int32_t result = area_doAlloc(pArea, org, size);
if (result != -1) {
return result;
}
@@ -177,15 +178,15 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
return -1;
}
SLONG
area_AllocAnyBank(SLONG size, SLONG alignment, enum eSectionType type) {
int32_t
area_AllocAnyBank(int32_t size, int32_t alignment, enum eSectionType type) {
ensureSectionTypeIsValid(type);
SLONG startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
int32_t startBank = SECT_ATTRIBUTES[type].bank;
int32_t bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) {
SLONG org = area_Alloc(&BankFree[startBank + i], size, alignment);
int32_t org = area_Alloc(&BankFree[startBank + i], size, alignment);
if (org != -1) {
return ((startBank + i) << 16) | org;
}
@@ -198,8 +199,8 @@ struct sSection *
FindLargestSection(enum eSectionType type, bool bankFixed)
{
struct sSection *pSection, *r = NULL;
SLONG nLargest = 0;
SLONG nLargestAlignment = 0;
int32_t nLargest = 0;
int32_t nLargestAlignment = 0;
pSection = pSections;
while (pSection) {
@@ -332,7 +333,7 @@ AssignFloatingBankSections(enum eSectionType type)
struct sSection *pSection;
while ((pSection = FindLargestSection(type, false))) {
SLONG org;
int32_t org;
if ((org = area_AllocAnyBank(pSection->nByteSize, pSection->nAlign, type)) != -1) {
if (options & OPT_OVERLAY) {
@@ -370,7 +371,7 @@ SetLinkerscriptName(char *tzLinkerscriptFile)
void
AssignSections(void)
{
SLONG i;
int32_t i;
struct sSection *pSection;
MaxBankUsed = 0;
@@ -557,7 +558,7 @@ CreateSymbolTable(void)
pSect = pSections;
while (pSect) {
SLONG i;
int32_t i;
i = pSect->nNumberOfSymbols;

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -21,8 +22,8 @@ enum eBlockType {
BLOCK_OUTPUT
};
SLONG options = 0;
SLONG fillchar = 0;
int32_t options = 0;
int32_t fillchar = 0;
char *smartlinkstartsymbol;
/*

View File

@@ -1,4 +1,5 @@
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -10,8 +11,8 @@
FILE *mf = NULL;
FILE *sf = NULL;
SLONG currentbank = 0;
SLONG sfbank;
int32_t currentbank = 0;
int32_t sfbank;
void
SetMapfileName(char *name)
@@ -49,26 +50,26 @@ CloseMapfile(void)
}
void
MapfileInitBank(SLONG bank)
MapfileInitBank(int32_t bank)
{
if (mf) {
currentbank = bank;
if (bank == BANK_ROM0)
fprintf(mf, "ROM Bank #0 (HOME):\n");
else if (bank < BANK_WRAM0)
fprintf(mf, "ROM Bank #%ld:\n", bank);
fprintf(mf, "ROM Bank #%d:\n", bank);
else if (bank == BANK_WRAM0)
fprintf(mf, "WRAM Bank #0:\n");
else if (bank < BANK_VRAM)
fprintf(mf, "WRAM Bank #%ld:\n", bank - BANK_WRAMX + 1);
fprintf(mf, "WRAM Bank #%d:\n", bank - BANK_WRAMX + 1);
else if (bank == BANK_HRAM)
fprintf(mf, "HRAM:\n");
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
fprintf(mf, "VRAM Bank #%ld:\n", bank - BANK_VRAM);
fprintf(mf, "VRAM Bank #%d:\n", bank - BANK_VRAM);
else if (bank == BANK_OAM)
fprintf(mf, "OAM:\n");
else if (bank < MAXBANKS)
fprintf(mf, "SRAM Bank #%ld:\n", bank - BANK_SRAM);
fprintf(mf, "SRAM Bank #%d:\n", bank - BANK_SRAM);
}
if (sf) {
if (bank < BANK_WRAM0)
@@ -93,15 +94,15 @@ MapfileInitBank(SLONG bank)
void
MapfileWriteSection(struct sSection * pSect)
{
SLONG i;
int32_t i;
if (mf) {
if (pSect->nByteSize > 0) {
fprintf(mf, " SECTION: $%04lX-$%04lX ($%04lX bytes) [\"%s\"]\n",
fprintf(mf, " SECTION: $%04X-$%04X ($%04X bytes) [\"%s\"]\n",
pSect->nOrg, pSect->nOrg + pSect->nByteSize - 1,
pSect->nByteSize, pSect->pzName);
} else {
fprintf(mf, " SECTION: $%04lX ($0 bytes) [\"%s\"]\n",
fprintf(mf, " SECTION: $%04X ($0 bytes) [\"%s\"]\n",
pSect->nOrg, pSect->pzName);
}
}
@@ -112,12 +113,12 @@ MapfileWriteSection(struct sSection * pSect)
if ((pSym->pSection == pSect)
&& (pSym->Type != SYM_IMPORT)) {
if (mf) {
fprintf(mf, " $%04lX = %s\n",
fprintf(mf, " $%04X = %s\n",
pSym->nOffset + pSect->nOrg,
pSym->pzName);
}
if (sf) {
fprintf(sf, "%02lX:%04lX %s\n", sfbank,
fprintf(sf, "%02X:%04X %s\n", sfbank,
pSym->nOffset + pSect->nOrg,
pSym->pzName);
}
@@ -126,7 +127,7 @@ MapfileWriteSection(struct sSection * pSect)
}
void
MapfileCloseBank(SLONG slack)
MapfileCloseBank(int32_t slack)
{
if (!mf)
return;
@@ -134,5 +135,5 @@ MapfileCloseBank(SLONG slack)
if (slack == MaxAvail[currentbank])
fprintf(mf, " EMPTY\n\n");
else
fprintf(mf, " SLACK: $%04lX bytes\n\n", slack);
fprintf(mf, " SLACK: $%04X bytes\n\n", slack);
}

View File

@@ -27,10 +27,10 @@ uint8_t oReadLib = 0;
*
*/
SLONG
int32_t
readlong(FILE * f)
{
SLONG r;
int32_t r;
r = fgetc(f);
r |= fgetc(f) << 8;
@@ -55,7 +55,7 @@ readword(FILE * f)
* Read a NULL terminated string from a file
*
*/
SLONG
int32_t
readasciiz(char **dest, FILE *f)
{
size_t r = 0;
@@ -226,7 +226,7 @@ obj_ReadRGBSection(FILE * f)
err(1, NULL);
}
SLONG nNumberOfPatches;
int32_t nNumberOfPatches;
struct sPatch **ppPatch, *pPatch;
if (fread(pSection->pData, sizeof(uint8_t),
@@ -281,7 +281,7 @@ void
obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
{
struct sSection *pFirstSection;
SLONG nNumberOfSymbols, nNumberOfSections, i;
int32_t nNumberOfSymbols, nNumberOfSections, i;
nNumberOfSymbols = readlong(pObjfile);
nNumberOfSections = readlong(pObjfile);
@@ -322,7 +322,7 @@ obj_ReadRGB(FILE * pObjfile, char *tzObjectfile)
if (tSymbols[i]->Type != SYM_IMPORT
&& tSymbols[i]->nSectionID != -1) {
SLONG j = 0;
int32_t j = 0;
while (j != tSymbols[i]->nSectionID) {
j += 1;
pConvSect = pConvSect->pNext;
@@ -381,7 +381,7 @@ obj_Readfile(char *tzObjectfile)
oReadLib = 0;
}
SLONG
int32_t
file_Length(FILE * f)
{
ULONG r, p;

View File

@@ -10,24 +10,24 @@
#include "link/main.h"
struct sSection *pCurrentSection;
SLONG rpnstack[256];
SLONG rpnp;
SLONG nPC;
int32_t rpnstack[256];
int32_t rpnp;
int32_t nPC;
void
rpnpush(SLONG i)
rpnpush(int32_t i)
{
rpnstack[rpnp++] = i;
}
SLONG
int32_t
rpnpop(void)
{
return (rpnstack[--rpnp]);
}
SLONG
getsymvalue(SLONG symid)
int32_t
getsymvalue(int32_t symid)
{
switch (pCurrentSection->tSymbols[symid]->Type) {
case SYM_IMPORT:
@@ -52,10 +52,10 @@ getsymvalue(SLONG symid)
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
}
SLONG
getsymbank(SLONG symid)
int32_t
getsymbank(int32_t symid)
{
SLONG nBank;
int32_t nBank;
switch (pCurrentSection->tSymbols[symid]->Type) {
case SYM_IMPORT:
@@ -83,10 +83,10 @@ getsymbank(SLONG symid)
return nBank;
}
SLONG
int32_t
calcrpn(struct sPatch * pPatch)
{
SLONG t, size;
int32_t t, size;
uint8_t *rpn;
rpnp = 0;
@@ -224,7 +224,7 @@ Patch(void)
pCurrentSection = pSect;
pPatch = pSect->pPatches;
while (pPatch) {
SLONG t;
int32_t t;
nPC = pSect->nOrg + pPatch->nOffset;
t = calcrpn(pPatch);

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -11,8 +12,8 @@
struct ISymbol {
char *pzName;
SLONG nValue;
SLONG nBank; /* -1 = constant */
int32_t nValue;
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. */
@@ -21,10 +22,10 @@ struct ISymbol {
struct ISymbol *tHash[HASHSIZE];
SLONG
int32_t
calchash(char *s)
{
SLONG r = 0;
int32_t r = 0;
while (*s)
r += *s++;
@@ -34,12 +35,12 @@ calchash(char *s)
void
sym_Init(void)
{
SLONG i;
int32_t i;
for (i = 0; i < HASHSIZE; i += 1)
tHash[i] = NULL;
}
SLONG
int32_t
sym_GetValue(char *tzName)
{
if (strcmp(tzName, "@") == 0) {
@@ -60,7 +61,7 @@ sym_GetValue(char *tzName)
}
}
SLONG
int32_t
sym_GetBank(char *tzName)
{
struct ISymbol **ppSym;
@@ -78,7 +79,7 @@ sym_GetBank(char *tzName)
}
void
sym_CreateSymbol(char *tzName, SLONG nValue, SLONG nBank, char *tzObjFileName,
sym_CreateSymbol(char *tzName, int32_t nValue, int32_t nBank, char *tzObjFileName,
char *tzFileName, ULONG nFileLine)
{
if (strcmp(tzName, "@") == 0)