cc, ?[acl]: fix gethunk() and move common memory allocator code to cc/compat
for gethunk() to work, all allocators have to use it, including allocations done by libc thru malloc(), so the fake allocation functions are mandatory for everyone. to avoid duplication the code is moved to cc/compat and prototypes provided in new cc/compat.h header.
This commit is contained in:
parent
9d46360c9d
commit
1b8a569417
72 changed files with 228 additions and 1230 deletions
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../2c/2.out.h"
|
#include "../2c/2.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Ref Ref;
|
typedef struct Ref Ref;
|
||||||
|
@ -113,14 +110,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -132,11 +127,9 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -172,28 +165,7 @@ void macend(void);
|
||||||
void dodefine(char*);
|
void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2,
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../2c/2.out.h\
|
../2c/2.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
../2c/2.out.h\
|
../2c/2.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc(0x%p %ld) called\n", p, n);
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../2c/2.out.h"
|
#include "../2c/2.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define P ((Prog*)0)
|
#define P ((Prog*)0)
|
||||||
#define S ((Sym*)0)
|
#define S ((Sym*)0)
|
||||||
|
@ -178,7 +175,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -187,7 +183,6 @@ EXTERN long lcsize;
|
||||||
EXTERN long relocsize;
|
EXTERN long relocsize;
|
||||||
EXTERN long ndata;
|
EXTERN long ndata;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN long nsymbol;
|
EXTERN long nsymbol;
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN short* op;
|
EXTERN short* op;
|
||||||
|
@ -200,7 +195,6 @@ EXTERN Sym* symlist;
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
|
|
||||||
|
@ -240,7 +234,6 @@ void errorexit(void);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
int find2(long, int);
|
int find2(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
int gnuxi(Ieee*, int, int);
|
int gnuxi(Ieee*, int, int);
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
|
@ -254,7 +247,6 @@ Sym* lookup(char*, int);
|
||||||
void lput(long);
|
void lput(long);
|
||||||
void main(int, char*[]);
|
void main(int, char*[]);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void nuxiinit(void);
|
void nuxiinit(void);
|
||||||
void objfile(char*);
|
void objfile(char*);
|
||||||
void patch(void);
|
void patch(void);
|
||||||
|
|
|
@ -14,9 +14,12 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../2c/2.out.h\
|
../2c/2.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
|
||||||
enam.$O: ../2c/enam.c
|
enam.$O: ../2c/enam.c
|
||||||
$CC $CFLAGS ../2c/enam.c
|
$CC $CFLAGS ../2c/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
|
@ -1082,28 +1082,6 @@ copyp(Prog *q)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../2c/2.out.h"
|
#include "../2c/2.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Ref Ref;
|
typedef struct Ref Ref;
|
||||||
|
@ -115,14 +112,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -134,10 +129,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -173,29 +166,7 @@ void macend(void);
|
||||||
void dodefine(char*);
|
void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../2c/2.out.h\
|
../2c/2.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
2.out.h\
|
2.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc(0x%p %ld) called\n", p, n);
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../2c/2.out.h"
|
#include "../2c/2.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define P ((Prog*)0)
|
#define P ((Prog*)0)
|
||||||
#define S ((Sym*)0)
|
#define S ((Sym*)0)
|
||||||
|
@ -168,7 +165,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -177,7 +173,6 @@ EXTERN long lcsize;
|
||||||
EXTERN long ncase;
|
EXTERN long ncase;
|
||||||
EXTERN long ndata;
|
EXTERN long ndata;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN long nsymbol;
|
EXTERN long nsymbol;
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN short* op;
|
EXTERN short* op;
|
||||||
|
@ -190,7 +185,6 @@ EXTERN Sym* symlist;
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
|
|
||||||
|
@ -238,7 +232,6 @@ void errorexit(void);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
int find2(long, int);
|
int find2(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
int gnuxi(Ieee*, int, int);
|
int gnuxi(Ieee*, int, int);
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
|
@ -250,7 +243,6 @@ Sym* lookup(char*, int);
|
||||||
void lput(long);
|
void lput(long);
|
||||||
void main(int, char*[]);
|
void main(int, char*[]);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void nuxiinit(void);
|
void nuxiinit(void);
|
||||||
void objfile(char*);
|
void objfile(char*);
|
||||||
void patch(void);
|
void patch(void);
|
||||||
|
|
|
@ -14,9 +14,12 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../2c/2.out.h\
|
../2c/2.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
|
||||||
enam.$O: ../2c/enam.c
|
enam.$O: ../2c/enam.c
|
||||||
$CC $CFLAGS ../2c/enam.c
|
$CC $CFLAGS ../2c/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
|
@ -1104,28 +1104,6 @@ appendp(Prog *q)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../5c/5.out.h"
|
#include "../5c/5.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Gen Gen;
|
typedef struct Gen Gen;
|
||||||
|
@ -96,14 +93,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -115,11 +110,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* alloc(long);
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -160,20 +152,3 @@ void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2,
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
int myfork(void);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../5c/5.out.h\
|
../5c/5.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
@ -16,4 +17,4 @@ BIN=/$objtype/bin
|
||||||
< /sys/src/cmd/mkone
|
< /sys/src/cmd/mkone
|
||||||
YFLAGS=-D1 -d
|
YFLAGS=-D1 -d
|
||||||
|
|
||||||
lex.$O: ../cc/macbody ../cc/lexbody
|
lex.$O: ../cc/macbody ../cc/lexbody ../cc/compat
|
||||||
|
|
|
@ -18,6 +18,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
5.out.h\
|
5.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc(0x%p %ld) called\n", p, n);
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../5c/5.out.h"
|
#include "../5c/5.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LIBNAMELEN 300
|
#define LIBNAMELEN 300
|
||||||
|
|
||||||
|
@ -252,7 +249,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -260,7 +256,6 @@ EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN char literal[32];
|
EXTERN char literal[32];
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN long instoffset;
|
EXTERN long instoffset;
|
||||||
EXTERN Opcross opcross[8];
|
EXTERN Opcross opcross[8];
|
||||||
EXTERN Oprang oprange[ALAST];
|
EXTERN Oprang oprange[ALAST];
|
||||||
|
@ -270,7 +265,6 @@ EXTERN uchar repop[ALAST];
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN char xcmp[C_GOK+1][C_GOK+1];
|
EXTERN char xcmp[C_GOK+1][C_GOK+1];
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
|
@ -349,7 +343,6 @@ int fileexists(char*);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
char* findlib(char*);
|
char* findlib(char*);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
long ieeedtof(Ieee*);
|
long ieeedtof(Ieee*);
|
||||||
|
@ -363,7 +356,6 @@ void cput(int);
|
||||||
void lput(long);
|
void lput(long);
|
||||||
void lputl(long);
|
void lputl(long);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void names(void);
|
void names(void);
|
||||||
void nocache(Prog*);
|
void nocache(Prog*);
|
||||||
void nuxiinit(void);
|
void nuxiinit(void);
|
||||||
|
|
|
@ -15,6 +15,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../5c/5.out.h\
|
../5c/5.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
@ -25,5 +26,7 @@ BIN=/$objtype/bin
|
||||||
enam.$O: ../5c/enam.c
|
enam.$O: ../5c/enam.c
|
||||||
$CC $CFLAGS ../5c/enam.c
|
$CC $CFLAGS ../5c/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
||||||
x:V: $O.out
|
x:V: $O.out
|
||||||
$O.out -la -o/dev/null x.5
|
$O.out -la -o/dev/null x.5
|
||||||
|
|
|
@ -1135,28 +1135,6 @@ prg(void)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../6c/6.out.h"
|
#include "../6c/6.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
|
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Ref Ref;
|
typedef struct Ref Ref;
|
||||||
|
@ -109,14 +105,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -128,10 +122,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -168,28 +160,7 @@ void macend(void);
|
||||||
void dodefine(char*);
|
void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* Posix.c/Inferno.c/Nt.c
|
|
||||||
*/
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../6c/6.out.h\
|
../6c/6.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
6.out.h\
|
6.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,55 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void*, ulong)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc called\n");
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void*, uintptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../6c/6.out.h"
|
#include "../6c/6.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define P ((Prog*)0)
|
#define P ((Prog*)0)
|
||||||
#define S ((Sym*)0)
|
#define S ((Sym*)0)
|
||||||
|
@ -279,7 +276,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN uchar inuxi1[1];
|
EXTERN uchar inuxi1[1];
|
||||||
EXTERN uchar inuxi2[2];
|
EXTERN uchar inuxi2[2];
|
||||||
EXTERN uchar inuxi4[4];
|
EXTERN uchar inuxi4[4];
|
||||||
|
@ -293,7 +289,6 @@ EXTERN int regrex[D_NONE+1];
|
||||||
EXTERN Prog* lastp;
|
EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN long nsymbol;
|
EXTERN long nsymbol;
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -303,7 +298,6 @@ EXTERN Sym* symlist;
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN vlong textsize;
|
EXTERN vlong textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
EXTERN int dtype;
|
EXTERN int dtype;
|
||||||
|
@ -358,7 +352,6 @@ int find1(long, int);
|
||||||
int find1v(vlong, int);
|
int find1v(vlong, int);
|
||||||
int find2(long, int);
|
int find2(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
long ieeedtof(Ieee*);
|
long ieeedtof(Ieee*);
|
||||||
|
@ -371,7 +364,6 @@ void lput(long);
|
||||||
void lputl(long);
|
void lputl(long);
|
||||||
void main(int, char*[]);
|
void main(int, char*[]);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void nuxiinit(void);
|
void nuxiinit(void);
|
||||||
void objfile(char*);
|
void objfile(char*);
|
||||||
int opsize(Prog*);
|
int opsize(Prog*);
|
||||||
|
|
|
@ -29,3 +29,4 @@ UPDATE=\
|
||||||
enam.$O: ../6c/enam.c
|
enam.$O: ../6c/enam.c
|
||||||
$CC $CFLAGS ../6c/enam.c
|
$CC $CFLAGS ../6c/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
|
@ -1205,28 +1205,6 @@ appendp(Prog *q)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,13 +5,10 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../7c/7.out.h"
|
#include "../7c/7.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
|
|
||||||
typedef vlong int64;
|
typedef vlong int64;
|
||||||
|
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Gen Gen;
|
typedef struct Gen Gen;
|
||||||
typedef struct Io Io;
|
typedef struct Io Io;
|
||||||
|
@ -101,14 +98,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -120,11 +115,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* alloc(long);
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -161,25 +153,7 @@ void outhist(void);
|
||||||
void dodefine(char*);
|
void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2,
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
int myfork(void);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../7c/7.out.h\
|
../7c/7.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
@ -16,4 +17,5 @@ BIN=/$objtype/bin
|
||||||
< /sys/src/cmd/mkone
|
< /sys/src/cmd/mkone
|
||||||
YFLAGS=-D1 -d
|
YFLAGS=-D1 -d
|
||||||
|
|
||||||
lex.$O: ../cc/macbody ../cc/lexbody
|
lex.$O: ../cc/macbody ../cc/lexbody ../cc/compat
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
7.out.h\
|
7.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc(0x%p %ld) called\n", p, n);
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../7c/7.out.h"
|
#include "../7c/7.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LIBNAMELEN 300
|
#define LIBNAMELEN 300
|
||||||
|
|
||||||
|
@ -291,7 +288,6 @@ EXTERN Sym* hash[NHASH];
|
||||||
EXTERN Sym* histfrog[MAXHIST];
|
EXTERN Sym* histfrog[MAXHIST];
|
||||||
EXTERN int histfrogp;
|
EXTERN int histfrogp;
|
||||||
EXTERN int histgen;
|
EXTERN int histgen;
|
||||||
EXTERN char* hunk;
|
|
||||||
|
|
||||||
EXTERN char* library[50];
|
EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
|
@ -300,7 +296,6 @@ EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN char literal[32];
|
EXTERN char literal[32];
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN vlong instoffset;
|
EXTERN vlong instoffset;
|
||||||
EXTERN Opcross opcross[8];
|
EXTERN Opcross opcross[8];
|
||||||
|
@ -310,7 +305,6 @@ EXTERN uchar repop[ALAST];
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN vlong textsize;
|
EXTERN vlong textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN char xcmp[C_NCLASS][C_NCLASS];
|
EXTERN char xcmp[C_NCLASS][C_NCLASS];
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
|
@ -378,7 +372,6 @@ vlong entryvalue(void);
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void export(void);
|
void export(void);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
void* halloc(usize);
|
void* halloc(usize);
|
||||||
int isnop(Prog*);
|
int isnop(Prog*);
|
||||||
|
@ -395,7 +388,6 @@ void lput(long);
|
||||||
void lputl(long);
|
void lputl(long);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
int movcon(vlong);
|
int movcon(vlong);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void names(void);
|
void names(void);
|
||||||
void nocache(Prog*);
|
void nocache(Prog*);
|
||||||
void nuxiinit(void);
|
void nuxiinit(void);
|
||||||
|
|
|
@ -20,6 +20,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../7c/7.out.h\
|
../7c/7.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
@ -33,5 +34,7 @@ cnam.c: l.h mkcname
|
||||||
enam.$O: ../7c/enam.c
|
enam.$O: ../7c/enam.c
|
||||||
$CC $CFLAGS ../7c/enam.c
|
$CC $CFLAGS ../7c/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
||||||
x:V: $O.out
|
x:V: $O.out
|
||||||
$O.out -la -o/dev/null x.7
|
$O.out -la -o/dev/null x.7
|
||||||
|
|
|
@ -1161,28 +1161,6 @@ halloc(usize n)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../8c/8.out.h"
|
#include "../8c/8.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Ref Ref;
|
typedef struct Ref Ref;
|
||||||
|
@ -109,14 +106,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -128,10 +123,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -168,28 +161,7 @@ void macend(void);
|
||||||
void dodefine(char*);
|
void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../8c/8.out.h\
|
../8c/8.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
8.out.h\
|
8.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void*, ulong)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc called\n");
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../8c/8.out.h"
|
#include "../8c/8.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define P ((Prog*)0)
|
#define P ((Prog*)0)
|
||||||
#define S ((Sym*)0)
|
#define S ((Sym*)0)
|
||||||
|
@ -255,7 +252,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -266,7 +262,6 @@ EXTERN char reg[D_XNONE];
|
||||||
EXTERN Prog* lastp;
|
EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN long nsymbol;
|
EXTERN long nsymbol;
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -276,7 +271,6 @@ EXTERN Sym* symlist;
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
EXTERN int dtype;
|
EXTERN int dtype;
|
||||||
|
@ -328,7 +322,6 @@ void export(void);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
int find2(long, int);
|
int find2(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
long ieeedtof(Ieee*);
|
long ieeedtof(Ieee*);
|
||||||
|
@ -341,7 +334,6 @@ void lput(long);
|
||||||
void lputl(long);
|
void lputl(long);
|
||||||
void main(int, char*[]);
|
void main(int, char*[]);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void nuxiinit(void);
|
void nuxiinit(void);
|
||||||
void objfile(char*);
|
void objfile(char*);
|
||||||
int opsize(Prog*);
|
int opsize(Prog*);
|
||||||
|
|
|
@ -13,6 +13,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
|
../cc/compat.h\
|
||||||
../8c/8.out.h\
|
../8c/8.out.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
|
@ -29,3 +30,4 @@ UPDATE=\
|
||||||
enam.$O: ../8c/enam.c
|
enam.$O: ../8c/enam.c
|
||||||
$CC $CFLAGS ../8c/enam.c
|
$CC $CFLAGS ../8c/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
|
@ -1179,28 +1179,6 @@ appendp(Prog *q)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
|
|
||||||
#pragma lib "../cc/cc.a$O"
|
#pragma lib "../cc/cc.a$O"
|
||||||
|
|
||||||
#ifndef EXTERN
|
#include "../cc/compat.h"
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Node Node;
|
typedef struct Node Node;
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
|
@ -184,13 +182,6 @@ enum
|
||||||
NALIGN,
|
NALIGN,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum /* also in ../{8a,0a}.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DMARK,
|
DMARK,
|
||||||
|
@ -437,7 +428,6 @@ EXTERN Decl* firstdcl;
|
||||||
EXTERN int fperror;
|
EXTERN int fperror;
|
||||||
EXTERN Sym* hash[NHASH];
|
EXTERN Sym* hash[NHASH];
|
||||||
EXTERN int hasdoubled;
|
EXTERN int hasdoubled;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[20];
|
EXTERN char* include[20];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
|
@ -451,7 +441,6 @@ EXTERN long lineno;
|
||||||
EXTERN long nearln;
|
EXTERN long nearln;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Node* nodproto;
|
EXTERN Node* nodproto;
|
||||||
EXTERN Node* nodcast;
|
EXTERN Node* nodcast;
|
||||||
|
@ -471,7 +460,6 @@ EXTERN Type* tufield;
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN Type* thisfn;
|
EXTERN Type* thisfn;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Type* types[NTYPE];
|
EXTERN Type* types[NTYPE];
|
||||||
EXTERN Type* fntypes[NTYPE];
|
EXTERN Type* fntypes[NTYPE];
|
||||||
EXTERN Node* initlist;
|
EXTERN Node* initlist;
|
||||||
|
@ -521,21 +509,6 @@ extern ulong thash2;
|
||||||
extern ulong thash3;
|
extern ulong thash3;
|
||||||
extern ulong thash[];
|
extern ulong thash[];
|
||||||
|
|
||||||
/*
|
|
||||||
* compat.c/unix.c/windows.c
|
|
||||||
*/
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
int myaccess(char*);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parser
|
* parser
|
||||||
*/
|
*/
|
||||||
|
@ -545,8 +518,6 @@ int mpatov(char*, vlong*);
|
||||||
/*
|
/*
|
||||||
* lex.c
|
* lex.c
|
||||||
*/
|
*/
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void* alloc(long);
|
|
||||||
void cinit(void);
|
void cinit(void);
|
||||||
int compile(char*, char**, int);
|
int compile(char*, char**, int);
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
|
@ -666,7 +637,6 @@ int castucom(Node*);
|
||||||
int deadheads(Node*);
|
int deadheads(Node*);
|
||||||
Type* dotsearch(Sym*, Type*, Node*, long*);
|
Type* dotsearch(Sym*, Type*, Node*, long*);
|
||||||
long dotoffset(Type*, Type*, Node*);
|
long dotoffset(Type*, Type*, Node*);
|
||||||
void gethunk(void);
|
|
||||||
Node* invert(Node*);
|
Node* invert(Node*);
|
||||||
int bitno(long);
|
int bitno(long);
|
||||||
void makedot(Node*, Type*, long);
|
void makedot(Node*, Type*, long);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
int
|
int
|
||||||
myaccess(char *f)
|
myaccess(char *f)
|
||||||
{
|
{
|
||||||
|
@ -77,3 +76,117 @@ myfork(void)
|
||||||
{
|
{
|
||||||
return fork();
|
return fork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* real allocs
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gethunk(void)
|
||||||
|
{
|
||||||
|
char *h;
|
||||||
|
ulong nh;
|
||||||
|
|
||||||
|
nh = NHUNK;
|
||||||
|
if(thunk >= 10L*NHUNK)
|
||||||
|
nh = 10L*NHUNK;
|
||||||
|
h = (char*)mysbrk(nh);
|
||||||
|
if(h == (char*)-1)
|
||||||
|
sysfatal("out of memory");
|
||||||
|
if(nhunk == 0)
|
||||||
|
hunk = h;
|
||||||
|
else
|
||||||
|
nh += (h - hunk) - nhunk;
|
||||||
|
nhunk += nh;
|
||||||
|
thunk += nh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
alloc(long n)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
while((uintptr)hunk & 7) {
|
||||||
|
hunk++;
|
||||||
|
nhunk--;
|
||||||
|
}
|
||||||
|
while(nhunk < n)
|
||||||
|
gethunk();
|
||||||
|
p = hunk;
|
||||||
|
nhunk -= n;
|
||||||
|
hunk += n;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
allocn(void *p, long on, long n)
|
||||||
|
{
|
||||||
|
void *q;
|
||||||
|
|
||||||
|
q = (uchar*)p + on;
|
||||||
|
if(q != hunk || nhunk < n) {
|
||||||
|
while(nhunk < on+n)
|
||||||
|
gethunk();
|
||||||
|
memmove(hunk, p, on);
|
||||||
|
p = hunk;
|
||||||
|
hunk += on;
|
||||||
|
nhunk -= on;
|
||||||
|
}
|
||||||
|
hunk += n;
|
||||||
|
nhunk -= n;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fake mallocs
|
||||||
|
*/
|
||||||
|
void*
|
||||||
|
malloc(ulong n)
|
||||||
|
{
|
||||||
|
return alloc(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
calloc(ulong m, ulong n)
|
||||||
|
{
|
||||||
|
return alloc(m*n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
realloc(void *o, ulong n)
|
||||||
|
{
|
||||||
|
ulong m;
|
||||||
|
void *a;
|
||||||
|
|
||||||
|
if(n == 0)
|
||||||
|
return nil;
|
||||||
|
if(o == nil)
|
||||||
|
return alloc(n);
|
||||||
|
a = alloc(n);
|
||||||
|
m = (char*)a - (char*)o;
|
||||||
|
if(m < n)
|
||||||
|
n = m;
|
||||||
|
memmove(a, o, n);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
free(void*)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* needed when profiling */
|
||||||
|
void*
|
||||||
|
mallocz(ulong size, int)
|
||||||
|
{
|
||||||
|
return alloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setmalloctag(void*, uintptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setrealloctag(void*, uintptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -1,62 +1,2 @@
|
||||||
#include "cc.h"
|
#include "cc.h"
|
||||||
#include "compat"
|
#include "compat"
|
||||||
|
|
||||||
/*
|
|
||||||
* fake mallocs
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
return alloc(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
return alloc(m*n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *o, ulong n)
|
|
||||||
{
|
|
||||||
ulong m;
|
|
||||||
void *a;
|
|
||||||
|
|
||||||
if(n == 0)
|
|
||||||
return nil;
|
|
||||||
if(o == nil)
|
|
||||||
return alloc(n);
|
|
||||||
a = alloc(n);
|
|
||||||
m = (char*)a - (char*)o;
|
|
||||||
if(m < n)
|
|
||||||
n = m;
|
|
||||||
memmove(a, o, n);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void*)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* needed when profiling */
|
|
||||||
void*
|
|
||||||
mallocz(ulong size, int clr)
|
|
||||||
{
|
|
||||||
void *v;
|
|
||||||
|
|
||||||
v = alloc(size);
|
|
||||||
if(clr && v != nil)
|
|
||||||
memset(v, 0, size);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void*, uintptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setrealloctag(void*, uintptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
35
sys/src/cmd/cc/compat.h
Normal file
35
sys/src/cmd/cc/compat.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* functions shared by compilers, linkers and assemblers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXTERN
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
Plan9 = 1<<0,
|
||||||
|
Unix = 1<<1,
|
||||||
|
Windows = 1<<2
|
||||||
|
};
|
||||||
|
EXTERN int systemtype(int);
|
||||||
|
EXTERN int pathchar(void);
|
||||||
|
|
||||||
|
EXTERN int myaccess(char *);
|
||||||
|
EXTERN int mywait(int*);
|
||||||
|
EXTERN int mycreat(char*, int);
|
||||||
|
EXTERN char* mygetwd(char*, int);
|
||||||
|
EXTERN int myexec(char*, char*[]);
|
||||||
|
EXTERN int mydup(int, int);
|
||||||
|
EXTERN int myfork(void);
|
||||||
|
EXTERN int mypipe(int*);
|
||||||
|
EXTERN void* mysbrk(ulong);
|
||||||
|
|
||||||
|
EXTERN void gethunk(void);
|
||||||
|
|
||||||
|
EXTERN char* hunk;
|
||||||
|
EXTERN uintptr nhunk;
|
||||||
|
EXTERN uintptr thunk;
|
||||||
|
|
||||||
|
EXTERN void* alloc(long n);
|
||||||
|
EXTERN void* allocn(void *p, long on, long n);
|
|
@ -1524,45 +1524,6 @@ VBconv(Fmt *fp)
|
||||||
return fmtstrcpy(fp, str);
|
return fmtstrcpy(fp, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* real allocs
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
alloc(long n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while((uintptr)hunk & MAXALIGN) {
|
|
||||||
hunk++;
|
|
||||||
nhunk--;
|
|
||||||
}
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
allocn(void *p, long on, long n)
|
|
||||||
{
|
|
||||||
void *q;
|
|
||||||
|
|
||||||
q = (uchar*)p + on;
|
|
||||||
if(q != hunk || nhunk < n) {
|
|
||||||
while(nhunk < on+n)
|
|
||||||
gethunk();
|
|
||||||
memmove(hunk, p, on);
|
|
||||||
p = hunk;
|
|
||||||
hunk += on;
|
|
||||||
nhunk -= on;
|
|
||||||
}
|
|
||||||
hunk += n;
|
|
||||||
nhunk -= n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setinclude(char *p)
|
setinclude(char *p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,45 +37,6 @@ pragincomplete(void)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* real allocs
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
alloc(long n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while((uintptr)hunk & MAXALIGN) {
|
|
||||||
hunk++;
|
|
||||||
nhunk--;
|
|
||||||
}
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
allocn(void *p, long on, long n)
|
|
||||||
{
|
|
||||||
void *q;
|
|
||||||
|
|
||||||
q = (uchar*)p + on;
|
|
||||||
if(q != hunk || nhunk < n) {
|
|
||||||
while(nhunk < on+n)
|
|
||||||
gethunk();
|
|
||||||
memmove(hunk, p, on);
|
|
||||||
p = hunk;
|
|
||||||
hunk += on;
|
|
||||||
nhunk -= on;
|
|
||||||
}
|
|
||||||
hunk += n;
|
|
||||||
nhunk -= n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setinclude(char *p)
|
setinclude(char *p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
#include "cc.h"
|
#include "cc.h"
|
||||||
|
|
||||||
#include "macbody"
|
#include "macbody"
|
||||||
|
|
|
@ -847,22 +847,3 @@ linehist(char *f, int offset)
|
||||||
ehist->link = h;
|
ehist->link = h;
|
||||||
ehist = h;
|
ehist = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 10L*NHUNK)
|
|
||||||
nh = 10L*NHUNK;
|
|
||||||
h = (char*)mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
yyerror("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ OFILES=\
|
||||||
omachcap.$O\
|
omachcap.$O\
|
||||||
|
|
||||||
HFILES=cc.h\
|
HFILES=cc.h\
|
||||||
|
compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
|
|
||||||
YFILES=cc.y\
|
YFILES=cc.y\
|
||||||
|
@ -36,6 +37,8 @@ $LIB: $LIBOBJ
|
||||||
|
|
||||||
mac.$O: macbody
|
mac.$O: macbody
|
||||||
|
|
||||||
|
compat.$O: compat
|
||||||
|
|
||||||
everything:V:
|
everything:V:
|
||||||
# mk the current compilers
|
# mk the current compilers
|
||||||
for(DIR in cc $CURCC){
|
for(DIR in cc $CURCC){
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../kc/k.out.h"
|
#include "../kc/k.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Gen Gen;
|
typedef struct Gen Gen;
|
||||||
|
@ -95,14 +92,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN int nosched;
|
EXTERN int nosched;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
|
@ -115,11 +110,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* alloc(long);
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -154,29 +146,7 @@ void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void outhist(void);
|
void outhist(void);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../kc/k.out.h\
|
../kc/k.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
k.out.h\
|
k.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc(0x%p %ld) called\n", p, n);
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../kc/k.out.h"
|
#include "../kc/k.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Adr Adr;
|
typedef struct Adr Adr;
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
|
@ -224,7 +221,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -232,7 +228,6 @@ EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN char literal[32];
|
EXTERN char literal[32];
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN long instoffset;
|
EXTERN long instoffset;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -241,7 +236,6 @@ EXTERN long symsize;
|
||||||
EXTERN long staticgen;
|
EXTERN long staticgen;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr tothunk;
|
|
||||||
EXTERN char xcmp[C_NCLASS][C_NCLASS];
|
EXTERN char xcmp[C_NCLASS][C_NCLASS];
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
|
@ -290,7 +284,6 @@ void errorexit(void);
|
||||||
void exchange(Prog*);
|
void exchange(Prog*);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
long ieeedtof(Ieee*);
|
long ieeedtof(Ieee*);
|
||||||
int isnop(Prog*);
|
int isnop(Prog*);
|
||||||
|
@ -301,7 +294,6 @@ void initmuldiv(void);
|
||||||
Sym* lookup(char*, int);
|
Sym* lookup(char*, int);
|
||||||
void lput(long);
|
void lput(long);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void names(void);
|
void names(void);
|
||||||
void nocache(Prog*);
|
void nocache(Prog*);
|
||||||
void noops(void);
|
void noops(void);
|
||||||
|
|
|
@ -16,9 +16,13 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../kc/k.out.h\
|
../kc/k.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
|
||||||
enam.$O: ../kc/enam.c
|
enam.$O: ../kc/enam.c
|
||||||
$CC $CFLAGS ../kc/enam.c
|
$CC $CFLAGS ../kc/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ main(int argc, char *argv[])
|
||||||
out:
|
out:
|
||||||
if(debug['v']) {
|
if(debug['v']) {
|
||||||
Bprint(&bso, "%5.2f cpu time\n", cputime());
|
Bprint(&bso, "%5.2f cpu time\n", cputime());
|
||||||
Bprint(&bso, "%zud memory used\n", tothunk);
|
Bprint(&bso, "%zud memory used\n", thunk);
|
||||||
Bprint(&bso, "%d sizeof adr\n", sizeof(Adr));
|
Bprint(&bso, "%d sizeof adr\n", sizeof(Adr));
|
||||||
Bprint(&bso, "%d sizeof prog\n", sizeof(Prog));
|
Bprint(&bso, "%d sizeof prog\n", sizeof(Prog));
|
||||||
}
|
}
|
||||||
|
@ -976,29 +976,6 @@ prg(void)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(tothunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(tothunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char *)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
tothunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../qc/q.out.h"
|
#include "../qc/q.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Gen Gen;
|
typedef struct Gen Gen;
|
||||||
|
@ -115,14 +112,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int nosched;
|
EXTERN int nosched;
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
|
@ -135,7 +130,6 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
|
@ -173,28 +167,7 @@ void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void outhist(void);
|
void outhist(void);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../qc/q.out.h\
|
../qc/q.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
q.out.h\
|
q.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void*, ulong)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc called\n");
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../qc/q.out.h"
|
#include "../qc/q.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Adr Adr;
|
typedef struct Adr Adr;
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
|
@ -216,7 +213,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -224,7 +220,6 @@ EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN char literal[32];
|
EXTERN char literal[32];
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN char* noname;
|
EXTERN char* noname;
|
||||||
EXTERN long instoffset;
|
EXTERN long instoffset;
|
||||||
EXTERN char* outfile;
|
EXTERN char* outfile;
|
||||||
|
@ -234,7 +229,6 @@ EXTERN long symsize;
|
||||||
EXTERN long staticgen;
|
EXTERN long staticgen;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr tothunk;
|
|
||||||
EXTERN char xcmp[C_NCLASS][C_NCLASS];
|
EXTERN char xcmp[C_NCLASS][C_NCLASS];
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
|
@ -289,7 +283,6 @@ void exchange(Prog*);
|
||||||
void export(void);
|
void export(void);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
long ieeedtof(Ieee*);
|
long ieeedtof(Ieee*);
|
||||||
void import(void);
|
void import(void);
|
||||||
|
@ -301,7 +294,6 @@ void initmuldiv(void);
|
||||||
Sym* lookup(char*, int);
|
Sym* lookup(char*, int);
|
||||||
void lput(long);
|
void lput(long);
|
||||||
void mkfwd(void);
|
void mkfwd(void);
|
||||||
void* mysbrk(ulong);
|
|
||||||
void names(void);
|
void names(void);
|
||||||
void nocache(Prog*);
|
void nocache(Prog*);
|
||||||
void noops(void);
|
void noops(void);
|
||||||
|
|
|
@ -18,6 +18,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../qc/q.out.h\
|
../qc/q.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
@ -26,3 +27,4 @@ enam.$O: ../qc/enam.c
|
||||||
$CC $CFLAGS ../qc/enam.c
|
$CC $CFLAGS ../qc/enam.c
|
||||||
cnam.c: l.h
|
cnam.c: l.h
|
||||||
rc mkcname
|
rc mkcname
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
|
@ -273,7 +273,7 @@ main(int argc, char *argv[])
|
||||||
out:
|
out:
|
||||||
if(debug['v']) {
|
if(debug['v']) {
|
||||||
Bprint(&bso, "%5.2f cpu time\n", cputime());
|
Bprint(&bso, "%5.2f cpu time\n", cputime());
|
||||||
Bprint(&bso, "%zud memory used\n", tothunk);
|
Bprint(&bso, "%zud memory used\n", thunk);
|
||||||
Bprint(&bso, "%d sizeof adr\n", sizeof(Adr));
|
Bprint(&bso, "%d sizeof adr\n", sizeof(Adr));
|
||||||
Bprint(&bso, "%d sizeof prog\n", sizeof(Prog));
|
Bprint(&bso, "%d sizeof prog\n", sizeof(Prog));
|
||||||
}
|
}
|
||||||
|
@ -1110,29 +1110,6 @@ prg(void)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(tothunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(tothunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char *)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
tothunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../vc/v.out.h"
|
#include "../vc/v.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
typedef struct Gen Gen;
|
typedef struct Gen Gen;
|
||||||
|
@ -94,14 +91,12 @@ EXTERN int nDlist;
|
||||||
EXTERN Hist* ehist;
|
EXTERN Hist* ehist;
|
||||||
EXTERN int newflag;
|
EXTERN int newflag;
|
||||||
EXTERN Hist* hist;
|
EXTERN Hist* hist;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char* include[NINCLUDE];
|
EXTERN char* include[NINCLUDE];
|
||||||
EXTERN Io* iofree;
|
EXTERN Io* iofree;
|
||||||
EXTERN Io* ionext;
|
EXTERN Io* ionext;
|
||||||
EXTERN Io* iostack;
|
EXTERN Io* iostack;
|
||||||
EXTERN long lineno;
|
EXTERN long lineno;
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN int nosched;
|
EXTERN int nosched;
|
||||||
EXTERN int ninclude;
|
EXTERN int ninclude;
|
||||||
EXTERN Gen nullgen;
|
EXTERN Gen nullgen;
|
||||||
|
@ -114,11 +109,8 @@ EXTERN int sym;
|
||||||
EXTERN char symb[NSYMB];
|
EXTERN char symb[NSYMB];
|
||||||
EXTERN int thechar;
|
EXTERN int thechar;
|
||||||
EXTERN char* thestring;
|
EXTERN char* thestring;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN Biobuf obuf;
|
EXTERN Biobuf obuf;
|
||||||
|
|
||||||
void* alloc(long);
|
|
||||||
void* allocn(void*, long, long);
|
|
||||||
void errorexit(void);
|
void errorexit(void);
|
||||||
void pushio(void);
|
void pushio(void);
|
||||||
void newio(void);
|
void newio(void);
|
||||||
|
@ -154,29 +146,7 @@ void outhist(void);
|
||||||
void dodefine(char*);
|
void dodefine(char*);
|
||||||
void prfile(long);
|
void prfile(long);
|
||||||
void linehist(char*, int);
|
void linehist(char*, int);
|
||||||
void gethunk(void);
|
|
||||||
void yyerror(char*, ...);
|
void yyerror(char*, ...);
|
||||||
int yyparse(void);
|
int yyparse(void);
|
||||||
void setinclude(char*);
|
void setinclude(char*);
|
||||||
int assemble(char*);
|
int assemble(char*);
|
||||||
|
|
||||||
/*
|
|
||||||
* system-dependent stuff from ../cc/compat.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum /* keep in synch with ../cc/cc.h */
|
|
||||||
{
|
|
||||||
Plan9 = 1<<0,
|
|
||||||
Unix = 1<<1,
|
|
||||||
Windows = 1<<2
|
|
||||||
};
|
|
||||||
int mywait(int*);
|
|
||||||
int mycreat(char*, int);
|
|
||||||
int systemtype(int);
|
|
||||||
int pathchar(void);
|
|
||||||
char* mygetwd(char*, int);
|
|
||||||
int myexec(char*, char*[]);
|
|
||||||
int mydup(int, int);
|
|
||||||
int myfork(void);
|
|
||||||
int mypipe(int*);
|
|
||||||
void* mysbrk(ulong);
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ OFILES=\
|
||||||
|
|
||||||
HFILES=\
|
HFILES=\
|
||||||
../vc/v.out.h\
|
../vc/v.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
y.tab.h\
|
y.tab.h\
|
||||||
a.h\
|
a.h\
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
gc.h\
|
gc.h\
|
||||||
v.out.h\
|
v.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
../cc/cc.h\
|
../cc/cc.h\
|
||||||
|
|
||||||
LIB=../cc/cc.a$O
|
LIB=../cc/cc.a$O
|
||||||
|
|
|
@ -1,56 +1,2 @@
|
||||||
#include "l.h"
|
#include "l.h"
|
||||||
|
#include "../cc/compat"
|
||||||
/*
|
|
||||||
* fake malloc
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
malloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while(n & 7)
|
|
||||||
n++;
|
|
||||||
while(nhunk < n)
|
|
||||||
gethunk();
|
|
||||||
p = hunk;
|
|
||||||
nhunk -= n;
|
|
||||||
hunk += n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
USED(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
calloc(ulong m, ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
n *= m;
|
|
||||||
p = malloc(n);
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
realloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
fprint(2, "realloc(0x%p %ld) called\n", p, n);
|
|
||||||
abort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
mysbrk(ulong size)
|
|
||||||
{
|
|
||||||
return sbrk(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setmalloctag(void *v, uintptr pc)
|
|
||||||
{
|
|
||||||
USED(v, pc);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include "../vc/v.out.h"
|
#include "../vc/v.out.h"
|
||||||
|
#include "../cc/compat.h"
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct Adr Adr;
|
typedef struct Adr Adr;
|
||||||
typedef struct Sym Sym;
|
typedef struct Sym Sym;
|
||||||
|
@ -215,7 +212,6 @@ EXTERN char* library[50];
|
||||||
EXTERN char* libraryobj[50];
|
EXTERN char* libraryobj[50];
|
||||||
EXTERN int libraryp;
|
EXTERN int libraryp;
|
||||||
EXTERN int xrefresolv;
|
EXTERN int xrefresolv;
|
||||||
EXTERN char* hunk;
|
|
||||||
EXTERN char inuxi1[1];
|
EXTERN char inuxi1[1];
|
||||||
EXTERN char inuxi2[2];
|
EXTERN char inuxi2[2];
|
||||||
EXTERN char inuxi4[4];
|
EXTERN char inuxi4[4];
|
||||||
|
@ -223,7 +219,6 @@ EXTERN Prog* lastp;
|
||||||
EXTERN long lcsize;
|
EXTERN long lcsize;
|
||||||
EXTERN char literal[32];
|
EXTERN char literal[32];
|
||||||
EXTERN int nerrors;
|
EXTERN int nerrors;
|
||||||
EXTERN long nhunk;
|
|
||||||
EXTERN long instoffset;
|
EXTERN long instoffset;
|
||||||
EXTERN Opcross opcross[10];
|
EXTERN Opcross opcross[10];
|
||||||
EXTERN Oprang oprange[ALAST];
|
EXTERN Oprang oprange[ALAST];
|
||||||
|
@ -233,7 +228,6 @@ EXTERN uchar repop[ALAST];
|
||||||
EXTERN long symsize;
|
EXTERN long symsize;
|
||||||
EXTERN Prog* textp;
|
EXTERN Prog* textp;
|
||||||
EXTERN long textsize;
|
EXTERN long textsize;
|
||||||
EXTERN uintptr thunk;
|
|
||||||
EXTERN int version;
|
EXTERN int version;
|
||||||
EXTERN char xcmp[32][32];
|
EXTERN char xcmp[32][32];
|
||||||
EXTERN Prog zprg;
|
EXTERN Prog zprg;
|
||||||
|
@ -292,7 +286,6 @@ void errorexit(void);
|
||||||
void exchange(Prog*);
|
void exchange(Prog*);
|
||||||
int find1(long, int);
|
int find1(long, int);
|
||||||
void follow(void);
|
void follow(void);
|
||||||
void gethunk(void);
|
|
||||||
void histtoauto(void);
|
void histtoauto(void);
|
||||||
double ieeedtod(Ieee*);
|
double ieeedtod(Ieee*);
|
||||||
long ieeedtof(Ieee*);
|
long ieeedtof(Ieee*);
|
||||||
|
|
|
@ -16,6 +16,7 @@ OFILES=\
|
||||||
HFILES=\
|
HFILES=\
|
||||||
l.h\
|
l.h\
|
||||||
../vc/v.out.h\
|
../vc/v.out.h\
|
||||||
|
../cc/compat.h\
|
||||||
|
|
||||||
BIN=/$objtype/bin
|
BIN=/$objtype/bin
|
||||||
</sys/src/cmd/mkone
|
</sys/src/cmd/mkone
|
||||||
|
@ -23,6 +24,8 @@ BIN=/$objtype/bin
|
||||||
enam.$O: ../vc/enam.c
|
enam.$O: ../vc/enam.c
|
||||||
$CC $CFLAGS ../vc/enam.c
|
$CC $CFLAGS ../vc/enam.c
|
||||||
|
|
||||||
|
compat.$O: ../cc/compat
|
||||||
|
|
||||||
x:V: $O.out
|
x:V: $O.out
|
||||||
$O.out -la -o/dev/null x.v
|
$O.out -la -o/dev/null x.v
|
||||||
|
|
||||||
|
|
|
@ -1058,28 +1058,6 @@ prg(void)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gethunk(void)
|
|
||||||
{
|
|
||||||
char *h;
|
|
||||||
long nh;
|
|
||||||
|
|
||||||
nh = NHUNK;
|
|
||||||
if(thunk >= 5L*NHUNK) {
|
|
||||||
nh = 5L*NHUNK;
|
|
||||||
if(thunk >= 25L*NHUNK)
|
|
||||||
nh = 25L*NHUNK;
|
|
||||||
}
|
|
||||||
h = mysbrk(nh);
|
|
||||||
if(h == (char*)-1) {
|
|
||||||
diag("out of memory");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
hunk = h;
|
|
||||||
nhunk = nh;
|
|
||||||
thunk += nh;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doprof1(void)
|
doprof1(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue