From: Damien Date: Thu, 28 Sep 2017 02:45:57 +0000 (+1100) Subject: Replace conditionnal compilation symbol with internal configuration bit X-Git-Tag: archive/raspbian/1.68-2+rpi1~56^2~1^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3141c30a8691ce1cdead871e2f0f8a67c7500784;p=pigpio.git Replace conditionnal compilation symbol with internal configuration bit --- diff --git a/pigpio.c b/pigpio.c index a4391a7..76816a2 100644 --- a/pigpio.c +++ b/pigpio.c @@ -195,17 +195,11 @@ bit 0 READ_LAST_NOT_SET_ERROR #define BIT (1<<(gpio&0x1F)) -#ifndef EMBEDDED_IN_VM -#define DBG(level, format, arg...) DO_DBG(level, format, ## arg) -#else -#define DBG(level, format, arg...) -#endif - -#define DO_DBG(level, format, arg...) \ - { \ - if (gpioCfg.dbgLevel >= level) \ - fprintf(stderr, "%s %s: " format "\n" , \ - myTimeStamp(), __FUNCTION__ , ## arg); \ +#define DBG(level, format, arg...) \ + { \ + if (gpioCfg.dbgLevel >= level && (gpioCfg.internals & PI_CFG_SIGHANDLER)) \ + fprintf(stderr, "%s %s: " format "\n" , \ + myTimeStamp(), __FUNCTION__ , ## arg); \ } #ifndef DISABLE_SER_CHECK_INITED @@ -1344,7 +1338,7 @@ static volatile gpioCfg_t gpioCfg = PI_DEFAULT_MEM_ALLOC_MODE, 0, /* dbgLevel */ 0, /* alertFreq */ - 0, /* internals */ + PI_CFG_SIGHANDLER, /* internals */ }; /* no initialisation required */ @@ -8109,9 +8103,8 @@ int initInitialise(void) gpioMaskSet = 1; } -#ifndef EMBEDDED_IN_VM - sigSetHandler(); -#endif + if(gpioCfg.internals & PI_CFG_SIGHANDLER) + sigSetHandler(); if (initPeripherals() < 0) return PI_INIT_FAILED; @@ -8499,8 +8492,7 @@ void gpioTerminate(void) if (dmaReg != MAP_FAILED) dmaIn[DMA_CS] = DMA_CHANNEL_RESET; if (dmaReg != MAP_FAILED) dmaOut[DMA_CS] = DMA_CHANNEL_RESET; -#ifndef EMBEDDED_IN_VM - if (gpioCfg.internals & PI_CFG_STATS) + if ((gpioCfg.internals & PI_CFG_STATS) && (gpioCfg.internals & PI_CFG_SIGHANDLER)) { fprintf(stderr, "\n#####################################################\n"); @@ -8533,7 +8525,6 @@ void gpioTerminate(void) fprintf(stderr, "\n#####################################################\n\n\n"); } -#endif initReleaseResources(); diff --git a/pigpio.h b/pigpio.h index 24fc8c4..ea1f55b 100644 --- a/pigpio.h +++ b/pigpio.h @@ -31,7 +31,7 @@ For more information, please refer to #include #include -#define PIGPIO_VERSION 64 +#define PIGPIO_VERSION 65 /*TEXT @@ -864,8 +864,10 @@ typedef void *(gpioThreadFunc_t) (void *); #define PI_CFG_ALERT_FREQ 4 /* bits 4-7 */ #define PI_CFG_RT_PRIORITY (1<<8) #define PI_CFG_STATS (1<<9) +#define PI_CFG_SIGHANDLER (1<<10) + +#define PI_CFG_ILLEGAL_VAL (1<<11) -#define PI_CFG_ILLEGAL_VAL (1<<10) /* gpioISR */