MagickCore 7.1.1
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
random-private.h
1/*
2 Copyright @ 2001 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
4
5 You may not use this file except in compliance with the License. You may
6 obtain a copy of the License at
7
8 https://imagemagick.org/script/license.php
9
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.
15
16 MagickCore random generation private methods.
17*/
18#ifndef MAGICKCORE_RANDOM_PRIVATE_H
19#define MAGICKCORE_RANDOM_PRIVATE_H
20
21#include "MagickCore/thread-private.h"
22
23#if defined(__cplusplus) || defined(c_plusplus)
24extern "C" {
25#endif
26
27extern MagickPrivate double
28 GetRandomInfoNormalize(const RandomInfo *);
29
30extern MagickPrivate MagickBooleanType
31 RandomComponentGenesis(void);
32
33extern MagickPrivate unsigned long
34 *GetRandomInfoSeed(RandomInfo *);
35
36extern MagickPrivate void
37 RandomComponentTerminus(void);
38
39static inline RandomInfo **DestroyRandomInfoTLS(RandomInfo **random_info)
40{
41 ssize_t
42 i;
43
44 for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
45 if (random_info[i] != (RandomInfo *) NULL)
46 random_info[i]=DestroyRandomInfo(random_info[i]);
47 return((RandomInfo **) RelinquishMagickMemory(random_info));
48}
49
50static inline RandomInfo **AcquireRandomInfoTLS(void)
51{
52 ssize_t
53 i;
54
56 **random_info;
57
58 size_t
59 number_threads;
60
61 number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
62 random_info=(RandomInfo **) AcquireQuantumMemory(number_threads,
63 sizeof(*random_info));
64 if (random_info == (RandomInfo **) NULL)
65 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
66 (void) memset(random_info,0,number_threads*sizeof(*random_info));
67 for (i=0; i < (ssize_t) number_threads; i++)
68 random_info[i]=AcquireRandomInfo();
69 return(random_info);
70}
71
72#if defined(__cplusplus) || defined(c_plusplus)
73}
74#endif
75
76#endif