diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-05-06 23:37:40 +0200 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-05-06 23:37:40 +0200 |
commit | c263cfdcde0402cf44be7b14841d567f00e0af11 (patch) | |
tree | 311052b6ad6e391571f4e45631f5c3ca991b0cda /guix/build | |
parent | 3b7f3108e0ebd459ec9c75717988fc61755e7185 (diff) | |
parent | 13c18af1d835db11f3f4cf34e65c7da706625a3f (diff) |
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/build')
-rw-r--r-- | guix/build/syscalls.scm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 73b439fb7d..00d8ceb480 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -23,6 +23,7 @@ (define-module (guix build syscalls) #:use-module (system foreign) + #:use-module (system base target) #:use-module (rnrs bytevectors) #:autoload (ice-9 binary-ports) (get-bytevector-n) #:use-module (srfi srfi-1) @@ -194,9 +195,14 @@ (* (sizeof* type) n)) ((_ type) (let-syntax ((v (lambda (s) - (let ((val (sizeof type))) - (syntax-case s () - (_ val)))))) + ;; When compiling natively, call 'sizeof' at expansion + ;; time; otherwise, emit code to call it at run time. + (syntax-case s () + (_ + (if (= (target-word-size) + (with-target %host-type target-word-size)) + (sizeof type) + #'(sizeof type))))))) v)))) (define-syntax alignof* @@ -208,9 +214,14 @@ (alignof* type)) ((_ type) (let-syntax ((v (lambda (s) - (let ((val (alignof type))) - (syntax-case s () - (_ val)))))) + ;; When compiling natively, call 'sizeof' at expansion + ;; time; otherwise, emit code to call it at run time. + (syntax-case s () + (_ + (if (= (target-word-size) + (with-target %host-type target-word-size)) + (alignof type) + #'(alignof type))))))) v)))) (define-syntax align ;as found in (system foreign) |