mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
686 B
C
37 lines
686 B
C
11 years ago
|
/*
|
||
11 years ago
|
* Copyright 2004, Phil Karn, KA9Q
|
||
|
* May be used under the terms of the GNU Lesser General Public License (LGPL)
|
||
|
*/
|
||
|
|
||
|
|
||
|
#ifdef __x86_64__
|
||
|
#define __i386__
|
||
|
#endif
|
||
|
|
||
|
/* Determine parity of argument: 1 = odd, 0 = even */
|
||
|
#ifdef __i386__
|
||
11 years ago
|
static inline uint32_t parityb(uint8_t x){
|
||
11 years ago
|
__asm__ __volatile__ ("test %1,%1;setpo %0" : "=qhm" (x) : "qh" (x));
|
||
11 years ago
|
return x;
|
||
|
}
|
||
|
#else
|
||
|
void partab_init();
|
||
|
|
||
11 years ago
|
static inline uint32_t parityb(uint8_t x){
|
||
|
extern uint8_t Partab[256];
|
||
|
extern uint32_t P_init;
|
||
11 years ago
|
if(!P_init){
|
||
|
partab_init();
|
||
|
}
|
||
|
return Partab[x];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
|
||
11 years ago
|
static inline uint32_t parity(int x){
|
||
11 years ago
|
/* Fold down to one byte */
|
||
|
x ^= (x >> 16);
|
||
|
x ^= (x >> 8);
|
||
|
return parityb(x);
|
||
|
}
|