diff options
Diffstat (limited to 'Utilities/KWIML/test/test_ABI_endian.h.in')
-rw-r--r-- | Utilities/KWIML/test/test_ABI_endian.h.in | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Utilities/KWIML/test/test_ABI_endian.h.in b/Utilities/KWIML/test/test_ABI_endian.h.in new file mode 100644 index 0000000..992baea --- /dev/null +++ b/Utilities/KWIML/test/test_ABI_endian.h.in @@ -0,0 +1,47 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include <stdio.h> + +#ifdef __cplusplus +# define LANG "C++ " +#else +# define LANG "C " +#endif + +static int test_ABI_endian(void) +{ + int result = 1; + { +#if defined(@KWIML@_ABI_ENDIAN_ID) + int expect; + union { short s; unsigned char c[sizeof(short)]; } x; + x.s = 1; + expect = (x.c[0] == 1 ? + @KWIML@_ABI_ENDIAN_ID_LITTLE : @KWIML@_ABI_ENDIAN_ID_BIG); + printf(LANG "@KWIML@_ABI_ENDIAN_ID: expected [%d], got [%d]", + expect, @KWIML@_ABI_ENDIAN_ID); + if(@KWIML@_ABI_ENDIAN_ID == expect) + { + printf(", PASSED\n"); + } + else + { + printf(", FAILED\n"); + result = 0; + } +#else + printf(LANG "@KWIML@_ABI_ENDIAN_ID: unknown, FAILED\n"); + result = 0; +#endif + } + return result; +} |