Relax `asm-to-bytecode.test' for when target CPU == native CPU.
authorLudovic Courtès <ludo@gnu.org>
Sat, 21 Jan 2012 15:35:58 +0000 (16:35 +0100)
committerLudovic Courtès <ludo@gnu.org>
Sun, 22 Jan 2012 22:23:44 +0000 (23:23 +0100)
* test-suite/tests/asm-to-bytecode.test (native-cpu, native-word-size):
  New procedures.
  (test-target): When the target is the native CPU, use the native word
  size instead of WORD-SIZE.

test-suite/tests/asm-to-bytecode.test

index edb9bfd..d36b33d 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; Assembly to bytecode compilation -*- mode: scheme; coding: utf-8; -*-
 ;;;;
-;;;;   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+;;;;   Copyright (C) 2010, 2011, 2012 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
                (string=? (target-vendor) vendor)
                (string=? (target-os) os)))))))
 
+(define (native-cpu)
+  (with-target %host-type target-cpu))
+
+(define (native-word-size)
+  ((@ (system foreign) sizeof) '*))
+
 (define %objcode-cookie-size
   (string-length "GOOF----LE-8-2.0"))
 
       (lambda (p get-objcode)
         (with-target triplet
           (lambda ()
-            (let ((b (compile-bytecode
+            (let ((word-size
+                   ;; When the target is the native CPU, rather trust
+                   ;; the native CPU's word size.  This is because
+                   ;; Debian's `sparc64-linux-gnu' port, for instance,
+                   ;; actually has a 32-bit user-land, for instance (see
+                   ;; <http://www.debian.org/ports/sparc/#sparc64bit>
+                   ;; for details.)
+                   (if (string=? (native-cpu) (target-cpu))
+                       (native-word-size)
+                       word-size))
+                  (b (compile-bytecode
                       '(load-program () 16 #f
                                      (assert-nargs-ee/locals 1)
                                      (make-int8 77)