nuttx/libs/libc/stdlib
hanzhijian 9e467388de stdlib/rand: replace weak LCG with xorshift32 PRNG
The existing first-order LCG (seed = 470001 * seed % 999563) has several
quality problems:
- Output range limited to [1, 999562] (~20 bits) instead of full 32-bit
- Lower bits have very short periods (8-bit period = 1, 16-bit = 105)
- Overall period only ~1M, far too short for many applications
- Causes mbedtls_rsa_gen_key to loop forever when rand() consumption
  aligns with the cycle length (issue #16760)

Replace the entire order-based LCG implementation (CONFIG_LIBC_RAND_ORDER
0-3) with Marsaglia's xorshift32:
- Full 32-bit output range
- Period 2^32 - 1 (~4.29 billion)
- Fast: just three XOR/shift operations
- No floating-point math needed
- No CONFIG_LIBC_RAND_ORDER configuration required

Remove the CONFIG_LIBC_RAND_ORDER Kconfig option and clean up all
defconfig references (12 boards) and related comments.

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
2026-07-03 15:08:12 +08:00
..
CMakeLists.txt libc: improve libc dependencies in case of LIBM_NONE 2025-12-14 17:57:27 -03:00
Kconfig stdlib/rand: replace weak LCG with xorshift32 PRNG 2026-07-03 15:08:12 +08:00
lib_abort.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_abs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_aligned_alloc.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_arc4random.c libc: Fix lib_arc4random.c:111:(.text.arc4random_buf+0x26): undefined reference to `clock_systime_ticks' 2024-10-28 09:23:19 +01:00
lib_atexit.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_atof.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_atoi.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_atol.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_atoll.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_bsearch.c style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
lib_checkbase.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_div.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_exit.c Revert "libs/libc/stdlib/lib_exit.c: fix multiple definition of __dso_handle in msys2" 2025-07-31 22:10:36 +08:00
lib_getprogname.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_itoa.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_labs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ldiv.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_llabs.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_lldiv.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_mblen.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_mbstowcs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_mbtowc.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_mkdtemp.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_mkstemp.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_mktemp.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_openpty.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_posix_memalign.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_ptsname.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ptsnamer.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_qsort.c libs/libc/stdlib: migrate to SPDX identifier 2024-12-17 09:36:46 +08:00
lib_rand.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_rand48.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_reallocarray.c style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
lib_realpath.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_srand.c stdlib/rand: replace weak LCG with xorshift32 PRNG 2026-07-03 15:08:12 +08:00
lib_strtol.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_strtold.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_strtoll.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_strtoul.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_strtoull.c !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
lib_unlockpt.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_valloc.c libc: remove reference to non-existent readme 2025-10-11 17:07:51 -04:00
lib_wcstombs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_wctomb.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
Make.defs libc: improve libc dependencies in case of LIBM_NONE 2025-12-14 17:57:27 -03:00