% MagickCore Methods to Generate Random Numbers %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% December 2001 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#define environ (*_NSGetEnviron())
#endif
+#if !defined(MAGICKCORE_WINDOWS_SUPPORT)
extern char
**environ;
+#endif
\f
/*
Global declarations.
random_info->secret_key=secret_key;
random_info->protocol_major=RandomProtocolMajorVersion;
random_info->protocol_minor=RandomProtocolMinorVersion;
- random_info->semaphore=AllocateSemaphoreInfo();
+ random_info->semaphore=AcquireSemaphoreInfo();
random_info->timestamp=(ssize_t) time(0);
random_info->signature=MagickSignature;
/*
(void) ResetMagickMemory(random_info->seed,0,sizeof(*random_info->seed));
random_info->signature=(~MagickSignature);
UnlockSemaphoreInfo(random_info->semaphore);
- DestroySemaphoreInfo(&random_info->semaphore);
+ RelinquishSemaphoreInfo(&random_info->semaphore);
random_info=(RandomInfo *) RelinquishMagickMemory(random_info);
return(random_info);
}
#if defined(MAGICKCORE_HAVE_MKSTEMP)
{
char
- *filename;
+ path[MaxTextExtent];
int
file;
- filename=ConstantString("magickXXXXXX");
- file=mkstemp(filename);
+ (void) GetPathTemplate(path);
+ file=mkstemp(path);
#if defined(__OS2__)
setmode(file,O_BINARY);
#endif
if (file != -1)
(void) close(file);
- (void) remove_utf8(filename);
- SetStringInfoLength(chaos,strlen(filename));
- SetStringInfoDatum(chaos,(unsigned char *) filename);
+ (void) remove_utf8(path);
+ SetStringInfoLength(chaos,strlen(path));
+ SetStringInfoDatum(chaos,(unsigned char *) path);
ConcatenateStringInfo(entropy,chaos);
- filename=DestroyString(filename);
}
#endif
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
*/
MagickPrivate MagickBooleanType RandomComponentGenesis(void)
{
- AcquireSemaphoreInfo(&random_semaphore);
+ if (random_semaphore == (SemaphoreInfo *) NULL)
+ random_semaphore=AcquireSemaphoreInfo();
return(MagickTrue);
}
\f
MagickPrivate void RandomComponentTerminus(void)
{
if (random_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&random_semaphore);
- DestroySemaphoreInfo(&random_semaphore);
+ ActivateSemaphoreInfo(&random_semaphore);
+ RelinquishSemaphoreInfo(&random_semaphore);
}
\f
/*
{
gather_true_random=true_random;
}
+
+MagickPrivate unsigned long *GetRandomInfoSeed(RandomInfo *random_info)
+{
+ assert(random_info != (RandomInfo *) NULL);
+ return random_info->seed;
+}
+
+MagickPrivate double GetRandomInfoNormalize(RandomInfo *random_info)
+{
+ assert(random_info != (RandomInfo *) NULL);
+ return random_info->normalize;
+}