scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 355c64cd5eeb10a365b65b89e51384c61f55cadf
parent c7f20efa5745699d2ca0b8812a909dd700c2cb1c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 24 Nov 2017 14:01:53 +0000

[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.

Diffstat:
as/myro.c | 10+++++-----
inc/myro.h | 16++++++++--------
lib/scc/rmyro.c | 8++++----
lib/scc/wmyro.c | 8++++----
nm/main.c | 2+-
5 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/as/myro.c b/as/myro.c @@ -56,7 +56,7 @@ writesections(FILE *fp) sect.aligment = 0; sect.offset = off; sect.len = 0; - off += writesec(fp, &sect); + off += wrmyrosec(fp, &sect); } return off; @@ -76,7 +76,7 @@ writesymbols(FILE *fp) symbol.flags = 0; symbol.offset = off; symbol.len = 0; - off += writesym(fp, &symbol); + off += wrmyrosym(fp, &symbol); } return off; @@ -97,7 +97,7 @@ writerelocs(FILE *fp) 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 @@ writeout(char *name) 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 @@ writeout(char *name) writedata(fp); fseek(fp, 0, SEEK_SET); - writehdr(fp, &hdr); + wrmyrohdr(fp, &hdr); if (fclose(fp)) die("error writing the output file"); diff --git a/inc/myro.h b/inc/myro.h @@ -44,11 +44,11 @@ struct myrorel { 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); diff --git a/lib/scc/rmyro.c b/lib/scc/rmyro.c @@ -8,7 +8,7 @@ static char sccsid[] = "@(#) ./lib/scc/rmyro.c"; #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 @@ readhdr(FILE *fp, struct myrohdr *hdr) } int -readsec(FILE *fp, struct myrosect *sect) +rdmyrosec(FILE *fp, struct myrosect *sect) { unsigned char buf[MYROSECT_SIZ]; int len; @@ -52,7 +52,7 @@ readsec(FILE *fp, struct myrosect *sect) } int -readsym(FILE *fp, struct myrosym *sym) +rdmyrosym(FILE *fp, struct myrosym *sym) { unsigned char buf[MYROSYM_SIZ]; int len; @@ -73,7 +73,7 @@ readsym(FILE *fp, struct myrosym *sym) } int -readrel(FILE *fp, struct myrorel *rel) +rdmyrorel(FILE *fp, struct myrorel *rel) { unsigned char buf[MYROREL_SIZ]; int len; diff --git a/lib/scc/wmyro.c b/lib/scc/wmyro.c @@ -8,7 +8,7 @@ static char sccsid[] = "@(#) ./lib/scc/wmyro.c"; #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 @@ writehdr(FILE *fp, struct myrohdr *hdr) } int -writesec(FILE *fp, struct myrosect *sect) +wrmyrosec(FILE *fp, struct myrosect *sect) { unsigned char buf[MYROSECT_SIZ]; int len; @@ -48,7 +48,7 @@ writesec(FILE *fp, struct myrosect *sect) } int -writesym(FILE *fp, struct myrosym *sym) +wrmyrosym(FILE *fp, struct myrosym *sym) { unsigned char buf[MYROSYM_SIZ]; int len; @@ -67,7 +67,7 @@ writesym(FILE *fp, struct myrosym *sym) } int -writerel(FILE *fp, struct myrorel *rel) +wrmyrorel(FILE *fp, struct myrorel *rel) { unsigned char buf[MYROREL_SIZ]; int len; diff --git a/nm/main.c b/nm/main.c @@ -50,7 +50,7 @@ nm(char *fname, char *member, FILE *fp) 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;