ReactOS 0.4.16-dev-2110-ge3521eb
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}
int errno_t
Definition: corecrt.h:249
#define __cdecl
Definition: corecrt.h:121
#define EINVAL
Definition: errno.h:44
#define ENOMEM
Definition: errno.h:35
#define errno
Definition: errno.h:120
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
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN WINAPI __acrt_RtlGenRandom(PVOID const buffer, ULONG const buffer_count)