From: Sascha Hauer <s.hauer@pengutronix.de>
To: Peter Korsgaard <jacmet@sunsite.dk>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 04/11] include support for a simple pseudo number generator
Date: Tue, 15 Jun 2010 13:54:52 +0200 [thread overview]
Message-ID: <20100615115452.GC20799@pengutronix.de> (raw)
In-Reply-To: <87d3vseisk.fsf@macbook.be.48ers.dk>
Hi Peter,
On Tue, Jun 15, 2010 at 11:39:39AM +0200, Peter Korsgaard wrote:
> >>>>> "Sascha" == Sascha Hauer <s.hauer@pengutronix.de> writes:
>
> Sascha> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Sascha> ---
> Sascha> include/random.h | 7 +++++++
> Sascha> lib/Makefile | 1 +
> Sascha> lib/random.c | 22 ++++++++++++++++++++++
> Sascha> 3 files changed, 30 insertions(+), 0 deletions(-)
> Sascha> create mode 100644 include/random.h
> Sascha> create mode 100644 lib/random.c
>
> Sascha> diff --git a/lib/random.c b/lib/random.c
> Sascha> new file mode 100644
> Sascha> index 0000000..25315e7
> Sascha> --- /dev/null
> Sascha> +++ b/lib/random.c
> Sascha> @@ -0,0 +1,22 @@
> Sascha> +#include <common.h>
> Sascha> +#include <random.h>
> Sascha> +
> Sascha> +static int random_seed;
> Sascha> +
> Sascha> +static unsigned char rand(void)
> Sascha> +{
> Sascha> + random_seed = random_seed * 1103515245 + 12345;
> Sascha> + return (unsigned char)(random_seed / 65536) % 256;
> Sascha> +}
>
> Any reason to not make this public and return int instead similar to
> rand(3)?
The reason was that I did not need rand but get_random_bytes and I
wasn't aware that rand() is that close to the corresponding libc
function.
>
> We could presumably simply do:
>
> #define RAND_MAX 255
>
> And to be completely correct, these prototypes should be in stdlib.h
> instead.
Ok, will do.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2010-06-15 11:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-14 9:48 More patches Sascha Hauer
2010-06-14 9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
2010-06-14 9:48 ` [PATCH 02/11] bootu: Allow passing in devices as parameter Sascha Hauer
2010-06-14 9:48 ` [PATCH 03/11] Allow to merge default environment from more than one directory Sascha Hauer
2010-06-14 9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
2010-06-15 9:39 ` Peter Korsgaard
2010-06-15 11:54 ` Sascha Hauer [this message]
2010-06-17 13:17 ` Sascha Hauer
2010-06-17 13:26 ` Andy Pont
2010-06-17 14:14 ` Peter Korsgaard
2010-06-14 9:48 ` [PATCH 05/11] net: implement random_ether_addr Sascha Hauer
2010-06-14 9:48 ` [PATCH 06/11] net: use a random mac address if the current device does not have one Sascha Hauer
2010-06-14 9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
2010-06-15 9:13 ` Uwe Kleine-König
2010-06-17 13:20 ` Sascha Hauer
2010-06-19 20:14 ` Uwe Kleine-König
2010-06-14 9:48 ` [PATCH 08/11] pcm038: use generic default env Sascha Hauer
2010-06-14 9:48 ` [PATCH 09/11] pcm043: " Sascha Hauer
2010-06-14 9:48 ` [PATCH 10/11] pcm037: " Sascha Hauer
2010-06-14 9:48 ` [PATCH 11/11] pca100: " Sascha Hauer
2010-06-18 6:28 [PATCH 04/11] include support for a simple pseudo number generator 'Sascha Hauer'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100615115452.GC20799@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jacmet@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox