From c56d099afde2f4081eaa4972b76f8a65b728babb Mon Sep 17 00:00:00 2001 From: ismagom Date: Mon, 9 Jun 2014 18:59:57 +0100 Subject: [PATCH] Compute parity without using assembler --- lte/lib/fec/src/parity.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lte/lib/fec/src/parity.c diff --git a/lte/lib/fec/src/parity.c b/lte/lib/fec/src/parity.c new file mode 100644 index 000000000..568994888 --- /dev/null +++ b/lte/lib/fec/src/parity.c @@ -0,0 +1,29 @@ +/* + * Copyright 2004, Phil Karn, KA9Q + * May be used under the terms of the GNU Lesser General Public License (LGPL) + */ + +#include + +unsigned char Partab[256]; +int P_init; + +/* Create 256-entry odd-parity lookup table + * Needed only on non-ia32 machines + */ +void partab_init(void) { + int i, cnt, ti; + + /* Initialize parity lookup table */ + for (i = 0; i < 256; i++) { + cnt = 0; + ti = i; + while (ti) { + if (ti & 1) + cnt++; + ti >>= 1; + } + Partab[i] = cnt & 1; + } + P_init = 1; +}