On 27 February 2013 07:15, Kuo-Jung Su <dant...@gmail.com> wrote: > From: Kuo-Jung Su <dant...@faraday-tech.com> > > Some ethernet mac relies on the bit ordering reversal functions > to performance the multicast address hash code calculation. > So I've ported the bitrev.[ch] from linux kernel into QEMU. > > Signed-off-by: Kuo-Jung Su <dant...@faraday-tech.com> > --- > include/qemu/bitrev.h | 25 +++++++++++++++++++++ > util/Makefile.objs | 2 +- > util/bitrev.c | 59 > +++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 85 insertions(+), 1 deletion(-) > create mode 100644 include/qemu/bitrev.h > create mode 100644 util/bitrev.c > > diff --git a/include/qemu/bitrev.h b/include/qemu/bitrev.h > new file mode 100644 > index 0000000..7d570c2 > --- /dev/null > +++ b/include/qemu/bitrev.h
There's no need for a new header just for these three functions: put them in include/qemu/bitops.h. Similarly, the implementations should go in utils/bitops.c. There is a minor snag that bitops.[ch] are LGPL2.1+ and this code is GPL2, but since LGPL lets you "upgrade" the LGPL code to GPL, we can just mark the whole of bitops.[ch] as GPL by updating the license statement at the top. I've cc'd Anthony to advise on the specific mechanics of doing that. > @@ -0,0 +1,25 @@ > +/* > + * Bit ordering reversal functions (From linux-kernel/include/linux/bitrev.h) > + * > + * Written by Akinobu Mita <akinobu.m...@gmail.com> > + * Ported to QEMU by Kuo-Jung Su <dant...@gmail.com> > + * > + * This code is licensed under GNU GPL > + */ > + > +#ifndef BITREV_H > +#define BITREV_H > + > +#include "qemu-common.h" > + > +extern uint8_t const byte_rev_table[256]; > + > +static inline uint8_t bitrev8(uint8_t byte) > +{ > + return byte_rev_table[byte]; > +} > + > +extern uint16_t bitrev16(uint16_t in); > +extern uint32_t bitrev32(uint32_t in); Please provide documentation comments for all these functions (in the header file, not in the .c file). thanks -- PMM