random-private.h

Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
00003   dedicated to making software imaging solutions freely available.
00004   
00005   You may not use this file except in compliance with the License.  You may
00006   obtain a copy of the License at
00007   
00008     https://imagemagick.org/script/license.php
00009   
00010   Unless required by applicable law or agreed to in writing, software
00011   distributed under the License is distributed on an "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013   See the License for the specific language governing permissions and
00014   limitations under the License.
00015 
00016   MagickCore random generation private methods.
00017 */
00018 #ifndef MAGICKCORE_RANDOM_PRIVATE_H
00019 #define MAGICKCORE_RANDOM_PRIVATE_H
00020 
00021 #include "MagickCore/thread-private.h"
00022 
00023 #if defined(__cplusplus) || defined(c_plusplus)
00024 extern "C" {
00025 #endif
00026 
00027 extern MagickPrivate double
00028   GetRandomInfoNormalize(const RandomInfo *);
00029 
00030 extern MagickPrivate MagickBooleanType
00031   RandomComponentGenesis(void);
00032 
00033 extern MagickPrivate unsigned long
00034   *GetRandomInfoSeed(RandomInfo *);
00035 
00036 extern MagickPrivate void
00037   RandomComponentTerminus(void);
00038 
00039 static inline RandomInfo **DestroyRandomInfoThreadSet(
00040   RandomInfo **random_info)
00041 {
00042   register ssize_t
00043     i;
00044 
00045   assert(random_info != (RandomInfo **) NULL);
00046   for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
00047     if (random_info[i] != (RandomInfo *) NULL)
00048       random_info[i]=DestroyRandomInfo(random_info[i]);
00049   return((RandomInfo **) RelinquishMagickMemory(random_info));
00050 }
00051 
00052 static inline RandomInfo **AcquireRandomInfoThreadSet(void)
00053 {
00054   register ssize_t
00055     i;
00056 
00057   RandomInfo
00058     **random_info;
00059 
00060   size_t
00061     number_threads;
00062 
00063   number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
00064   random_info=(RandomInfo **) AcquireQuantumMemory(number_threads,
00065     sizeof(*random_info));
00066   if (random_info == (RandomInfo **) NULL)
00067     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00068   (void) memset(random_info,0,number_threads*sizeof(*random_info));
00069   for (i=0; i < (ssize_t) number_threads; i++)
00070     random_info[i]=AcquireRandomInfo();
00071   return(random_info);
00072 }
00073 
00074 #if defined(__cplusplus) || defined(c_plusplus)
00075 }
00076 #endif
00077 
00078 #endif

Generated on 27 Nov 2019 for MagickCore by  doxygen 1.6.1