ReactOS 0.4.15-dev-8236-g99f0937
rand_s.c File Reference
#include <apitest.h>
#include <stdio.h>
Include dependency graph for rand_s.c:

Go to the source code of this file.

Typedefs

typedef int __cdecl rand_s_t(unsigned int *)
 

Functions

void test_rand_s_performance (void)
 
 START_TEST (rand_s)
 

Variables

rand_s_tp_rand_s
 

Typedef Documentation

◆ rand_s_t

typedef int __cdecl rand_s_t(unsigned int *)

Definition at line 15 of file rand_s.c.

Function Documentation

◆ START_TEST()

START_TEST ( rand_s  )

Definition at line 33 of file rand_s.c.

34{
35 unsigned int val;
36 int ret;
37
38#ifndef TEST_STATIC_CRT
39 /* Dynamically load rand_s from mvcrt */
40 HMODULE msvcrt = GetModuleHandleA("msvcrt");
41 p_rand_s = (rand_s_t*)GetProcAddress(msvcrt, "rand_s");
42 if (!p_rand_s)
43 {
44 win_skip("rand_s is not available\n");
45 return;
46 }
47#else
49#endif
50
51 /* Test performance */
53
54 /* Test with NULL pointer */
55 ret = p_rand_s(NULL);
56 ok(ret == EINVAL, "Expected EINVAL, got %d\n", ret);
57
58 /* Test with valid pointer */
59 ret = p_rand_s(&val);
60 ok(ret == 0, "Expected 0, got %d\n", ret);
61}
#define EINVAL
Definition: acclib.h:90
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
GLuint GLfloat * val
Definition: glext.h:7180
int __cdecl rand_s_t(unsigned int *)
Definition: rand_s.c:15
rand_s_t * p_rand_s
Definition: rand_s.c:16
void test_rand_s_performance(void)
Definition: rand_s.c:18
#define win_skip
Definition: test.h:163
int CDECL rand_s(unsigned int *pval)
Definition: rand_s.c:18
int ret

◆ test_rand_s_performance()

void test_rand_s_performance ( void  )

Definition at line 18 of file rand_s.c.

19{
20 unsigned long long start, end;
21 unsigned int val;
22 int i;
23
24 start = __rdtsc();
25 for (i = 0; i < 10000; i++)
26 {
27 p_rand_s(&val);
28 }
29 end = __rdtsc();
30 printf("rand_s took %llu cycles\n", end - start);
31}
#define printf
Definition: freeldr.h:97
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688

Referenced by START_TEST().

Variable Documentation

◆ p_rand_s

rand_s_t* p_rand_s

Definition at line 16 of file rand_s.c.

Referenced by START_TEST(), and test_rand_s_performance().