prescheme.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <errno.h>
  2. #include "io.h"
  3. #define PS_READ_CHAR(PORT,RESULT,EOFP,STATUS) \
  4. { \
  5. FILE * TTport = PORT; \
  6. int TTchar; \
  7. if (EOF == (TTchar = getc(TTport))) \
  8. RESULT = ps_read_char(TTport, &EOFP, &STATUS, 0==1);\
  9. else { \
  10. RESULT = TTchar; \
  11. EOFP = 0; \
  12. STATUS = 0; } \
  13. }
  14. #define PS_PEEK_CHAR(PORT,RESULT,EOFP,STATUS) \
  15. { \
  16. FILE * TTport = PORT; \
  17. int TTchar; \
  18. if (EOF == (TTchar = getc(TTport))) \
  19. RESULT = ps_read_char(TTport, &EOFP, &STATUS, 0==0);\
  20. else { \
  21. RESULT = TTchar; \
  22. ungetc(RESULT, TTport); \
  23. EOFP = 0; \
  24. STATUS = 0; } \
  25. }
  26. #define PS_READ_INTEGER(PORT,RESULT,EOFP,STATUS) \
  27. RESULT = ps_read_integer(PORT,&EOFP,&STATUS);
  28. #define PS_WRITE_CHAR(CHAR,PORT,STATUS) \
  29. { \
  30. FILE * TTport = PORT; \
  31. char TTchar = CHAR; \
  32. if (EOF == putc(TTchar,TTport)) \
  33. STATUS = ps_write_char(TTchar,TTport); \
  34. else { \
  35. STATUS = 0; } \
  36. }
  37. /* C shifts may not work if the amount is greater than the machine word size */
  38. /* Patched by JAR 6/6/93 */
  39. #define PS_SHIFT_RIGHT(X,Y,RESULT) \
  40. { \
  41. long TTx = X, TTy = Y; \
  42. RESULT = TTy >= 32 ? (TTx < 0 ? -1 : 0) : TTx >> TTy; \
  43. }
  44. #define PS_SHIFT_LEFT(X,Y,RESULT) \
  45. { \
  46. long TTy = Y; \
  47. RESULT = TTy >= 32 ? 0 : X << TTy; \
  48. }
  49. extern long s48_return_value, s48_run_machine();