home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / tile.lzh / tile.3 / PORTING
Encoding:
Text File  |  1990-07-26  |  6.1 KB  |  246 lines

  1. THREADED INTERPRETIVE LANGUAGE ENVIRONMENT (TILE) PORTING [RELEASE 2.0]
  2.  
  3. June 28, 1990
  4.  
  5. Mikael R.K. Patel
  6. Computer Aided Design Laboratory (CADLAB)
  7. Department of Computer and Information Science
  8. Linkoping University
  9. S-581 83 LINKOPING
  10. SWEDEN
  11. Email: mip@ida.liu.se
  12.  
  13.  
  14. INTRODUCTION
  15.  
  16. This brief document describes some to the section in the tile forth
  17. kernel which may have to be changed to port the code to other machines.
  18. Any changes made should be made in a "#ifdef" section and reported.
  19.  
  20.  
  21. 1. KERNEL DEFINITIONS
  22.  
  23. 1.1    Vocabulary listing parameters (File: kernel.c)
  24.  
  25. The column and line width used by "words" may be altered by changing
  26. the lines:
  27.  
  28. #define COLUMNWIDTH 15
  29. #define LINEWIDTH 75
  30.  
  31.  
  32. 1.2    Set of search vocabularies (File: kernel.c)
  33.  
  34. The set of search vocabularies, "context", is realized as a vector.
  35. The maximum number of vocabularies in is defined by:
  36.  
  37. #define CONTEXTSIZE 64
  38.  
  39. An error will occur it the set is filled. No checking is currently 
  40. performed.
  41.  
  42.  
  43. 1.3    Lookup cache (File: kernel.c)
  44.  
  45. The lookup function in the kernel is supported by a simple cache.
  46. A hash function (see below) is used to map a string into the cache
  47. and there, if possible, find the entry. The size of the cache
  48. is given by:
  49.  
  50. #define CACHESIZE 256
  51. #define hash(s) ((s[0] + (s[1] << 4)) & (CACHESIZE - 1))
  52.  
  53. The hash function is tailored for the current cache size and thus
  54. special care must be taken when altering these.
  55.  
  56.  
  57. 1.4    Internal structures (File: kernel.c)
  58.  
  59. The "pad" and the "tib" may be changed by altering:
  60.  
  61. #define PADSIZE 84
  62. #define TIBSIZE 256
  63.  
  64.  
  65. 1.5    Word alignment (File: kernel.h)
  66.  
  67. Alignment of threaded code and data structures are performed by the
  68. macro:
  69.  
  70. #define align(p) p = (PTR32) ((INT32) ((PTR8) p + 3) & -4)
  71.  
  72. This macro currently aligns to word (long) boundaries and is used by
  73. "colon" and "create".
  74.  
  75.  
  76. 1.6    Typing system (File: kernel.h)
  77.  
  78. The kernel is written in its own typing system. The typing system may
  79. be extended to allow other data types etc. All types in the kernel
  80. are written with uppercase words.
  81.  
  82. #define VOID void
  83.  
  84. typedef char*  PTR8;
  85. typedef short* PTR16;
  86. typedef long*  PTR32;
  87.  
  88. typedef VOID (*SUBR)();
  89.  
  90. #define NIL 0
  91.  
  92. typedef long BOOL;
  93.  
  94. #define TRUE  ((BOOL) -1)
  95. #define FALSE ((BOOL)  0)
  96.  
  97. typedef unsigned       NUM;
  98. typedef unsigned char  NUM8;
  99. typedef unsigned short NUM16;
  100. typedef unsigned long  NUM32;
  101.  
  102. typedef int   INT;
  103. typedef char  INT8;
  104. typedef short INT16;
  105. typedef long  INT32;
  106.  
  107. typedef float  FLOAT32;
  108. typedef double FLOAT64;
  109.  
  110. typedef char  CHAR;
  111. typedef char* CSTR;
  112. typedef char* PSTR;
  113.  
  114. typedef union {
  115.     BOOL             BOOL;
  116.     NUM32            NUM32;
  117.     INT32            INT32;
  118.     FLOAT32          FLOAT32;
  119.     CSTR             CSTR;
  120.     PTR8             PTR8;
  121.     PTR16            PTR16;
  122.     PTR32            PTR32;
  123.     SUBR             SUBR;
  124.     QUEUE            QUEUE;
  125.     TASK             TASK;
  126.     ENTRY            ENTRY;
  127.     CODE_ENTRY       CODE_ENTRY;
  128.     VOCABULARY_ENTRY VOCABULARY_ENTRY;
  129. } UNIV, *PTR;
  130.  
  131.  
  132. 1.7    Initialization of the kernel (File: kernel.c)
  133.  
  134. The initialization function for the kernel requires five parameters.
  135. The two first allows the application such as forth.c to extend the
  136. basic forth vocabulary by giving the first and last entry in the 
  137. application vocabulary. The three following parameters specify the
  138. size of the foreground task, the forth interpreter. See the file
  139. forth.c for an example.
  140.  
  141.  
  142. 2.     IO MANAGEMENT
  143.  
  144. 2.1    File and path name size (File: io.c)
  145.  
  146. The maximum length of a file or path name is defined as:
  147.  
  148. #define FILENAMESIZE 128
  149. #define PATHNAMESIZE 128
  150.  
  151. These length are not test for currently. An error may occur if
  152. a file or path name is longer than the given sizes.
  153.  
  154.  
  155. 2.2    File buffer stack (File: io.c)
  156.  
  157. The io management package implements a stack of input file buffers to
  158. allow loading of files from within other files etc. The maximum depth
  159. of this stack is defined as:
  160.  
  161. #define INFSTACKSIZE 32
  162.  
  163. The depth should be chosen to the maximum number of open files.
  164.  
  165.  
  166. 2.3    Set of loaded files (File: io.c)
  167.  
  168. The file loading mechanism automatically looks if the file already
  169. has been opened. The set of opened files is maintained as a vector.
  170. The maximum number of loaded files is:
  171.  
  172. #define INFILESSIZE 64
  173.  
  174. The vector contains the fully expanded names of the loaded files.
  175. An error may occur if this limit is succeeded. It is not checked for
  176. currently.
  177.  
  178.  
  179. 2.4    Set of paths (File: io.c)
  180.  
  181. The io packages also maintains an ordered collection of paths which
  182. are used to expand file names with when search for the file. The
  183. maximum size of this collection is defined by:
  184.  
  185. #define PATHSSIZE 32
  186.  
  187. This collection is automatically appended by the $TILEPATH environ-
  188. ment variable when the io package is initiated.
  189.  
  190.  
  191. 2.5    White space (File: io.h)
  192.  
  193. The definition of "white" space is defined as:
  194.  
  195. #define ISSPACE(c) ((c) <= ' ')
  196.  
  197. This eliminates space and any control characters. Some application
  198. might want to redefine this. 
  199.  
  200.  
  201. 2.6.    Directory separator character (File: io.h)
  202.  
  203. The directory separator character is defined as:
  204.  
  205. #define DIRSEPCHAR '/'
  206.  
  207. This makes the code more portable to other machines.
  208.  
  209.  
  210. 2.6    Non-blocking read operation (File: io.c)
  211.  
  212. To achieve multi-tasking during input wait the input package function
  213. "io_fillbuf" uses a non-blocking read operation. Some environments
  214. do not support this. Thus this may require re-implementation.
  215.  
  216.  
  217. 3.     ERROR MANAGEMENT
  218.  
  219. 3.1    Signals (File: error.c)
  220.  
  221. Error handing is realized using two basic mechanisms; first signals from
  222. the execution environment and second by user defined exceptions in
  223. the kernel (high level code).
  224.  
  225. The signal message table and the appropriate operations, "error_restart",
  226. or "error_fatal", may have to be changed to give the right performance.
  227.  
  228. Please see these functions and "error_initiate" where the actual binding
  229. of signals and actions is performed.
  230.  
  231.  
  232. 4.    MEMORY MANAGEMENT
  233.  
  234. 4.1    Memory allocation (File: forth.c)
  235.  
  236. Currently memory for the dictionary, strings, entries, and task blocks
  237. are allocated using "malloc".
  238.  
  239. The size of the dictionary is determined when calling the initialization
  240. function in the memory management package, "memory_initiate". The
  241. current default size is defined as:
  242.  
  243. #define DICTIONARYSIZE 1024L * 1024L
  244.  
  245. And may be too large for "small" machines. 
  246.