From e6dd6b678be613a2117b98ee520aecd3f95240c5 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 18 Mar 2019 20:26:56 -0400 Subject: [PATCH] ... --- MagickCore/cache.c | 6 +-- MagickCore/exception-private.h | 6 +++ MagickCore/exception.c | 71 ++++++++++++++++++++++++++++++++++ MagickCore/magick.c | 2 + 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 64db93696..fc67bb46a 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -137,7 +137,7 @@ static Quantum const size_t,ExceptionInfo *), *SetPixelCacheNexusPixels(const CacheInfo *,const MapMode,const ssize_t, const ssize_t,const size_t,const size_t,const MagickBooleanType, - NexusInfo *,ExceptionInfo *) magick_hot_spot; + NexusInfo *magick_restrict,ExceptionInfo *) magick_hot_spot; #if defined(MAGICKCORE_OPENCL_SUPPORT) static void @@ -4916,7 +4916,7 @@ MagickPrivate void SetPixelCacheMethods(Cache cache,CacheMethods *cache_methods) % Quantum SetPixelCacheNexusPixels(const CacheInfo *cache_info, % const MapMode mode,const ssize_t x,const ssize_t y,const size_t width, % const size_t height,const MagickBooleanType buffered, -% NexusInfo *nexus_info,ExceptionInfo *exception) +% NexusInfo *magick_restrict nexus_info,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -4936,7 +4936,7 @@ MagickPrivate void SetPixelCacheMethods(Cache cache,CacheMethods *cache_methods) static inline MagickBooleanType AcquireCacheNexusPixels( const CacheInfo *magick_restrict cache_info,const MagickSizeType length, - NexusInfo *nexus_info,ExceptionInfo *exception) + NexusInfo *magick_restrict nexus_info,ExceptionInfo *exception) { if (length != (MagickSizeType) ((size_t) length)) { diff --git a/MagickCore/exception-private.h b/MagickCore/exception-private.h index e6b32314e..12e99d480 100644 --- a/MagickCore/exception-private.h +++ b/MagickCore/exception-private.h @@ -92,6 +92,12 @@ extern "C" { extern MagickPrivate void InitializeExceptionInfo(ExceptionInfo *); +extern MagickPrivate MagickBooleanType + ExceptionComponentGenesis(void); + +extern MagickPrivate void + ExceptionComponentTerminus(void); + #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/MagickCore/exception.c b/MagickCore/exception.c index e7d4d5a92..414233ce3 100644 --- a/MagickCore/exception.c +++ b/MagickCore/exception.c @@ -50,6 +50,7 @@ #include "MagickCore/magick.h" #include "MagickCore/memory_.h" #include "MagickCore/memory-private.h" +#include "MagickCore/semaphore.h" #include "MagickCore/string_.h" #include "MagickCore/utility.h" #include "MagickCore/utility-private.h" @@ -87,6 +88,12 @@ static FatalErrorHandler static WarningHandler warning_handler = DefaultWarningHandler; +/* + Static declarations. +*/ +static SemaphoreInfo + *exception_semaphore = (SemaphoreInfo *) NULL; + /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % @@ -445,6 +452,58 @@ MagickExport ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception) % % % % % % ++ E x e c e p t i o n C o m p o n e n t G e n e s i s % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ExceptionComponentGenesis() instantiates the exception component. +% +% The format of the ExceptionComponentGenesis method is: +% +% MagickBooleanType ExceptionComponentGenesis(void) +% +*/ +MagickPrivate MagickBooleanType ExceptionComponentGenesis(void) +{ + if (exception_semaphore == (SemaphoreInfo *) NULL) + exception_semaphore=AcquireSemaphoreInfo(); + return(MagickTrue); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % ++ E x c e p t i o n C o m p o n e n t T e r m i n u s % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ExceptionComponentTerminus() destroys the exception component. +% +% The format of the ExceptionComponentTerminus method is: +% +% void ExceptionComponentTerminus(void) +% +*/ +MagickPrivate void ExceptionComponentTerminus(void) +{ + if (exception_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&exception_semaphore); + LockSemaphoreInfo(exception_semaphore); + UnlockSemaphoreInfo(exception_semaphore); + RelinquishSemaphoreInfo(&exception_semaphore); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % G e t E x c e p t i o n M e s s a g e % % % % % @@ -816,8 +875,12 @@ MagickExport ErrorHandler SetErrorHandler(ErrorHandler handler) ErrorHandler previous_handler; + if (exception_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&exception_semaphore); + LockSemaphoreInfo(exception_semaphore); previous_handler=error_handler; error_handler=handler; + UnlockSemaphoreInfo(exception_semaphore); return(previous_handler); } @@ -849,8 +912,12 @@ MagickExport FatalErrorHandler SetFatalErrorHandler(FatalErrorHandler handler) FatalErrorHandler previous_handler; + if (exception_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&exception_semaphore); + LockSemaphoreInfo(exception_semaphore); previous_handler=fatal_error_handler; fatal_error_handler=handler; + UnlockSemaphoreInfo(exception_semaphore); return(previous_handler); } @@ -882,8 +949,12 @@ MagickExport WarningHandler SetWarningHandler(WarningHandler handler) WarningHandler previous_handler; + if (exception_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&exception_semaphore); + LockSemaphoreInfo(exception_semaphore); previous_handler=warning_handler; warning_handler=handler; + UnlockSemaphoreInfo(exception_semaphore); return(previous_handler); } diff --git a/MagickCore/magick.c b/MagickCore/magick.c index 9951a9589..ce7bb9b9f 100644 --- a/MagickCore/magick.c +++ b/MagickCore/magick.c @@ -1435,6 +1435,7 @@ MagickExport void MagickCoreGenesis(const char *path, return; } (void) SemaphoreComponentGenesis(); + (void) ExceptionComponentGenesis(); (void) LogComponentGenesis(); (void) LocaleComponentGenesis(); (void) RandomComponentGenesis(); @@ -1601,6 +1602,7 @@ MagickExport void MagickCoreTerminus(void) RandomComponentTerminus(); LocaleComponentTerminus(); LogComponentTerminus(); + ExceptionComponentTerminus(); instantiate_magickcore=MagickFalse; UnlockMagickMutex(); SemaphoreComponentTerminus(); -- 2.40.0