ocrt.c 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* $Id$ */
  2. /* ocrt.c - Occam runtime support */
  3. #include "ocm_chan.h"
  4. int chandes[]= { 0, 0, sizeof(int)+sizeof(long) };
  5. int worddes[]= { 0, 0, sizeof(long) };
  6. int bytedes[]= { 0, 0, 1 };
  7. long any;
  8. void catch(sig, file, line) int sig; char *file; int line;
  9. /* Catches traps in the occam program */
  10. {
  11. register char *mes;
  12. switch (sig) {
  13. case 0:
  14. mes="array bound error";
  15. break;
  16. case 6:
  17. mes="division by zero";
  18. break;
  19. case 8:
  20. mes="undefined variable";
  21. break;
  22. default:
  23. return;
  24. }
  25. fprintf(stderr, "%s (%d) F: %s\n", file, line, mes);
  26. abort();
  27. }
  28. chan file[20];
  29. FILE *unix_file[20];
  30. void initfile()
  31. {
  32. register i;
  33. register chan *c=file;
  34. for (i=0; i<20; i++) {
  35. c->type=C_T_FILE;
  36. c->f.flgs=0;
  37. (c++)->f.index=i;
  38. }
  39. file[0].f.flgs|=C_F_INUSE;
  40. unix_file[0]=stdin;
  41. file[1].f.flgs|=C_F_INUSE;
  42. unix_file[1]=stdout;
  43. file[2].f.flgs|=C_F_INUSE;
  44. unix_file[2]=stderr;
  45. }