/*
* Copyright 2006 Perforce Software. All rights reserved.
*
* This file is part of Perforce - the FAST SCM System.
*/
#define NEED_TIME
// Add defined tests here as needed for build problems...
# if defined(OS_MINGW) || defined(OS_MVS) || defined(OS_AS400)
# define NEED_OLD_RAND
# endif
# if defined(OS_NT) && !defined(OS_MINGW)
# define NEED_RAND_S
# define _CRT_RAND_S
# endif
#include <stdhdrs.h>
#include <pid.h>
#include "random.h"
static void
Initialize()
{
# ifndef NEED_RAND_S
MT_STATIC int inited = 0;
if( !inited )
{
int tim = time( NULL ) ^ Pid().GetID();
# ifdef NEED_OLD_RAND
srand( tim );
# else
srandom( tim );
# endif
inited = 1;
}
# endif
}
int
Random::Integer( int low, int high )
{
Initialize();
# ifdef NEED_RAND_S
unsigned int r;
rand_s( &r );
r = r >> 2;
# elif defined(NEED_OLD_RAND)
int r = rand() >> 2;
# else
int r = random();
# endif
return low + r % ( high - low + 1 );
}
# |
Change |
User |
Description |
Committed |
|
#1
|
15902 |
Matt Attaway |
A second renaming that I will not obliterate as a badge of shame |
|
|
//guest/perforce_software/p4/2014_1/support/random.cc |
#1
|
15901 |
Matt Attaway |
Clean up code to fit modern Workshop naming standards |
|
|
//guest/perforce_software/p4/2014.1/support/random.cc |
#1
|
12188 |
Matt Attaway |
Move 'main' p4 into a release specific directory in prep for new releases |
|
|
//guest/perforce_software/p4/support/random.cc |
#1
|
9129 |
Matt Attaway |
Initial commit of the 2014.1 p4/p4api source code |
|
|