2 Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
8 https://www.imagemagick.org/script/license.php
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 MagickCore random generation private methods.
18 #ifndef MAGICKCORE_RANDOM_PRIVATE_H
19 #define MAGICKCORE_RANDOM_PRIVATE_H
21 #include "MagickCore/thread-private.h"
23 #if defined(__cplusplus) || defined(c_plusplus)
27 extern MagickPrivate double
28 GetRandomInfoNormalize(const RandomInfo *);
30 extern MagickPrivate MagickBooleanType
31 RandomComponentGenesis(void);
33 extern MagickPrivate unsigned long
34 *GetRandomInfoSeed(RandomInfo *);
36 extern MagickPrivate void
37 RandomComponentTerminus(void);
39 static inline RandomInfo **DestroyRandomInfoThreadSet(
40 RandomInfo **random_info)
45 assert(random_info != (RandomInfo **) NULL);
46 for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
47 if (random_info[i] != (RandomInfo *) NULL)
48 random_info[i]=DestroyRandomInfo(random_info[i]);
49 return((RandomInfo **) RelinquishMagickMemory(random_info));
52 static inline RandomInfo **AcquireRandomInfoThreadSet(void)
63 number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
64 random_info=(RandomInfo **) AcquireQuantumMemory(number_threads,
65 sizeof(*random_info));
66 if (random_info == (RandomInfo **) NULL)
67 return((RandomInfo **) NULL);
68 (void) ResetMagickMemory(random_info,0,number_threads*sizeof(*random_info));
69 for (i=0; i < (ssize_t) number_threads; i++)
71 random_info[i]=AcquireRandomInfo();
72 if (random_info[i] == (RandomInfo *) NULL)
73 return(DestroyRandomInfoThreadSet(random_info));
78 #if defined(__cplusplus) || defined(c_plusplus)