gmio_core: add typedef for 64b integers
This commit is contained in:
parent
4b64d196db
commit
5a6ef8366c
@ -60,6 +60,7 @@ endif()
|
||||
|
||||
# Find bit size of the target architecture
|
||||
math(EXPR GMIO_TARGET_ARCH_BIT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
message(STATUS "GMIO_TARGET_ARCH_BIT_SIZE = ${GMIO_TARGET_ARCH_BIT_SIZE}")
|
||||
|
||||
# Test if host's architecture is big-endian
|
||||
include(TestBigEndian)
|
||||
@ -82,6 +83,27 @@ check_include_files(stdint.h GMIO_HAVE_STDINT_H)
|
||||
|
||||
# Check non-ANSI available features
|
||||
if(NOT GMIO_BUILD_STRICT_C90)
|
||||
# Check availability of a 64b integer type
|
||||
if(GMIO_HAVE_STDINT_H)
|
||||
set(CMAKE_REQUIRED_INCLUDES stdint.h)
|
||||
endif()
|
||||
check_type_size("int64_t" GMIO_SIZEOF_INT64_T)
|
||||
if(NOT HAVE_GMIO_SIZEOF_INT64_T)
|
||||
check_type_size("__int64" GMIO_SIZEOF_MSVC_INT64)
|
||||
if(NOT HAVE_GMIO_SIZEOF_MSVC_INT64)
|
||||
check_type_size("long long" GMIO_SIZEOF_LONG_LONG)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
if(HAVE_GMIO_SIZEOF_INT64_T)
|
||||
set(GMIO_HAVE_INT64_T ${HAVE_GMIO_SIZEOF_INT64_T})
|
||||
elseif(HAVE_GMIO_SIZEOF_MSVC_INT64)
|
||||
set(GMIO_HAVE_MSVC_INT64 ${HAVE_GMIO_SIZEOF_MSVC_INT64})
|
||||
elseif(HAVE_GMIO_SIZEOF_LONG_LONG)
|
||||
set(GMIO_HAVE_LONG_LONG ${HAVE_GMIO_SIZEOF_LONG_LONG})
|
||||
endif()
|
||||
|
||||
# Check C99 features
|
||||
check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC)
|
||||
|
||||
|
@ -18,6 +18,11 @@
|
||||
#ifndef GMIO_CONFIG_H_CMAKE
|
||||
#define GMIO_CONFIG_H_CMAKE
|
||||
|
||||
/* 64b integer type */
|
||||
#cmakedefine GMIO_HAVE_INT64_T
|
||||
#cmakedefine GMIO_HAVE_MSVC_INT64
|
||||
#cmakedefine GMIO_HAVE_LONG_LONG
|
||||
|
||||
/* C99 */
|
||||
#ifndef GMIO_HAVE_STDINT_H
|
||||
#cmakedefine GMIO_HAVE_STDINT_H
|
||||
|
@ -75,22 +75,31 @@
|
||||
typedef char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
/* TODO: short is not necessarily 16b on all archs */
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
|
||||
/* TODO: int is not necessarily 32b on all archs */
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
/*# ifdef _MSC_VER
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# else
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# endif*/ /* _MSC_VER */
|
||||
|
||||
#endif /* GMIO_USE_STDINT_H */
|
||||
|
||||
#ifndef GMIO_HAVE_INT64_T
|
||||
# if defined(GMIO_HAVE_MSVC_INT64)
|
||||
typedef __int64_t int64_t;
|
||||
typedef unsigned __int64_t uint64_t;
|
||||
# elif defined(GMIO_HAVE_LONG_LONG)
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# endif
|
||||
#endif /* !GMIO_HAVE_INT64_T */
|
||||
|
||||
#if defined(GMIO_HAVE_INT64_T) \
|
||||
|| defined(GMIO_HAVE_MSVC_INT64) \
|
||||
|| defined(GMIO_HAVE_LONG_LONG)
|
||||
# define GMIO_HAVE_INT64_TYPE
|
||||
#endif
|
||||
|
||||
#ifdef GMIO_HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
|
||||
|
@ -55,6 +55,11 @@ const char* test_platform__global_h()
|
||||
UTEST_ASSERT(sizeof(int32_t) == 4);
|
||||
UTEST_ASSERT(sizeof(uint32_t) == 4);
|
||||
|
||||
#ifdef GMIO_HAVE_INT64_TYPE
|
||||
UTEST_ASSERT(sizeof(int64_t) == 8);
|
||||
UTEST_ASSERT(sizeof(uint64_t) == 8);
|
||||
#endif
|
||||
|
||||
UTEST_ASSERT(sizeof(gmio_float32_t) == 4);
|
||||
UTEST_ASSERT(sizeof(gmio_float64_t) == 8);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user