提交 16e56014 编写于 作者: M Mark VanderVoord

further refinement of auto-detecting integer types

上级 47a778d6
...@@ -10,18 +10,29 @@ ...@@ -10,18 +10,29 @@
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
// Unity attempts to determine sizeof(various types) // Unity Attempts to Auto-Detect Integer Types
// based on UINT_MAX, ULONG_MAX, etc. These are typically // Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h>
// defined in limits.h. // Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h>
#ifdef UNITY_USE_LIMITS_H // Attempt 3: Deduced from sizeof() macros
#include <limits.h>
#endif
// As a fallback, hope that including stdint.h will
// provide this information.
#ifndef UNITY_EXCLUDE_STDINT_H #ifndef UNITY_EXCLUDE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
#ifndef UNITY_EXCLUDE_LIMITS_H
#include <limits.h>
#endif
#ifndef UNITY_EXCLUDE_SIZEOF
#ifndef UINT_MAX
#define UINT_MAX (sizeof(unsigned int) * 256 - 1)
#endif
#ifndef ULONG_MAX
#define ULONG_MAX (sizeof(unsigned long) * 256 - 1)
#endif
#ifndef UINTPTR_MAX
#define UINTPTR_MAX ULONG_MAX //apparently this is not a constant expression: (sizeof(unsigned int *) * 256 - 1)
#endif
#endif
//------------------------------------------------------- //-------------------------------------------------------
// Guess Widths If Not Specified // Guess Widths If Not Specified
//------------------------------------------------------- //-------------------------------------------------------
...@@ -38,9 +49,6 @@ ...@@ -38,9 +49,6 @@
#define UNITY_INT_WIDTH (32) #define UNITY_INT_WIDTH (32)
#elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF) #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF)
#define UNITY_INT_WIDTH (64) #define UNITY_INT_WIDTH (64)
#ifndef UNITY_SUPPORT_64
#define UNITY_SUPPORT_64
#endif
#endif #endif
#endif #endif
#endif #endif
...@@ -59,9 +67,6 @@ ...@@ -59,9 +67,6 @@
#define UNITY_LONG_WIDTH (32) #define UNITY_LONG_WIDTH (32)
#elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF) #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF)
#define UNITY_LONG_WIDTH (64) #define UNITY_LONG_WIDTH (64)
#ifndef UNITY_SUPPORT_64
#define UNITY_SUPPORT_64
#endif
#endif #endif
#endif #endif
#endif #endif
...@@ -80,9 +85,6 @@ ...@@ -80,9 +85,6 @@
#define UNITY_POINTER_WIDTH (32) #define UNITY_POINTER_WIDTH (32)
#elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF) #elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF)
#define UNITY_POINTER_WIDTH (64) #define UNITY_POINTER_WIDTH (64)
#ifndef UNITY_SUPPORT_64
#define UNITY_SUPPORT_64
#endif
#endif #endif
#endif #endif
#endif #endif
...@@ -94,9 +96,6 @@ ...@@ -94,9 +96,6 @@
#define UNITY_POINTER_WIDTH (32) #define UNITY_POINTER_WIDTH (32)
#elif (INTPTR_MAX <= 0x7FFFFFFFFFFFFFFF) #elif (INTPTR_MAX <= 0x7FFFFFFFFFFFFFFF)
#define UNITY_POINTER_WIDTH (64) #define UNITY_POINTER_WIDTH (64)
#ifndef UNITY_SUPPORT_64
#define UNITY_SUPPORT_64
#endif
#endif #endif
#endif #endif
#endif #endif
...@@ -105,7 +104,7 @@ ...@@ -105,7 +104,7 @@
#endif #endif
//------------------------------------------------------- //-------------------------------------------------------
// Int Support // Int Support (Define types based on detected sizes)
//------------------------------------------------------- //-------------------------------------------------------
#if (UNITY_INT_WIDTH == 32) #if (UNITY_INT_WIDTH == 32)
...@@ -130,6 +129,17 @@ ...@@ -130,6 +129,17 @@
// 64-bit Support // 64-bit Support
//------------------------------------------------------- //-------------------------------------------------------
#ifndef UNITY_SUPPORT_64
#if UNITY_LONG_WIDTH > 32
#define UNITY_SUPPORT_64
#endif
#endif
#ifndef UNITY_SUPPORT_64
#if UNITY_POINTER_WIDTH > 32
#define UNITY_SUPPORT_64
#endif
#endif
#ifndef UNITY_SUPPORT_64 #ifndef UNITY_SUPPORT_64
//No 64-bit Support //No 64-bit Support
...@@ -161,9 +171,6 @@ typedef _US64 _U_SINT; ...@@ -161,9 +171,6 @@ typedef _US64 _U_SINT;
typedef _UU32 _UP; typedef _UU32 _UP;
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32
#elif (UNITY_POINTER_WIDTH == 64) #elif (UNITY_POINTER_WIDTH == 64)
#ifndef UNITY_SUPPORT_64
#error "You've Specified 64-bit pointers without enabling 64-bit Support. Define UNITY_SUPPORT_64"
#endif
typedef _UU64 _UP; typedef _UU64 _UP;
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64
#elif (UNITY_POINTER_WIDTH == 16) #elif (UNITY_POINTER_WIDTH == 16)
...@@ -184,12 +191,17 @@ typedef _US64 _U_SINT; ...@@ -184,12 +191,17 @@ typedef _US64 _U_SINT;
#ifdef UNITY_EXCLUDE_FLOAT #ifdef UNITY_EXCLUDE_FLOAT
//No Floating Point Support //No Floating Point Support
#undef UNITY_INCLUDE_FLOAT
#undef UNITY_FLOAT_PRECISION #undef UNITY_FLOAT_PRECISION
#undef UNITY_FLOAT_TYPE #undef UNITY_FLOAT_TYPE
#undef UNITY_FLOAT_VERBOSE #undef UNITY_FLOAT_VERBOSE
#else #else
#ifndef UNITY_INCLUDE_FLOAT
#define UNITY_INCLUDE_FLOAT
#endif
//Floating Point Support //Floating Point Support
#ifndef UNITY_FLOAT_PRECISION #ifndef UNITY_FLOAT_PRECISION
#define UNITY_FLOAT_PRECISION (0.00001f) #define UNITY_FLOAT_PRECISION (0.00001f)
......
...@@ -19,6 +19,9 @@ compiler: ...@@ -19,6 +19,9 @@ compiler:
defines: defines:
prefix: '-D' prefix: '-D'
items: items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_EXCLUDE_SIZEOF
- UNITY_INCLUDE_DOUBLE - UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES - UNITY_SUPPORT_TEST_CASES
object_files: object_files:
......
...@@ -19,6 +19,9 @@ compiler: ...@@ -19,6 +19,9 @@ compiler:
defines: defines:
prefix: '-D' prefix: '-D'
items: items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_EXCLUDE_SIZEOF
- UNITY_INCLUDE_DOUBLE - UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES - UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64 - UNITY_SUPPORT_64
......
compiler:
path: gcc
source_path: 'src/'
unit_tests_path: &unit_tests_path 'test/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []
compiler:
path: gcc
source_path: 'src/'
unit_tests_path: &unit_tests_path 'test/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMTIS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []
compiler:
path: gcc
source_path: 'src/'
unit_tests_path: &unit_tests_path 'test/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册