Merge remote-tracking branch 'origin/master'
authorAndy Wingo <wingo@pobox.com>
Mon, 21 May 2012 17:20:55 +0000 (19:20 +0200)
committerAndy Wingo <wingo@pobox.com>
Mon, 21 May 2012 17:20:55 +0000 (19:20 +0200)
libguile/foreign.c
libguile/weak-set.c
libguile/weak-table.c
test-suite/tests/foreign.test

index 00e9c75..8329131 100644 (file)
@@ -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);
index bdabedf..33402b5 100644 (file)
@@ -362,7 +362,7 @@ resize_set (scm_t_weak_set *set)
          run anything, so drop our lock to avoid deadlocks.  */
       new_entries = scm_gc_malloc_pointerless (new_size * sizeof(scm_t_weak_entry),
                                                "weak set");
-      scm_i_pthread_mutex_unlock (&set->lock);
+      scm_i_pthread_mutex_lock (&set->lock);
     }
   while (!is_acceptable_size_index (set, new_size_index));
 
index 6a3fecd..be73e1b 100644 (file)
@@ -484,7 +484,7 @@ resize_table (scm_t_weak_table *table)
       /* Allocating memory might cause finalizers to run, which could
          run anything, so drop our lock to avoid deadlocks.  */
       new_entries = allocate_entries (new_size, table->kind);
-      scm_i_pthread_mutex_unlock (&table->lock);
+      scm_i_pthread_mutex_lock (&table->lock);
     }
   while (!is_acceptable_size_index (table, new_size_index));
 
index 6eafe95..47686ee 100644 (file)
     (= (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)