in favor of the lib9 compatibility layer. no need for two.
now that mycreate is gone, .6 files are 0644 not 0755.
TBR=r
OCL=26679
CL=26679
c = 0;
nout = 0;
for(;;) {
+ Waitmsg *w;
+
while(nout < nproc && argc > 0) {
- i = myfork();
+ i = fork();
if(i < 0) {
- i = mywait(&status);
- if(i < 0)
- errorexit();
- if(status)
- c++;
- nout--;
- continue;
+ fprint(2, "fork: %r\n");
+ errorexit();
}
if(i == 0) {
print("%s:\n", *argv);
argc--;
argv++;
}
- i = mywait(&status);
- if(i < 0) {
+ w = wait();
+ if(w == nil) {
if(c)
errorexit();
exits(0);
}
- if(status)
+ if(w->msg[0])
c++;
nout--;
}
}
}
- of = mycreat(outfile, 0664);
+ of = create(outfile, OWRITE, 0664);
if(of < 0) {
yyerror("%ca: cannot create %s", thechar, outfile);
errorexit();
#include "y.tab.h"
#include <ctype.h>
+enum
+{
+ Plan9 = 1<<0,
+ Unix = 1<<1,
+ Windows = 1<<2,
+};
+
+int
+systemtype(int sys)
+{
+ return sys&Plan9;
+}
+
+int
+pathchar(void)
+{
+ return '/';
+}
+
void
main(int argc, char *argv[])
{
char *p;
- int nout, nproc, status, i, c;
+ int nout, nproc, i, c;
thechar = '6';
thestring = "amd64";
c = 0;
nout = 0;
for(;;) {
+ Waitmsg *w;
+
while(nout < nproc && argc > 0) {
- i = myfork();
+ i = fork();
if(i < 0) {
- i = mywait(&status);
- if(i < 0)
- errorexit();
- if(status)
- c++;
- nout--;
- continue;
+ fprint(2, "fork: %r\n");
+ errorexit();
}
if(i == 0) {
print("%s:\n", *argv);
argc--;
argv++;
}
- i = mywait(&status);
- if(i < 0) {
+ w = wait();
+ if(w == nil) {
if(c)
errorexit();
exits(0);
}
- if(status)
+ if(w->msg[0])
c++;
nout--;
}
}
}
- of = mycreate(outfile, 0664);
+ of = create(outfile, OWRITE, 0664);
if(of < 0) {
yyerror("%ca: cannot create %s", thechar, outfile);
errorexit();
}
pathname = allocn(pathname, 0, 100);
- if(mygetwd(pathname, 99) == 0) {
+ if(getwd(pathname, 99) == 0) {
pathname = allocn(pathname, 100, 900);
- if(mygetwd(pathname, 999) == 0)
+ if(getwd(pathname, 999) == 0)
strcpy(pathname, "/???");
}
}
case 6:
debug['8'] = 1; /* 64-bit addresses */
v = HEADR+textsize;
- myseek(cout, v);
+ seek(cout, v, 0);
v = rnd(v, 4096) - v;
while(v > 0) {
cput(0);
strtabsize = linuxstrtable();
cflush();
v = rnd(HEADR+textsize, INITRND);
- myseek(cout, v);
+ seek(cout, v, 0);
break;
}
c = 0;
nout = 0;
for(;;) {
+ Waitmsg *w;
+
while(nout < nproc && argc > 0) {
- i = myfork();
+ i = fork();
if(i < 0) {
- i = mywait(&status);
- if(i < 0)
- errorexit();
- if(status)
- c++;
- nout--;
- continue;
+ fprint(2, "fork: %r\n");
+ errorexit();
}
if(i == 0) {
print("%s:\n", *argv);
argc--;
argv++;
}
- i = mywait(&status);
- if(i < 0) {
+ w = wait();
+ if(w == nil) {
if(c)
errorexit();
exits(0);
}
- if(status)
+ if(w->msg[0])
c++;
nout--;
}
}
}
- of = mycreate(outfile, 0664);
+ of = create(outfile, OWRITE, 0664);
if(of < 0) {
yyerror("%ca: cannot create %s", thechar, outfile);
errorexit();
#include <libc.h>
#include <bio.h>
#include <ctype.h>
-#include "compat.h"
#pragma lib "../cc/cc.a$O"
/*
* 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(uint32);
/*
* parser
#pragma varargck type "O" int
#pragma varargck type "T" Type*
#pragma varargck type "|" int
+
+enum
+{
+ Plan9 = 1<<0,
+ Unix = 1<<1,
+ Windows = 1<<2,
+};
+int pathchar(void);
+int systemtype(int);
+void* alloc(int32 n);
+void* allocn(void*, int32, int32);
#define CPP "/bin/cpp"
#endif
+int
+systemtype(int sys)
+{
+
+ return sys&Plan9;
+}
+
+int
+pathchar(void)
+{
+ return '/';
+}
+
/*
* known debug flags
* -a acid declaration output
main(int argc, char *argv[])
{
char *defs[50], *p;
- int nproc, nout, status, i, c, ndef;
+ int nproc, nout, i, c, ndef;
memset(debug, 0, sizeof(debug));
tinit();
c = 0;
nout = 0;
for(;;) {
+ Waitmsg *w;
+
while(nout < nproc && argc > 0) {
- i = myfork();
+ i = fork();
if(i < 0) {
- i = mywait(&status);
- if(i < 0) {
- print("cannot create a process\n");
- errorexit();
- }
- if(status)
- c++;
- nout--;
- continue;
+ print("cannot create a process\n");
+ errorexit();
}
if(i == 0) {
fprint(2, "%s:\n", *argv);
argc--;
argv++;
}
- i = mywait(&status);
- if(i < 0) {
+ w = wait();
+ if(w == nil) {
if(c)
errorexit();
exits(0);
}
- if(status)
+ if(w->msg[0])
c++;
nout--;
}
dup(2, 1);
}
} else {
- c = mycreate(outfile, 0664);
+ c = create(outfile, OWRITE, 0664);
if(c < 0) {
diag(Z, "cannot open %s - %r", outfile);
outfile = 0;
diag(Z, "-p option not supported on windows");
errorexit();
}
- if(myaccess(file) < 0) {
+ if(access(file, AREAD) < 0) {
diag(Z, "%s does not exist", file);
errorexit();
}
- if(mypipe(fd) < 0) {
+ if(pipe(fd) < 0) {
diag(Z, "pipe failed");
errorexit();
}
- switch(myfork()) {
+ switch(fork()) {
case -1:
diag(Z, "fork failed");
errorexit();
case 0:
close(fd[0]);
- mydup(fd[1], 1);
+ dup(fd[1], 1);
close(fd[1]);
av[0] = CPP;
i = 1;
fprint(2, "%s ", av[c]);
fprint(2, "\n");
}
- myexec(av[0], av);
+ exec(av[0], av);
fprint(2, "can't exec C preprocessor %s: %r\n", CPP);
errorexit();
default:
dclstack = D;
pathname = allocn(pathname, 0, 100);
- if(mygetwd(pathname, 99) == 0) {
+ if(getwd(pathname, 99) == 0) {
pathname = allocn(pathname, 100, 900);
- if(mygetwd(pathname, 999) == 0)
+ if(getwd(pathname, 999) == 0)
strcpy(pathname, "/???");
}
p = e+1;
}
}
+
+void*
+alloc(int32 n)
+{
+ void *p;
+
+ p = malloc(n);
+ if(p == nil) {
+ print("alloc out of mem\n");
+ exit(1);
+ }
+ memset(p, 0, n);
+ return p;
+}
+
+void*
+allocn(void *p, int32 n, int32 d)
+{
+
+ if(p == nil)
+ return alloc(d);
+ p = realloc(p, n+d);
+ if(p == nil) {
+ print("allocn out of mem\n");
+ exit(1);
+ }
+ if(d > 0)
+ memset((char*)p+n, 0, d);
+ return p;
+}
if(strcmp(symb, "./") == 0)
symb[0] = 0;
strcat(symb, str);
- f = myopen(symb);
+ f = open(symb, OREAD);
if(f >= 0)
break;
}
/*
* subr.c
*/
-void myexit(int);
void* mal(int32);
void* remal(void*, int32, int32);
void errorexit(void);
goto usage;
pathname = mal(100);
- if(mygetwd(pathname, 99) == 0)
+ if(getwd(pathname, 99) == 0)
strcpy(pathname, "/???");
fmtinstall('O', Oconv); // node opcodes
if(nerrors)
errorexit();
- myexit(0);
+ exit(0);
return 0;
usage:
print(" -p print the assembly language\n");
print(" -w print the parse tree after typing\n");
print(" -x print lex tokens\n");
- myexit(0);
+ exit(0);
return 0;
}
{
if(outfile)
remove(outfile);
- myexit(1);
+ exit(1);
}
void
print("\n");
if(debug['h'])
*(int*)0 = 0;
- myexit(1);
+ exit(1);
}
void