From ab7489e20def1703b7ffc72f5dab9c89e6ece32e Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 20 Sep 2005 09:35:20 +0000 Subject: [PATCH] Add a byte swap test utility. --- src/MultiPlayer/Makefile.am | 4 ++++ src/MultiPlayer/swap_test.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/MultiPlayer/swap_test.cpp diff --git a/src/MultiPlayer/Makefile.am b/src/MultiPlayer/Makefile.am index 9057a991c..0ad23d80a 100644 --- a/src/MultiPlayer/Makefile.am +++ b/src/MultiPlayer/Makefile.am @@ -1,3 +1,7 @@ +noinst_PROGRAMS = swap_test + +swap_test_SOURCES = swap_test.cpp + noinst_LIBRARIES = libMultiPlayer.a libMultiPlayer_a_SOURCES = multiplayrxmgr.cxx multiplayrxmgr.hxx multiplaytxmgr.cxx multiplaytxmgr.hxx mpplayer.cxx mpplayer.hxx mpmessages.hxx tiny_xdr.cpp tiny_xdr.hpp diff --git a/src/MultiPlayer/swap_test.cpp b/src/MultiPlayer/swap_test.cpp new file mode 100644 index 000000000..5f91521c2 --- /dev/null +++ b/src/MultiPlayer/swap_test.cpp @@ -0,0 +1,15 @@ + +#include +#include +#include "tiny_xdr.hpp" + +int main() +{ + uint32_t ui32 = 0xFFAACCEE; + uint64_t ui64 = 0x00BBAADDFFAACCEELL; + + printf("UI32: (normal) %x\nUI32: (swapped) %x\n\n", ui32, bswap_32(ui32) ); + printf("UI64: (normal) %llx\nUI64: (swapped) %llx\n\n", ui64, bswap_64(ui64) ); + + return 0; +}