lib/diff: Add compile-time ABI check on 64 bit arches
authorColin Walters <walters@verbum.org>
Wed, 27 Sep 2017 17:15:06 +0000 (13:15 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 27 Sep 2017 18:20:10 +0000 (18:20 +0000)
Like what was done for most of the `ostree-repo.h` values.  Prep
for adding a new option.

Closes: #1223
Approved by: jlebon

src/libostree/ostree-diff.c
src/libostree/ostree-diff.h
src/libostree/ostree-repo.c

index 064b873c2ecdc18fedcdf35a34a2ebf9da886c22..0c6cb0e7a000db266484cab25720af984c7586e8 100644 (file)
 #include "ostree-repo-private.h"
 #include "otutil.h"
 
+/* See ostree-repo.c for a bit more info about these ABI checks */
+#if __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 8 && __SIZEOF_INT__ == 4
+G_STATIC_ASSERT(sizeof(OstreeDiffDirsOptions) ==
+                sizeof(int) * 2 +
+                sizeof(gpointer) +
+                sizeof(int) * (7+6) +
+                sizeof(int) +  /* hole */
+                sizeof(gpointer) * 7);
+#endif
+
 static gboolean
 get_file_checksum (OstreeDiffFlags  flags,
                    GFile *f,
index 6e324e2ac16c8b61f58d17ee240e48345267ef96..64fd7f8bc99d9c1b9bbcc0e7e6fb2dcd5a471b05 100644 (file)
@@ -85,6 +85,7 @@ typedef struct {
 
   gboolean unused_bools[7];
   int unused_ints[6];
+  /* 4 byte hole on 64 bit */
   gpointer unused_ptrs[7];
 } OstreeDiffDirsOptions;
 
index 82c01e05ae45ce51ef0bff74037213f8b71365ff..e02ea87aeeab2de2f9e1d4a898b7879188fb3244 100644 (file)
 
 /* ABI Size checks for ostree-repo.h, only for LP64 systems;
  * https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
+ *
+ * To generate this data, I used `pahole` from gdb. More concretely, `gdb --args
+ * /usr/bin/ostree`, then `start`, (to ensure debuginfo was loaded), then e.g.
+ * `$ pahole OstreeRepoTransactionStats`.
  */
 #if __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 8 && __SIZEOF_INT__ == 4
 G_STATIC_ASSERT(sizeof(OstreeRepoTransactionStats) == sizeof(int) * 4 + 8 * 5);