guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. v2.1.0-266-gcff1d39


From: Ken Raeburn
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-266-gcff1d39
Date: Mon, 21 May 2012 05:14:07 +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=cff1d39b2003470b5dcdab988e279587ae2eed8c

The branch, master has been updated
       via  cff1d39b2003470b5dcdab988e279587ae2eed8c (commit)
      from  a722bcaa13acd3185e8e7b84f64cb614a46f3532 (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 cff1d39b2003470b5dcdab988e279587ae2eed8c
Author: Ken Raeburn <address@hidden>
Date:   Mon May 21 00:30:45 2012 -0400

    Fix FFI struct sizing to account for trailing padding.
    
    * libguile/foreign.c (scm_sizeof): Make sure the overall size is a
      multiple of the alignment of the structure.
    * test-suite/tests/foreign.test: Test size of { double, int8 }.

-----------------------------------------------------------------------

Summary of changes:
 libguile/foreign.c            |    3 ++-
 test-suite/tests/foreign.test |    4 ++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/libguile/foreign.c b/libguile/foreign.c
index 00e9c75..8329131 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -536,13 +536,14 @@ SCM_DEFINE (scm_sizeof, "sizeof", 1, 0, 0, (SCM type),
     {
       /* a struct */
       size_t off = 0;
+      size_t align = scm_to_size_t (scm_alignof(type));
       while (scm_is_pair (type))
         {
           off = ROUND_UP (off, scm_to_size_t (scm_alignof (scm_car (type))));
           off += scm_to_size_t (scm_sizeof (scm_car (type)));
           type = scm_cdr (type);
         }
-      return scm_from_size_t (off);
+      return scm_from_size_t (ROUND_UP(off, align));
     }
   else
     scm_wrong_type_arg (FUNC_NAME, 1, type);
diff --git a/test-suite/tests/foreign.test b/test-suite/tests/foreign.test
index 6eafe95..47686ee 100644
--- a/test-suite/tests/foreign.test
+++ b/test-suite/tests/foreign.test
@@ -303,6 +303,10 @@
     (= (sizeof (list int8 double))
        (+ (alignof double) (sizeof double))))
 
+  (pass-if "sizeof { double, int8 }"
+    (= (sizeof (list double int8))
+       (+ (alignof double) (sizeof double))))
+
   (pass-if "sizeof { short, int, long, pointer }"
     (let ((layout (list short int long '*)))
       (>= (sizeof layout)


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]