~ chicken-core (chicken-5) fad0550f6afef54fd3a30752ff0551d7c78b5991


commit fad0550f6afef54fd3a30752ff0551d7c78b5991
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Sat Apr 22 21:37:25 2017 +0200
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Sat Apr 29 17:24:47 2017 +1200

    Add chicken.platform module (incomplete)
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/README b/README
index 360d2b68..633d364a 100644
--- a/README
+++ b/README
@@ -308,6 +308,7 @@ _/        _/    _/    _/    _/        _/  _/    _/        _/    _/_/
 	|   |       |-- chicken.lolevel.import.so
 	|   |       |-- chicken.memory.import.so
 	|   |       |-- chicken.pathname.import.so
+	|   |       |-- chicken.platform.import.so
 	|   |       |-- chicken.port.import.so
 	|   |       |-- chicken.posix.import.so
 	|   |       |-- chicken.pretty-print.import.so
diff --git a/batch-driver.scm b/batch-driver.scm
index 23a1db63..d57d5ddb 100644
--- a/batch-driver.scm
+++ b/batch-driver.scm
@@ -40,6 +40,7 @@
 	chicken.format
 	chicken.gc
 	chicken.pathname
+	chicken.platform
 	chicken.pretty-print
 	chicken.time
 	chicken.compiler.support
diff --git a/chicken-bug.scm b/chicken-bug.scm
index e2d294b8..e0977546 100644
--- a/chicken-bug.scm
+++ b/chicken-bug.scm
@@ -33,6 +33,7 @@
 	chicken.pathname
 	chicken.port
 	chicken.posix
+	chicken.platform
 	chicken.time)
 
 (define-constant +bug-report-file+ "chicken-bug-report.~a-~a-~a")
diff --git a/chicken-install.scm b/chicken-install.scm
index 4dbf9717..133d9f9d 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -40,6 +40,7 @@
 (import (chicken io))
 (import (chicken time))
 (import (chicken pathname))
+(import (chicken platform))
 (import (chicken process))
 (import (chicken pretty-print))
 
diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index 4441055c..65367b83 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -1355,8 +1355,6 @@
 
 (##sys#macro-subset me0 ##sys#default-macro-environment)))
 
-
 ;; register features
 
-(eval-when (compile load eval)
-  (register-feature! 'srfi-8 'srfi-11 'srfi-15 'srfi-16 'srfi-26 'srfi-31) )
+(chicken.platform#register-feature! 'srfi-8 'srfi-11 'srfi-15 'srfi-16 'srfi-26 'srfi-31)
diff --git a/chicken.import.scm b/chicken.import.scm
index 9af70ecb..433001f5 100644
--- a/chicken.import.scm
+++ b/chicken.import.scm
@@ -35,12 +35,12 @@
    blob-size
    blob?
    blob=?
-   build-platform
+   (build-platform . chicken.platform#build-platform)
    call/cc
    case-sensitive
    char-name
    (chicken-home . chicken.eval#chicken-home)
-   chicken-version
+   (chicken-version . chicken.platform#chicken-version)
    command-line-arguments
    condition-predicate
    condition-property-accessor
@@ -67,8 +67,8 @@
    exit-handler
    (expand . chicken.expand#expand)
    (extension-information . chicken.eval#extension-information)
-   feature?
-   features
+   (feature? . chicken.platform#feature?)
+   (features . chicken.platform#features)
    file-exists?
    finite?
    (fixnum-bits . chicken.fixnum#fixnum-bits)
@@ -123,8 +123,8 @@
    (load-noisily . chicken.eval#load-noisily)
    (load-relative . chicken.eval#load-relative)
    (load-verbose . chicken.eval#load-verbose)
-   machine-byte-order
-   machine-type
+   (machine-byte-order . chicken.platform#machine-byte-order)
+   (machine-type . chicken.platform#machine-type)
    make-blob
    make-composite-condition
    make-parameter
@@ -158,7 +158,7 @@
    quotient&modulo
    quotient&remainder
    ratnum?
-   register-feature!
+   (register-feature! . chicken.platform#register-feature!)
    remprop!
    rename-file
    (repository-path . chicken.eval#repository-path)
@@ -173,8 +173,8 @@
    signum
    singlestep
    sleep
-   software-type
-   software-version
+   (software-type . chicken.platform#software-type)
+   (software-version . chicken.platform#software-version)
    string->blob
    string->uninterned-symbol
    (strip-syntax . chicken.expand#strip-syntax)
@@ -185,7 +185,7 @@
    symbol-plist
    (syntax-error . chicken.expand#syntax-error)
    system
-   unregister-feature!
+   (unregister-feature! . chicken.platform#unregister-feature!)
    vector-resize
    vector-copy!
    void
diff --git a/csi.scm b/csi.scm
index bebd2311..a60d620b 100644
--- a/csi.scm
+++ b/csi.scm
@@ -51,6 +51,7 @@ EOF
 	chicken.gc
 	chicken.keyword
 	chicken.io
+	chicken.platform
 	chicken.port
 	chicken.pretty-print
 	chicken.repl)
diff --git a/defaults.make b/defaults.make
index 675c5cd1..51af1cd2 100644
--- a/defaults.make
+++ b/defaults.make
@@ -266,8 +266,9 @@ CHICKEN_PROGRAM_OPTIONS += $(if $(PROFILE_OBJECTS),-profile)
 PRIMITIVE_IMPORT_LIBRARIES = chicken chicken.csi chicken.foreign
 DYNAMIC_IMPORT_LIBRARIES = srfi-4
 DYNAMIC_CHICKEN_IMPORT_LIBRARIES = bitwise errno file.posix fixnum flonum \
-	format gc io keyword locative memory posix pretty-print process \
-	process.signal process-context random time time.posix
+	format gc io keyword locative memory platform posix \
+	pretty-print process process.signal process-context random \
+	time time.posix
 DYNAMIC_CHICKEN_COMPILER_IMPORT_LIBRARIES = user-pass
 DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES = continuation data-structures \
 	eval expand file files internal irregex lolevel pathname port \
diff --git a/distribution/manifest b/distribution/manifest
index 3698913b..834a7b83 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -310,6 +310,8 @@ chicken.memory.import.scm
 chicken.memory.import.c
 chicken.pathname.import.scm
 chicken.pathname.import.c
+chicken.platform.import.scm
+chicken.platform.import.c
 chicken.port.import.scm
 chicken.port.import.c
 chicken.posix.import.scm
diff --git a/eval.scm b/eval.scm
index 74089147..2e410f49 100644
--- a/eval.scm
+++ b/eval.scm
@@ -63,7 +63,8 @@
 (import chicken.expand
 	chicken.foreign
 	chicken.internal
-	chicken.keyword)
+	chicken.keyword
+	chicken.platform)
 
 (include "common-declarations.scm")
 (include "mini-srfi-1.scm")
diff --git a/expand.scm b/expand.scm
index 3a6b4364..9e6b1d5a 100644
--- a/expand.scm
+++ b/expand.scm
@@ -52,7 +52,8 @@
    expansion-result-hook)
 
 (import scheme chicken
-	chicken.keyword)
+	chicken.keyword
+	chicken.platform)
 
 (include "common-declarations.scm")
 
@@ -1417,7 +1418,7 @@
 
 (##sys#extend-macro-environment
  'cond-expand
- '()
+ '((feature? . chicken.platform#feature?))
  (##sys#er-transformer
   (lambda (form r c)
     (let ((clauses (cdr form))
@@ -1430,7 +1431,7 @@
 		     x
 		     (cons 'cond-expand clauses)) )
       (define (test fx)
-	(cond ((symbol? fx) (##sys#feature? (strip-syntax fx)))
+	(cond ((symbol? fx) (feature? (strip-syntax fx)))
 	      ((not (pair? fx)) (err fx))
 	      (else
 	       (let ((head (car fx))
diff --git a/extras.scm b/extras.scm
index afc06839..a49b96d2 100644
--- a/extras.scm
+++ b/extras.scm
@@ -566,7 +566,7 @@
 (module chicken.format
   (format fprintf printf sprintf)
 
-(import scheme chicken)
+(import scheme chicken chicken.platform)
 
 (define fprintf0
   (lambda (loc port msg args)
diff --git a/library.scm b/library.scm
index 1063e409..1f980d86 100644
--- a/library.scm
+++ b/library.scm
@@ -42,7 +42,8 @@
   (not inline ##sys#user-read-hook ##sys#error-hook ##sys#signal-hook
        ##sys#sleep-hook ##sys#schedule ##sys#default-read-info-hook
        ##sys#infix-list-hook ##sys#sharp-number-hook
-       ##sys#user-print-hook ##sys#user-interrupt-hook)
+       ##sys#user-print-hook ##sys#user-interrupt-hook
+       ##sys#windows-platform ##sys#features)
   (foreign-declare #<<EOF
 #include <errno.h>
 #include <float.h>
@@ -4384,24 +4385,41 @@ EOF
 
 ;;; Platform configuration inquiry:
 
+(module chicken.platform
+    (build-platform chicken-version
+     feature? features software-type
+     software-version register-feature! unregister-feature!
+     machine-byte-order machine-type
+
+     ;;; TODO, move these from eval:
+     ;; chicken-home extension-information
+     ;; provide provided? repository-path
+
+     ;;; TODO, move these from posix:
+     ;; get-host-name system-information
+     )
+
+(import scheme chicken.fixnum chicken.foreign chicken.keyword)
+(import (only chicken when unless))
+
 (define software-type
-  (let ([sym (string->symbol ((##core#primitive "C_software_type")))])
+  (let ((sym (string->symbol ((##core#primitive "C_software_type")))))
     (lambda () sym) ) )
 
 (define machine-type
-  (let ([sym (string->symbol ((##core#primitive "C_machine_type")))])
+  (let ((sym (string->symbol ((##core#primitive "C_machine_type")))))
     (lambda () sym) ) )
 
 (define machine-byte-order
-  (let ([sym (string->symbol ((##core#primitive "C_machine_byte_order")))])
+  (let ((sym (string->symbol ((##core#primitive "C_machine_byte_order")))))
     (lambda () sym) ) )
 
 (define software-version
-  (let ([sym (string->symbol ((##core#primitive "C_software_version")))])
+  (let ((sym (string->symbol ((##core#primitive "C_software_version")))))
     (lambda () sym) ) )
 
 (define build-platform
-  (let ([sym (string->symbol ((##core#primitive "C_build_platform")))])
+  (let ((sym (string->symbol ((##core#primitive "C_build_platform")))))
     (lambda () sym) ) )
 
 (define ##sys#windows-platform
@@ -4411,10 +4429,10 @@ EOF
 
 (define (chicken-version #!optional full)
   (define (get-config)
-    (let ([bp (build-platform)]
-	  [st (software-type)]
-	  [sv (software-version)]
-	  [mt (machine-type)] )
+    (let ((bp (build-platform))
+	  (st (software-type))
+	  (sv (software-version))
+	  (mt (machine-type)))
       (define (str x)
 	(if (eq? 'unknown x)
 	    ""
@@ -4440,10 +4458,9 @@ EOF
 	 (or (##sys#build-tag) "")))
       ##sys#build-version) )
 
-
 ;;; Feature identifiers:
 
-(define ##sys#->feature-id
+(define ->feature-id ; TODO: export this?  It might be useful..
   (let ()
     (define (err . args)
       (apply ##sys#signal-hook #:type-error "bad argument type - not a valid feature identifer" args) )
@@ -4467,7 +4484,7 @@ EOF
 
 (let ((check (lambda (f)
 	       (unless (eq? 'unknown f)
-		 (set! ##sys#features (cons (##sys#->feature-id f) ##sys#features))))))
+		 (set! ##sys#features (cons (->feature-id f) ##sys#features))))))
   (check (software-type))
   (check (software-version))
   (check (build-platform))
@@ -4488,27 +4505,26 @@ EOF
 (set! ##sys#features
   (let ((major (##sys#number->string (foreign-value "C_MAJOR_VERSION" int)))
 	(minor (##sys#number->string (foreign-value "C_MINOR_VERSION" int))))
-    (cons (##sys#->feature-id (string-append "chicken-" major))
-	  (cons (##sys#->feature-id
-		 (string-append "chicken-" major "." minor))
+    (cons (->feature-id (string-append "chicken-" major))
+	  (cons (->feature-id (string-append "chicken-" major "." minor))
 		##sys#features))))
 
 (define (register-feature! . fs)
   (for-each
    (lambda (f)
-     (let ([id (##sys#->feature-id f)])
+     (let ((id (->feature-id f)))
        (unless (memq id ##sys#features) (set! ##sys#features (cons id ##sys#features))) ) )
    fs)
   (##core#undefined) )
 
 (define (unregister-feature! . fs)
-  (let ([fs (map ##sys#->feature-id fs)])
+  (let ((fs (map ->feature-id fs)))
     (set! ##sys#features
-      (let loop ([ffs ##sys#features])
+      (let loop ((ffs ##sys#features))
 	(if (null? ffs)
 	    '()
-	    (let ([f (##sys#slot ffs 0)]
-		  [r (##sys#slot ffs 1)] )
+	    (let ((f (##sys#slot ffs 0))
+		  (r (##sys#slot ffs 1)))
 	      (if (memq f fs)
 		  (loop r)
 		  (cons f (loop r)) ) ) ) ) )
@@ -4517,13 +4533,14 @@ EOF
 (define (features) ##sys#features)
 
 (define (feature? . ids)
-  (let loop ([ids ids])
+  (let loop ((ids ids))
     (or (null? ids)
-	(and (memq (##sys#->feature-id (##sys#slot ids 0)) ##sys#features)
+	(and (memq (->feature-id (##sys#slot ids 0)) ##sys#features)
 	     (loop (##sys#slot ids 1)) ) ) ) )
 
-(define ##sys#feature? feature?)
+) ; chicken.platform
 
+(import chicken.platform)
 
 ;;; Access backtrace:
 
diff --git a/modules.scm b/modules.scm
index 91099db1..292dedaf 100644
--- a/modules.scm
+++ b/modules.scm
@@ -41,7 +41,8 @@
 
 (import chicken.expand
 	chicken.internal
-	chicken.keyword)
+	chicken.keyword
+	chicken.platform)
 
 (define-alias dd d)
 (define-alias dm d)
@@ -964,6 +965,7 @@
 (##sys#register-module-alias 'lolevel 'chicken.lolevel)
 (##sys#register-module-alias 'memory 'chicken.memory)
 (##sys#register-module-alias 'pathname 'chicken.pathname)
+(##sys#register-module-alias 'platform 'chicken.platform)
 (##sys#register-module-alias 'port 'chicken.port)
 (##sys#register-module-alias 'posix 'chicken.posix)
 (##sys#register-module-alias 'pretty-print 'chicken.pretty-print)
diff --git a/pathname.scm b/pathname.scm
index 00ac0ace..6c3a4804 100644
--- a/pathname.scm
+++ b/pathname.scm
@@ -49,7 +49,8 @@
 
 (import chicken scheme
         chicken.data-structures
-        chicken.irregex)
+        chicken.irregex
+	chicken.platform)
 
 (include "common-declarations.scm")
 
diff --git a/posix.scm b/posix.scm
index e3b2b189..7d6dc431 100644
--- a/posix.scm
+++ b/posix.scm
@@ -118,7 +118,7 @@
    with-output-to-pipe process process* pipe/buf process-group-id
    create-session)
 
-(import chicken scheme chicken.posix)
+(import chicken scheme chicken.posix chicken.platform)
 
 
 ;;; Like `system', but bombs on nonzero return code:
diff --git a/read-syntax.scm b/read-syntax.scm
index 6a97e075..9c002dd6 100644
--- a/read-syntax.scm
+++ b/read-syntax.scm
@@ -32,7 +32,7 @@
   (copy-read-table define-reader-ctor set-read-syntax!
    set-sharp-read-syntax! set-parameterized-read-syntax!)
 
-(import scheme chicken)
+(import scheme chicken chicken.platform)
 
 (include "common-declarations.scm")
 
diff --git a/rules.make b/rules.make
index 44dd0c4a..a3d97577 100644
--- a/rules.make
+++ b/rules.make
@@ -510,6 +510,7 @@ $(eval $(call declare-emitted-import-lib-dependency,chicken.fixnum,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.flonum,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.gc,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.keyword,library))
+$(eval $(call declare-emitted-import-lib-dependency,chicken.platform,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.time,library))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.format,extras))
 $(eval $(call declare-emitted-import-lib-dependency,chicken.io,extras))
@@ -538,6 +539,7 @@ batch-driver.c: batch-driver.scm mini-srfi-1.scm \
 		chicken.format.import.scm \
 		chicken.gc.import.scm \
 		chicken.pathname.import.scm \
+		chicken.platform.import.scm \
 		chicken.pretty-print.import.scm \
 		chicken.time.import.scm
 c-platform.c: c-platform.scm mini-srfi-1.scm \
@@ -608,7 +610,8 @@ support.c: support.scm mini-srfi-1.scm \
 modules.c: modules.scm \
 		chicken.expand.import.scm \
 		chicken.internal.import.scm \
-		chicken.keyword.import.scm
+		chicken.keyword.import.scm \
+		chicken.platform.import.scm
 csc.c: csc.scm \
 		chicken.data-structures.import.scm \
 		chicken.eval.import.scm \
@@ -621,6 +624,7 @@ csi.c: csi.scm \
 		chicken.format.import.scm \
 		chicken.gc.import.scm \
 		chicken.keyword.import.scm \
+		chicken.platform.import.scm \
 		chicken.io.import.scm \
 		chicken.port.import.scm \
 		chicken.pretty-print.import.scm \
@@ -631,6 +635,7 @@ chicken-bug.c: chicken-bug.scm \
 		chicken.io.import.scm \
 		chicken.keyword.import.scm \
 		chicken.pathname.import.scm \
+		chicken.platform.import.scm \
 		chicken.port.import.scm \
 		chicken.posix.import.scm \
 		chicken.time.import.scm
@@ -653,6 +658,7 @@ chicken-install.c: chicken-install.scm \
 		chicken.format.import.scm \
 		chicken.io.import.scm \
 		chicken.irregex.import.scm \
+		chicken.platform.import.scm \
 		chicken.pathname.import.scm \
 		chicken.port.import.scm \
 		chicken.posix.import.scm \
@@ -666,17 +672,21 @@ chicken-uninstall.c: chicken-uninstall.scm \
 		chicken.pathname.import.scm \
 		chicken.port.import.scm \
 		chicken.posix.import.scm
+chicken-syntax.c: chicken-syntax.scm \
+		chicken.platform.import.scm
 srfi-4.c: srfi-4.scm \
 		chicken.bitwise.import.scm \
 		chicken.expand.import.scm \
 		chicken.foreign.import.scm \
-		chicken.gc.import.scm
+		chicken.gc.import.scm \
+		chicken.platform.import.scm
 posixunix.c: posixunix.scm \
 		chicken.bitwise.import.scm \
 		chicken.foreign.import.scm \
 		chicken.irregex.import.scm \
 		chicken.memory.import.scm \
 		chicken.pathname.import.scm \
+		chicken.platform.import.scm \
 		chicken.port.import.scm \
 		chicken.time.import.scm
 posixwin.c: posixwin.scm \
@@ -685,12 +695,14 @@ posixwin.c: posixwin.scm \
 		chicken.irregex.import.scm \
 		chicken.memory.import.scm \
 		chicken.pathname.import.scm \
+		chicken.platform.import.scm \
 		chicken.port.import.scm \
 		chicken.time.import.scm
 data-structures.c: data-structures.scm \
 		chicken.foreign.import.scm
 expand.c: expand.scm \
 		chicken.keyword.import.scm \
+		chicken.platform.import.scm \
 		chicken.internal.import.scm
 extras.c: extras.scm \
 		chicken.data-structures.import.scm \
@@ -699,7 +711,8 @@ eval.c: eval.scm \
 		chicken.expand.import.scm \
 		chicken.foreign.import.scm \
 		chicken.internal.import.scm \
-		chicken.keyword.import.scm
+		chicken.keyword.import.scm \
+		chicken.platform.import.scm
 repl.c: repl.scm \
 		chicken.eval.import.scm
 file.c: file.scm \
@@ -715,9 +728,12 @@ lolevel.c: lolevel.scm \
 		chicken.foreign.import.scm
 pathname.c: pathname.scm \
 		chicken.data-structures.import.scm \
-		chicken.irregex.import.scm
+		chicken.irregex.import.scm \
+		chicken.platform.import.scm
 port.c: port.scm \
 		chicken.io.import.scm
+read-syntax.c: read-syntax.scm \
+		chicken.platform.import.scm
 tcp.c: tcp.scm \
 		chicken.foreign.import.scm \
 		chicken.port.import.scm \
@@ -736,6 +752,7 @@ library.c: $(SRCDIR)library.scm $(SRCDIR)banner.scm $(SRCDIR)common-declarations
 	-emit-import-library chicken.flonum \
 	-emit-import-library chicken.gc \
 	-emit-import-library chicken.keyword \
+	-emit-import-library chicken.platform \
 	-emit-import-library chicken.time
 internal.c: $(SRCDIR)internal.scm $(SRCDIR)mini-srfi-1.scm
 	$(bootstrap-lib) -emit-import-library chicken.internal
diff --git a/scripts/makedist.scm b/scripts/makedist.scm
index 01898ba8..2bf80f9f 100644
--- a/scripts/makedist.scm
+++ b/scripts/makedist.scm
@@ -1,7 +1,11 @@
 ;;;; makedist.scm - Make distribution tarballs
 
 
-(use data-structures files io irregex pathname posix setup-api (chicken process))
+(use data-structures files irregex posix setup-api
+     (chicken io)
+     (chicken pathname)
+     (chicken platform)
+     (chicken process))
 
 (include "mini-srfi-1.scm")
 
diff --git a/srfi-4.scm b/srfi-4.scm
index 3d532d80..22266c22 100644
--- a/srfi-4.scm
+++ b/srfi-4.scm
@@ -82,7 +82,8 @@ EOF
 (import chicken.bitwise
 	chicken.expand
 	chicken.foreign
-	chicken.gc)
+	chicken.gc
+	chicken.platform)
 
 (include "common-declarations.scm")
 
diff --git a/tests/apply-test.scm b/tests/apply-test.scm
index eb9dd915..563effab 100644
--- a/tests/apply-test.scm
+++ b/tests/apply-test.scm
@@ -1,4 +1,4 @@
-(require-extension format)
+(use format (chicken platform))
 
 (define (list-tabulate n proc)
   (let loop ((i 0))
diff --git a/tests/arithmetic-test.scm b/tests/arithmetic-test.scm
index 9584c693..36e6c136 100644
--- a/tests/arithmetic-test.scm
+++ b/tests/arithmetic-test.scm
@@ -15,9 +15,7 @@
   (else))
 
 
-(use pretty-print random)
-
-#+use-numbers (use numbers)
+(use pretty-print random (chicken platform))
 
 (define range 2)
 (define random-range 32000)
diff --git a/tests/fixnum-tests.scm b/tests/fixnum-tests.scm
index 3b4fb278..44648884 100644
--- a/tests/fixnum-tests.scm
+++ b/tests/fixnum-tests.scm
@@ -1,3 +1,5 @@
+(use (chicken platform))
+
 (define (fxo+ x y) (##core#inline "C_i_o_fixnum_plus" x y))
 (define (fxo- x y) (##core#inline "C_i_o_fixnum_difference" x y))
 
diff --git a/tests/lolevel-tests.scm b/tests/lolevel-tests.scm
index 7ec05541..1896b4cd 100644
--- a/tests/lolevel-tests.scm
+++ b/tests/lolevel-tests.scm
@@ -1,6 +1,6 @@
 ;;;; Unit lolevel testing
 
-(use chicken.memory format locative lolevel srfi-4)
+(use chicken.memory chicken.platform format locative lolevel srfi-4)
 
 (define-syntax assert-error
   (syntax-rules ()
diff --git a/tests/numbers-test.scm b/tests/numbers-test.scm
index af415abc..d494f8f6 100644
--- a/tests/numbers-test.scm
+++ b/tests/numbers-test.scm
@@ -2,7 +2,7 @@
 
 (include "test.scm")
 
-(use bitwise flonum format posix)
+(use bitwise flonum format posix (chicken platform))
 
 ;; The default "comparator" doesn't know how to deal with extended number types
 (current-test-comparator
diff --git a/tests/posix-tests.scm b/tests/posix-tests.scm
index ac4a36b7..83317848 100644
--- a/tests/posix-tests.scm
+++ b/tests/posix-tests.scm
@@ -1,5 +1,6 @@
 (import (chicken pathname)
         (chicken files)
+        (chicken platform)
         (chicken posix)
         (chicken lolevel))
 
diff --git a/tests/version-tests.scm b/tests/version-tests.scm
index f26d3d1d..92b8f288 100644
--- a/tests/version-tests.scm
+++ b/tests/version-tests.scm
@@ -1,4 +1,4 @@
-(use data-structures irregex)
+(use data-structures irregex chicken.platform)
 
 (let* ((version-tokens (string-split (chicken-version) "."))
        (major (string->number (car version-tokens)))
diff --git a/types.db b/types.db
index 668862d9..96c794d1 100644
--- a/types.db
+++ b/types.db
@@ -955,11 +955,9 @@
 (blob? (#(procedure #:pure #:predicate blob) blob? (*) boolean))
 
 (blob=? (#(procedure #:clean #:enforce #:foldable) blob=? (blob blob) boolean))
-(build-platform (#(procedure #:pure) build-platform () symbol))
 (call/cc (#(procedure #:enforce) call/cc ((procedure (*) . *)) . *))
 (case-sensitive (#(procedure #:clean) case-sensitive (#!optional *) *))
 (char-name (#(procedure #:clean #:enforce) char-name ((or char symbol) #!optional char) *)) ;XXX -> (or char symbol) ?
-(chicken-version (#(procedure #:pure) chicken-version (#!optional *) string))
 (command-line-arguments (#(procedure #:clean) command-line-arguments (#!optional (list-of string)) (list-of string)))
 (condition-predicate (#(procedure #:clean #:enforce) condition-predicate (symbol) (procedure ((struct condition)) boolean)))
 (condition-property-accessor (#(procedure #:clean #:enforce) condition-property-accessor (symbol symbol #!optional *) (procedure ((struct condition)) *)))
@@ -1042,8 +1040,6 @@
 (exit (procedure exit (#!optional fixnum) noreturn))
 (exit-handler (#(procedure #:clean #:enforce) exit-handler (#!optional (procedure (fixnum) . *)) procedure))
 (chicken.expand#expand (procedure chicken.expand#expand (* #!optional list) *))
-(feature? (#(procedure #:clean) feature? (#!rest symbol) boolean))
-(features (#(procedure #:clean) features () (list-of symbol)))
 (file-exists? (#(procedure #:clean #:enforce) file-exists? (string) (or false string)))
 (directory-exists? (#(procedure #:clean #:enforce) directory-exists? (string) (or false string)))
 
@@ -1220,6 +1216,20 @@
 (chicken.keyword#keyword? (#(procedure #:pure) chicken.keyword#keyword? (*) boolean))
 (chicken.keyword#string->keyword (#(procedure #:clean #:enforce) chicken.keyword#string->keyword (string) symbol))
 
+;; platform
+
+(chicken.platform#build-platform (#(procedure #:pure) chicken.platform#build-platform () symbol))
+(chicken.platform#chicken-version (#(procedure #:pure) chicken.platform#chicken-version (#!optional *) string))
+(chicken.platform#feature? (#(procedure #:clean) chicken.platform#feature? (#!rest symbol) boolean))
+(chicken.platform#features (#(procedure #:clean) chicken.platform#features () (list-of symbol)))
+(chicken.platform#software-type (#(procedure #:pure) chicken.platform#software-type () symbol))
+(chicken.platform#software-version (#(procedure #:pure) chicken.platform#software-version () symbol))
+(chicken.platform#register-feature! (#(procedure #:clean #:enforce) chicken.platform#register-feature! (#!rest symbol) undefined))
+(chicken.platform#unregister-feature! (#(procedure #:clean #:enforce) chicken.platform#unregister-feature! (#!rest symbol) undefined))
+(chicken.platform#machine-byte-order (#(procedure #:pure) chicken.platform#machine-byte-order () symbol))
+(chicken.platform#machine-type (#(procedure #:pure) chicken.platform#machine-type () symbol))
+
+
 (getter-with-setter
  (#(procedure #:clean #:enforce)
   getter-with-setter
@@ -1236,8 +1246,6 @@
   (struct transformer)))
 
 (keyword-style (#(procedure #:clean) keyword-style (#!optional symbol) symbol))
-(machine-byte-order (#(procedure #:pure) machine-byte-order () symbol))
-(machine-type (#(procedure #:pure) machine-type () symbol))
 
 (make-blob (#(procedure #:clean #:enforce) make-blob (fixnum) blob)
 	   ((fixnum) (##sys#make-blob #(1))))
@@ -1282,7 +1290,6 @@
 
 (quit (procedure quit (#!optional *) noreturn))
 
-(register-feature! (#(procedure #:clean #:enforce) register-feature! (#!rest symbol) undefined))
 (remprop! (#(procedure #:clean #:enforce) remprop! (symbol symbol) undefined))
 (rename-file (#(procedure #:clean #:enforce) rename-file (string string) string))
 (reset (procedure reset () noreturn))
@@ -1318,8 +1325,6 @@
 	((cplxnum) ((or float cplxnum)) (##sys#extended-signum #(1))))
 
 (sleep (#(procedure #:clean #:enforce) sleep (fixnum) undefined))
-(software-type (#(procedure #:pure) software-type () symbol))
-(software-version (#(procedure #:pure) software-version () symbol))
 (string->blob (#(procedure #:clean #:enforce) string->blob (string) blob))
 (string->uninterned-symbol (#(procedure #:clean #:enforce) string->uninterned-symbol (string) symbol))
 (chicken.expand#strip-syntax (#(procedure #:clean) chicken.expand#strip-syntax (*) *))
@@ -1342,7 +1347,6 @@
 
 (chicken.expand#syntax-error (procedure chicken.expand#syntax-error (* #!rest) noreturn))
 (system (#(procedure #:clean #:enforce) system (string) fixnum))
-(unregister-feature! (#(procedure #:clean #:enforce) unregister-feature! (#!rest symbol) undefined))
 (vector-resize
  (forall (a b) (#(procedure #:clean #:enforce) vector-resize ((vector-of a) fixnum #!optional b)
 	       (vector-of (or a b)))))
Trap