···105105/* Bitmask of enabled paranoia checks */
106106#define BUFLIB_PARANOIA 0
107107108108+#if BUFLIB_PARANOIA & PARANOIA_CHECK_CRC
109109+# define BUFLIB_HAS_CRC
110110+#endif
111111+108112/* Forward indices, used to index a block start pointer as block[fidx_XXX] */
109113enum {
110114 fidx_LEN, /* length of the block, must come first */
···116120/* Backward indices, used to index a block end pointer as block[-bidx_XXX] */
117121enum {
118122 bidx_USER, /* dummy to get below fields to be 1-based */
123123+#ifdef BUFLIB_HAS_CRC
119124 bidx_CRC, /* CRC, protects all metadata behind it */
125125+#endif
120126 bidx_BSIZE, /* total size of the block header */
121127};
122128123129/* Number of fields in the block header, excluding the name, which is
124130 * accounted for using the BSIZE field. Note that bidx_USER is not an
125131 * actual field so it is not included in the count. */
126126-#define BUFLIB_NUM_FIELDS 5
132132+#ifdef BUFLIB_HAS_CRC
133133+# define BUFLIB_NUM_FIELDS 5
134134+#else
135135+# define BUFLIB_NUM_FIELDS 4
136136+#endif
127137128138struct buflib_callbacks buflib_ops_locked = {
129139 .move_callback = NULL,
···12111221 }
12121222}
1213122312241224+#ifdef BUFLIB_HAS_CRC
12141225static uint32_t calc_block_crc(union buflib_data *block,
12151226 union buflib_data *block_end)
12161227{
···12471258 }
12481259 }
12491260}
12611261+#else
12621262+static void update_block_crc(struct buflib_context *ctx,
12631263+ union buflib_data *block,
12641264+ union buflib_data *block_end)
12651265+{
12661266+ (void)ctx;
12671267+ (void)block;
12681268+ (void)block_end;
12691269+}
12701270+12711271+static void check_block_crc(struct buflib_context *ctx,
12721272+ union buflib_data *block,
12731273+ union buflib_data *block_end)
12741274+{
12751275+ (void)ctx;
12761276+ (void)block;
12771277+ (void)block_end;
12781278+}
12791279+#endif