prescheme.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Marcus Crestani,
  5. * David Frese, Timo Harter
  6. */
  7. #include <errno.h>
  8. #include "io.h"
  9. #include "scheme48arch.h"
  10. #ifdef __GNUC__
  11. // This requires the "labels as values" extension of GCC
  12. #define USE_DIRECT_THREADING
  13. #endif
  14. #if SIZEOF_VOID_P == 4
  15. #define BITS_PER_CELL 32
  16. #elif SIZEOF_VOID_P == 8
  17. #define BITS_PER_CELL 64
  18. #else
  19. #error "What size are your pointers, really?"
  20. #endif
  21. #define PS_READ_CHAR(PORT,RESULT,EOFP,STATUS) \
  22. { \
  23. FILE * TTport = PORT; \
  24. int TTchar; \
  25. if (EOF == (TTchar = getc(TTport))) \
  26. RESULT = ps_read_char(TTport, &EOFP, &STATUS, 0==1);\
  27. else { \
  28. RESULT = TTchar; \
  29. EOFP = 0; \
  30. STATUS = 0; } \
  31. }
  32. #define PS_PEEK_CHAR(PORT,RESULT,EOFP,STATUS) \
  33. { \
  34. FILE * TTport = PORT; \
  35. int TTchar; \
  36. if (EOF == (TTchar = getc(TTport))) \
  37. RESULT = ps_read_char(TTport, &EOFP, &STATUS, 0==0);\
  38. else { \
  39. RESULT = TTchar; \
  40. ungetc(RESULT, TTport); \
  41. EOFP = 0; \
  42. STATUS = 0; } \
  43. }
  44. #define PS_READ_INTEGER(PORT,RESULT,EOFP,STATUS) \
  45. RESULT = ps_read_integer(PORT,&EOFP,&STATUS);
  46. #define PS_WRITE_CHAR(CHAR,PORT,STATUS) \
  47. { \
  48. FILE * TTport = PORT; \
  49. char TTchar = CHAR; \
  50. if (EOF == putc(TTchar,TTport)) \
  51. STATUS = ps_write_char(TTchar,TTport); \
  52. else { \
  53. STATUS = 0; } \
  54. }
  55. /* C shifts may not work if the amount is greater than the machine word size */
  56. /* Patched by JAR 6/6/93 */
  57. #define PS_SHIFT_RIGHT(X,Y,RESULT) \
  58. { \
  59. long TTx = X, TTy = Y; \
  60. RESULT = TTy >= BITS_PER_CELL ? (TTx < 0 ? -1 : 0) : TTx >> TTy; \
  61. }
  62. #define PS_SHIFT_LEFT(X,Y,RESULT) \
  63. { \
  64. long TTy = Y; \
  65. RESULT = TTy >= BITS_PER_CELL ? 0 : X << TTy; \
  66. }
  67. #define PS_SHIFT_RIGHT_LOGICAL(X,Y,RESULT) \
  68. { \
  69. RESULT = ((unsigned long) X) >> Y; \
  70. }
  71. extern double ps_pos_infinity(void), ps_neg_infinity(void), ps_not_a_number(void);
  72. #define PS_POS_INF ps_pos_infinity()
  73. #define PS_NEG_INF ps_neg_infinity()
  74. #define PS_NAN ps_not_a_number()
  75. extern long s48_return_value, s48_run_machine();