summaryrefslogtreecommitdiff
path: root/libc/string
AgeCommit message (Collapse)Author
2016-06-19bugfix: ARM: memset.S: use unsigned comparisonsLucian Cojocar
The 'BLT' instruction checks for *signed* values. So if a3, length parameter of memset, is negative, then value added to the PC will be large. memset(buf, 0xaa, 0xffff0000) triggers the bug. GDB session without the patch: """ $ gdb ./main-buggy-memset.elf -q Reading symbols from ./main-buggy-memset.elf...done. (gdb) x/i memset 0x8770 <memset>: mov r3, r0 (gdb) r Starting program: /root/memset/main-buggy-memset.elf Program received signal SIGSEGV, Segmentation fault. 0x00048808 in ?? () """ The $pc is outside of the memset function because: """ (gdb) x/i $pc => 0x87e4 <memset+116>: add pc, pc, r2, lsl #2 (gdb) info reg $r2 r2 0x10007 65543 """ GDB session with the bug fixed (patch applied): """ $ gdb ./main-fixed-memset.elf -q Reading symbols from ./main-fixed-memset.elf...done. (gdb) x/i memset 0x8770 <memset>: mov r3, r0 (gdb) r Starting program: /root/memset/main-fixed-memset.elf Program received signal SIGSEGV, Segmentation fault. memset () at libc/string/arm/memset.S:92 92 libc/string/arm/memset.S: No such file or directory. (gdb) x/i $pc => 0x87b0 <memset+64>: stmia r3!, {r1, r12} (gdb) info reg $r3 r3 0x15000 86016 (gdb) info proc mappings process 5822 Mapped address spaces: Start Addr End Addr Size Offset objfile 0x8000 0xb000 0x3000 0x0 /root/memset/main-fixed-memset.elf 0x12000 0x15000 0x3000 0x2000 /root/memset/main-fixed-memset.elf 0xb6fff000 0xb7000000 0x1000 0x0 [sigpage] 0xbefdf000 0xbf000000 0x21000 0x0 0xffff0000 0xffff1000 0x1000 0x0 [vectors] (gdb) info reg $sp sp 0x14d78 0x14d78 """ GDB crashes inside the memset function, on the store instruction. This time the crash is (as expected) because of a memory access imediately after the memory region that contains the stack -- the buffer that's being memset'd is allocated on the stack. Signed-off-by: Lucian Cojocar <lucian.cojocar@vu.nl>
2016-06-01remove MJN only debug messagesWaldemar Brodkorb
2016-05-29mips: allow to disable prefetch support in memcpy/memsetWaldemar Brodkorb
There exist some problem with the new memcpy/memset functions imported from GNU libc/newlib. If you have any problem with the new MIPS optimized assembly try to disable prefetching support. Thanks to Rene Nielsen and Matthew Fortune analyzing the problem so far.
2016-02-03mips: fix build if threads are disabledWaldemar Brodkorb
Reported-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
2016-01-31mips64: fix memcpy, patch from glibcWaldemar Brodkorb
Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-22Replace MIPS specific memcpy.S/memset.S with version from glibc/newlib.Steve Ellcey
These MIPS specific versions of memcpy.S and memset.S are faster than the current ones and match what is in newlib and glibc. They also have support for the mips32r6 and mips64r6 architectures. Signed-off-by: Steve Ellcey <sellcey@imgtec.com>
2015-12-22Use gcc's __builtin_mempcpy() as __mempcpy(), if possibleWaldemar Brodkorb
Patch from OpenWrt. Reported-by: Leonid Lisovskiy <lly.dev@gmail.com>
2015-12-05remove sh64 supportWaldemar Brodkorb
No real hardware available. The project for sh64 with sh5 seems dead since 10 years. Gcc will remove support for it soon.
2015-10-08xtensa: support call0 ABIMax Filippov
Most changes are mechanical replacement of 'retw' instruction with 'abi_ret' macro, defined to 'retw' or 'ret' according to ABI. Assembly code that makes calls is duplicated for call0 ABI with changed register numbers for parameters/return value and call instruction. 'entry' instructions are replaced with 'abi_entry' macro. More interesting changes: - non-leaf assembly functions (e.g. _dl_tlsdesc_dynamic, _dl_linux_resolve, SYSCALL_ERROR_HANDLER, PSEUDO) now need to preserve registers around intermediate calls they make, use temporary stack frame for that; - setjmp/longjmp only need to save and restore return address, stack pointer and callee-saved registers in the jmpbuf; - __clone and syscall functions had hardcoded offsets to parameter passed on stack, on call0 ABI they don't need stack frame, so the offset is different. Replace these offsets with FRAMESIZE macro. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-07-22ARCv2: update memset() so it could be used without double load/storesClaudiu Zissulescu
Existing version of memset() relies on existence of 64-bit load/stores. While ARC HS38 may not have those instructions implemented in SoC. Proposed implementation checks if "-mno-ll64" option was passed to gcc (for ARCv2 "-mll64" is set implicitly by default) by checking __LL64__ definition and if it is not defined uses 32-bit load/stores. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Vineet Gupta <vgupta@synopsys.com>
2015-04-24merge uClibc changesWaldemar Brodkorb
2015-04-22arm: Add BX and BXC macrosBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-04-12remove more of the link_warningsWaldemar Brodkorb
Only the stub warnings left for now.
2015-03-17libc: update strverscmpBernhard Reutner-Fischer
Closes bugzilla #7936 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-02-20ARCv2: optimised string routinesVineet Gupta
Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-02-20ARCv2 ISA supportVineet Gupta
This is next gen Instruction Set Architecture from Synopsys and basis for the ARC HS family of processors. http://www.synopsys.com/dw/ipdir.php?ds=arc-hs38-processor&elq_mid=5732&elq_cid=458802 http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/arc-hs/Pages/default.aspx Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2015-01-22libc: Avoid redundant setting of ENOMEMBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2014-09-04sparc: remove sparc64/sparcv9 codeWaldemar Brodkorb
The sparc64/sparcv9 code is incomplete. Furthermore there is no real embedded hardware for sparc64 available, so better remove it until someone comes up with a complete port. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2014-06-12arm: move check for BX to its own headerYann E. MORIN
As Will noticed, the header this check is currently done in is asm-only, and is not meant to be included from C code. This breaks compilation when compiled for a Thumb2-aware CPU. Move the BX check to its own header, and revert 7a246fd. Reported-by: Will Newton <will.newton@gmail.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Will Newton <will.newton@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2014-04-01xtensa: add missing .literal_position directivesMax Filippov
This addition allows building uClibc with -mtext-section-literals Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-12-20string: Add ARC supportJoern Rennecke
Signed-off-by: Joern Rennecke <joern.rennecke@embecosm.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-14Add support for the Meta architectureMarkos Chandras
Meta cores are 32-bit, hardware multithreaded, general purpose, embedded processors which also feature a DSP instruction set, and can be found in many digital radios. They are capable of running different operating systems on different hardware threads, for example a digital radio might run RTOSes for DAB decoding and audio decoding on 3 hardware threads, and run Linux on the 4th hardware thread to manage the user interface, networking etc. HTPs are also capable of running SMP Linux on multiple hardware threads. Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-11-18Replace FSF snail mail address with URLsMike Frysinger
This matches a similar change made to glibc. No functional changes here. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-11-17string/microblaze: fix preprocessor styleMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-11-12string/microblaze: Fix for little-endianSteve Bennett
Fix the asm-optimised memcpy and memmove so they work for little-endian as well as big-endian. Testing has shown no issues, but I am not a microblaze asm expert so YMMV. Signed-off-by: Steve Bennett <steveb@workware.net.au> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15remove sysdep.h from arch specific string implementationPeter S. Mazinger
Remove hardcoded path from xtensa, we have sysdep.h in path Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15_collate.c: avoid initialization warningPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15memmove.c,strchrnul.c: use real name in libc_hidden_defPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15bcopy.c,bzero.c: include string.h instead of _string.hPeter S. Mazinger
No need for internal _string.h. For now include string.h, although the correct header would be strings.h. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15dirname.c: include only what is neededPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15basename.c: define it correctly, use the proper header for each versionPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15*_strerror_r.c: keep all occurences in sync with string.hPeter S. Mazinger
libc-internal.h: this has to provide the reversed case of what string.h defines. Accomodate for later possibility to compile without _GNU_SOURCE defined Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15__xpg_strerror_r.c, {ge,se}trlimit.c: use strong_alias_untypedPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15remove unneeded hiddens for rtime, basename, strtof* and wcstof*Peter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-05-03string: remove unused variableBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-03-10str[n]casecmp.c: fix hidden usagePeter S. Mazinger
Provide visible str[n]casecmp[_l], wcs[n]casecmp[_l]. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09remove unused hidden functionsPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09frv/memset.S: add missing libc_hidden_defPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09memmem.c, string.h: remove unused hidden memmemPeter S. Mazinger
It is used only by gen_collate, not included into libc. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09_collate.c: remove duplicated libc_hidden_proto() for strcoll*/wcscoll*Peter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09wchar.h, _collate.c, strlcpy.c: use a common prototype of __wcslcpyPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09ctype.c, _collate.c, str[n]casecmp.c, strlcpy.c: remove unused hidden functionsPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-09guard *_chk() related stuff with UCLIBC_HAS_FORTIFYPeter S. Mazinger
Guard x86_64 memset_chk/memcpy_chk be guarded by UCLIBC_HAS_FORTIFY. Compile ssp.c if one of SSP/FORTIFY is defined. Guard __chk_fail() with UCLIBC_HAS_FORTIFY and move its prototype to libc-internal.h. Disable _FORTIFY_SOURCE if UCLIBC_HAS_FORTIFY is not set. The config option itself is omitted on purpose, headers need to be reviewed and generic *_chk() functions need to be first provided. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-06simplify ffs* codePeter S. Mazinger
Remove __libc_ffs*, unneeded Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2011-03-05Implement ffsl and ffsll.Bernd Schmidt
This imports and adapts ffsll.c from glibc. The same mechanism as in glibc is used to choose between ffs and ffsll to implement ffsl. The single user in libc is changed to use the hidden version __libc_ffs. Signed-off-by: Bernd Schmidt <bernds@codesourcery.com> Acked-by: Bernhard Reutner-Fischer <aldot@uclibc.org>
2011-03-03strcpy: remove unneeded includes from the generic versionPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
2010-12-14sh: fix memcpy saving/restoring FR12-FR15 registersGiuseppe Cavallaro
This patch fixes a bug in the memcpy that doesn't save/restore the FR12-FR15 registers (callee save registers in ST40 ABI) while copying many cache lines with FPU in single paired precision mode and by using all FPU registers (DR and XD). Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Reviewed-by: Carmelo Amoroso <carmelo.amoroso@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-11-10microblaze: optimized memcpy/memmoveSteven J. Magnani
Port optimized memcpy/memmove from the kernel. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-09-15sh: update the memcpy adding a new loop with aggressive prefetchingSalvatore Cro
After exploring different prefetch distance-degree combinations in this new update of the memcpy function, a new loop has been added for moving many cache lines with an aggressive prefetching schema. Prefetch has been removed when move few cache line aligned blocks. As final result, this memcpy gives us the same performances for small sizes (we already had!) and better numbers for big copies. In case of SH4-300 CPU Series, benchmarks show a gain of ~20% for sizes from 4KiB to 256KiB. In case of the SH4-200, there is a gain of ~40% for sizes bigger than 32KiB. Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
2010-09-15sh: move data without fetching cache block within the memsetSalvatore Cro
With this patch the movca.l instruction is used within the memset. The current memset implementation only uses the FPU and there is an real gain for all the sizes. Adding the movca.l instruction numbers always are better than the generic code. There is a big gain for size greater than 64 KiB but number are worst for 4-32KiB sizes compared with the implementation without movca.l. Time Memory Bandwidth (Mbytes) ------------------------------------------------- Generic SH4 SH4 (FPU) (FPU+movca.l) ------------------------------------------------- 512 1143 1998 1596 1 KiB 1273 2567 1915 2 KiB 1350 2993 2128 4-32KiB 1391 3262 2252 64KiB-16MiB 170 186 *830* Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>