Coverage Report

Created: 2025-07-23 08:18

/src/graphicsmagick/magick/random-private.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
  Copyright (C) 2009, 2014 GraphicsMagick Group
3
4
  This program is covered by multiple licenses, which are described in
5
  Copyright.txt. You should have received a copy of Copyright.txt with this
6
  package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
7
8
  Random number generator (private not-installed parts).
9
10
  Currently based on George Marsaglia's multiply-with-carry generator.
11
  This is a k=2 generator with a period >2^60.
12
*/
13
14
/*
15
  Initialize the random kernel with suitable entropy
16
*/
17
MagickExport void InitializeMagickRandomKernel(MagickRandomKernel *kernel);
18
19
/*
20
  Acquire the default random number kernel.  Memory is owned by
21
  library and should not be freed.
22
*/
23
MagickExport MagickRandomKernel* AcquireMagickRandomKernel();
24
25
/*
26
  Initialize the random number generator system.
27
*/
28
extern void InitializeMagickRandomGenerator();
29
30
/*
31
  Destroy the random number generator system.
32
*/
33
extern void DestroyMagickRandomGenerator();
34
35
/*
36
  You may replace the following two constants MAGICK_RANDOM_ZC and
37
  MAGICK_RANDOM_WC by any pair of distinct constants from this list:
38
39
  18000 18030 18273 18513 18879 19074 19098 19164 19215 19584
40
  19599 19950 20088 20508 20544 20664 20814 20970 21153 21243
41
  21423 21723 21954 22125 22188 22293 22860 22938 22965 22974
42
  23109 23124 23163 23208 23508 23520 23553 23658 23865 24114
43
  24219 24660 24699 24864 24948 25023 25308 25443 26004 26088
44
  26154 26550 26679 26838 27183 27258 27753 27795 27810 27834
45
  27960 28320 28380 28689 28710 28794 28854 28959 28980 29013
46
  29379 29889 30135 30345 30459 30714 30903 30963 31059 31083
47
48
  (or any other 16-bit constants k for which both k*2^16-1 and
49
  k*2^15-1 are prime).
50
*/
51
2.49M
#define MAGICK_RANDOM_ZC 36969
52
2.49M
#define MAGICK_RANDOM_WC 18000
53
54
/*
55
  Generate a random integer value
56
*/
57
static MAGICK_FUNC_ALWAYSINLINE inline magick_uint32_t MagickRandomIntegerInlined(MagickRandomKernel *kernel)
58
2.49M
{
59
2.49M
  kernel->z = MAGICK_RANDOM_ZC * (kernel->z & 65535U) + (kernel->z >> 16U);
60
2.49M
  kernel->w = MAGICK_RANDOM_WC * (kernel->w & 65535U) + (kernel->w >> 16U);
61
2.49M
  return (kernel->z << 16U) + (kernel->w & 65535U);
62
2.49M
}
Unexecuted instantiation: Blob.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: BlobRef.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Exception.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Image.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: ImageRef.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Options.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Pixels.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Thread.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Color.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Drawable.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Functions.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Geometry.cpp:MagickLib::MagickRandomIntegerInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: annotate.c:MagickRandomIntegerInlined
Unexecuted instantiation: colorspace.c:MagickRandomIntegerInlined
Unexecuted instantiation: composite.c:MagickRandomIntegerInlined
Unexecuted instantiation: draw.c:MagickRandomIntegerInlined
Unexecuted instantiation: effect.c:MagickRandomIntegerInlined
Unexecuted instantiation: enhance.c:MagickRandomIntegerInlined
Unexecuted instantiation: fx.c:MagickRandomIntegerInlined
Unexecuted instantiation: gem.c:MagickRandomIntegerInlined
Unexecuted instantiation: image.c:MagickRandomIntegerInlined
Unexecuted instantiation: magick.c:MagickRandomIntegerInlined
Unexecuted instantiation: operator.c:MagickRandomIntegerInlined
random.c:MagickRandomIntegerInlined
Line
Count
Source
58
2.49M
{
59
2.49M
  kernel->z = MAGICK_RANDOM_ZC * (kernel->z & 65535U) + (kernel->z >> 16U);
60
2.49M
  kernel->w = MAGICK_RANDOM_WC * (kernel->w & 65535U) + (kernel->w >> 16U);
61
2.49M
  return (kernel->z << 16U) + (kernel->w & 65535U);
62
2.49M
}
Unexecuted instantiation: render.c:MagickRandomIntegerInlined
Unexecuted instantiation: tempfile.c:MagickRandomIntegerInlined
Unexecuted instantiation: utility.c:MagickRandomIntegerInlined
Unexecuted instantiation: pcd.c:MagickRandomIntegerInlined
Unexecuted instantiation: svg.c:MagickRandomIntegerInlined
Unexecuted instantiation: analyze.c:MagickRandomIntegerInlined
Unexecuted instantiation: command.c:MagickRandomIntegerInlined
Unexecuted instantiation: montage.c:MagickRandomIntegerInlined
63
64
/*
65
  Generate a random double value (0.0 to 1.0)
66
*/
67
static MAGICK_FUNC_ALWAYSINLINE inline double MagickRandomRealInlined(MagickRandomKernel *kernel)
68
0
{
69
0
  double result = MagickRandomIntegerInlined(kernel) * 2.3283064370807974e-10;
70
0
  if (result > 1.0)
71
0
    result=1.0;
72
0
  return result;
73
0
}
Unexecuted instantiation: Blob.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: BlobRef.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Exception.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Image.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: ImageRef.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Options.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Pixels.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Thread.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Color.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Drawable.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Functions.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: Geometry.cpp:MagickLib::MagickRandomRealInlined(MagickLib::_MagickRandomKernel*)
Unexecuted instantiation: annotate.c:MagickRandomRealInlined
Unexecuted instantiation: colorspace.c:MagickRandomRealInlined
Unexecuted instantiation: composite.c:MagickRandomRealInlined
Unexecuted instantiation: draw.c:MagickRandomRealInlined
Unexecuted instantiation: effect.c:MagickRandomRealInlined
Unexecuted instantiation: enhance.c:MagickRandomRealInlined
Unexecuted instantiation: fx.c:MagickRandomRealInlined
Unexecuted instantiation: gem.c:MagickRandomRealInlined
Unexecuted instantiation: image.c:MagickRandomRealInlined
Unexecuted instantiation: magick.c:MagickRandomRealInlined
Unexecuted instantiation: operator.c:MagickRandomRealInlined
Unexecuted instantiation: random.c:MagickRandomRealInlined
Unexecuted instantiation: render.c:MagickRandomRealInlined
Unexecuted instantiation: tempfile.c:MagickRandomRealInlined
Unexecuted instantiation: utility.c:MagickRandomRealInlined
Unexecuted instantiation: pcd.c:MagickRandomRealInlined
Unexecuted instantiation: svg.c:MagickRandomRealInlined
Unexecuted instantiation: analyze.c:MagickRandomRealInlined
Unexecuted instantiation: command.c:MagickRandomRealInlined
Unexecuted instantiation: montage.c:MagickRandomRealInlined
74
75
/*
76
 * Local Variables:
77
 * mode: c
78
 * c-basic-offset: 2
79
 * fill-column: 78
80
 * End:
81
 */