From owner-freebsd-chat@FreeBSD.ORG Tue Jul 13 21:18:21 2010 Return-Path: Delivered-To: freebsd-chat@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A6BB1065673 for ; Tue, 13 Jul 2010 21:18:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id EA22A8FC18 for ; Tue, 13 Jul 2010 21:18:20 +0000 (UTC) Received: (qmail 1583 invoked by uid 399); 13 Jul 2010 20:51:39 -0000 Received: from localhost (HELO laptop.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 13 Jul 2010 20:51:39 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Date: Tue, 13 Jul 2010 13:51:35 -0700 (PDT) From: Doug Barton To: freebsd-chat@FreeBSD.org Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-message-flag: Outlook -- Not just for spreading viruses anymore! OpenPGP: id=1A1ABC84 Organization: http://SupersetSolutions.com/ MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Cc: Subject: Request for PGP/MIME mail X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2010 21:18:21 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Howdy, I wrote ports/mail/pine-pgp-filters to help integrate Pine, and later Alpine with PGP. One of the most difficult aspects of this is dealing with PGP/MIME since there is no direct mechanism within Alpine to handle MIME messages. However, I've got some stuff that works pretty well at the moment, and now I'm looking to refine it so I need more samples. If you use PGP, and sign/encrypt your mail using MIME I'd like to ask for your help. If you use a client OTHER than Apple Mail, Evolution, Kmail, Thunderbird and Mutt, I'm particularly interested in signed mail from your client. I have lots of examples from those clients, but if you'd like to send some anyway, I appreciate all the help I can get. :) Regarding encrypted mail I can use samples from all the clients. Feel free to reply to this message, I don't need anything fancy. I would however appreciate if some people could send encrypted messages with attachments since that's something I don't have a lot of examples for. You can use the key I signed this message with, 0x1A1ABC84. Thanks in advance, Doug - -- Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ Computers are useless. They can only give you answers. -- Pablo Picasso -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (FreeBSD) iQEcBAEBCAAGBQJMPNHaAAoJEFzGhvEaGryE14sIAKOY0jVM6aja+H0T/J/I6rQ5 /2u2NtGMwHzu9FxNS8qifYkGTyL/SBDK8M3iFo5DjSdNo1Fv0AZXxDoNvfPODIu3 LzZ0wGUNpF6Ziqkrw1FhmpKxzEjWiz38PJTAD5pOtUu8OLYEvdss97I+iD9bn2uR IEviwJAXBsqOh73Km0kVuHt9A31Y33zOGA5uPEJkeAFRcYWd+YjuUNRoOwFP7ZhO mRD9tqO2dL5OYUQNbVwTD2hAGRfg2MH2+xiWNsnE52PJdKc/eLlKf0X68F4/ZlB+ 1rRua6W4PtGOUJtchTScDlIpGcLye3R8zz0ErIRuA73dy9WBSL10Egf4cbJ6Dcc= =XaF8 -----END PGP SIGNATURE----- From owner-freebsd-chat@FreeBSD.ORG Thu Jul 15 22:38:54 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85EDC1065670 for ; Thu, 15 Jul 2010 22:38:54 +0000 (UTC) (envelope-from deeptech71@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 198B48FC15 for ; Thu, 15 Jul 2010 22:38:53 +0000 (UTC) Received: by fxm13 with SMTP id 13so822201fxm.13 for ; Thu, 15 Jul 2010 15:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=htWj6I0srRutTvR1fuPHickPSHlsP0pg15XHLns0p7M=; b=IZIYgzyiXEfyvwXemc4lp1GbfX+zYWqiI5jr7pMTnWVURWuJVdoPuX+ZYV6hStJXRt YWmJOly/lBlJ42MNyZXs5Q5s3N5oDu3S3VnhH8V6bHHSrgrJZRRGTd4CLe6IoIPUmBw7 2XN3C4hPAAxqZEibKyYHb0O/i1Q+wPB04BlMk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=h1il+emK1rtDm7AJQAnpbtRdhbvlQk1WMommraVFm8bYJgl82kgoflMLH5ArGeek6A KsUeV7lTc3hanaPZOv/Dd0PwzQeV8CZi42twhLnBRZ8qtrFccRbKaL3nLUzRx0pSfboJ rkyCXR8FUbBlnwCOs1buC5tgkYdjXOe4G2CIE= MIME-Version: 1.0 Received: by 10.239.164.134 with SMTP id t6mr1562638hbd.204.1279233532699; Thu, 15 Jul 2010 15:38:52 -0700 (PDT) Received: by 10.239.160.138 with HTTP; Thu, 15 Jul 2010 15:38:52 -0700 (PDT) Date: Fri, 16 Jul 2010 00:38:52 +0200 Message-ID: From: "deeptech71@gmail.com" To: freebsd-chat@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 22:38:54 -0000 Some C implementations use the read-4-bytes-ahead technique to speed up strlen(). Does the C standard state anything about strlen() being allowed to read past the terminating zero? From owner-freebsd-chat@FreeBSD.ORG Thu Jul 15 22:44:08 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC9061065673 for ; Thu, 15 Jul 2010 22:44:08 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [IPv6:2001:470:a803::1]) by mx1.freebsd.org (Postfix) with ESMTP id 95E568FC13 for ; Thu, 15 Jul 2010 22:44:08 +0000 (UTC) Received: from mail.geekcn.org (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id 3E216A5FBEE; Fri, 16 Jul 2010 06:44:07 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by mail.geekcn.org (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with LMTP id 2Xit1TIH4qKJ; Fri, 16 Jul 2010 06:44:01 +0800 (CST) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id CB89AA5F9E6; Fri, 16 Jul 2010 06:44:00 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=Goaba4EpV6tltnDqaxR9LEFfYeLeHrtPjRKAgDPmonp8wDhUJ0QN9mBVOoC0zIPB7 a9Z7eFLTipZxT9/bKjVrA== Message-ID: <4C3F8F2E.9080705@delphij.net> Date: Thu, 15 Jul 2010 15:43:58 -0700 From: Xin LI Organization: The Geek China Organization User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.10) Gecko/20100629 Thunderbird/3.0.5 ThunderBrowse/3.3 MIME-Version: 1.0 To: "deeptech71@gmail.com" References: In-Reply-To: X-Enigmail-Version: 1.0.1 OpenPGP: id=3FCA37C1; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-chat@freebsd.org Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 22:44:09 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 2010/07/15 15:38, deeptech71@gmail.com wrote: > Some C implementations use the read-4-bytes-ahead technique to speed > up strlen(). Does the C standard state anything about strlen() being > allowed to read past the terminating zero? It's not 4-bytes-ahead, but read a whole (aligned) word at one time. I think C standard does not dictate in this detail. But why? Cheers, - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (FreeBSD) iQEcBAEBCAAGBQJMP48tAAoJEATO+BI/yjfBBNwIAJrqtefoZJ90095Aurk5H9kv SQZ8wVO1vgFu4qN2yT8InuXtpCB9Q6onuFQmMphdQrbqJWIDb+lxCD8UZUp6ocZE 544RPI9kLwWfUwQ0WdrTNmdAHGIbqc6nrhlS3IwTn82NCjuFH5pEpUmt0r53b19I jy/FlJjjTSiSC32tODLa922mo1GB50CA3fFlgUVlB7PHLRvdLeE6JsmvRA89gfRi /TOIRP8X/tJeDE4yuDycRmMCvOI+hFHdFchMxYQG2bifo1aZQzny+iNRA0xvYpO7 oZble3Cgwfs+jj2RkGW/syOXtvYA1CTxAJ67vf4OCX5Facq+Yfi3pto7xbIJCKE= =rxAG -----END PGP SIGNATURE----- From owner-freebsd-chat@FreeBSD.ORG Fri Jul 16 07:41:24 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B38A21065670 for ; Fri, 16 Jul 2010 07:41:24 +0000 (UTC) (envelope-from deeptech71@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 4A3598FC1D for ; Fri, 16 Jul 2010 07:41:23 +0000 (UTC) Received: by fxm13 with SMTP id 13so963642fxm.13 for ; Fri, 16 Jul 2010 00:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=fp+sS5jjHQevZALzux+kY5kRWwvKKMqa2bWALFFarkk=; b=Pg3x+q/dpZ7hEbYiFXVWRv5+oGtYDH6bY9DesbrJRbhWc8wsRhoo+oeRCD7qiDusaD J8chyMXORoCAmdktvO3FrJVbktZH53R+DEJAUJiuDEgZF4ss7G+rjSgsmq6hlBYKo045 2iVnoSeyiz77BdEQEIsoe1jp/LvMe/BzYVgGo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=eRzJ5TeRCPYtjJnm6dq3vTKOpGYZ3++1Nd1mIk90wAw8MpNL1NL6XnLgZenrCzZNIl +yGD+Xex9+20dCjgN6sRfXTdh9XCCen1/suaZnXAvPnYhAO4XjLvp3seb/lbckiB+yt+ LUKZ8rWZOsyj6uoO9dwVOBXYdVNpp3Uatk3sM= MIME-Version: 1.0 Received: by 10.239.169.194 with SMTP id p2mr34954hbe.96.1279266083140; Fri, 16 Jul 2010 00:41:23 -0700 (PDT) Received: by 10.239.160.138 with HTTP; Fri, 16 Jul 2010 00:41:23 -0700 (PDT) Date: Fri, 16 Jul 2010 09:41:23 +0200 Message-ID: From: "deeptech71@gmail.com" To: freebsd-chat@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2010 07:41:24 -0000 Xin LI wrote: > On 2010/07/15 15:38, deeptech71@gmail.com wrote: >> Some C implementations use the read-4-bytes-ahead technique to speed >> up strlen(). Does the C standard state anything about strlen() being >> allowed to read past the terminating zero? > > It's not 4-bytes-ahead, but read a whole (aligned) word at one time. > > I think C standard does not dictate in this detail. OK, can anyone confirm this? > But why? Just wondering. From owner-freebsd-chat@FreeBSD.ORG Fri Jul 16 08:06:09 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99F3F1065672 for ; Fri, 16 Jul 2010 08:06:09 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 5C0B98FC1C for ; Fri, 16 Jul 2010 08:06:09 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 6A4B51FFC33; Fri, 16 Jul 2010 08:06:08 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 07C62845D5; Fri, 16 Jul 2010 10:03:55 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: d@delphij.net References: <4C3F8F2E.9080705@delphij.net> Date: Fri, 16 Jul 2010 10:03:54 +0200 In-Reply-To: <4C3F8F2E.9080705@delphij.net> (Xin LI's message of "Thu, 15 Jul 2010 15:43:58 -0700") Message-ID: <868w5bkg45.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: "deeptech71@gmail.com" , freebsd-chat@freebsd.org Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2010 08:06:09 -0000 Xin LI writes: > deeptech71@gmail.com writes: > > Some C implementations use the read-4-bytes-ahead technique to speed > > up strlen(). Does the C standard state anything about strlen() being > > allowed to read past the terminating zero? > It's not 4-bytes-ahead, but read a whole (aligned) word at one time. > I think C standard does not dictate in this detail. My guess is that it invokes undefined behavior, but it doesn't matter in practice, because as long as you only read one aligned word at a time, and as long as the pointer you got is valid and points to a properly terminated string, you might read trash (which is expected), but you will never read unmapped memory. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-chat@FreeBSD.ORG Fri Jul 16 08:30:50 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8ADAF106566B for ; Fri, 16 Jul 2010 08:30:50 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id CC85D8FC14 for ; Fri, 16 Jul 2010 08:30:49 +0000 (UTC) X-Spam-Status: No X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.2, required 5, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_50 0.80) X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-ID: o6G8JXvS029572 Received: from kobe.laptop (188.4.25.184.dsl.dyn.forthnet.gr [188.4.25.184]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-9.1) with ESMTP id o6G8JXvS029572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Jul 2010 11:19:39 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.4/8.14.4) with ESMTP id o6G8JSMc025891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Jul 2010 11:19:28 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.4/8.14.4/Submit) id o6G8JRDT025884; Fri, 16 Jul 2010 11:19:27 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: deeptech71@gmail.com References: Date: Fri, 16 Jul 2010 11:19:27 +0300 In-Reply-To: (deeptech's message of "Fri, 16 Jul 2010 09:41:23 +0200") Message-ID: <874ofzu9dc.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-chat@freebsd.org Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2010 08:30:50 -0000 On Fri, 16 Jul 2010 09:41:23 +0200, "deeptech71@gmail.com" wrote: >Xin LI wrote: >>On 2010/07/15 15:38, deeptech71@gmail.com wrote: >>> Some C implementations use the read-4-bytes-ahead technique to speed >>> up strlen(). Does the C standard state anything about strlen() being >>> allowed to read past the terminating zero? >> >> It's not 4-bytes-ahead, but read a whole (aligned) word at one time. >> >> I think C standard does not dictate in this detail. > > OK, can anyone confirm this? The only text about strlen()'s behavior in my copy of the ISO/IEC 9899:1999 (E) standard is: | 7.21.6.3 The strlen function | | Synopsis | | 1 #include | size_t strlen(const char *s); | | Description | | 2 The strlen function computes the length of the string pointed | to by s. | | Returns | | 3 The strlen function returns the number of characters that | precede the terminating null character. There is no reference to *how* this may be implemented, so you can safely assume that the usual "as if" rules of the C standard apply. The underlying code may read a single character at a time, a word at a time, or may even call system-specific kernel calls that do 'magic' behind the scenes to compute the string length. What _really_ matters, as far as the standard is concerned, is that you get a meaningful return value that matches the current length of the input string. From owner-freebsd-chat@FreeBSD.ORG Fri Jul 16 09:27:47 2010 Return-Path: Delivered-To: freebsd-chat@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 53DC7106566C for ; Fri, 16 Jul 2010 09:27:47 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id C83C38FC1B for ; Fri, 16 Jul 2010 09:27:46 +0000 (UTC) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id o6G9RUhI020755; Fri, 16 Jul 2010 11:27:45 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id o6G9RU34020754; Fri, 16 Jul 2010 11:27:30 +0200 (CEST) (envelope-from olli) Date: Fri, 16 Jul 2010 11:27:30 +0200 (CEST) Message-Id: <201007160927.o6G9RU34020754@lurza.secnetix.de> From: Oliver Fromme To: freebsd-chat@FreeBSD.ORG, deeptech71@gmail.com In-Reply-To: X-Newsgroups: list.freebsd-chat User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.4 (lurza.secnetix.de [127.0.0.1]); Fri, 16 Jul 2010 11:27:45 +0200 (CEST) Cc: Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2010 09:27:47 -0000 deeptech71@gmail.com wrote: > Xin LI wrote: > > On 2010/07/15 15:38, deeptech71@gmail.com wrote: > > > Some C implementations use the read-4-bytes-ahead technique to speed > > > up strlen(). Does the C standard state anything about strlen() being > > > allowed to read past the terminating zero? > > > > It's not 4-bytes-ahead, but read a whole (aligned) word at one time. > > > > I think C standard does not dictate in this detail. > > OK, can anyone confirm this? When Xin LI states it, it doesn't need confirmation. ;-) You can look up for yourself, it's in section 7.21.6.3 (page 333) of ISO/IEC 9899:1999 a.k.a. "C99". It only states that "The strlen function computes the length of the string" and "The strlen function returns the number of characters that precede the terminating null character". Nothing more. > > But why? > > Just wondering. There's no reason not to read the string as aligned words. Because they're aligned, there's no risk to accidentally hit the next VM page after the end of the string. On the other hand, I don't think it is clear that doing this for strlen() would be a performance win in every situation. BTW, some languages (and also some string libraries for C) store the length separately for every string, so you don't have to iterate through the whole string to get its length. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd I suggested holding a "Python Object Oriented Programming Seminar", but the acronym was unpopular. -- Joseph Strout From owner-freebsd-chat@FreeBSD.ORG Fri Jul 16 13:25:45 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D3D01065673 for ; Fri, 16 Jul 2010 13:25:45 +0000 (UTC) (envelope-from doconnor@gsoft.com.au) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) by mx1.freebsd.org (Postfix) with ESMTP id A2D768FC19 for ; Fri, 16 Jul 2010 13:25:44 +0000 (UTC) Received: from ur.dons.net.au (ppp121-45-157-100.lns6.adl6.internode.on.net [121.45.157.100]) (authenticated bits=0) by cain.gsoft.com.au (8.14.4/8.14.3) with ESMTP id o6GDPYQ2045707 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 16 Jul 2010 22:55:40 +0930 (CST) (envelope-from doconnor@gsoft.com.au) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: "Daniel O'Connor" In-Reply-To: <201007160927.o6G9RU34020754@lurza.secnetix.de> Date: Fri, 16 Jul 2010 22:55:33 +0930 Content-Transfer-Encoding: quoted-printable Message-Id: <1DE534FE-4BCB-4524-AB6C-7E758589A9CD@gsoft.com.au> References: <201007160927.o6G9RU34020754@lurza.secnetix.de> To: Oliver Fromme X-Mailer: Apple Mail (2.1081) X-Spam-Score: 0.163 () BAYES_00,RDNS_DYNAMIC X-Scanned-By: MIMEDefang 2.67 on 203.31.81.10 Cc: deeptech71@gmail.com, freebsd-chat@freebsd.org Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2010 13:25:45 -0000 On 16/07/2010, at 18:57, Oliver Fromme wrote: >> Just wondering. >=20 > There's no reason not to read the string as aligned words. > Because they're aligned, there's no risk to accidentally > hit the next VM page after the end of the string. Unless you're calling strlen on something that isn't memory (eg memory = mapped device). Although that would be dumb precisely because you don't know how it's = implemented. Also the compiler would warn you because your mmap'd device pointer = should be declared volatile anyway.. -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C From owner-freebsd-chat@FreeBSD.ORG Fri Jul 16 14:21:30 2010 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2AAF11065673 for ; Fri, 16 Jul 2010 14:21:30 +0000 (UTC) (envelope-from freebsd-chat-local@be-well.ilk.org) Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net [69.17.117.48]) by mx1.freebsd.org (Postfix) with ESMTP id 047D78FC20 for ; Fri, 16 Jul 2010 14:21:29 +0000 (UTC) Received: (qmail 3519 invoked from network); 16 Jul 2010 14:21:28 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 16 Jul 2010 14:21:28 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id DB17C5084D; Fri, 16 Jul 2010 10:21:22 -0400 (EDT) From: Lowell Gilbert To: deeptech71@gmail.com, freebsd-chat@freebsd.org References: <4C3F8F2E.9080705@delphij.net> <868w5bkg45.fsf@ds4.des.no> Date: Fri, 16 Jul 2010 10:21:20 -0400 In-Reply-To: <868w5bkg45.fsf@ds4.des.no> ("Dag-Erling =?iso-8859-1?Q?Sm=F8?= =?iso-8859-1?Q?rgrav=22's?= message of "Fri, 16 Jul 2010 10:03:54 +0200") Message-ID: <44mxtr33tr.fsf@be-well.ilk.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Subject: Re: is strlen()'s read-4-bytes-ahead a standard? X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jul 2010 14:21:30 -0000 Dag-Erling Sm=F8rgrav writes: > Xin LI writes: >> deeptech71@gmail.com writes: >> > Some C implementations use the read-4-bytes-ahead technique to speed >> > up strlen(). Does the C standard state anything about strlen() being >> > allowed to read past the terminating zero? >> It's not 4-bytes-ahead, but read a whole (aligned) word at one time. >> I think C standard does not dictate in this detail. > > My guess is that it invokes undefined behavior, but it doesn't matter in > practice, because as long as you only read one aligned word at a time, > and as long as the pointer you got is valid and points to a properly > terminated string, you might read trash (which is expected), but you > will never read unmapped memory. strlen() is part of the implementation, and doesn't have to worry about undefined behaviour. Any conforming *program* will work properly, and that's all the standard library needs to ensure.