summaryrefslogtreecommitdiff
path: root/module/system/base/target.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-11-03 09:22:44 +0100
committerAndy Wingo <wingo@pobox.com>2017-11-05 15:00:16 +0100
commitecff426b8934e882e7e45ee8bfbf94e9d92120dc (patch)
treecc93de75257dfe45938759309af7241fdb449c05 /module/system/base/target.scm
parente8b883035d6febdbe5a98442c6cf01c5733ec79c (diff)
downloadguile-ecff426b8934e882e7e45ee8bfbf94e9d92120dc.tar.gz
(system base types) uses target's idea of max size_t
* module/system/base/target.scm (target-max-size-t): (target-max-size-t/scm, target-max-vector-length): New public functions. * module/language/cps/types.scm (type-entry-saturating-union): Remove restriction of polymorphic types to be within max-size-t; this could incorrectly apply constraints on numeric values. (&max/size, &max/scm-size): Use target-max-size-t. (*max-size-t*): Remove; replace uses with (target-max-size-t).
Diffstat (limited to 'module/system/base/target.scm')
-rw-r--r--module/system/base/target.scm28
1 files changed, 26 insertions, 2 deletions
diff --git a/module/system/base/target.scm b/module/system/base/target.scm
index e80bf84e4..34c9e8205 100644
--- a/module/system/base/target.scm
+++ b/module/system/base/target.scm
@@ -1,6 +1,6 @@
;;; Compilation targets
-;; Copyright (C) 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2012, 2013, 2014, 2017 Free Software Foundation, Inc.
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -26,7 +26,11 @@
target-cpu target-vendor target-os
- target-endianness target-word-size))
+ target-endianness target-word-size
+
+ target-max-size-t
+ target-max-size-t/scm
+ target-max-vector-length))
@@ -142,3 +146,23 @@
(define (target-word-size)
"Return the word size, in bytes, of the target platform."
(fluid-ref %target-word-size))
+
+(define (target-max-size-t)
+ "Return the maximum size_t value of the target platform, in bytes."
+ ;; Apply the currently-universal restriction of a maximum 48-bit
+ ;; address space.
+ (1- (ash 1 (min (* (target-word-size) 8) 48))))
+
+(define (target-max-size-t/scm)
+ "Return the maximum size_t value of the target platform, in units of
+SCM words."
+ ;; Apply the currently-universal restriction of a maximum 48-bit
+ ;; address space.
+ (/ (target-max-size-t) (target-word-size)))
+
+(define (target-max-vector-length)
+ "Return the maximum vector length of the target platform, in units of
+SCM words."
+ ;; Vector size fits in first word; the low 8 bits are taken by the
+ ;; type tag. Additionally, restrict to 48-bit address space.
+ (1- (ash 1 (min (- (* (target-word-size) 8) 8) 48))))