This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/19500 ) Change subject: dahdi: Use osmo_revbytebits_buf() instead of local flip table ...................................................................... dahdi: Use osmo_revbytebits_buf() instead of local flip table We've had osmo_revbytebits_buf() in libosmocore for ages. As it recently turned out, the flip_bits[] lookup table approach implemented here is faster at least on x86 systems of the last decade or so. As of Change-Id I25029fe7e54c92979fb0119992fb8dc167e1536e in libosmocore, it has been migrated to the lookup table approach. This means there's no performance penalty of migrating to using it, and hence no reason whatsoever to have a private implementation here. Change-Id: I285a87a9fc6abae7d8b47923a46cd082f46829f8 --- M src/input/dahdi.c 1 file changed, 8 insertions(+), 41 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/src/input/dahdi.c b/src/input/dahdi.c index 0cbf9da..bf6da3e 100644 --- a/src/input/dahdi.c +++ b/src/input/dahdi.c @@ -329,33 +329,6 @@ static int invertbits = 1; -static uint8_t flip_table[256]; - -static void init_flip_bits(void) -{ - int i,k; - - for (i = 0 ; i < 256 ; i++) { - uint8_t sample = 0 ; - for (k = 0; k<8; k++) { - if ( i & 1 << k ) sample |= 0x80 >> k; - } - flip_table[i] = sample; - } -} - -static uint8_t * flip_buf_bits ( uint8_t * buf , int len) -{ - int i; - uint8_t * start = buf; - - for (i = 0 ; i < len; i++) { - buf[i] = flip_table[(uint8_t)buf[i]]; - } - - return start; -} - /* write to a B channel TS */ static int handle_tsX_write(struct osmo_fd *bfd) { @@ -376,9 +349,8 @@ LOGPITS(e1i_ts, DLMIB, LOGL_DEBUG, "BCHAN TX: %s\n", osmo_hexdump(tx_buf, D_BCHAN_TX_GRAN)); - if (invertbits) { - flip_buf_bits(tx_buf, ret); - } + if (invertbits) + osmo_revbytebits_buf(tx_buf, ret); ret = write(bfd->fd, tx_buf, ret); if (ret < D_BCHAN_TX_GRAN) @@ -407,9 +379,8 @@ return ret; } - if (invertbits) { - flip_buf_bits(msg->data, ret); - } + if (invertbits) + osmo_revbytebits_buf(msg->data, ret); msgb_put(msg, ret); @@ -447,9 +418,8 @@ LOGPITS(e1i_ts, DLMIB, LOGL_DEBUG, "RAW CHAN TX: %s\n", osmo_hexdump(msg->data, msg->len)); - if (0/*invertbits*/) { - flip_buf_bits(msg->data, msg->len); - } + if (0/*invertbits*/) + osmo_revbytebits_buf(msg->data, msg->len); ret = write(bfd->fd, msg->data, msg->len); if (ret < msg->len) @@ -476,9 +446,8 @@ return ret; } - if (0/*invertbits*/) { - flip_buf_bits(msg->data, ret); - } + if (0/*invertbits*/) + osmo_revbytebits_buf(msg->data, ret); msgb_put(msg, ret); @@ -763,8 +732,6 @@ int e1inp_dahdi_init(void) { - init_flip_bits(); - /* register the driver with the core */ return e1inp_driver_register(&dahdi_driver); } -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/19500 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I285a87a9fc6abae7d8b47923a46cd082f46829f8 Gerrit-Change-Number: 19500 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200802/2dec8ced/attachment.htm>