home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sa104os2.zip / SATHR104.ZIP / SATHER / SYSTEM / HEADER.H < prev    next >
Text File  |  1995-01-31  |  4KB  |  125 lines

  1. /*
  2. * Copyright (C) International Computer Science Institute, 1994.  COPYRIGHT 
  3. * NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject
  4. * to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in   
  5. * the file "Doc/License" of the Sather distribution.  The license is also  
  6. * available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA.
  7. * -----> Please email comments to "sather-bugs@icsi.berkeley.edu". <-----
  8. */
  9.  
  10. /* This file is included at the head of the compiler-generated header file. */
  11.  
  12. #include <stdio.h>
  13. #include <math.h>
  14. #include <string.h>
  15. #include <setjmp.h>
  16. #include <signal.h>
  17. #include <limits.h>
  18. #include <stdlib.h>                                   /* -- NLP */
  19. #include <direct.h>                                   /* -- NLP */
  20. #include <process.h>                                  /* -- NLP */
  21.  
  22. /* Determine the machine type: */
  23. # if defined(sun) && defined(sparc)
  24. #   define SPARC
  25.     /* Test for SunOS 5.x */
  26. #     include <errno.h>
  27. #     ifdef ECHRNG
  28. #       define SUNOS5
  29. #     else
  30. #       define SUNOS4
  31. #     endif
  32. # endif
  33. # if defined(NeXT) && defined(mc68000)
  34. #   define M68K
  35. #   define NEXT
  36. # endif
  37. # if defined(vax)
  38. #    define VAX
  39. #    ifdef ultrix
  40. #       define ULTRIX
  41. #    else
  42. #       define BSD
  43. #    endif
  44. # endif
  45.  
  46. /* ALLOCATE(x) returns a zeroed memory region of size and type x.
  47.  * The Boehm GC_malloc, unlike regular malloc, zeros memory.
  48.  * The compiler emits typedefs such that "x_struct" is the name
  49.  * of the struct type that *x refers to.
  50. */
  51.  
  52. #define ALLOCATE(x) ((x) GC_malloc(sizeof(struct x##_struct)))
  53.  
  54. /* These may be defined as appropriate to the target system */
  55.  
  56. typedef char BOOL;
  57. #define FALSE 0
  58. #define TRUE 1
  59.  
  60. #ifdef ALPHA
  61.     typedef int INT;
  62.     #define SINT_MAX INT_MAX
  63.     #define SINT_MIN INT_MIN
  64. #else
  65.     typedef long INT;
  66.     #define SINT_MAX LONG_MAX
  67.     #define SINT_MIN LONG_MIN
  68. #endif
  69. typedef char CHAR;
  70. typedef float FLT;
  71. typedef double FLTD;
  72. typedef double FLTX;  /* This is a hack */
  73. typedef double FLTDX; /* This is a hack */
  74. typedef void* EXT_OB;
  75.  
  76. /* Little boxes made of ticky-tacky */
  77.  
  78. typedef struct BOOL_boxed_struct { INT tag; BOOL value_part; } *BOOL_boxed;
  79. typedef struct CHAR_boxed_struct { INT tag; CHAR value_part; } *CHAR_boxed;
  80. typedef struct INT_boxed_struct { INT tag; INT value_part; } *INT_boxed;
  81. typedef struct FLT_boxed_struct { INT tag; FLT value_part; } *FLT_boxed;
  82. typedef struct FLTD_boxed_struct { INT tag; FLTD value_part; } *FLTD_boxed;
  83. typedef struct FLTX_boxed_struct { INT tag; FLTX value_part; } *FLTX_boxed;
  84. typedef struct FLTDX_boxed_struct { INT tag; FLTDX value_part; } *FLTDX_boxed;
  85.  
  86. /* Layouts for the Sather classes which are built-in */
  87.  
  88. #ifdef DETERMINISTIC
  89.     typedef struct { INT tag; INT id; } OB_HEADER;
  90. #else
  91.     typedef struct { INT tag; } OB_HEADER;
  92. #endif
  93.  
  94. typedef struct STR_struct {
  95.     OB_HEADER header;
  96.     INT asize;
  97.     CHAR arr_part[1];
  98. } *STR;
  99.  
  100. typedef struct OB_struct {
  101.     OB_HEADER header;
  102. } *OB;
  103.  
  104. #undef ferror
  105. #undef feof
  106.  
  107. /* We use bzero and bcopy internally.  They may not be available.       */
  108. # if defined(SPARC) && defined(SUNOS4)
  109. #   define BCOPY_EXISTS
  110. # endif
  111. # if defined(M68K) && defined(NEXT)
  112. #   define BCOPY_EXISTS
  113. # endif
  114. # if defined(VAX)
  115. #   define BCOPY_EXISTS
  116. # endif
  117.  
  118. # ifndef BCOPY_EXISTS
  119. #   include <string.h>
  120. #   define bcopy(x,y,n) memcpy(y, x, (size_t)(n))
  121. #   define bzero(x,n)   memset(x, 0, (size_t)(n))
  122. # endif
  123.  
  124.  
  125.