X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fstructeq%2F_info;h=1ac8d56ddcbf5e1defa01d86ace0f92f3002e3b3;hp=d66e2960c7183b97e3a5934f787890aa4e9fb9e9;hb=92be2eff52133138e4975308f6e731c46b53ace1;hpb=ac8694de3ef34483ce02811c1ba45096ee547a5f diff --git a/ccan/structeq/_info b/ccan/structeq/_info index d66e2960..1ac8d56d 100644 --- a/ccan/structeq/_info +++ b/ccan/structeq/_info @@ -6,9 +6,11 @@ * structeq - bitwise comparison of structs. * * This is a replacement for memcmp, which checks the argument types are the - * same. + * same, and takes into account padding in the structure. When there is no + * padding, it becomes a memcmp at compile time (assuming a + * constant-optimizing compiler). * - * License: CC0 (Public domain) + * License: BSD-MIT * Author: Rusty Russell * * Example: @@ -19,26 +21,22 @@ * struct mydata { * int start, end; * }; + * // Defines mydata_eq(a, b) + * STRUCTEQ_DEF(mydata, 0, start, end); * * int main(void) * { * struct mydata a, b; * - * // No padding in struct, otherwise this doesn't work! - * BUILD_ASSERT(sizeof(a) == sizeof(a.start) + sizeof(a.end)); - * * a.start = 100; * a.end = 101; * - * b.start = 100; - * b.end = 101; - * * // They are equal. - * assert(structeq(&a, &b)); + * assert(mydata_eq(&a, &b)); * * b.end++; * // Now they are not. - * assert(!structeq(&a, &b)); + * assert(!mydata_eq(&a, &b)); * * return 0; * } @@ -50,6 +48,8 @@ int main(int argc, char *argv[]) return 1; if (strcmp(argv[1], "depends") == 0) { + printf("ccan/build_assert\n"); + printf("ccan/cppmagic\n"); return 0; }