Dear Graeme Russ, In message <CALButCJF1p+60WOLtiJqhcAed-71VxmP2mBqY2wdNURPk5=q...@mail.gmail.com> you wrote: > > >> > it's fairly easy as well: > >> > #define CIRC_BUF_IDX(idx) ((idx) & (CONFIG_SYS_TMP_CON_BUF_SZ-1)) > >> > buffer[CIRC_BUF_IDX(gd->conf_buf_idx++)] = c; > >> > >> But does that work for non power-of-two buffer sizes... > > > > no, but not that big of a deal. so you get limited to the last 1KiB, 4KiB, > > 8KiB, 16KiB, etc... amount of data. > > Until someone doesn't read the documentation and figures they can only > squeeze 200 bytes out of their L1 cache after making room for gd and stack > and then tries to print 201 bytes of debug info and trashes either the > stack or gd and then things start to get a lot weirder than simply having > their early debug messgaes clipped... > > To be safe, CONFIG_SYS_TMP_CON_BUF_SZ would need to be checked for ^2 size > and now we only get 128 bytes rather than 200 :( - Better to add another > long in gd and get 196
Grrrgh. If you want to support arbitrary buffer sizes, then just use #define CIRC_BUF_IDX(idx) ((idx) % CONFIG_SYS_TMP_CON_BUF_SZ) Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Use C++ to confuse your enemies; use C to produce stable code. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot