ref: 7d55e1d54dde85955f717157deb8797b89e4f1e4
parent: e646a0300cdd915eeaeeada2f44b4380c27fa654
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 24 09:01:53 EST 2017
[myro] Don't pollute the namespace It is better to use a better prefix for myro functions. Using read and write was a really bad idea.
--- a/as/myro.c
+++ b/as/myro.c
@@ -56,7 +56,7 @@
sect.aligment = 0;
sect.offset = off;
sect.len = 0;
- off += writesec(fp, §);
+ off += wrmyrosec(fp, §);
}
return off;
@@ -76,7 +76,7 @@
symbol.flags = 0;
symbol.offset = off;
symbol.len = 0;
- off += writesym(fp, &symbol);
+ off += wrmyrosym(fp, &symbol);
}
return off;
@@ -97,7 +97,7 @@
reloc.nbits = bp->nbits;
reloc.shift = bp->shift;
reloc.offset = bp->offset;
- off += writerel(fp, &reloc);
+ off += wrmyrorel(fp, &reloc);
}
return off;
}
@@ -123,7 +123,7 @@
if ((fp = fopen(name, "wb")) == NULL)
die("error opening output file '%s'\n", name);
- writehdr(fp, &hdr);
+ wrmyrohdr(fp, &hdr);
hdr.strsize = writestrings(fp);
hdr.secsize = writesections(fp);
hdr.symsize = writesymbols(fp);
@@ -131,7 +131,7 @@
writedata(fp);
fseek(fp, 0, SEEK_SET);
- writehdr(fp, &hdr);
+ wrmyrohdr(fp, &hdr);
if (fclose(fp))
die("error writing the output file");
--- a/inc/myro.h
+++ b/inc/myro.h
@@ -44,11 +44,11 @@
unsigned long long offset;
};
-extern int writehdr(FILE *fp, struct myrohdr *hdr);
-extern int writesec(FILE *fp, struct myrosect *sect);
-extern int writesym(FILE *fp, struct myrosym *sym);
-extern int writerel(FILE *fp, struct myrorel *rel);
-extern int readhdr(FILE *fp, struct myrohdr *hdr);
-extern int readsec(FILE *fp, struct myrosect *sect);
-extern int readsym(FILE *fp, struct myrosym *sym);
-extern int readrel(FILE *fp, struct myrorel *rel);
+extern int wrmyrohdr(FILE *fp, struct myrohdr *hdr);
+extern int wrmyrosec(FILE *fp, struct myrosect *sect);
+extern int wrmyrosym(FILE *fp, struct myrosym *sym);
+extern int wrmyrorel(FILE *fp, struct myrorel *rel);
+extern int rdmyrohdr(FILE *fp, struct myrohdr *hdr);
+extern int rdmyrosec(FILE *fp, struct myrosect *sect);
+extern int rdmyrosym(FILE *fp, struct myrosym *sym);
+extern int rdmyrorel(FILE *fp, struct myrorel *rel);
--- a/lib/scc/rmyro.c
+++ b/lib/scc/rmyro.c
@@ -8,7 +8,7 @@
#include "../../inc/myro.h"
int
-readhdr(FILE *fp, struct myrohdr *hdr)
+rdmyrohdr(FILE *fp, struct myrohdr *hdr)
{
unsigned char buf[MYROHDR_SIZ];
int len;
@@ -31,7 +31,7 @@
}
int
-readsec(FILE *fp, struct myrosect *sect)
+rdmyrosec(FILE *fp, struct myrosect *sect)
{
unsigned char buf[MYROSECT_SIZ];
int len;
@@ -52,7 +52,7 @@
}
int
-readsym(FILE *fp, struct myrosym *sym)
+rdmyrosym(FILE *fp, struct myrosym *sym)
{
unsigned char buf[MYROSYM_SIZ];
int len;
@@ -73,7 +73,7 @@
}
int
-readrel(FILE *fp, struct myrorel *rel)
+rdmyrorel(FILE *fp, struct myrorel *rel)
{
unsigned char buf[MYROREL_SIZ];
int len;
--- a/lib/scc/wmyro.c
+++ b/lib/scc/wmyro.c
@@ -8,7 +8,7 @@
#include "../../inc/myro.h"
int
-writehdr(FILE *fp, struct myrohdr *hdr)
+wrmyrohdr(FILE *fp, struct myrohdr *hdr)
{
unsigned char buf[MYROHDR_SIZ];
int len;
@@ -29,7 +29,7 @@
}
int
-writesec(FILE *fp, struct myrosect *sect)
+wrmyrosec(FILE *fp, struct myrosect *sect)
{
unsigned char buf[MYROSECT_SIZ];
int len;
@@ -48,7 +48,7 @@
}
int
-writesym(FILE *fp, struct myrosym *sym)
+wrmyrosym(FILE *fp, struct myrosym *sym)
{
unsigned char buf[MYROSYM_SIZ];
int len;
@@ -67,7 +67,7 @@
}
int
-writerel(FILE *fp, struct myrorel *rel)
+wrmyrorel(FILE *fp, struct myrorel *rel)
{
unsigned char buf[MYROREL_SIZ];
int len;
--- a/nm/main.c
+++ b/nm/main.c
@@ -50,7 +50,7 @@
size_t n;
rewind(fp);
- if (readhdr(fp, &hdr) == EOF)
+ if (rdmyrohdr(fp, &hdr) == EOF)
fdie(fname);
if (strncmp(hdr.magic, MYROMAGIC, MYROMAGIC_SIZ))
n = hdr.symsize / MYROSYM_SIZ;