Next batch of changes!

This commit is contained in:
Godzil 2013-03-20 01:58:06 +01:00 committed by Manoël Trapier
parent a05a174f40
commit 1c4e04de3a
29 changed files with 129 additions and 78 deletions

View File

@ -51,5 +51,6 @@ _PROTOTYPE(unsigned int rd_unsigned2, (int fd));
_PROTOTYPE(long rd_long, (int fd));
_PROTOTYPE(void rd_bytes, (int fd, char *buf, long l));
_PROTOTYPE(int rd_fd, (void));
_PROTOTYPE(void rd_rew_relos, (struct outhead *head));
#endif /* __OBJECT_INCLUDED__ */

View File

@ -22,6 +22,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>

View File

@ -15,9 +15,15 @@
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "out.h"
#include "arch.h"
#include "ranlib.h"
#include "object.h"
int numsort_flg;
int sectsort_flg;
@ -98,8 +104,6 @@ int main(int argc, char *argv[])
exit(0);
}
int rd_unsigned2(int fd);
void process(int fd)
{
unsigned int magic;

View File

@ -1,4 +1,3 @@
static char rcsid[] = "$Id$";
/*
* show - make the contents of an ACK object file human readable.
*/
@ -9,6 +8,7 @@ static char rcsid[] = "$Id$";
#include <sys/types.h>
#include <sys/stat.h>
#include <out.h>
#include "object.h"
#define OK 0 /* Return value of gethead if Orl Korekt. */
#define BMASK 0xFF /* To extract least significant 8 bits from an int. */

View File

@ -7,7 +7,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "out.h"
#include "object.h"
/*
asize -- determine object size

View File

@ -21,6 +21,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
#include "out.h"

View File

@ -6,9 +6,13 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include "out.h"
#include "object.h"
/*
astrip -- remove symbols and relocation bits
@ -17,12 +21,13 @@
char temp_name[] = "/tmp/sXXXXXX";
char *tname;
char *mktemp();
FILE *fopen();
FILE *tf;
struct outhead buf;
int readerror, writeerror;
int strip(char *name);
int copy(char *fnam, char *tnam, long size, int fr, int fw);
int main(int argc, char *argv[])
{
int status;
@ -113,7 +118,7 @@ int strip(char *name)
int copy(char *fnam, char *tnam, long size, int fr, int fw)
{
int s, n;
int s/*, n*/;
char lbuf[512];
while(size != (long)0) {

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "arch.h"
@ -15,6 +11,7 @@ static char rcsid[] = "$Id$";
#include "debug.h"
#include "memory.h"
#include "defs.h"
#include "object.h"
#define ENDLIB ((long)0)

13
util/led/archive.h Normal file
View File

@ -0,0 +1,13 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_LED_ARCHIVE_H
#define UTIL_LED_ARCHIVE_H
/* util/led/archive.c */
void arch(void);
void arch2(void);
#endif /* UTIL_LED_ARCHIVE_H */

View File

@ -2,16 +2,15 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <out.h>
#include "const.h"
static short nerrors = 0;
static void diag(char *, char *, va_list);

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "arch.h"

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <out.h>
#include "const.h"
#include "arch.h"
@ -13,6 +9,7 @@ static char rcsid[] = "$Id$";
#include "defs.h"
#include "orig.h"
#include "scan.h"
#include "object.h"
extern bool incore;
extern unsigned short NLocals;
@ -22,8 +19,9 @@ static void adjust_names(struct outname *name, struct outhead *head, char *chars
static void handle_relos(struct outhead *head, struct outsect *sects, struct outname *names);
static void put_locals(struct outname *name, unsigned int nnames);
static void compute_origins(struct outsect *sect, unsigned int nsect);
static put_dbug(long offdbug);
#ifdef SYMDBUG
static void put_dbug(long offdbug);
#endif
/*
* We know all there is to know about the current module.
* Now we relocate the values in the emitted bytes and write
@ -235,7 +233,7 @@ static void compute_origins(struct outsect *sect, unsigned int nsect)
* Write out what is after the string area. This is likely to be
* debugging information.
*/
static put_dbug(long offdbug)
static void put_dbug(long offdbug)
{
char buf[512];
int nbytes;

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
/*
* led - linkage editor for ACK assemblers output format
*/

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
/*
* Memory manager. Memory is divided into NMEMS pieces. There is a struct
* for each piece telling where it is, how many bytes are used, and how may
@ -22,6 +18,7 @@ static char rcsid[] = "$Id$";
*/
#include <stdio.h>
#include <unistd.h>
#include <out.h>
#include "const.h"
#include "assert.h"
@ -29,6 +26,9 @@ static char rcsid[] = "$Id$";
#include "arch.h"
#include "memory.h"
#include "defs.h"
#include "object.h"
#include <missing_proto.h>
static ind_t move_up(int piece, ind_t incr);
static bool compact(int piece, ind_t incr, int flag);
@ -56,7 +56,7 @@ int sbreak(ind_t incr)
if ((refused && refused < incr) ||
(sizeof(char *) < sizeof(long) &&
(inc != incr || BASE + inc < BASE)) ||
brk(BASE + incr) == -1) {
brk(BASE + incr) == (void *)-1) {
if (!refused || refused > incr)
refused = incr;
return -1;
@ -74,17 +74,16 @@ void init_core()
char *base;
ind_t total_size;
struct memory *mem;
extern char *sbrk();
#include "mach.c"
#define ALIGN 8 /* minimum alignment for pieces */
#define AT_LEAST (ind_t)2*ALIGN /* See comment about string areas. */
total_size = (ind_t)0; /* Will accumulate the sizes. */
BASE = base = sbrk(0); /* First free. */
BASE = base = (char *)sbrk(0); /* First free. */
if ((int)base % ALIGN) {
base = sbrk(ALIGN - (int)base % ALIGN);
BASE = base = sbrk(0);
base = (char *)sbrk(ALIGN - (int)base % ALIGN);
BASE = base = (char *)sbrk(0);
}
/*
* String areas are special-cased. The first byte is unused as a way to
@ -537,7 +536,7 @@ void write_bytes()
extern int flagword;
extern struct outhead outhead;
extern struct outsect outsect[];
extern char *outputname;
/* extern char *outputname; */
int sectionno = 0;
nsect = outhead.oh_nsect;

View File

@ -2,13 +2,11 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <out.h>
#include "const.h"
#include "memory.h"
#include "object.h"
#include "defs.h"
static void generate_section_names();

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdio.h>
#include <out.h>
#include "const.h"

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "out.h"

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
/*
* If everything is kept in core, we must save some things for the second pass.
*/

View File

@ -2,17 +2,13 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef SYMDBUG
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif /* SYMDBUG */
#include "arch.h"
#include "out.h"
#include "ranlib.h"
@ -22,6 +18,7 @@ static char rcsid[] = "$Id$";
#include "scan.h"
#include "debug.h"
#include "defs.h"
#include "object.h"
#define READ 0

View File

@ -2,10 +2,6 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
/*
* Symbol table management.
*/

View File

@ -2,19 +2,21 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "out.h"
#include "const.h"
#include "assert.h"
#include "memory.h"
#include "arch.h"
#include "defs.h"
#include "object.h"
extern struct outhead outhead;
extern struct outsect outsect[];
extern int flagword;

View File

@ -13,6 +13,7 @@
# include "tunable.h"
# include "token.h"
# include "Lpars.h"
# include "main.h"
struct token dot; /* current token */
static struct token aside; /* to put currrent token aside, when a token

View File

@ -14,6 +14,8 @@
#include <string.h>
#include "misc.h"
struct hlist { /* linear list of pattern numbers */
int h_patno;
struct hlist *h_next;
@ -76,7 +78,7 @@ void printhashtable()
* pointers to them
*/
int i;
struct hlist *p;
/*struct hlist *p;*/
for (i = 1; i <= 128; i++) {
fprintf(genc,"int hash%d[] = { ",i);

13
util/topgen/hash.h Normal file
View File

@ -0,0 +1,13 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_TOPGEN_HASH_H
#define UTIL_TOPGEN_HASH_H
/* util/topgen/hash.c */
void addtohashtable(char *s, int n);
void printhashtable(void);
#endif /* UTIL_TOPGEN_HASH_H */

View File

@ -11,6 +11,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
extern int lineno, newline;
@ -19,6 +20,9 @@ static int nerrors;
char *linedir = "#line %d \"%s\"\n"; /* format of line directive */
char *inpfile;
/* From Lexer */
void LLparse(void);
int main(int argc, char *argv[])
{
newline = 1;
@ -44,11 +48,14 @@ int main(int argc, char *argv[])
}
/* VARARGS1 */
void error(char *s, char *s1)
void error(char *s, ...)
{
va_list va;
nerrors++;
fprintf(stderr,"\"%s\", line %d: ",inpfile,lineno);
fprintf(stderr,s,s1);
va_start(va, s);
vfprintf(stderr, s, va);
va_end(va);
putc('\n',stderr);
}

14
util/topgen/main.h Normal file
View File

@ -0,0 +1,14 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_TOPGEN_MAIN_H
#define UTIL_TOPGEN_MAIN_H
/* util/topgen/main.c */
int main(int argc, char *argv[]);
void error(char *s, ...);
int onlyspace(char *s);
#endif /* UTIL_TOPGEN_MAIN_H */

13
util/topgen/pattern.h Normal file
View File

@ -0,0 +1,13 @@
/*
* The Amsterdam Compiler Kit
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef UTIL_TOPGEN_PATTERN_H
#define UTIL_TOPGEN_PATTERN_H
/* util/topgen/pattern.c */
void addpattern(char *str, int l, int np, int nr);
void printpatterns(void);
#endif /* UTIL_TOPGEN_PATTERN_H */

View File

@ -12,19 +12,20 @@
#include <stdlib.h>
#include <string.h>
#include "symtab.h"
#include "main.h"
struct symtab *idtable, *deftable;
struct symtab *
findident(s, mode, table) char *s; struct symtab **table; {
struct symtab *findident(char *s, int mode, struct symtab **table)
{
/*
* Look for identifier s in the symboltable referred to by *table.
* If mode = LOOKING, no new entry's will be made.
* If mode = ENTERING, a new entry will be made if s is not in the
* table yet, otherwise an error results
*/
register struct symtab *p;
register n;
struct symtab *p;
int n;
if (!*table) { /* No entry for this symbol */
if (mode == LOOKING) return (struct symtab *) 0;

View File

@ -21,6 +21,9 @@
#include "token.h"
#include "symtab.h"
#include "misc.h"
#include "main.h"
#include "pattern.h"
#include "hash.h"
char idbuf[BUFSIZ], buf[BUFSIZ];
int countid; /* # of variables */