lkml.org 
[lkml]   [1999]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] strlen
On 10/28/1999 22:28 +0200, Arjan van de Ven wrote:
>> > Here is an optimized strlen function for i586+ processors, it works by
>> > testing 4 bytes at a time and averages 1.8 clock cycles per byte (scas =
>> > 4n).
>>
>> This, I think, is a problem on i386. You _cannot_ read beyond the end of the
>> string (might be on an other, unmapped page), but you don't know that until
>> you do, when doing 4 bytes at a time. I mean: You can only know that you
>> went to far...
>>

However, if it's written right (I haven't looked at the code, so
I don't know), and only accesses 32-bit aligned words with
special cases for the front and back of the string, where
alignment may be off, it should work. It would IMHO be extremely
odd for a word-aligned word to cross a page boundary...


tw



--
+------------------------------+--------------------------+
| Tim Walberg | Phone: 847-782-2472 |
| TERAbridge Technologies Corp | FAX: 847-623-1717 |
| 1375 Tri-State Parkway | twalberg@terabridge.com |
| Gurnee, IL 60031 | 800-SKY-TEL2 PIN 9353299 |
+------------------------------+--------------------------+
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 13:54    [W:1.118 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site