mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-22 07:24:28 +08:00
further refinement of auto-detecting integer types
This commit is contained in:
@ -10,18 +10,29 @@
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
// Unity attempts to determine sizeof(various types)
|
||||
// based on UINT_MAX, ULONG_MAX, etc. These are typically
|
||||
// defined in limits.h.
|
||||
#ifdef UNITY_USE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
// As a fallback, hope that including stdint.h will
|
||||
// provide this information.
|
||||
// Unity Attempts to Auto-Detect Integer Types
|
||||
// Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h>
|
||||
// Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h>
|
||||
// Attempt 3: Deduced from sizeof() macros
|
||||
#ifndef UNITY_EXCLUDE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#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
|
||||
//-------------------------------------------------------
|
||||
@ -38,9 +49,6 @@
|
||||
#define UNITY_INT_WIDTH (32)
|
||||
#elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF)
|
||||
#define UNITY_INT_WIDTH (64)
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
#define UNITY_SUPPORT_64
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -59,9 +67,6 @@
|
||||
#define UNITY_LONG_WIDTH (32)
|
||||
#elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF)
|
||||
#define UNITY_LONG_WIDTH (64)
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
#define UNITY_SUPPORT_64
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -80,9 +85,6 @@
|
||||
#define UNITY_POINTER_WIDTH (32)
|
||||
#elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF)
|
||||
#define UNITY_POINTER_WIDTH (64)
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
#define UNITY_SUPPORT_64
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -94,9 +96,6 @@
|
||||
#define UNITY_POINTER_WIDTH (32)
|
||||
#elif (INTPTR_MAX <= 0x7FFFFFFFFFFFFFFF)
|
||||
#define UNITY_POINTER_WIDTH (64)
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
#define UNITY_SUPPORT_64
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -105,7 +104,7 @@
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Int Support
|
||||
// Int Support (Define types based on detected sizes)
|
||||
//-------------------------------------------------------
|
||||
|
||||
#if (UNITY_INT_WIDTH == 32)
|
||||
@ -130,6 +129,17 @@
|
||||
// 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
|
||||
|
||||
//No 64-bit Support
|
||||
@ -161,9 +171,6 @@ typedef _US64 _U_SINT;
|
||||
typedef _UU32 _UP;
|
||||
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32
|
||||
#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;
|
||||
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64
|
||||
#elif (UNITY_POINTER_WIDTH == 16)
|
||||
@ -184,12 +191,17 @@ typedef _US64 _U_SINT;
|
||||
#ifdef UNITY_EXCLUDE_FLOAT
|
||||
|
||||
//No Floating Point Support
|
||||
#undef UNITY_INCLUDE_FLOAT
|
||||
#undef UNITY_FLOAT_PRECISION
|
||||
#undef UNITY_FLOAT_TYPE
|
||||
#undef UNITY_FLOAT_VERBOSE
|
||||
|
||||
#else
|
||||
|
||||
#ifndef UNITY_INCLUDE_FLOAT
|
||||
#define UNITY_INCLUDE_FLOAT
|
||||
#endif
|
||||
|
||||
//Floating Point Support
|
||||
#ifndef UNITY_FLOAT_PRECISION
|
||||
#define UNITY_FLOAT_PRECISION (0.00001f)
|
||||
|
@ -19,6 +19,9 @@ compiler:
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
- UNITY_EXCLUDE_STDINT_H
|
||||
- UNITY_EXCLUDE_LIMITS_H
|
||||
- UNITY_EXCLUDE_SIZEOF
|
||||
- UNITY_INCLUDE_DOUBLE
|
||||
- UNITY_SUPPORT_TEST_CASES
|
||||
object_files:
|
||||
|
@ -19,6 +19,9 @@ compiler:
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
- UNITY_EXCLUDE_STDINT_H
|
||||
- UNITY_EXCLUDE_LIMITS_H
|
||||
- UNITY_EXCLUDE_SIZEOF
|
||||
- UNITY_INCLUDE_DOUBLE
|
||||
- UNITY_SUPPORT_TEST_CASES
|
||||
- UNITY_SUPPORT_64
|
||||
|
46
targets/gcc_auto_limits.yml
Normal file
46
targets/gcc_auto_limits.yml
Normal file
@ -0,0 +1,46 @@
|
||||
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: []
|
47
targets/gcc_auto_sizeof.yml
Normal file
47
targets/gcc_auto_sizeof.yml
Normal file
@ -0,0 +1,47 @@
|
||||
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: []
|
45
targets/gcc_auto_stdint.yml
Normal file
45
targets/gcc_auto_stdint.yml
Normal file
@ -0,0 +1,45 @@
|
||||
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: []
|
Reference in New Issue
Block a user