ReactOS 0.4.16-dev-1078-g21d3e29
rand_s.cpp
Go to the documentation of this file.
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{
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}
#define EINVAL
Definition: acclib.h:90
#define ENOMEM
Definition: acclib.h:84
#define __cdecl
Definition: accygwin.h:79
GLuint64EXT * result
Definition: glext.h:11304
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
errno_t __cdecl rand_s(unsigned int *const result)
Definition: rand_s.cpp:13
#define errno
Definition: errno.h:18
uint32_t ULONG
Definition: typedefs.h:59
int errno_t
Definition: corecrt.h:615
BOOLEAN WINAPI __acrt_RtlGenRandom(PVOID const buffer, ULONG const buffer_count)