2014-06-09 10:59:57 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2004, Phil Karn, KA9Q
|
2015-05-08 08:05:40 -07:00
|
|
|
* May be used under the terms of the GNU Affero General Public License (LGPL)
|
2014-06-09 10:59:57 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2014-07-05 12:00:32 -07:00
|
|
|
#include <stdint.h>
|
2014-06-09 10:59:57 -07:00
|
|
|
|
2014-07-05 12:00:32 -07:00
|
|
|
uint8_t Partab[256];
|
|
|
|
uint32_t P_init;
|
2014-06-09 10:59:57 -07:00
|
|
|
|
|
|
|
/* Create 256-entry odd-parity lookup table
|
|
|
|
* Needed only on non-ia32 machines
|
|
|
|
*/
|
|
|
|
void partab_init(void) {
|
2014-07-05 12:00:32 -07:00
|
|
|
uint32_t i, cnt, ti;
|
2014-06-09 10:59:57 -07:00
|
|
|
|
2014-07-05 12:00:32 -07:00
|
|
|
/* Initialize parity lookup table */
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
cnt = 0;
|
|
|
|
ti = i;
|
|
|
|
while (ti) {
|
|
|
|
if (ti & 1)
|
|
|
|
cnt++;
|
2016-08-29 15:49:31 -07:00
|
|
|
ti >>= 1;
|
2014-07-05 12:00:32 -07:00
|
|
|
}
|
|
|
|
Partab[i] = cnt & 1;
|
|
|
|
}
|
|
|
|
P_init = 1;
|
2014-06-09 10:59:57 -07:00
|
|
|
}
|