[PATCH v2 05/16] lib: random: add stubs for PBL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux