Re: [PATCH] strlen

Tim Walberg (twalberg@terabridge.com)
Thu, 28 Oct 1999 16:31:41 -0500


--PEIAKu/WMn1b1Hv9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

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=
=3D
>> > 4n).
>>=09
>> 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 un=
til
>> you do, when doing 4 bytes at a time. I mean: You can only know that you
>> went to far...
>>=09

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

--=20
+------------------------------+--------------------------+
| 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 |
+------------------------------+--------------------------+

--PEIAKu/WMn1b1Hv9
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: y/9/STqdVt919vEjPMGvGmm40MI2SJpM

iQA/AwUBOBjAvcPlnI9tqyVmEQLNxgCeJZoiy4WlRqNZDK0a16XjQLOi0ksAnjVK
NlJR8V/5aC01M1k6tGL6u4lI
=m6Lg
-----END PGP SIGNATURE-----

--PEIAKu/WMn1b1Hv9--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/