diff --git a/src/unity_internals.h b/src/unity_internals.h index 2d047b12e74684f7583081de1b1d45170ca7bbe2..9e6e3219fea03d722077a7552c0b16a0a725c33c 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -10,18 +10,29 @@ #include #include -// 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 -#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 +// Attempt 2: UINT_MAX, ULONG_MAX, etc in +// Attempt 3: Deduced from sizeof() macros #ifndef UNITY_EXCLUDE_STDINT_H #include #endif +#ifndef UNITY_EXCLUDE_LIMITS_H +#include +#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) diff --git a/targets/gcc_32.yml b/targets/gcc_32.yml index f9d1318187a8daf4ac4108ad8dd7cfb281e990cb..5f46c6053bbc4834b0e6340dd602dde561dd5425 100644 --- a/targets/gcc_32.yml +++ b/targets/gcc_32.yml @@ -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: diff --git a/targets/gcc_64.yml b/targets/gcc_64.yml index e49e26863fe8cf8396df76618ea97f6b6a7b38aa..6d8dda20349bec6ca96aab5ff908b3d260b71554 100644 --- a/targets/gcc_64.yml +++ b/targets/gcc_64.yml @@ -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 diff --git a/targets/gcc_auto_limits.yml b/targets/gcc_auto_limits.yml new file mode 100644 index 0000000000000000000000000000000000000000..c06cf7558fbfc6e57aa87fcfb4eb3c3418d0cac5 --- /dev/null +++ b/targets/gcc_auto_limits.yml @@ -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: [] diff --git a/targets/gcc_auto_sizeof.yml b/targets/gcc_auto_sizeof.yml new file mode 100644 index 0000000000000000000000000000000000000000..aa7c279f0087a921f331dd4c8ae8aeda6a2a5c91 --- /dev/null +++ b/targets/gcc_auto_sizeof.yml @@ -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: [] diff --git a/targets/gcc_auto_stdint.yml b/targets/gcc_auto_stdint.yml new file mode 100644 index 0000000000000000000000000000000000000000..e49e26863fe8cf8396df76618ea97f6b6a7b38aa --- /dev/null +++ b/targets/gcc_auto_stdint.yml @@ -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: []