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

@@ -142,7 +142,7 @@ area_AllocAbsAnyBank(int32_t org, int32_t size, enum eSectionType type)
int32_t startBank = SECT_ATTRIBUTES[type].bank;
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) {
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 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);
if (org != -1) {
return ((startBank + i) << 16) | org;
@@ -217,7 +217,7 @@ FindLargestSection(enum eSectionType type, bool bankFixed)
return r;
}
int
int32_t
IsSectionNameInUse(const char *name)
{
struct sSection *pSection;
@@ -234,8 +234,8 @@ IsSectionNameInUse(const char *name)
}
int
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank)
int32_t
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int32_t bank)
{
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);
}
unsigned int
AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank)
uint32_t
AssignSectionAddressAndBankByName(const char *name, uint32_t address, int32_t bank)
{
struct sSection *pSection;

View File

@@ -19,6 +19,7 @@
%{
#include <stdarg.h>
#include <stdint.h>
#include <unistd.h>
#include "extern/err.h"
@@ -36,11 +37,11 @@ extern int yyparse();
#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 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 */
%}
@@ -151,7 +152,7 @@ void script_IncludeFile(const char * path)
unput('\n');
}
int script_IncludeDepthGet(void)
int32_t script_IncludeDepthGet(void)
{
return include_stack_ptr;
}
@@ -169,7 +170,7 @@ void script_IncludePop(void)
void script_PrintFileStack(void)
{
int i = include_stack_ptr;
int32_t i = include_stack_ptr;
include_line[i] = yylineno;

View File

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

View File

@@ -121,7 +121,7 @@ main(int argc, char *argv[])
if (argc == 0)
usage();
for (int i = 0; i < argc; ++i)
for (int32_t i = 0; i < argc; ++i)
obj_Readfile(argv[i]);
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 */
switch (pSection->Type)
@@ -353,7 +353,7 @@ obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile)
strlen(RGBDS_OBJECT_VERSION_STRING)) == 0) {
obj_ReadRGB(pObjfile, tzObjectfile);
} 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]))
tzHeader[i] = '?';
errx(1, "%s: Invalid file or object file version [%s]",

View File

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

View File

@@ -14,23 +14,26 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdint.h>
#include <string.h>
#include "extern/err.h"
#include "link/assign.h"
#include "link/mylink.h"
static struct {
unsigned int address; /* current address to write sections to */
unsigned int top_address; /* not inclusive */
uint32_t address; /* current address to write sections to */
uint32_t top_address; /* not inclusive */
enum eSectionType type;
} bank[MAXBANKS];
static int 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_bank = -1; /* Bank as seen by the bank array */
static int32_t current_real_bank = -1; /* bank as seen by the GB */
void script_InitSections(void)
{
int i;
int32_t i;
for (i = 0; i < MAXBANKS; i++) {
if (i == BANK_ROM0) {
/* 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 (bank != 0)
@@ -150,7 +153,7 @@ void script_SetCurrentSectionType(const char *type, unsigned int bank)
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) {
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) {
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);
}
unsigned int size = 1 << alignment;
unsigned int mask = size - 1;
uint32_t size = 1 << alignment;
uint32_t mask = size - 1;
if (bank[current_bank].address & mask) {
bank[current_bank].address &= ~mask;