The ups and downs of strlcpy()
Posted Jul 19, 2012 11:29 UTC (Thu) by cladisch (✭ supporter ✭, #50193)
x86 has several string instructions that essentially implement mem* functions: rep movs for memcpy(), repne scas for memchr(), rep stos for memset(), and repe cmps for memcmp().
As far as I can see, strcpy(), strncpy(), and strlcpy() could be implemented equally well on top of these primitives.
Posted Jul 19, 2012 22:00 UTC (Thu) by nix (subscriber, #2304)
strlcpy() gets none of this. (However, a countervailing caveat: ome of the assembler implementations are so huge and unrolled that I'm not sure they don't cost more in icache hit than they gain in speed...)
Posted Jul 19, 2012 22:04 UTC (Thu) by Cyberax (✭ supporter ✭, #52523)
Posted Jul 20, 2012 2:45 UTC (Fri) by Ben_P (guest, #74247)
Posted Jul 20, 2012 12:54 UTC (Fri) by nix (subscriber, #2304)
Obviously the GCC builtins for strcpy() et al still work.
Posted Jul 23, 2012 17:58 UTC (Mon) by BenHutchings (subscriber, #37955)
Posted Apr 28, 2014 16:56 UTC (Mon) by mirabilos (subscriber, #84359)
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds