Merge branch 'upstream-KWIML' into import-kwiml

* upstream-KWIML:
  KWIML 2015-12-09 (43f9f8d0)
This commit is contained in:
Brad King 2015-12-17 14:56:40 -05:00
commit 12293371ee
20 changed files with 2329 additions and 0 deletions

1
Utilities/KWIML/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.md conflict-marker-size=78

View File

@ -0,0 +1,104 @@
#
# Copyright Kitware, Inc.
# Distributed under the OSI-approved BSD 3-Clause License.
# See accompanying file Copyright.txt for details.
#
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set(kwiml_standalone 1)
project(KWIML)
include(CTest)
mark_as_advanced(BUILD_TESTING)
if(BUILD_TESTING)
set(KWIML_TEST_ENABLE 1)
endif()
if(NOT DEFINED KWIML_INSTALL_INCLUDE_DIR)
set(KWIML_INSTALL_INCLUDE_DIR include)
endif()
set(KWIML_INCLUDE_PREFIX kwiml)
else()
cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR)
set(kwiml_standalone 0)
if(KWIML_INSTALL_INCLUDE_DIR AND NOT DEFINED KWIML_INCLUDE_PREFIX)
message(FATAL_ERROR "Host project must set KWIML_INCLUDE_PREFIX")
endif()
endif()
get_property(KWIML_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach(lang ${KWIML_LANGUAGES})
set(KWIML_LANGUAGE_${lang} 1)
endforeach()
if(NOT KWIML_LANGUAGE_C AND NOT KWIML_LANGUAGE_CXX)
set(BUILD_TESTING OFF)
endif()
if(KWIML_INSTALL_INCLUDE_DIR)
install(FILES
include/kwiml/abi.h
include/kwiml/int.h
DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/${KWIML_INCLUDE_PREFIX}
${KWIML_INSTALL_INCLUDE_OPTIONS}
)
endif()
if(KWIML_TEST_ENABLE)
add_subdirectory(test)
endif()
if(NOT kwiml_standalone)
return()
endif()
#----------------------------------------------------------------------------
set(KWIML_VERSION 1.0.0)
if(KWIML_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(KWIML_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(KWIML_VERSION_MINOR "${CMAKE_MATCH_2}")
set(KWIML_VERSION_PATCH "${CMAKE_MATCH_3}")
math(EXPR KWIML_VERSION_DECIMAL
"${KWIML_VERSION_MAJOR}*1000000 + ${KWIML_VERSION_MINOR}*1000 + ${KWIML_VERSION_PATCH}")
else()
message(FATAL_ERROR "Failed to parse KWIML_VERSION='${KWIML_VERSION}'")
endif()
configure_file(src/version.h.in include/kwiml/version.h @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/include/kwiml/version.h
DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/kwiml
)
if(NOT KWIML_INSTALL_PACKAGE_DIR)
set(KWIML_INSTALL_PACKAGE_DIR share/cmake/kwiml-${KWIML_VERSION_MAJOR}.${KWIML_VERSION_MINOR})
endif()
add_library(kwiml INTERFACE)
target_include_directories(kwiml INTERFACE
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${KWIML_INSTALL_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
export(TARGETS kwiml
NAMESPACE kwiml::
FILE kwiml-targets.cmake
)
install(TARGETS kwiml
DESTINATION lib
EXPORT kwiml-targets
)
install(EXPORT kwiml-targets
NAMESPACE kwiml::
DESTINATION ${KWIML_INSTALL_PACKAGE_DIR}
)
configure_file(src/kwiml-config.cmake.in kwiml-config.cmake @ONLY)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/kwiml-config-version.cmake"
VERSION ${KWIML_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/kwiml-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/kwiml-config-version.cmake
DESTINATION ${KWIML_INSTALL_PACKAGE_DIR}
)

View File

@ -0,0 +1,30 @@
Kitware Information Macro Library
Copyright 2010-2015 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Kitware, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

36
Utilities/KWIML/README.md Normal file
View File

@ -0,0 +1,36 @@
Kitware Information Macro Library (KWIML)
=========================================
KWIML provides header files that use preprocessor tests to detect and
provide information about the compiler and its target architecture.
The headers contain no configuration-time test results and thus may
be installed into an architecture-independent include directory.
This makes them suitable for use in the public interface of any package.
The following headers are provided. See header comments for details:
* [kwiml/abi.h][]: Fundamental type size and representation.
* [kwiml/int.h][]: Fixed-size integer types and format specifiers.
* [kwiml/version.h][]: Information about this version of KWIML.
The [test][] subdirectory builds tests that verify correctness of the
information provided by each header.
License
=======
KWIML is distributed under the OSI-approved 3-clause BSD License.
Files used only for build and test purposes contain a copyright notice and
reference [Copyright.txt][] for details. Headers meant for installation and
distribution outside the source tree come with full inlined copies of the
copyright notice and license text. This makes them suitable for distribution
with any package under compatible license terms.
[Copyright.txt]: Copyright.txt
[kwiml/abi.h]: include/kwiml/abi.h
[kwiml/int.h]: include/kwiml/int.h
[kwiml/version.h]: src/version.h.in
[test]: test/

View File

@ -0,0 +1,562 @@
/*============================================================================
Kitware Information Macro Library
Copyright 2010-2015 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Kitware, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
============================================================================*/
/*
This header defines macros with information about the C ABI.
Only information that can be determined using the preprocessor at
compilation time is available. No try-compile results may be added
here. Instead we memorize results on platforms of interest.
An includer may optionally define the following macros to suppress errors:
KWIML_ABI_NO_VERIFY = skip verification declarations
KWIML_ABI_NO_ERROR_CHAR_SIGN = signedness of 'char' may be unknown
KWIML_ABI_NO_ERROR_LONG_LONG = existence of 'long long' may be unknown
KWIML_ABI_NO_ERROR_ENDIAN = byte order of CPU may be unknown
An includer may test the following macros after inclusion:
KWIML_ABI_VERSION = interface version number # of this header
KWIML_ABI_SIZEOF_DATA_PTR = sizeof(void*)
KWIML_ABI_SIZEOF_CODE_PTR = sizeof(void(*)(void))
KWIML_ABI_SIZEOF_FLOAT = sizeof(float)
KWIML_ABI_SIZEOF_DOUBLE = sizeof(double)
KWIML_ABI_SIZEOF_CHAR = sizeof(char)
KWIML_ABI_SIZEOF_SHORT = sizeof(short)
KWIML_ABI_SIZEOF_INT = sizeof(int)
KWIML_ABI_SIZEOF_LONG = sizeof(long)
KWIML_ABI_SIZEOF_LONG_LONG = sizeof(long long) or 0 if not a type
Undefined if existence is unknown and error suppression macro
KWIML_ABI_NO_ERROR_LONG_LONG was defined.
KWIML_ABI_SIZEOF___INT64 = 8 if '__int64' exists or 0 if not
Undefined if existence is unknown.
KWIML_ABI___INT64_IS_LONG = 1 if '__int64' is 'long' (same type)
Undefined otherwise.
KWIML_ABI___INT64_IS_LONG_LONG = 1 if '__int64' is 'long long' (same type)
Undefined otherwise.
KWIML_ABI___INT64_IS_UNIQUE = 1 if '__int64' is a distinct type
Undefined otherwise.
KWIML_ABI_CHAR_IS_UNSIGNED = 1 if 'char' is unsigned, else undefined
KWIML_ABI_CHAR_IS_SIGNED = 1 if 'char' is signed, else undefined
One of these is defined unless signedness of 'char' is unknown and
error suppression macro KWIML_ABI_NO_ERROR_CHAR_SIGN was defined.
KWIML_ABI_ENDIAN_ID_BIG = id for big-endian (always defined)
KWIML_ABI_ENDIAN_ID_LITTLE = id for little-endian (always defined)
KWIML_ABI_ENDIAN_ID = id of byte order of target CPU
Defined to KWIML_ABI_ENDIAN_ID_BIG or KWIML_ABI_ENDIAN_ID_LITTLE
unless byte order is unknown and error suppression macro
KWIML_ABI_NO_ERROR_ENDIAN was defined.
We verify most results using dummy "extern" declarations that are
invalid if the macros are wrong. Verification is disabled if
suppression macro KWIML_ABI_NO_VERIFY was defined.
*/
#define KWIML_ABI_private_VERSION 1
/* Guard definition of this version. */
#ifndef KWIML_ABI_detail_DEFINED_VERSION_1
# define KWIML_ABI_detail_DEFINED_VERSION_1 1
# define KWIML_ABI_private_DO_DEFINE
#endif
/* Guard verification of this version. */
#if !defined(KWIML_ABI_NO_VERIFY)
# ifndef KWIML_ABI_detail_VERIFIED_VERSION_1
# define KWIML_ABI_detail_VERIFIED_VERSION_1
# define KWIML_ABI_private_DO_VERIFY
# endif
#endif
#ifdef KWIML_ABI_private_DO_DEFINE
#undef KWIML_ABI_private_DO_DEFINE
/* Define version as most recent of those included. */
#if !defined(KWIML_ABI_VERSION) || KWIML_ABI_VERSION < KWIML_ABI_private_VERSION
# undef KWIML_ABI_VERSION
# define KWIML_ABI_VERSION 1
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_DATA_PTR)
# if defined(__SIZEOF_POINTER__)
# define KWIML_ABI_SIZEOF_DATA_PTR __SIZEOF_POINTER__
# elif defined(_SIZE_PTR)
# define KWIML_ABI_SIZEOF_DATA_PTR (_SIZE_PTR >> 3)
# elif defined(_LP64) || defined(__LP64__)
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(_ILP32)
# define KWIML_ABI_SIZEOF_DATA_PTR 4
# elif defined(__64BIT__) /* IBM XL */
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(_M_X64)
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(__ia64)
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(__sparcv9)
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(__x86_64) || defined(__x86_64__)
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(__amd64) || defined(__amd64__)
# define KWIML_ABI_SIZEOF_DATA_PTR 8
# elif defined(__i386) || defined(__i386__)
# define KWIML_ABI_SIZEOF_DATA_PTR 4
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_DATA_PTR)
# define KWIML_ABI_SIZEOF_DATA_PTR 4
#endif
#if !defined(KWIML_ABI_SIZEOF_CODE_PTR)
# define KWIML_ABI_SIZEOF_CODE_PTR KWIML_ABI_SIZEOF_DATA_PTR
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_CHAR)
# define KWIML_ABI_SIZEOF_CHAR 1
#endif
#if !defined(KWIML_ABI_CHAR_IS_UNSIGNED) && !defined(KWIML_ABI_CHAR_IS_SIGNED)
# if defined(__CHAR_UNSIGNED__) /* GNU, some IBM XL, others? */
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
# elif defined(_CHAR_UNSIGNED) /* Intel, IBM XL, MSVC, Borland, others? */
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
# elif defined(_CHAR_SIGNED) /* IBM XL, others? */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(__CHAR_SIGNED__) /* IBM XL, Watcom, others? */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(__SIGNED_CHARS__) /* EDG, Intel, SGI MIPSpro */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(_CHAR_IS_SIGNED) /* Some SunPro, others? */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(_CHAR_IS_UNSIGNED) /* SunPro, others? */
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
# elif defined(__GNUC__) /* GNU default */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro default */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(__HP_cc) || defined(__HP_aCC) /* HP default (unless +uc) */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(_SGI_COMPILER_VERSION) /* SGI MIPSpro default */
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
# elif defined(__PGIC__) /* PGI default */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(_MSC_VER) /* MSVC default */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(__WATCOMC__) /* Watcom default */
# define KWIML_ABI_CHAR_IS_UNSIGNED 1
# elif defined(__BORLANDC__) /* Borland default */
# define KWIML_ABI_CHAR_IS_SIGNED 1
# elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */
# define KWIML_ABI_CHAR_IS_SIGNED 1 /* (unless +uc) */
# endif
#endif
#if !defined(KWIML_ABI_CHAR_IS_UNSIGNED) && !defined(KWIML_ABI_CHAR_IS_SIGNED) \
&& !defined(KWIML_ABI_NO_ERROR_CHAR_SIGN)
# error "Signedness of 'char' unknown."
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_SHORT)
# if defined(__SIZEOF_SHORT__)
# define KWIML_ABI_SIZEOF_SHORT __SIZEOF_SHORT__
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_SHORT)
# define KWIML_ABI_SIZEOF_SHORT 2
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_INT)
# if defined(__SIZEOF_INT__)
# define KWIML_ABI_SIZEOF_INT __SIZEOF_INT__
# elif defined(_SIZE_INT)
# define KWIML_ABI_SIZEOF_INT (_SIZE_INT >> 3)
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_INT)
# define KWIML_ABI_SIZEOF_INT 4
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_LONG)
# if defined(__SIZEOF_LONG__)
# define KWIML_ABI_SIZEOF_LONG __SIZEOF_LONG__
# elif defined(_SIZE_LONG)
# define KWIML_ABI_SIZEOF_LONG (_SIZE_LONG >> 3)
# elif defined(__LONG_MAX__)
# if __LONG_MAX__ == 0x7fffffff
# define KWIML_ABI_SIZEOF_LONG 4
# elif __LONG_MAX__>>32 == 0x7fffffff
# define KWIML_ABI_SIZEOF_LONG 8
# endif
# elif defined(_MSC_VER) /* MSVC and Intel on Windows */
# define KWIML_ABI_SIZEOF_LONG 4
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_LONG)
# define KWIML_ABI_SIZEOF_LONG KWIML_ABI_SIZEOF_DATA_PTR
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_LONG_LONG)
# if defined(__SIZEOF_LONG_LONG__)
# define KWIML_ABI_SIZEOF_LONG_LONG __SIZEOF_LONG_LONG__
# elif defined(__LONG_LONG_MAX__)
# if __LONG_LONG_MAX__ == 0x7fffffff
# define KWIML_ABI_SIZEOF_LONG_LONG 4
# elif __LONG_LONG_MAX__>>32 == 0x7fffffff
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# endif
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_LONG_LONG)
# if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ \
&& !defined(_MSC_VER)
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(_LONG_LONG) /* IBM XL, perhaps others. */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__NO_LONG_LONG) /* EDG */
# define KWIML_ABI_SIZEOF_LONG_LONG 0
# elif defined(__cplusplus) && __cplusplus > 199711L /* C++0x */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__HP_cc) || defined(__HP_aCC) /* HP */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__PGIC__) /* PGI */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__WATCOMC__) /* Watcom */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__INTEL_COMPILER) /* Intel */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__BORLANDC__) /* Borland */
# if __BORLANDC__ >= 0x0560
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# else
# define KWIML_ABI_SIZEOF_LONG_LONG 0
# endif
# elif defined(_MSC_VER) /* Microsoft */
# if _MSC_VER >= 1310
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# else
# define KWIML_ABI_SIZEOF_LONG_LONG 0
# endif
# elif defined(__GNUC__) /* GNU */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */
# define KWIML_ABI_SIZEOF_LONG_LONG 8
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_LONG_LONG) && !defined(KWIML_ABI_NO_ERROR_LONG_LONG)
# error "Existence of 'long long' unknown."
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF___INT64)
# if defined(__INTEL_COMPILER)
# define KWIML_ABI_SIZEOF___INT64 8
# elif defined(_MSC_VER)
# define KWIML_ABI_SIZEOF___INT64 8
# elif defined(__BORLANDC__)
# define KWIML_ABI_SIZEOF___INT64 8
# else
# define KWIML_ABI_SIZEOF___INT64 0
# endif
#endif
#if defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
# if KWIML_ABI_SIZEOF_LONG == 8
# define KWIML_ABI___INT64_IS_LONG 1
# elif defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG == 8
# define KWIML_ABI___INT64_IS_LONG_LONG 1
# else
# define KWIML_ABI___INT64_IS_UNIQUE 1
# endif
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_FLOAT)
# if defined(__SIZEOF_FLOAT__)
# define KWIML_ABI_SIZEOF_FLOAT __SIZEOF_FLOAT__
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_FLOAT)
# define KWIML_ABI_SIZEOF_FLOAT 4
#endif
/*--------------------------------------------------------------------------*/
#if !defined(KWIML_ABI_SIZEOF_DOUBLE)
# if defined(__SIZEOF_DOUBLE__)
# define KWIML_ABI_SIZEOF_DOUBLE __SIZEOF_DOUBLE__
# endif
#endif
#if !defined(KWIML_ABI_SIZEOF_DOUBLE)
# define KWIML_ABI_SIZEOF_DOUBLE 8
#endif
/*--------------------------------------------------------------------------*/
/* Identify possible endian cases. The macro KWIML_ABI_ENDIAN_ID will be
defined to one of these, or undefined if unknown. */
#if !defined(KWIML_ABI_ENDIAN_ID_BIG)
# define KWIML_ABI_ENDIAN_ID_BIG 4321
#endif
#if !defined(KWIML_ABI_ENDIAN_ID_LITTLE)
# define KWIML_ABI_ENDIAN_ID_LITTLE 1234
#endif
#if KWIML_ABI_ENDIAN_ID_BIG == KWIML_ABI_ENDIAN_ID_LITTLE
# error "KWIML_ABI_ENDIAN_ID_BIG == KWIML_ABI_ENDIAN_ID_LITTLE"
#endif
#if defined(KWIML_ABI_ENDIAN_ID) /* Skip #elif cases if already defined. */
/* Use dedicated symbols if the compiler defines them. Do this first
because some architectures allow runtime byte order selection by
the operating system (values for such architectures below are
guesses for compilers that do not define a dedicated symbol).
Ensure that only one is defined in case the platform or a header
defines both as possible values for some third symbol. */
#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
#elif defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
#elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* Alpha */
#elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* Arm */
#elif defined(__arm__)
# if !defined(__ARMEB__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
# else
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
# endif
/* Intel x86 */
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
#elif defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
#elif defined(__MWERKS__) && defined(__INTEL__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* Intel x86-64 */
#elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
#elif defined(__amd64) || defined(__amd64__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* Intel Architecture-64 (Itanium) */
#elif defined(__ia64) || defined(__ia64__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
#elif defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* PowerPC */
#elif defined(__powerpc) || defined(__powerpc__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
#elif defined(__ppc) || defined(__ppc__) || defined(__POWERPC__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* SPARC */
#elif defined(__sparc) || defined(__sparc__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* HP/PA RISC */
#elif defined(__hppa) || defined(__hppa__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* Motorola 68k */
#elif defined(__m68k__) || defined(M68000)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* MIPSel (MIPS little endian) */
#elif defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* MIPSeb (MIPS big endian) */
#elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* MIPS (fallback, big endian) */
#elif defined(__mips) || defined(__mips__) || defined(__MIPS__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* NIOS2 */
#elif defined(__NIOS2__) || defined(__NIOS2) || defined(__nios2__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* OpenRISC 1000 */
#elif defined(__or1k__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* RS/6000 */
#elif defined(__THW_RS600) || defined(_IBMR2) || defined(_POWER)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
#elif defined(_ARCH_PWR) || defined(_ARCH_PWR2)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* System/370 */
#elif defined(__370__) || defined(__THW_370__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* System/390 */
#elif defined(__s390__) || defined(__s390x__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* z/Architecture */
#elif defined(__SYSC_ZARCH__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* VAX */
#elif defined(__vax__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
/* Aarch64 */
#elif defined(__aarch64__)
# if !defined(__AARCH64EB__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
# else
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
# endif
/* Xtensa */
#elif defined(__XTENSA_EB__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_BIG
#elif defined(__XTENSA_EL__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* Unknown CPU */
#elif !defined(KWIML_ABI_NO_ERROR_ENDIAN)
# error "Byte order of target CPU unknown."
#endif
#endif /* KWIML_ABI_private_DO_DEFINE */
/*--------------------------------------------------------------------------*/
#ifdef KWIML_ABI_private_DO_VERIFY
#undef KWIML_ABI_private_DO_VERIFY
#if defined(_MSC_VER)
# pragma warning (push)
# pragma warning (disable:4310) /* cast truncates constant value */
#endif
#define KWIML_ABI_private_VERIFY(n, x, y) KWIML_ABI_private_VERIFY_0(KWIML_ABI_private_VERSION, n, x, y)
#define KWIML_ABI_private_VERIFY_0(V, n, x, y) KWIML_ABI_private_VERIFY_1(V, n, x, y)
#define KWIML_ABI_private_VERIFY_1(V, n, x, y) extern int (*n##_v##V)[x]; extern int (*n##_v##V)[y]
#define KWIML_ABI_private_VERIFY_SAME_IMPL(n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_0(KWIML_ABI_private_VERSION, n, x, y)
#define KWIML_ABI_private_VERIFY_SAME_IMPL_0(V, n, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y)
#define KWIML_ABI_private_VERIFY_SAME_IMPL_1(V, n, x, y) extern int (*n##_v##V)(x*); extern int (*n##_v##V)(y*)
#define KWIML_ABI_private_VERIFY_DIFF_IMPL(n, x, y) KWIML_ABI_private_VERIFY_DIFF_IMPL_0(KWIML_ABI_private_VERSION, n, x, y)
#define KWIML_ABI_private_VERIFY_DIFF_IMPL_0(V, n, x, y) KWIML_ABI_private_VERIFY_DIFF_IMPL_1(V, n, x, y)
#if defined(__cplusplus)
# define KWIML_ABI_private_VERIFY_DIFF_IMPL_1(V, n, x, y) extern int* n##_v##V(x*); extern char* n##_v##V(y*)
#else
# define KWIML_ABI_private_VERIFY_DIFF_IMPL_1(V, n, x, y) extern int* n##_v##V(x*) /* TODO: possible? */
#endif
#define KWIML_ABI_private_VERIFY_BOOL(m, b) KWIML_ABI_private_VERIFY(KWIML_ABI_detail_VERIFY_##m, 2, (b)?2:3)
#define KWIML_ABI_private_VERIFY_SIZE(m, t) KWIML_ABI_private_VERIFY(KWIML_ABI_detail_VERIFY_##m, m, sizeof(t))
#define KWIML_ABI_private_VERIFY_SAME(m, x, y) KWIML_ABI_private_VERIFY_SAME_IMPL(KWIML_ABI_detail_VERIFY_##m, x, y)
#define KWIML_ABI_private_VERIFY_DIFF(m, x, y) KWIML_ABI_private_VERIFY_DIFF_IMPL(KWIML_ABI_detail_VERIFY_##m, x, y)
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_DATA_PTR, int*);
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_CODE_PTR, int(*)(int));
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_CHAR, char);
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_SHORT, short);
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_INT, int);
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_LONG, long);
#if defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG > 0
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_LONG_LONG, long long);
#endif
#if defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF___INT64, __int64);
#endif
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_FLOAT, float);
KWIML_ABI_private_VERIFY_SIZE(KWIML_ABI_SIZEOF_DOUBLE, double);
#if defined(KWIML_ABI___INT64_IS_LONG)
KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG, __int64, long);
#elif defined(KWIML_ABI___INT64_IS_LONG_LONG)
KWIML_ABI_private_VERIFY_SAME(KWIML_ABI___INT64_IS_LONG_LONG, __int64, long long);
#elif defined(KWIML_ABI_SIZEOF___INT64) && KWIML_ABI_SIZEOF___INT64 > 0
KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG, __int64, long);
# if defined(KWIML_ABI_SIZEOF_LONG_LONG) && KWIML_ABI_SIZEOF_LONG_LONG > 0
KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG_LONG, __int64, long long);
# endif
#endif
#if defined(KWIML_ABI_CHAR_IS_UNSIGNED)
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_UNSIGNED, (char)0x80 > 0);
#elif defined(KWIML_ABI_CHAR_IS_SIGNED)
KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED, (char)0x80 < 0);
#endif
#undef KWIML_ABI_private_VERIFY_DIFF
#undef KWIML_ABI_private_VERIFY_SAME
#undef KWIML_ABI_private_VERIFY_SIZE
#undef KWIML_ABI_private_VERIFY_BOOL
#undef KWIML_ABI_private_VERIFY_DIFF_IMPL_1
#undef KWIML_ABI_private_VERIFY_DIFF_IMPL_0
#undef KWIML_ABI_private_VERIFY_DIFF_IMPL
#undef KWIML_ABI_private_VERIFY_SAME_IMPL_1
#undef KWIML_ABI_private_VERIFY_SAME_IMPL_0
#undef KWIML_ABI_private_VERIFY_SAME_IMPL
#undef KWIML_ABI_private_VERIFY_1
#undef KWIML_ABI_private_VERIFY_0
#undef KWIML_ABI_private_VERIFY
#if defined(_MSC_VER)
# pragma warning (pop)
#endif
#endif /* KWIML_ABI_private_DO_VERIFY */
#undef KWIML_ABI_private_VERSION

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/kwiml-targets.cmake)

View File

@ -0,0 +1,59 @@
/*============================================================================
Kitware Information Macro Library
Copyright 2010-2015 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Kitware, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
============================================================================*/
#ifndef KWIML_VERSION_H
#define KWIML_VERSION_H
/*
This header defines macros with information about this version of KWIML.
An includer may test the following macros after inclusion:
KWIML_VERSION = KWIML version number encoded in an integer as
`printf("%d%03d%03d", MAJOR, MINOR, PATCH)`.
MAJOR is incremented on incompatible changes.
MINOR is incremented on interface additions.
PATCH is incremented on implementation updates.
KWIML_VERSION_STRING = KWIML version number in string formatted as
`printf("%d.%d.%d", MAJOR, MINOR PATCH)`.
KWIML_VERSION_HAS_ABI_H = header 'kwiml/abi.h' is available
KWIML_VERSION_HAS_INT_H = header 'kwiml/int.h' is available
*/
#define KWIML_VERSION @KWIML_VERSION_DECIMAL@
#define KWIML_VERSION_STRING "@KWIML_VERSION@"
#define KWIML_VERSION_HAS_ABI_H 1
#define KWIML_VERSION_HAS_INT_H 1
#endif

View File

@ -0,0 +1,54 @@
#
# Copyright Kitware, Inc.
# Distributed under the OSI-approved BSD 3-Clause License.
# See accompanying file Copyright.txt for details.
#
if(NOT KWIML_TEST_PREFIX)
set(KWIML_TEST_PREFIX kwiml)
endif()
# Suppress printf/scanf format warnings; we test if the sizes match.
foreach(lang C CXX)
if(KWIML_LANGUAGE_${lang} AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wno-format")
endif()
endforeach()
if(KWIML_LANGUAGE_C)
set(test_srcs test.c)
else()
set(test_srcs test.cxx)
endif()
if(KWIML_LANGUAGE_C)
list(APPEND test_defs KWIML_LANGUAGE_C)
list(APPEND test_srcs
test_abi_C.c
test_int_C.c
test_include_C.c
)
endif()
if(KWIML_LANGUAGE_CXX)
list(APPEND test_defs KWIML_LANGUAGE_CXX)
list(APPEND test_srcs
test_abi_CXX.cxx
test_int_CXX.cxx
test_include_CXX.cxx
)
endif()
add_executable(kwiml_test ${test_srcs})
set_property(TARGET kwiml_test PROPERTY COMPILE_DEFINITIONS ${test_defs})
set_property(TARGET kwiml_test PROPERTY
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_test(NAME ${KWIML_TEST_PREFIX}.test COMMAND kwiml_test)
set_property(TEST ${KWIML_TEST_PREFIX}.test PROPERTY LABELS ${KWIML_TEST_LABELS})
# Xcode 2.x forgets to create the output directory before linking
# the individual architectures.
if(CMAKE_OSX_ARCHITECTURES AND XCODE
AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
add_custom_command(
TARGET kwiml_test
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
)
endif()

View File

@ -0,0 +1,33 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#ifdef __cplusplus
extern "C" {
#endif
extern int test_abi_C(void);
extern int test_int_C(void);
extern int test_abi_CXX(void);
extern int test_int_CXX(void);
extern int test_include_C(void);
extern int test_include_CXX(void);
#ifdef __cplusplus
} // extern "C"
#endif
int main(void)
{
int result = 1;
#ifdef KWIML_LANGUAGE_C
result = test_abi_C() && result;
result = test_int_C() && result;
result = test_include_C() && result;
#endif
#ifdef KWIML_LANGUAGE_CXX
result = test_abi_CXX() && result;
result = test_int_CXX() && result;
result = test_include_CXX() && result;
#endif
return result? 0 : 1;
}

View File

@ -0,0 +1,6 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include "test.c"

View File

@ -0,0 +1,16 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#ifndef KWIML_TEST_H
#define KWIML_TEST_H
/* Quiet MS standard library deprecation warnings. */
#ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
#endif
#else
# error "test.h included multiple times."
#endif

View File

@ -0,0 +1,19 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include "test.h"
#include "../include/kwiml/abi.h"
#include "test_abi_endian.h"
#ifndef KWIML_ABI_VERSION
# error "KWIML_ABI_VERSION not defined!"
#endif
int test_abi_C(void)
{
if(!test_abi_endian())
{
return 0;
}
return 1;
}

View File

@ -0,0 +1,19 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include "test.h"
#include "../include/kwiml/abi.h"
#include "test_abi_endian.h"
#ifndef KWIML_ABI_VERSION
# error "KWIML_ABI_VERSION not defined!"
#endif
extern "C" int test_abi_CXX(void)
{
if(!test_abi_endian())
{
return 0;
}
return 1;
}

View File

@ -0,0 +1,41 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#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;
}

View File

@ -0,0 +1,16 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include <stdio.h>
/* Test KWIML header inclusion after above system headers. */
#include "test.h"
#include "../include/kwiml/abi.h"
#include "../include/kwiml/int.h"
int test_include_C(void)
{
return 1;
}

View File

@ -0,0 +1,22 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include <string>
#if defined(_MSC_VER) && defined(NDEBUG)
// Use C++ runtime to avoid linker warning:
// warning LNK4089: all references to 'MSVCP71.dll' discarded by /OPT:REF
std::string test_include_CXX_use_stl_string;
#endif
/* Test KWIML header inclusion after above system headers. */
#include "test.h"
#include "../include/kwiml/abi.h"
#include "../include/kwiml/int.h"
extern "C" int test_include_CXX(void)
{
return 1;
}

View File

@ -0,0 +1,19 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include "test.h"
#include "../include/kwiml/int.h"
#include "test_int_format.h"
#ifndef KWIML_INT_VERSION
# error "KWIML_INT_VERSION not defined!"
#endif
int test_int_C(void)
{
if(!test_int_format())
{
return 0;
}
return 1;
}

View File

@ -0,0 +1,19 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include "test.h"
#include "../include/kwiml/int.h"
#include "test_int_format.h"
#ifndef KWIML_INT_VERSION
# error "KWIML_INT_VERSION not defined!"
#endif
extern "C" int test_int_CXX(void)
{
if(!test_int_format())
{
return 0;
}
return 1;
}

View File

@ -0,0 +1,203 @@
/*
Copyright Kitware, Inc.
Distributed under the OSI-approved BSD 3-Clause License.
See accompanying file Copyright.txt for details.
*/
#include <stdio.h>
#include <string.h>
#if defined(_MSC_VER)
# pragma warning (push)
# pragma warning (disable:4310) /* cast truncates constant value */
#endif
#ifdef __cplusplus
# define LANG "C++ "
#else
# define LANG "C "
#endif
#define VALUE(T, U) (T)((U)0xab << ((sizeof(T)-1)<<3))
#define TEST_C_(C, V, PRI, T, U) \
{ \
T const x = VALUE(T, U); \
T y = C(V); \
printf(LANG #C ":" \
" expression [%" KWIML_INT_PRI##PRI "]," \
" literal [%" KWIML_INT_PRI##PRI "]", x, y); \
if(x == y) \
{ \
printf(", PASSED\n"); \
} \
else \
{ \
printf(", FAILED\n"); \
result = 0; \
} \
}
#define TEST_PRI_(PRI, T, U, STR) \
{ \
T const x = VALUE(T, U); \
char const* str = STR; \
sprintf(buf, "%" KWIML_INT_PRI##PRI, x); \
printf(LANG "KWIML_INT_PRI" #PRI ":" \
" expected [%s], got [%s]", str, buf); \
if(strcmp(str, buf) == 0) \
{ \
printf(", PASSED\n"); \
} \
else \
{ \
printf(", FAILED\n"); \
result = 0; \
} \
}
#define TEST_SCN_(SCN, T, U, STR) TEST_SCN2_(SCN, SCN, T, U, STR)
#define TEST_SCN2_(PRI, SCN, T, U, STR) \
{ \
T const x = VALUE(T, U); \
T y; \
char const* str = STR; \
if(sscanf(str, "%" KWIML_INT_SCN##SCN, &y) != 1) \
{ \
y = 0; \
} \
printf(LANG "KWIML_INT_SCN" #SCN ":" \
" expected [%" KWIML_INT_PRI##PRI "]," \
" got [%" KWIML_INT_PRI##PRI "]", x, y); \
if(x == y) \
{ \
printf(", PASSED\n"); \
} \
else \
{ \
printf(", FAILED\n"); \
result = 0; \
} \
}
#define TEST_(FMT, T, U, STR) TEST2_(FMT, FMT, T, U, STR)
#define TEST2_(PRI, SCN, T, U, STR) \
TEST_PRI_(PRI, T, U, STR) \
TEST_SCN2_(PRI, SCN, T, U, STR)
/* Concatenate T and U now to avoid expanding them. */
#define TEST(FMT, T, U, STR) \
TEST_(FMT, KWIML_INT_##T, KWIML_INT_##U, STR)
#define TEST2(PRI, SCN, T, U, STR) \
TEST2_(PRI, SCN, KWIML_INT_##T, KWIML_INT_##U, STR)
#define TEST_C(C, V, PRI, T, U) \
TEST_C_(KWIML_INT_##C, V, PRI, KWIML_INT_##T, KWIML_INT_##U)
#define TEST_PRI(PRI, T, U, STR) \
TEST_PRI_(PRI, KWIML_INT_##T, KWIML_INT_##U, STR)
#define TEST_SCN(SCN, T, U, STR) \
TEST_SCN_(SCN, KWIML_INT_##T, KWIML_INT_##U, STR)
#define TEST_SCN2(PRI, SCN, T, U, STR) \
TEST_SCN2_(PRI, SCN, KWIML_INT_##T, KWIML_INT_##U, STR)
static int test_int_format(void)
{
int result = 1;
char buf[256];
TEST_PRI(i8, int8_t, uint8_t, "-85")
#if defined(KWIML_INT_SCNi8)
TEST_SCN(i8, int8_t, uint8_t, "-85")
#endif
TEST_PRI(d8, int8_t, uint8_t, "-85")
#if defined(KWIML_INT_SCNd8)
TEST_SCN(d8, int8_t, uint8_t, "-85")
#endif
TEST_PRI(o8, uint8_t, uint8_t, "253")
#if defined(KWIML_INT_SCNo8)
TEST_SCN(o8, uint8_t, uint8_t, "253")
#endif
TEST_PRI(u8, uint8_t, uint8_t, "171")
#if defined(KWIML_INT_SCNu8)
TEST_SCN(u8, uint8_t, uint8_t, "171")
#endif
TEST_PRI(x8, uint8_t, uint8_t, "ab")
TEST_PRI(X8, uint8_t, uint8_t, "AB")
#if defined(KWIML_INT_SCNx8)
TEST_SCN(x8, uint8_t, uint8_t, "ab")
TEST_SCN2(X8, x8, uint8_t, uint8_t, "AB")
#endif
TEST(i16, int16_t, uint16_t, "-21760")
TEST(d16, int16_t, uint16_t, "-21760")
TEST(o16, uint16_t, uint16_t, "125400")
TEST(u16, uint16_t, uint16_t, "43776")
TEST(x16, uint16_t, uint16_t, "ab00")
TEST2(X16, x16, uint16_t, uint16_t, "AB00")
TEST(i32, int32_t, uint32_t, "-1426063360")
TEST(d32, int32_t, uint32_t, "-1426063360")
TEST(o32, uint32_t, uint32_t, "25300000000")
TEST(u32, uint32_t, uint32_t, "2868903936")
TEST(x32, uint32_t, uint32_t, "ab000000")
TEST2(X32, x32, uint32_t, uint32_t, "AB000000")
TEST_PRI(i64, int64_t, uint64_t, "-6124895493223874560")
#if defined(KWIML_INT_SCNi64)
TEST_SCN(i64, int64_t, uint64_t, "-6124895493223874560")
#endif
TEST_PRI(d64, int64_t, uint64_t, "-6124895493223874560")
#if defined(KWIML_INT_SCNd64)
TEST_SCN(d64, int64_t, uint64_t, "-6124895493223874560")
#endif
TEST_PRI(o64, uint64_t, uint64_t, "1254000000000000000000")
#if defined(KWIML_INT_SCNo64)
TEST_SCN(o64, uint64_t, uint64_t, "1254000000000000000000")
#endif
TEST_PRI(u64, uint64_t, uint64_t, "12321848580485677056")
#if defined(KWIML_INT_SCNu64)
TEST_SCN(u64, uint64_t, uint64_t, "12321848580485677056")
#endif
TEST_PRI(x64, uint64_t, uint64_t, "ab00000000000000")
TEST_PRI(X64, uint64_t, uint64_t, "AB00000000000000")
#if defined(KWIML_INT_SCNx64)
TEST_SCN(x64, uint64_t, uint64_t, "ab00000000000000")
TEST_SCN2(X64, x64, uint64_t, uint64_t, "AB00000000000000")
#endif
#if !defined(KWIML_INT_NO_INTPTR_T)
# if KWIML_ABI_SIZEOF_DATA_PTR == 4
TEST(iPTR, intptr_t, uint32_t, "-1426063360")
TEST(dPTR, intptr_t, uint32_t, "-1426063360")
# else
TEST(iPTR, intptr_t, uint64_t, "-6124895493223874560")
TEST(dPTR, intptr_t, uint64_t, "-6124895493223874560")
# endif
#endif
#if !defined(KWIML_INT_NO_UINTPTR_T)
# if KWIML_ABI_SIZEOF_DATA_PTR == 4
TEST(oPTR, uintptr_t, uintptr_t, "25300000000")
TEST(uPTR, uintptr_t, uintptr_t, "2868903936")
TEST(xPTR, uintptr_t, uintptr_t, "ab000000")
TEST2(XPTR, xPTR, uintptr_t, uintptr_t, "AB000000")
# else
TEST(oPTR, uintptr_t, uintptr_t, "1254000000000000000000")
TEST(uPTR, uintptr_t, uintptr_t, "12321848580485677056")
TEST(xPTR, uintptr_t, uintptr_t, "ab00000000000000")
TEST2(XPTR, xPTR, uintptr_t, uintptr_t, "AB00000000000000")
# endif
#endif
TEST_C(INT8_C, -0x55, i8, int8_t, uint8_t)
TEST_C(UINT8_C, 0xAB, u8, uint8_t, uint8_t)
TEST_C(INT16_C, -0x5500, i16, int16_t, uint16_t)
TEST_C(UINT16_C, 0xAB00, u16, uint16_t, uint16_t)
TEST_C(INT32_C, -0x55000000, i32, int32_t, uint32_t)
TEST_C(UINT32_C, 0xAB000000, u32, uint32_t, uint32_t)
TEST_C(INT64_C, -0x5500000000000000, i64, int64_t, uint64_t)
TEST_C(UINT64_C, 0xAB00000000000000, u64, uint64_t, uint64_t)
return result;
}
#if defined(_MSC_VER)
# pragma warning (pop)
#endif