mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-21 09:45:21 +00:00
Replace the existing Apache 2.0 boilerplate header with an SPDX tag throughout the zephyr code tree. This patch was generated via a script run over the master branch. Also updated doc/porting/application.rst that had a dependency on line numbers in a literal include. Manually updated subsys/logging/sys_log.c that had a malformed header in the original file. Also cleanup several cases that already had a SPDX tag and we either got a duplicate or missed updating. Jira: ZEP-1457 Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c Signed-off-by: David B. Kinder <david.b.kinder@intel.com> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
/*
|
|
* Copyright (c) 2013-2015 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* @brief Non-random number generator based on system timer
|
|
*
|
|
* This module provides a non-random implementation of sys_rand32_get(), which
|
|
* is not meant to be used in a final product as a truly random number
|
|
* generator. It was provided to allow testing on a platform that does not (yet)
|
|
* provide a random number generator.
|
|
*/
|
|
|
|
#include <drivers/rand32.h>
|
|
#include <drivers/system_timer.h>
|
|
#include <kernel.h>
|
|
#include <atomic.h>
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
/*
|
|
* Symbols used to ensure a rapid series of calls to random number generator
|
|
* return different values.
|
|
*/
|
|
static atomic_val_t _rand32_counter;
|
|
|
|
#define _RAND32_INC 1000000013
|
|
|
|
/**
|
|
*
|
|
* @brief Get a 32 bit random number
|
|
*
|
|
* The non-random number generator returns values that are based off the
|
|
* target's clock counter, which means that successive calls will return
|
|
* different values.
|
|
*
|
|
* @return a 32-bit number
|
|
*/
|
|
|
|
uint32_t sys_rand32_get(void)
|
|
{
|
|
return k_cycle_get_32() + atomic_add(&_rand32_counter, _RAND32_INC);
|
|
}
|
|
|
|
#endif /* __GNUC__ */
|