---
 urjtag/include/urjtag/bitops.h |   53 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
 create mode 100644 urjtag/include/urjtag/bitops.h

diff --git a/urjtag/include/urjtag/bitops.h b/urjtag/include/urjtag/bitops.h
new file mode 100644
index 0000000..2422d9e
--- /dev/null
+++ b/urjtag/include/urjtag/bitops.h
@@ -0,0 +1,53 @@
+/*
+ * $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
+
+inline uint16_t flip16 (uint16_t v);
+inline uint32_t flip32 (uint32_t v);
+
+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;
+}
+
+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 */
-- 
1.7.1


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to