Reactos
at master 25 lines 514 B view raw
1// 2// rand_s.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// The implementation of the rand_s() function, which generates random numbers. 7// 8#include <corecrt_internal.h> 9#include <stdlib.h> 10 11 12 13extern "C" errno_t __cdecl rand_s(unsigned int* const result) 14{ 15 _VALIDATE_RETURN_ERRCODE(result != nullptr, EINVAL); 16 *result = 0; 17 18 if (!__acrt_RtlGenRandom(result, static_cast<ULONG>(sizeof(*result)))) 19 { 20 errno = ENOMEM; 21 return errno; 22 } 23 24 return 0; 25}