Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

buflib: omit CRC field if CRC paranoia is not enabled

If we don't check or generate CRCs then the CRC field can be left
out of the header, which reduces buflib overhead slightly.

Change-Id: I08b4cf77a701d8f6da453e019a0373d858a79ae4

+31 -1
+31 -1
firmware/buflib.c
··· 105 105 /* Bitmask of enabled paranoia checks */ 106 106 #define BUFLIB_PARANOIA 0 107 107 108 + #if BUFLIB_PARANOIA & PARANOIA_CHECK_CRC 109 + # define BUFLIB_HAS_CRC 110 + #endif 111 + 108 112 /* Forward indices, used to index a block start pointer as block[fidx_XXX] */ 109 113 enum { 110 114 fidx_LEN, /* length of the block, must come first */ ··· 116 120 /* Backward indices, used to index a block end pointer as block[-bidx_XXX] */ 117 121 enum { 118 122 bidx_USER, /* dummy to get below fields to be 1-based */ 123 + #ifdef BUFLIB_HAS_CRC 119 124 bidx_CRC, /* CRC, protects all metadata behind it */ 125 + #endif 120 126 bidx_BSIZE, /* total size of the block header */ 121 127 }; 122 128 123 129 /* Number of fields in the block header, excluding the name, which is 124 130 * accounted for using the BSIZE field. Note that bidx_USER is not an 125 131 * actual field so it is not included in the count. */ 126 - #define BUFLIB_NUM_FIELDS 5 132 + #ifdef BUFLIB_HAS_CRC 133 + # define BUFLIB_NUM_FIELDS 5 134 + #else 135 + # define BUFLIB_NUM_FIELDS 4 136 + #endif 127 137 128 138 struct buflib_callbacks buflib_ops_locked = { 129 139 .move_callback = NULL, ··· 1211 1221 } 1212 1222 } 1213 1223 1224 + #ifdef BUFLIB_HAS_CRC 1214 1225 static uint32_t calc_block_crc(union buflib_data *block, 1215 1226 union buflib_data *block_end) 1216 1227 { ··· 1247 1258 } 1248 1259 } 1249 1260 } 1261 + #else 1262 + static void update_block_crc(struct buflib_context *ctx, 1263 + union buflib_data *block, 1264 + union buflib_data *block_end) 1265 + { 1266 + (void)ctx; 1267 + (void)block; 1268 + (void)block_end; 1269 + } 1270 + 1271 + static void check_block_crc(struct buflib_context *ctx, 1272 + union buflib_data *block, 1273 + union buflib_data *block_end) 1274 + { 1275 + (void)ctx; 1276 + (void)block; 1277 + (void)block_end; 1278 + } 1279 + #endif