my version (CJ)

This commit is contained in:
ceriel 1987-02-25 16:41:09 +00:00
parent 59fd6b0334
commit 362378a94a
10 changed files with 143 additions and 13 deletions

11
lang/occam/lib/LIST Normal file
View file

@ -0,0 +1,11 @@
tail_ocm.a
builtin.c
chan_struct.c
channel.c
co.c
now.c
par.c
parco.c
misc.e
ocrt.c
par_misc.e

View file

@ -1,5 +1,5 @@
/* builtin.c - built in named processes */ /* builtin.c - built in named processes */
#include "channel.h" #include "ocm_chan.h"
#ifndef nil #ifndef nil
#define nil 0 #define nil 0
#endif #endif

View file

@ -2,7 +2,7 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <sgtty.h> #include <sgtty.h>
#include "channel.h" #include "ocm_chan.h"
static void disaster(); static void disaster();
@ -53,16 +53,16 @@ void chan_out(v, c) long v; register chan *c;
putc( (int) v, fp); putc( (int) v, fp);
else else
if (v==C_F_TEXT) { if (v==C_F_TEXT) {
ioctl(fileno(fp), TIOCGETP, &tty); gtty(fileno(fp), &tty);
tty.sg_flags&= ~CBREAK; tty.sg_flags&= ~CBREAK;
tty.sg_flags|= ECHO|CRMOD; tty.sg_flags|= ECHO|CRMOD;
ioctl(fileno(fp), TIOCSETN, &tty); stty(fileno(fp), &tty);
} else } else
if (v==C_F_RAW) { if (v==C_F_RAW) {
ioctl(fileno(fp), TIOCGETP, &tty); gtty(fileno(fp), &tty);
tty.sg_flags|= CBREAK; tty.sg_flags|= CBREAK;
tty.sg_flags&= ~(ECHO|CRMOD); tty.sg_flags&= ~(ECHO|CRMOD);
ioctl(fileno(fp), TIOCSETN, &tty); stty(fileno(fp), &tty);
} }
} break; } break;
case C_T_CHAN: case C_T_CHAN:

View file

@ -1,5 +1,5 @@
/* co.c - Routines to handle coroutines */ /* co.c - Routines to handle coroutines */
#include "process.h" #include "ocm_proc.h"
static void search(), RESUMERR(); static void search(), RESUMERR();

49
lang/occam/lib/misc.e Normal file
View file

@ -0,0 +1,49 @@
#
mes 2,EM_WSIZE,EM_PSIZE
oldtrp
bss EM_PSIZE, 0, 0
exp $init
pro $init, 0
loc -321-1
sim
lpi $catch1
sig
lae oldtrp
sti EM_PSIZE
cal $initfile
ret 0
end 0
pro $catch1, 0
lae oldtrp
loi EM_PSIZE
sig
asp EM_PSIZE
loe 0
lae 4
loi EM_PSIZE
lol 0
cal $catch
asp 2*EM_WSIZE+EM_PSIZE
lol 0
trp
rtt
end 0
exp $block_move
pro $block_move, 0
lal 4
loi EM_PSIZE
lal 8
loi EM_PSIZE
lal 0
loi EM_LSIZE
loc EM_LSIZE
loc EM_WSIZE
cuu
bls EM_WSIZE
ret 0
end 0

8
lang/occam/lib/now.c Normal file
View file

@ -0,0 +1,8 @@
long now()
{
extern int deadlock;
long time();
deadlock = 0;
return time((long *) 0);
}

View file

@ -1,5 +1,5 @@
/* ocrt.c - Occam runtime support */ /* ocrt.c - Occam runtime support */
#include "channel.h" #include "ocm_chan.h"
int chandes[]= { 0, 0, sizeof(int)+sizeof(long) }; int chandes[]= { 0, 0, sizeof(int)+sizeof(long) };
int worddes[]= { 0, 0, sizeof(long) }; int worddes[]= { 0, 0, sizeof(long) };
@ -28,15 +28,15 @@ void catch(sig, file, line) int sig; char *file; int line;
abort(); abort();
} }
chan file[_NFILE]; chan file[20];
FILE *unix_file[_NFILE]; FILE *unix_file[20];
void initfile() void initfile()
{ {
register i; register i;
register chan *c=file; register chan *c=file;
for (i=0; i<_NFILE; i++) { for (i=0; i<20; i++) {
c->type=C_T_FILE; c->type=C_T_FILE;
c->f.flgs=0; c->f.flgs=0;
(c++)->f.index=i; (c++)->f.index=i;

View file

@ -1,5 +1,5 @@
/* par.c - Routines to simulate parallelism */ /* par.c - Routines to simulate parallelism */
#include "process.h" #include "ocm_proc.h"
static void search_next(), DEADLOCK(); static void search_next(), DEADLOCK();

62
lang/occam/lib/par_misc.e Normal file
View file

@ -0,0 +1,62 @@
#
mes 2,EM_WSIZE,EM_PSIZE
exp $top_size
pro $top_size, 3*EM_WSIZE+3*EM_PSIZE
mes 11
lal 0
loi EM_PSIZE ; s_brk
lor 1 ; s_brk SP
sbs EM_PSIZE ; s_brk-SP
ret EM_PSIZE ; return size of block to be saved
end 3*EM_WSIZE+3*EM_PSIZE
exp $top_save
pro $top_save, 0
loe 0
lae 4 ; load line number and file name
loi EM_PSIZE
lim ; ignore mask
lor 0 ; LB
lal 0
loi EM_PSIZE ; size of block
loc EM_PSIZE
loc EM_WSIZE
cuu
dup EM_WSIZE
stl 0 ; push & store size in 2 bytes
lor 1 ; SP (the SP BEFORE pushing)
lor 1 ; SP (address of stack top to save)
lal EM_PSIZE ; area
loi EM_PSIZE
lol 0 ; size
bls EM_WSIZE ; move whole block
asp 3*EM_PSIZE+3*EM_WSIZE ; remove the lot from the stack
loc 1
ret EM_WSIZE ; return 1
end 0
exp $top_load
pro $top_load, 0
lal 0
loi EM_PSIZE
dup EM_PSIZE
loi EM_PSIZE
sti EM_PSIZE ; copy pointer from argument 0 to new frame
loi EM_PSIZE ; load indirect to
str 1 ; restore SP
dup EM_PSIZE ; givesargument 0 again
lor 1 ; SP (the SP AFTER, see above)
lor 1
adp EM_PSIZE
loi EM_PSIZE
lof EM_PSIZE ; size of block
bls EM_WSIZE ; move block back (SP becomes the SP BEFORE again!)
asp EM_WSIZE ; drop size
str 0 ; LB
sim ; ignore mask
lae EM_PSIZE
sti EM_PSIZE
ste 0 ; line and file
loc 0
ret EM_WSIZE ; return 0
end 0

View file

@ -1,7 +1,7 @@
/* parco.c - Common routines for simulating parallelism or coroutines on /* parco.c - Common routines for simulating parallelism or coroutines on
* machines with downward growing stacks * machines with downward growing stacks
*/ */
#include "process.h" #include "ocm_proc.h"
struct procgroup *group=nil, *highest_group; struct procgroup *group=nil, *highest_group;