Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
(Nearly) full tickless operation in 3.10
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 (subscriber, #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)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds