From 60fd8204f84077278ae5978a5d01d307d6d0bf4e Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 11 Jul 2018 13:27:43 -0400 Subject: [PATCH] rev148: Rework DEBUG Signed-off-by: Stefan Berger --- src/tpm2/GpMacros.h | 4 ---- src/tpm2/TpmBuildSwitches.h | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/tpm2/GpMacros.h b/src/tpm2/GpMacros.h index a3444f50..3b1c7b5f 100644 --- a/src/tpm2/GpMacros.h +++ b/src/tpm2/GpMacros.h @@ -183,10 +183,6 @@ #ifndef NOT_REFERENCED # define NOT_REFERENCED(x = x) ((void) (x)) #endif -/* Need an unambiguous definition for DEBUG. Don't change this */ -#if !defined NDEBUG && !defined DEBUG -# define DEBUG YES -#endif #define STD_RESPONSE_HEADER (sizeof(TPM_ST) + sizeof(UINT32) + sizeof(TPM_RC)) #define JOIN(x,y) x##y #define CONCAT(x,y) JOIN(x, y) diff --git a/src/tpm2/TpmBuildSwitches.h b/src/tpm2/TpmBuildSwitches.h index d246e54e..e4bb6f71 100644 --- a/src/tpm2/TpmBuildSwitches.h +++ b/src/tpm2/TpmBuildSwitches.h @@ -59,20 +59,41 @@ /* */ /********************************************************************************/ +/* This file contains the build switches. This contains switches for multiple versions of the + crypto-library so some may not apply to your environment. */ +/* The switches are guarded so that they can either be set on the command line or set here. If the + switch is listed on the command line (-DSOME_SWITCH) with no setting, then the switch will be set + to YES. If the switch setting is not on the command line or if the setting is other than YES or + NO, then the switch will be set to the default value. The default can either be YES or NO as + indicated on each line where the default is selected. */ +/* A caution. Do not try to test these macros by inserting #defines in this file. For some curious + reason, a variable set on the command line with no setting will have a value of 1. An #if + SOME_VARIABLE will work if the variable is not defined or is defined on the command line with no + initial setting. However, a #define SOME_VARIABLE is a null string and when used in #if + SOME_VARIABLE will not be a proper expression. */ + #ifndef TPMBUILDSWITCHES_H #define TPMBUILDSWITCHES_H -/* This file contains the build switches. This contains switches for multiple versions of the - crypto-library so some may not apply to your environment. */ -/* The switches are guarded so that they can either be set on the command line or set here. */ -/* Many of the #defines are guarded so that they can be set on the command line without causing - consternation in the compiler. */ -#ifndef INLINE_FUNCTIONS -//# define INLINE_FUNCTIONS +#undef YES +#define YES 1 +#undef NO +#define NO 0 + +// Need an unambiguous definition for DEBUG. Don't change this +#ifndef DEBUG +# ifdef NDEBUG +# define DEBUG NO +# else +# define DEBUG YES +# endif +#elif (DEBUG != NO) && (DEBUG != YES) +# undef DEBUG +# define DEBUG YES // Default: Either YES or NO #endif #include "CompilerDependencies.h" -/* This definition is required for the re-factored code */ +// This definition is required for the re-factored code #if (!defined USE_BN_ECC_DATA) || ((USE_BN_ECC_DATA != NO) && (USE_BN_ECC_DATA != YES)) # undef USE_BN_ECC_DATA # define USE_BN_ECC_DATA YES // Default: Either YES or NO