[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-94-g514642
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-94-g514642d |
Date: |
Thu, 10 Mar 2011 21:34:30 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=514642d3c7b5406952e5461918b718e13a06a2c1
The branch, stable-2.0 has been updated
via 514642d3c7b5406952e5461918b718e13a06a2c1 (commit)
via d82f8518b96bbfa4f29e03d922369c37b64824d9 (commit)
from dd36ce77cd899c7b179026603e751e3bb47b2943 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 514642d3c7b5406952e5461918b718e13a06a2c1
Author: Ludovic Courtès <address@hidden>
Date: Thu Mar 10 22:24:40 2011 +0100
Thanks, Aidan.
commit d82f8518b96bbfa4f29e03d922369c37b64824d9
Author: Ludovic Courtès <address@hidden>
Date: Thu Mar 10 22:24:23 2011 +0100
FFI: Return the right alignment for structures.
* libguile/foreign.c (scm_alignof): Fix handling of structure alignment.
Reported by Aidan Gauland <address@hidden>.
* test-suite/tests/foreign.test ("structs")["alignof { int8, double,
int8 }", "int8, { int8, double, int8 }, int16"]: New tests.
-----------------------------------------------------------------------
Summary of changes:
THANKS | 1 +
libguile/foreign.c | 20 ++++++++++++++++++--
test-suite/tests/foreign.test | 12 ++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/THANKS b/THANKS
index f912c7b..a06ba4a 100644
--- a/THANKS
+++ b/THANKS
@@ -62,6 +62,7 @@ For fixes or providing information which led to a fix:
Barry Fishman
Charles Gagnon
Fu-gangqiang
+ Aidan Gauland
Peter Gavin
Nils Gey
Eric Gillespie, Jr
diff --git a/libguile/foreign.c b/libguile/foreign.c
index 6f008e7..0f07c60 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -402,8 +402,24 @@ SCM_DEFINE (scm_alignof, "alignof", 1, 0, 0, (SCM type),
/* a pointer */
return scm_from_size_t (alignof (void*));
else if (scm_is_pair (type))
- /* a struct, yo */
- return scm_alignof (scm_car (type));
+ {
+ /* TYPE is a structure. Section 3-3 of the i386, x86_64, PowerPC,
+ and SPARC P.S. of the System V ABI all say: "Aggregates
+ (structures and arrays) and unions assume the alignment of
+ their most strictly aligned component." */
+ size_t max;
+
+ for (max = 0; scm_is_pair (type); type = SCM_CDR (type))
+ {
+ size_t align;
+
+ align = scm_to_size_t (scm_alignof (SCM_CAR (type)));
+ if (align > max)
+ max = align;
+ }
+
+ return scm_from_size_t (max);
+ }
else
scm_wrong_type_arg (FUNC_NAME, 1, type);
}
diff --git a/test-suite/tests/foreign.test b/test-suite/tests/foreign.test
index 3569c8a..b053639 100644
--- a/test-suite/tests/foreign.test
+++ b/test-suite/tests/foreign.test
@@ -228,6 +228,11 @@
(>= (sizeof layout)
(reduce + 0.0 (map sizeof layout)))))
+ (pass-if "alignof { int8, double, int8 }"
+ ;; alignment of the most strictly aligned component
+ (let ((layout (list int8 double int8)))
+ (= (alignof layout) (alignof double))))
+
(pass-if "parse-c-struct"
(let ((layout (list int64 uint8))
(data (list -300 43)))
@@ -268,4 +273,11 @@
(data (list 77 %null-pointer -42 3.14)))
(equal? (parse-c-struct (make-c-struct layout data)
layout)
+ data)))
+
+ (pass-if "int8, { int8, double, int8 }, int16"
+ (let ((layout (list int8 (list int8 double int8) int16))
+ (data (list 77 (list 42 4.2 55) 88)))
+ (equal? (parse-c-struct (make-c-struct layout data)
+ layout)
data))))
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-94-g514642d,
Ludovic Courtès <=