new generic bit operations by Michael Walle

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1850 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent 924288c8d9
commit 91bd7afa7f

@ -12,6 +12,9 @@
* configure.ac: Change to newer libtool macro (LT_INIT) to avoid warnings.
* acinclude.m4: Redirect LT_INIT to AC_PROG_LIBTOOL for older libtools.
* include/urjtag/bitops.h: New generic bit operations by Michael Walle.
* include/urjtag/Makefile.am (pkginclude_HEADERS): Add bitops.h
2010-08-30 Mike Frysinger <vapier@gentoo.org>
* configure.ac: Clean up libusb detection to prefer 1.0 over 0.1, and accept

@ -26,6 +26,7 @@ include $(top_srcdir)/Makefile.rules
pkginclude_HEADERS = \
bfin.h \
bitmask.h \
bitops.h \
bsbit.h \
bsdl.h \
bsdl_mode.h \

@ -0,0 +1,54 @@
/*
* $Id$
*
* Copyright (C) 2010, Michael Walle
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#ifndef URJ_BITOPS_H
#define URJ_BITOPS_H
#include <stdint.h>
static inline uint16_t flip16 (uint16_t v)
{
int i;
uint16_t out = 0;
/* flip bits (from left to right) */
for (i = 0; i < 16; i++)
if (v & (1 << i))
out |= (1 << (15 - i));
return out;
}
static inline uint32_t flip32 (uint32_t v)
{
int i;
uint32_t out = 0;
/* flip bits (from left to right) */
for (i = 0; i < 32; i++)
if (v & (1 << i))
out |= (1 << (31 - i));
return out;
}
#endif /* URJ_BITOPS_H */
Loading…
Cancel
Save