/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % U n l o c k S e m a p h o r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % UnlockSemaphoreInfo() unlocks a semaphore. % % The format of the UnlockSemaphoreInfo method is: % % void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info) % % A description of each parameter follows: % % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure. % */ MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info) { assert(semaphore_info != (SemaphoreInfo *) NULL); assert(semaphore_info->signature == MagickSignature); #if defined(MAGICKCORE_DEBUG) assert(IsMagickThreadEqual(semaphore_info->id) != MagickFalse); if (semaphore_info->reference_count == 0) { (void) FormatLocaleFile(stderr, "Warning: semaphore lock already unlocked!\n"); (void) fflush(stderr); return; } semaphore_info->reference_count--; #endif #if defined(MAGICKCORE_THREAD_SUPPORT) { int status; status=pthread_mutex_unlock(&semaphore_info->mutex); if (status != 0) { errno=status; ThrowFatalException(ResourceLimitFatalError,"UnableToUnlockSemaphore"); } } #elif defined(MAGICKCORE_HAVE_WINTHREADS) LeaveCriticalSection(&semaphore_info->mutex); #endif }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % U n l o c k S e m a p h o r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % UnlockSemaphoreInfo() unlocks a semaphore. % % The format of the UnlockSemaphoreInfo method is: % % MagickBooleanType UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info) % % A description of each parameter follows: % % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure. % */ MagickExport MagickBooleanType UnlockSemaphoreInfo( SemaphoreInfo *semaphore_info) { assert(semaphore_info != (SemaphoreInfo *) NULL); assert(semaphore_info->signature == MagickSignature); #if defined(MAGICKCORE_DEBUG) assert(IsMagickThreadEqual(semaphore_info->id) != MagickFalse); if (semaphore_info->reference_count == 0) { (void) fprintf(stderr,"Warning: semaphore lock already unlocked!\n"); (void) fflush(stderr); return(MagickFalse); } semaphore_info->reference_count--; #endif #if defined(MAGICKCORE_HAVE_PTHREAD) { int status; status=pthread_mutex_unlock(&semaphore_info->mutex); if (status != 0) { semaphore_info->reference_count++; return(MagickFalse); } } #elif defined(MAGICKORE_HAVE_WINTHREADS) LeaveCriticalSection(&semaphore_info->mutex); #endif return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L o c k S e m a p h o r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % LockSemaphoreInfo() locks a semaphore. % % The format of the LockSemaphoreInfo method is: % % void LockSemaphoreInfo(SemaphoreInfo *semaphore_info) % % A description of each parameter follows: % % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure. % */ MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info) { assert(semaphore_info != (SemaphoreInfo *) NULL); assert(semaphore_info->signature == MagickSignature); #if defined(MAGICKCORE_THREAD_SUPPORT) { int status; status=pthread_mutex_lock(&semaphore_info->mutex); if (status != 0) { errno=status; ThrowFatalException(ResourceLimitFatalError,"UnableToLockSemaphore"); } } #elif defined(MAGICKCORE_HAVE_WINTHREADS) EnterCriticalSection(&semaphore_info->mutex); #endif #if defined(MAGICKCORE_DEBUG) if ((semaphore_info->reference_count > 0) && (IsMagickThreadEqual(semaphore_info->id) != MagickFalse)) { (void) FormatLocaleFile(stderr,"Warning: unexpected recursive lock!\n"); (void) fflush(stderr); } #endif semaphore_info->id=GetMagickThreadId(); semaphore_info->reference_count++; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L o c k S e m a p h o r e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % LockSemaphoreInfo() locks a semaphore. % % The format of the LockSemaphoreInfo method is: % % MagickBooleanType LockSemaphoreInfo(SemaphoreInfo *semaphore_info) % % A description of each parameter follows: % % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure. % */ MagickExport MagickBooleanType LockSemaphoreInfo(SemaphoreInfo *semaphore_info) { assert(semaphore_info != (SemaphoreInfo *) NULL); assert(semaphore_info->signature == MagickSignature); #if defined(MAGICKCORE_HAVE_PTHREAD) { int status; status=pthread_mutex_lock(&semaphore_info->mutex); if (status != 0) return(MagickFalse); #if defined(MAGICKCORE_DEBUG) { if ((semaphore_info->reference_count > 0) && (IsMagickThreadEqual(semaphore_info->id) != MagickFalse)) { (void) fprintf(stderr,"Warning: unexpected recursive lock!\n"); (void) fflush(stderr); } } #endif } #elif defined(MAGICKORE_HAVE_WINTHREADS) { EnterCriticalSection(&semaphore_info->mutex); #if defined(MAGICKCORE_DEBUG) { if ((semaphore_info->reference_count > 0) && (IsMagickThreadEqual(semaphore_info->id) != MagickFalse)) { (void) fprintf(stderr,"Warning: unexpected recursive lock!\n"); (void) fflush(stderr); } } #endif } #endif semaphore_info->id=GetMagickThreadId(); semaphore_info->reference_count++; return(MagickTrue); }