X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fstructeq%2Fstructeq.h;h=81799539c51e45f9c2f1b9c23a1b3949b47564c1;hp=6b90754c73a92fe3d203644ba9b075c8b0f5fcbd;hb=8e6c2fecfd633171250b7f09ef4aa0328bd5b698;hpb=92be2eff52133138e4975308f6e731c46b53ace1 diff --git a/ccan/structeq/structeq.h b/ccan/structeq/structeq.h index 6b90754c..81799539 100644 --- a/ccan/structeq/structeq.h +++ b/ccan/structeq/structeq.h @@ -9,14 +9,15 @@ /** * STRUCTEQ_DEF - define an ..._eq function to compare two structures. * @sname: name of the structure, and function (_eq) to define. - * @padbytes: number of bytes of expected padding, or -1 if unknown. + * @padbytes: number of bytes of expected padding, or negative "max". * @...: name of every member of the structure. * * This generates a single memcmp() call in the common case where the * structure contains no padding. Since it can't tell the difference between * padding and a missing member, @padbytes can be used to assert that - * there isn't any, or how many we expect. -1 means "expect some", since - * it can be platform dependent. + * there isn't any, or how many we expect. A negative number means + * "up to or equal to that amount of padding", as padding can be + * platform dependent. */ #define STRUCTEQ_DEF(sname, padbytes, ...) \ static inline bool CPPMAGIC_GLUE2(sname, _eq)(const struct sname *_a, \ @@ -25,7 +26,7 @@ static inline bool CPPMAGIC_GLUE2(sname, _eq)(const struct sname *_a, \ BUILD_ASSERT(((padbytes) < 0 && \ CPPMAGIC_JOIN(+, CPPMAGIC_MAP(STRUCTEQ_MEMBER_SIZE_, \ __VA_ARGS__)) \ - > sizeof(*_a)) \ + - (padbytes) >= sizeof(*_a)) \ || CPPMAGIC_JOIN(+, CPPMAGIC_MAP(STRUCTEQ_MEMBER_SIZE_, \ __VA_ARGS__)) \ + (padbytes) == sizeof(*_a)); \