rts-packages.scm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. (define-structures ((scheme-level-1 scheme-level-1-interface)
  3. (util util-interface)
  4. (set-text-procedures (export set-char-map-procedures!
  5. set-string-ci-procedures!)))
  6. (open scheme-level-0 ascii simple-signals
  7. code-quote) ; needed by SYNTAX-RULES
  8. (usual-transforms case quasiquote syntax-rules)
  9. (files (rts charmap)
  10. (rts base)
  11. (rts util)
  12. (rts number)
  13. (rts lize)) ; Rationalize
  14. (optimize auto-integrate))
  15. ; "Level 2"
  16. (define-structures ((record-types record-types-interface)
  17. (records-internal records-internal-interface))
  18. (open scheme-level-1 records simple-signals
  19. primitives)
  20. (files (rts record))
  21. (optimize auto-integrate))
  22. ; The external code needs this to check the types of records.
  23. (define-structure export-the-record-type (export)
  24. (open scheme-level-1 records-internal shared-bindings)
  25. (begin
  26. (define-exported-binding "s48-the-record-type" :record-type)))
  27. (define-structures ((define-record-types define-record-types-interface)
  28. (define-sync-record-types
  29. (export (define-synchronized-record-type :syntax))))
  30. (open scheme-level-1
  31. records record-types records-internal
  32. loopholes
  33. low-proposals ;provisional-checked-record-{ref|set!}
  34. primitives) ;unspecific
  35. (files (rts jar-defrecord)))
  36. (define-structures ((methods methods-interface)
  37. (meta-methods meta-methods-interface))
  38. (open scheme-level-1
  39. define-record-types
  40. records record-types records-internal
  41. bitwise util primitives
  42. simple-signals)
  43. (files (rts method))
  44. (optimize auto-integrate))
  45. (define-structure number-i/o number-i/o-interface
  46. (open scheme-level-1 methods simple-signals ascii)
  47. (files (rts numio)))
  48. (define-structures ((fluids fluids-interface)
  49. (fluids-internal fluids-internal-interface))
  50. (open scheme-level-1 define-record-types primitives cells)
  51. (files (rts fluid))
  52. (optimize auto-integrate))
  53. (define-structure wind wind-interface
  54. (open scheme-level-1 simple-signals define-record-types
  55. fluids fluids-internal
  56. low-proposals
  57. escapes)
  58. (files (rts wind))
  59. (optimize auto-integrate))
  60. (define-structure session-data (export make-session-data-slot!
  61. initialize-session-data!
  62. session-data-ref
  63. session-data-set!)
  64. (open scheme-level-1
  65. primitives)
  66. (files (rts session))
  67. (optimize auto-integrate))
  68. (define-structure text-codecs text-codecs-interface
  69. (open scheme-level-1
  70. define-record-types
  71. bitwise
  72. unicode
  73. byte-vectors
  74. (subset primitives (encode-char decode-char))
  75. (subset architecture (text-encoding-option))
  76. enumerated enum-case)
  77. (files (rts text-codec))
  78. (optimize auto-integrate))
  79. (define-structure encodings encodings-interface
  80. (open scheme-level-2
  81. unicode
  82. byte-vectors
  83. (modify primitives
  84. (prefix primitive-)
  85. (expose encode-char decode-char))
  86. (subset architecture (text-encoding-option))
  87. text-codecs
  88. enumerated
  89. simple-conditions simple-signals
  90. proposals
  91. (subset silly (reverse-list->string)))
  92. (optimize auto-integrate)
  93. (files (rts encoding)))
  94. (define-structures ((os-strings os-strings-interface)
  95. (os-strings-internal (export initialize-os-string-text-codec!)))
  96. (open scheme-level-1
  97. define-record-types
  98. byte-vectors
  99. (subset primitives (system-parameter make-immutable! copy-bytes!))
  100. (subset architecture (system-parameter-option))
  101. text-codecs encodings
  102. enumerated
  103. fluids)
  104. (files (rts os-string)))
  105. (define-structures ((i/o i/o-interface)
  106. (i/o-internal i/o-internal-interface))
  107. (open scheme-level-1 simple-signals fluids
  108. architecture
  109. primitives
  110. ascii unicode
  111. ports byte-vectors bitwise
  112. define-record-types
  113. proposals
  114. (subset threads-internal (maybe-commit-no-interrupts))
  115. session-data
  116. debug-messages ; for error messages
  117. methods ; &disclose :input-port :output-port
  118. number-i/o ; number->string for debugging
  119. text-codecs
  120. handle ; report-errors-as-warnings
  121. vm-exceptions) ; wrong-number-of-args stuff
  122. (files (rts port)
  123. (rts port-buffer)
  124. (rts current-port))
  125. (optimize auto-integrate))
  126. (define-structure channel-i/o channel-i/o-interface
  127. (open scheme-level-1 byte-vectors cells
  128. channels
  129. i/o i/o-internal
  130. simple-conditions
  131. (subset threads-internal (maybe-commit-no-interrupts))
  132. proposals
  133. condvars condvars-internal
  134. interrupts
  135. architecture
  136. session-data
  137. debug-messages) ; for error messages
  138. (files (rts channel)))
  139. (define-structure channel-ports channel-ports-interface
  140. (open scheme-level-1 byte-vectors define-record-types ascii
  141. ports
  142. i/o i/o-internal text-codecs
  143. channels channel-i/o
  144. os-strings
  145. proposals
  146. condvars
  147. simple-signals simple-conditions
  148. architecture ; channel-opening options
  149. (subset primitives (channel-parameter))
  150. handle
  151. debug-messages ; for error messages
  152. (subset util (unspecific))
  153. (subset primitives (add-finalizer!)))
  154. (files (rts channel-port)))
  155. (define-structure simple-conditions simple-conditions-interface
  156. (open scheme-level-1 simple-signals
  157. (subset primitives (os-error-message)))
  158. (files (rts simple-condition)))
  159. (define-structure writing writing-interface
  160. (open scheme-level-1
  161. unicode
  162. number-i/o
  163. (subset i/o (write-char write-string))
  164. (subset i/o-internal (output-port-option))
  165. methods ;disclose
  166. (subset i/o-internal (open-output-port?))
  167. (subset simple-signals (call-error))
  168. (subset channels (channel? channel-id))
  169. (subset code-vectors (code-vector?)))
  170. (files (rts write)))
  171. (define-structure reading reading-interface
  172. (open scheme-level-1
  173. number-i/o
  174. (subset i/o-internal (input-port-option))
  175. ascii ;for dispatch table
  176. unicode
  177. simple-signals ;warn, signal-condition, make-condition
  178. simple-conditions ;define-condition-type
  179. primitives ;make-immutable!
  180. silly) ;reverse-list->string
  181. (files (rts read)
  182. (rts syntax-info))
  183. (optimize auto-integrate))
  184. (define-structure scheme-level-2 scheme-level-2-interface
  185. (open scheme-level-1
  186. number-i/o
  187. writing
  188. reading
  189. wind
  190. i/o
  191. channel-ports))
  192. (define-structure features features-interface
  193. (open primitives i/o))
  194. ; Hairier stuff now.
  195. (define-structure templates templates-interface
  196. (open scheme-level-1 primitives methods)
  197. (files (rts template))
  198. (optimize auto-integrate))
  199. (define-structure continuations continuations-interface
  200. (open scheme-level-1 primitives
  201. architecture code-vectors
  202. templates closures all-operators
  203. methods)
  204. (files (rts continuation))
  205. (optimize auto-integrate))
  206. (define-structure more-types (export :closure :code-vector :location :double
  207. :template :channel :port :weak-pointer
  208. :shared-binding :cell)
  209. (open scheme-level-1 methods
  210. closures code-vectors locations cells templates channels ports
  211. primitives shared-bindings)
  212. (begin (define-simple-type :closure (:value) closure?)
  213. (define-simple-type :code-vector (:value) code-vector?)
  214. (define-simple-type :location (:value) location?)
  215. (define-simple-type :cell (:value) cell?)
  216. (define-simple-type :template (:value) template?)
  217. (define-simple-type :channel (:value) channel?)
  218. (define-simple-type :port (:value) port?)
  219. (define-simple-type :double (:rational) double?)
  220. (define-simple-type :weak-pointer (:value) weak-pointer?)
  221. (define-method &disclose ((obj :weak-pointer)) (list 'weak-pointer))
  222. (define-simple-type :shared-binding (:value) shared-binding?)
  223. (define-method &disclose ((obj :shared-binding))
  224. (list (if (shared-binding-is-import? obj)
  225. 'imported-binding
  226. 'exported-binding)
  227. (shared-binding-name obj)))))
  228. (define-structure enumerated enumerated-interface
  229. (open scheme-level-1 simple-signals)
  230. (files (rts defenum scm)))
  231. (define-structure architecture vm-architecture-interface
  232. (open scheme-level-1 simple-signals enumerated platform)
  233. (files (vm/interp arch)))
  234. (define-structure vm-data vm-data-interface
  235. (open scheme-level-1 enumerated bitwise ascii
  236. architecture platform
  237. (subset simple-signals (error)))
  238. (begin
  239. ; Scheme/Pre-Scheme differences
  240. (define (arithmetic-shift-right n k)
  241. (arithmetic-shift n (- k)))
  242. (define shift-left arithmetic-shift)
  243. ; From vm/vm-utilities.scm
  244. (define (adjoin-bits high low k)
  245. (+ (arithmetic-shift high k) low))
  246. (define (low-bits n k)
  247. (bitwise-and n (- (arithmetic-shift 1 k) 1)))
  248. (define high-bits arithmetic-shift-right)
  249. (define unsigned-high-bits high-bits)
  250. (define-syntax assert
  251. (syntax-rules ()
  252. ((assert foo) #t)))
  253. (define (integer->unsigned x) x)
  254. (define un> >)
  255. ; We just know this.
  256. (define useful-bits-per-word c-useful-bits-per-word))
  257. (files (vm/data data)))
  258. (define-structure vm-exceptions vm-exceptions-interface
  259. (open scheme-level-1
  260. simple-conditions
  261. enumerated
  262. architecture
  263. (subset primitives (set-exception-handlers! unspecific)))
  264. (files (rts vm-exception)))
  265. (define-structures ((exceptions exceptions-interface)
  266. (exceptions-internal exceptions-internal-interface)
  267. (handle handle-interface))
  268. (open scheme-level-1
  269. simple-signals fluids cells
  270. simple-conditions
  271. vm-exceptions
  272. primitives ;set-exception-handlers!, etc.
  273. wind ;CWCC
  274. methods
  275. meta-methods
  276. more-types
  277. architecture
  278. enumerated
  279. debug-messages ; for printing from last-resort-condition handler
  280. vm-exposure ;primitive-catch
  281. templates ;template-code, template-info
  282. continuations ;continuation-pc, etc.
  283. locations ;location?, location-id
  284. closures ;closure-template
  285. number-i/o) ; number->string, for backtrace
  286. (files (rts exception))) ; Needs generic, arch
  287. (define-structure interrupts interrupts-interface
  288. (open scheme-level-1
  289. simple-signals fluids simple-conditions
  290. bitwise
  291. escapes
  292. session-data
  293. primitives
  294. architecture)
  295. (files (rts interrupt))
  296. (optimize auto-integrate)) ;mostly for threads package...
  297. (define-structure external-events external-events-interface
  298. (open scheme-level-1
  299. (subset wind (dynamic-wind))
  300. enumerated
  301. condvars condvars-internal proposals
  302. session-data
  303. interrupts)
  304. (files (rts external-event)))
  305. (define-structures ((threads threads-interface)
  306. (threads-internal threads-internal-interface))
  307. (open scheme-level-1 enumerated queues cells
  308. (subset proposals (define-synchronized-record-type))
  309. define-record-types
  310. interrupts
  311. wind
  312. fluids
  313. fluids-internal ;get-dynamic-env
  314. proposals ;maybe-commit
  315. escapes ;primitive-cwcc
  316. simple-conditions ;error?
  317. handle ;with-handler
  318. simple-signals ;signal, warn, call-error
  319. loopholes ;for converting #f to a continuation
  320. architecture ;time-option
  321. session-data
  322. debug-messages
  323. (subset primitives (find-all-records
  324. current-thread set-current-thread!
  325. unspecific
  326. collect
  327. time)))
  328. (optimize auto-integrate)
  329. (files (rts thread)
  330. (rts sleep)))
  331. (define-structure proposals proposals-interface
  332. (open scheme-level-1 low-proposals
  333. define-record-types define-sync-record-types
  334. primitives) ;unspecific
  335. (files (rts proposal)))
  336. (define-structure scheduler scheduler-interface
  337. (open scheme-level-1 threads threads-internal enumerated enum-case queues
  338. debug-messages
  339. simple-signals) ;error
  340. (files (rts scheduler)))
  341. (define-structure root-scheduler (export root-scheduler
  342. spawn-on-root
  343. scheme-exit-now
  344. call-when-deadlocked!)
  345. (open scheme-level-1 threads threads-internal scheduler queues
  346. session-data
  347. simple-conditions ;warning?, error?
  348. writing ;display
  349. debug-messages ;for debugging
  350. (subset i/o (current-error-port newline))
  351. (subset simple-signals (error))
  352. (subset handle (with-handler))
  353. (subset i/o-internal (output-port-forcers output-forcer-id))
  354. (subset fluids-internal (get-dynamic-env))
  355. (subset interrupts (with-interrupts-inhibited
  356. all-interrupts
  357. set-enabled-interrupts!))
  358. (subset external-events (waiting-for-external-events?))
  359. (subset wind (call-with-current-continuation))
  360. (subset channel-i/o (waiting-for-i/o?
  361. initialize-channel-i/o!
  362. abort-unwanted-reads!))
  363. (modify primitives (rename (wait primitive-wait))
  364. (expose wait unspecific)))
  365. (files (rts root-scheduler)))
  366. (define-structure enum-case (export (enum-case :syntax))
  367. (open scheme-level-1 enumerated util)
  368. (begin
  369. (define-syntax enum-case
  370. (syntax-rules (else)
  371. ((enum-case enumeration (x ...) clause ...)
  372. (let ((temp (x ...)))
  373. (enum-case enumeration temp clause ...)))
  374. ((enum-case enumeration value ((name ...) body ...) rest ...)
  375. (if (or (= value (enum enumeration name)) ...)
  376. (begin body ...)
  377. (enum-case enumeration value rest ...)))
  378. ((enum-case enumeration value (else body ...))
  379. (begin body ...))
  380. ((enum-case enumeration value)
  381. (unspecific))))))
  382. (define-structure queues queues-interface
  383. (open scheme-level-1 proposals simple-signals)
  384. (files (big queue))
  385. (optimize auto-integrate))
  386. ; No longer used
  387. ;(define-structure linked-queues (compound-interface
  388. ; queues-interface
  389. ; (export delete-queue-entry!
  390. ; queue-head))
  391. ; (open scheme-level-1 define-record-types simple-signals primitives)
  392. ; (files (big linked-queue))
  393. ; (optimize auto-integrate))
  394. (define-structures ((condvars condvars-interface)
  395. (condvars-internal (export condvar-has-waiters?)))
  396. (open scheme-level-1 queues
  397. proposals
  398. threads threads-internal)
  399. (optimize auto-integrate)
  400. (files (rts condvar)))
  401. (define-structure usual-resumer (export usual-resumer
  402. make-usual-resumer
  403. add-initialization-thunk!)
  404. (open scheme-level-1
  405. os-strings
  406. (subset i/o-internal (initialize-i/o initialize-i/o-handlers!))
  407. (subset i/o (set-port-text-codec!))
  408. channel-i/o ;initialize-channel-i/o
  409. channel-ports ;{in,out}put-channel->port
  410. (subset text-codecs (find-text-codec))
  411. os-strings-internal
  412. session-data ;initialize-session-data!
  413. fluids-internal ;initialize-dynamic-state!
  414. exceptions-internal
  415. vm-exceptions
  416. interrupts ;initialize-interrupts!
  417. (subset external-events (initialize-external-events!))
  418. records-internal ;initialize-records!
  419. shared-bindings ;find-undefined-imported-bindings
  420. debug-messages ;warn about undefined bindings
  421. threads-internal ;start threads
  422. root-scheduler) ;start a scheduler
  423. (files (rts init)))
  424. ; Weak pointers & populations
  425. (define-structure weak weak-interface
  426. (open scheme-level-1 simple-signals
  427. primitives) ;Open primitives instead of loading (alt weak)
  428. (files ;;(alt weak) ;Only needed if VM's weak pointers are buggy
  429. (rts population)))