realtek-doc/sources/rtk-xgs1210/unittest/osal/osal_test_util.c
Markus Stockhausen 18a30ac6d1 add XGS1210 sdk
2025-04-27 15:53:52 -04:00

63 lines
1.3 KiB
C

/*
* Copyright (C) 2009-2016 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision: 71708 $
* $Date: 2016-09-19 11:31:17 +0800 (Mon, 19 Sep 2016) $
*
* Purpose : Definition of OSAL test APIs in the SDK
*
* Feature : OSAL test utility (OS dependent)
*
*/
/*
* Include Files
*/
#include <osal/osal_test_case.h>
#ifdef CONFIG_SDK_KERNEL_LINUX
/*
#include <asm/current.h>
#include <linux/jiffies.h>
*/
#include <linux/random.h>
#endif
/*
* Symbol Definition
*/
#ifdef CONFIG_SDK_KERNEL_LINUX
#define RAND_MAX 2147483647 /* 0x7FFFFFFF */
#endif
/*
* Data Declaration
*/
/*
* Macro
*/
/*
* Function Declaration
*/
#ifdef CONFIG_SDK_KERNEL_LINUX
int rand(void)
{
/* implementation 1: get a random word but it looks like kernel doesn't export this symbol */
// return (secure_ip_id(current->pid + jiffies) & RAND_MAX);
/* implementation 2: use exported symbol in kernel module */
int x;
get_random_bytes(&x, sizeof(x));
return (x & RAND_MAX);
}
#endif