aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-02-04 03:44:44 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-02-04 03:44:44 +0000
commit5ea3259964cf5639c1b1cc8e8189473eb23857d7 (patch)
treeba0f54342a2e6628a1d2d9d38a8aa2dc3bd136f8
parentb6f7ab0efa52e66ab9989d1cad5ae9380893e551 (diff)
downloadpaludis-5ea3259964cf5639c1b1cc8e8189473eb23857d7.tar.gz
paludis-5ea3259964cf5639c1b1cc8e8189473eb23857d7.tar.xz
Move byte_swap into paludis/util/.
-rw-r--r--paludis/util/byte_swap.hh80
-rw-r--r--paludis/util/byte_swap_TEST.cc (renamed from src/clients/reconcilio/util/byte_swap_TEST.cc)0
-rw-r--r--paludis/util/files.m41
-rw-r--r--src/clients/reconcilio/littlelf/elf.cc3
-rw-r--r--src/clients/reconcilio/littlelf/elf_dynamic_section.cc3
-rw-r--r--src/clients/reconcilio/littlelf/elf_relocation_section.cc3
-rw-r--r--src/clients/reconcilio/littlelf/elf_symbol_section.cc3
-rw-r--r--src/clients/reconcilio/util/Makefile.am12
-rw-r--r--src/clients/reconcilio/util/byte_swap.hh74
9 files changed, 87 insertions, 92 deletions
diff --git a/paludis/util/byte_swap.hh b/paludis/util/byte_swap.hh
new file mode 100644
index 0000000..b19fce3
--- /dev/null
+++ b/paludis/util/byte_swap.hh
@@ -0,0 +1,80 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007, 2008 David Leverton
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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 PALUDIS_GUARD_PALUDIS_UTIL_BYTE_SWAP_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_BYTE_SWAP_HH
+
+#include <cstddef>
+
+namespace paludis
+{
+ namespace byte_swap_internals
+ {
+ template <std::size_t, typename> struct ByteSwap;
+
+ template <typename T_>
+ struct ByteSwap<1, T_>
+ {
+ static T_ swap(T_ x)
+ {
+ return x;
+ }
+ };
+
+ template <typename T_>
+ struct ByteSwap<2, T_>
+ {
+ static T_ swap(T_ x)
+ {
+ return ((x << 8) & (T_(0xFF) << 8)) | ((x >> 8) & T_(0xFF));
+ }
+ };
+
+ template <typename T_>
+ struct ByteSwap<4, T_>
+ {
+ static T_ swap(T_ x)
+ {
+ return ((x << 24) & (T_(0xFF) << 24)) | ((x << 8) & (T_(0xFF) << 16))
+ | ((x >> 8) & (T_(0xFF) << 8)) | ((x >> 24) & T_(0xFF) );
+ }
+ };
+
+ template <typename T_>
+ struct ByteSwap<8, T_>
+ {
+ static T_ swap(T_ x)
+ {
+ return ((x << 56) & (T_(0xFF) << 56)) | ((x << 40) & (T_(0xFF) << 48))
+ | ((x << 24) & (T_(0xFF) << 40)) | ((x << 8) & (T_(0xFF) << 32))
+ | ((x >> 8) & (T_(0xFF) << 24)) | ((x >> 24) & (T_(0xFF) << 16))
+ | ((x >> 40) & (T_(0xFF) << 8)) | ((x >> 56) & T_(0xFF) );
+ }
+ };
+ }
+
+ template <typename T_>
+ inline T_
+ byte_swap(T_ x)
+ {
+ return byte_swap_internals::ByteSwap<sizeof(T_), T_>::swap(x);
+ }
+}
+
+#endif
diff --git a/src/clients/reconcilio/util/byte_swap_TEST.cc b/paludis/util/byte_swap_TEST.cc
index aad78b9..aad78b9 100644
--- a/src/clients/reconcilio/util/byte_swap_TEST.cc
+++ b/paludis/util/byte_swap_TEST.cc
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 76f0eda..af83b22 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -10,6 +10,7 @@ dnl on this file at present...
add(`action_queue', `hh', `cc', `test')
add(`attributes', `hh')
+add(`byte_swap', `hh', `test')
add(`config_file', `hh', `cc', `se', `test', `testscript')
add(`clone', `hh', `impl')
add(`condition_variable', `hh', `cc', `test')
diff --git a/src/clients/reconcilio/littlelf/elf.cc b/src/clients/reconcilio/littlelf/elf.cc
index 069e536..62e73f6 100644
--- a/src/clients/reconcilio/littlelf/elf.cc
+++ b/src/clients/reconcilio/littlelf/elf.cc
@@ -26,8 +26,7 @@
#include "elf_symbol_section.hh"
#include "elf_types.hh"
-#include <src/clients/reconcilio/util/byte_swap.hh>
-
+#include <paludis/util/byte_swap.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
diff --git a/src/clients/reconcilio/littlelf/elf_dynamic_section.cc b/src/clients/reconcilio/littlelf/elf_dynamic_section.cc
index 1bb282d..e200424 100644
--- a/src/clients/reconcilio/littlelf/elf_dynamic_section.cc
+++ b/src/clients/reconcilio/littlelf/elf_dynamic_section.cc
@@ -22,8 +22,7 @@
#include "elf_types.hh"
#include "elf.hh"
-#include <src/clients/reconcilio/util/byte_swap.hh>
-
+#include <paludis/util/byte_swap.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
diff --git a/src/clients/reconcilio/littlelf/elf_relocation_section.cc b/src/clients/reconcilio/littlelf/elf_relocation_section.cc
index 3bc72c3..ea610e4 100644
--- a/src/clients/reconcilio/littlelf/elf_relocation_section.cc
+++ b/src/clients/reconcilio/littlelf/elf_relocation_section.cc
@@ -22,8 +22,7 @@
#include "elf_types.hh"
#include "elf.hh"
-#include <src/clients/reconcilio/util/byte_swap.hh>
-
+#include <paludis/util/byte_swap.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
diff --git a/src/clients/reconcilio/littlelf/elf_symbol_section.cc b/src/clients/reconcilio/littlelf/elf_symbol_section.cc
index 7cb08d5..5718d7f 100644
--- a/src/clients/reconcilio/littlelf/elf_symbol_section.cc
+++ b/src/clients/reconcilio/littlelf/elf_symbol_section.cc
@@ -22,8 +22,7 @@
#include "elf_types.hh"
#include "elf.hh"
-#include <src/clients/reconcilio/util/byte_swap.hh>
-
+#include <paludis/util/byte_swap.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
diff --git a/src/clients/reconcilio/util/Makefile.am b/src/clients/reconcilio/util/Makefile.am
index 64f3a23..9735544 100644
--- a/src/clients/reconcilio/util/Makefile.am
+++ b/src/clients/reconcilio/util/Makefile.am
@@ -6,15 +6,14 @@ noinst_LIBRARIES = libreconcilioutil.a
libreconcilioutil_a_SOURCES = \
realpath.cc realpath.hh \
- wildcard_expander.cc wildcard_expander.hh \
- byte_swap.hh
+ wildcard_expander.cc wildcard_expander.hh
TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
bash $(top_srcdir)/test/run_test.sh bash
-TESTS = realpath_TEST wildcard_expander_TEST byte_swap_TEST
+TESTS = realpath_TEST wildcard_expander_TEST
check_PROGRAMS = $(TESTS)
EXTRA_DIST = \
@@ -35,13 +34,6 @@ wildcard_expander_TEST_LDADD = \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/test/libtest.a
-byte_swap_TEST_SOURCES = byte_swap_TEST.cc
-byte_swap_TEST_LDADD = \
- libreconcilioutil.a \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- $(top_builddir)/paludis/util/test_extras.o \
- $(top_builddir)/test/libtest.a
-
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/clients/reconcilio/util/byte_swap.hh b/src/clients/reconcilio/util/byte_swap.hh
deleted file mode 100644
index 5a359dd..0000000
--- a/src/clients/reconcilio/util/byte_swap.hh
+++ /dev/null
@@ -1,74 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 David Leverton
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis 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 PALUDIS_GUARD_RECONCILIO_UTIL_BYTE_SWAP_HH
-#define PALUDIS_GUARD_RECONCILIO_UTIL_BYTE_SWAP_HH
-
-#include <cstddef>
-
-template <std::size_t, typename> struct ByteSwap;
-
-template <typename T_>
-struct ByteSwap<1, T_>
-{
- static T_ swap(T_ x)
- {
- return x;
- }
-};
-
-template <typename T_>
-struct ByteSwap<2, T_>
-{
- static T_ swap(T_ x)
- {
- return ((x << 8) & (T_(0xFF) << 8)) | ((x >> 8) & T_(0xFF));
- }
-};
-
-template <typename T_>
-struct ByteSwap<4, T_>
-{
- static T_ swap(T_ x)
- {
- return ((x << 24) & (T_(0xFF) << 24)) | ((x << 8) & (T_(0xFF) << 16))
- | ((x >> 8) & (T_(0xFF) << 8)) | ((x >> 24) & T_(0xFF) );
- }
-};
-
-template <typename T_>
-struct ByteSwap<8, T_>
-{
- static T_ swap(T_ x)
- {
- return ((x << 56) & (T_(0xFF) << 56)) | ((x << 40) & (T_(0xFF) << 48))
- | ((x << 24) & (T_(0xFF) << 40)) | ((x << 8) & (T_(0xFF) << 32))
- | ((x >> 8) & (T_(0xFF) << 24)) | ((x >> 24) & (T_(0xFF) << 16))
- | ((x >> 40) & (T_(0xFF) << 8)) | ((x >> 56) & T_(0xFF) );
- }
-};
-
-template <typename T_>
-inline T_
-byte_swap(T_ x)
-{
- return ByteSwap<sizeof(T_), T_>::swap(x);
-}
-
-#endif