kernel/eka/kernel/random.cpp
changeset 270 ea2cef07f9fe
parent 90 947f0dc9f7a8
child 294 039a3e647356
equal deleted inserted replaced
255:d45b74d3fb20 270:ea2cef07f9fe
     1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   117 		K::PanicKernExec(EKUDesSetLengthInvalidType);
   117 		K::PanicKernExec(EKUDesSetLengthInvalidType);
   118 		}
   118 		}
   119 
   119 
   120 	// The random number generator requires a temporary buffer to write the data to, before we write it back to
   120 	// The random number generator requires a temporary buffer to write the data to, before we write it back to
   121 	// userspace's buffer. The buffer is allocated here on the stack to avoid having to heap-allocate, and if
   121 	// userspace's buffer. The buffer is allocated here on the stack to avoid having to heap-allocate, and if
   122 	// the requested amount of data is larger, a loop is used. 2048 bytes will always fit onto the stack in an
   122 	// the requested amount of data is larger, a loop is used. 1024 bytes will always fit onto the stack in an
   123 	// exec handler.
   123 	// exec handler.
   124 	const TInt KRandomBufferSize = 2048;
   124 	const TInt KRandomBufferSize = 1024;
   125 	TBuf8<KRandomBufferSize> randomBuffer;
   125 	TBuf8<KRandomBufferSize> randomBuffer;
   126 
   126 
   127 	TInt err = KErrNone;
   127 	TInt err = KErrNone;
   128 	TBool isKErrNotReadyTrue = EFalse;
   128 	TBool isKErrNotReadyTrue = EFalse;
   129 	while(randomValueLength > 0)
   129 	while(randomValueLength > 0)