Commit graph

6 commits

Author SHA1 Message Date
Xiang Xiao
d1dc791d11 libs/libc/string: Add 4-byte alignment middle path for BSD functions.
libc_data_t is 8 bytes wide, so a buffer which is 4-byte but not
8-byte aligned falls back to the byte at a time loop.  Add a 32-bit
middle path so such buffers still handle four bytes per iteration.

* Add DETECTNULL32/DETECTCHAR32, UNALIGNED4/UNALIGNED4_X,
  LITTLEBLOCKSIZE4/BIGBLOCKSIZE4 and TOO_SMALL4 to libs/libc/libc.h.
* Take the new path in memccpy, memcmp, memcpy, memset, stpcpy,
  stpncpy, strcmp, strcpy, strncmp and strncpy when both pointers are
  4-byte aligned but the 8-byte path can't be used.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-08-17 10:47:33 +02:00
anjiahao
bd6b226546 libs/libc/string: Use long long to speed up the BSD string functions.
Most hardware accesses the memory through a 64-bit bus, so handle the
data in 64-bit chunks instead of "long" chunks which are only 32-bit
wide on the 32-bit platforms.

* Add the libc_data_t type (unsigned long long) and move the shared
  UNALIGNED/UNALIGNED_X/ALIGNED, LITTLEBLOCKSIZE, TOO_SMALL and
  DETECTNULL helpers from the individual C files to libs/libc/libc.h.
* Convert all lib_bsd*.c implementations to the new type and macros,
  which also drops the duplicated LONG_MAX conditionals.

Assisted-by: Claude:claude-opus-5
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-08-17 10:47:33 +02:00
anjiahao
871a9b3261 libc_bsd:add missing SPDX-License
Just add SPDX-License, no code changes

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-02-04 03:02:04 +08:00
raiden00pl
13ab107d67 libc: remove reference to non-existent readme
remove reference to non-existent readme in libc.

Pointing to the documentation page doesn't make sense in this case,
because it doesn't explain the use of `#undef XXX` for this case anyway.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-10-11 17:07:51 -04:00
Lars Kruse
3ce85ca54e style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
yangguangcai
f07aba5c1e libc string:Separate code.
Separate the code that follows the BSD license into independent files.

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-23 09:49:19 +08:00