From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 05/16] lib: random: add stubs for PBL
Date: Thu, 28 Nov 2024 10:45:16 +0100 [thread overview]
Message-ID: <Z0g7rBciygTZ03TI@pengutronix.de> (raw)
In-Reply-To: <20241125151228.341441-6-a.fatoum@pengutronix.de>
On Mon, Nov 25, 2024 at 04:12:17PM +0100, Ahmad Fatoum wrote:
> To optimize out calls to undefined functions in PBL at compile-time
> instead of link time, let's define stubs for the functions that
> are referenced in obj-pbl-y files, but inside function sections
> that are ultimately unreferenced.
>
> We don't use IS_PROPER here as we want to fail the build in barebox
> proper as before, when HWRNG support is missing.
IS_PROPER is renamed to IN_PROPER in this series and you are actually
using it in this patch.
Just drop this sentence?
Sascha
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> include/stdlib.h | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/include/stdlib.h b/include/stdlib.h
> index c427cbc87f6e..20bdc0491e3c 100644
> --- a/include/stdlib.h
> +++ b/include/stdlib.h
> @@ -2,6 +2,7 @@
> #ifndef __STDLIB_H
> #define __STDLIB_H
>
> +#include <linux/bug.h>
> #include <types.h>
> #include <malloc.h>
>
> @@ -13,11 +14,27 @@ unsigned int rand(void);
> /* set the seed for rand () */
> void srand(unsigned int seed);
>
> +struct hwrng;
> +
> /* fill a buffer with pseudo-random data */
> +#if IN_PROPER
> void get_random_bytes(void *buf, int len);
> int get_crypto_bytes(void *buf, int len);
> -struct hwrng;
> int hwrng_get_crypto_bytes(struct hwrng *rng, void *buf, int len);
> +#else
> +static inline void get_random_bytes(void *buf, int len)
> +{
> + BUG();
> +}
> +static inline int get_crypto_bytes(void *buf, int len)
> +{
> + return -ENOSYS;
> +}
> +static inline int hwrng_get_crypto_bytes(struct hwrng *rng, void *buf, int len)
> +{
> + return -ENOSYS;
> +}
> +#endif
>
> static inline u32 random32(void)
> {
> --
> 2.39.5
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2024-11-28 9:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 15:12 [PATCH v2 00/16] Remove dependency on ld --gc-section in PBL Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 01/16] scripts: include: add definitions for printk and BUG() Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 02/16] xfuncs: include <malloc.h> for free definition Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 03/16] pbl: define IN_PBL & IN_PROPER macros globally Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 04/16] treewide: replace inverted check for PBL with new IN_PROPER macro Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 05/16] lib: random: add stubs for PBL Ahmad Fatoum
2024-11-28 9:45 ` Sascha Hauer [this message]
2024-11-25 15:12 ` [PATCH v2 06/16] bootsource: stub out when in PBL Ahmad Fatoum
2024-11-28 9:47 ` Sascha Hauer
2024-11-25 15:12 ` [PATCH v2 07/16] crypto: provide crypto_memneq for PBL Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 08/16] cdev: stub out cdev_read/write " Ahmad Fatoum
2024-11-28 9:52 ` Sascha Hauer
2024-11-25 15:12 ` [PATCH v2 09/16] libfile: stub out file descriptor API " Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 10/16] environment: stub out environment " Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 11/16] of: stub out live tree API when using PBL Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 12/16] errno: stub out perror/strerror API when built for PBL Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 13/16] xfuncs: stub out " Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 14/16] stdio: stub out basprintf and friends " Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 15/16] memory: stub out request_barebox_region " Ahmad Fatoum
2024-11-25 15:12 ` [PATCH v2 16/16] malloc: add PBL stubs Ahmad Fatoum
2024-11-29 11:55 ` [PATCH v2 00/16] Remove dependency on ld --gc-section in PBL 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=Z0g7rBciygTZ03TI@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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