From: Strake <strake888@gmail.com>
To: musl@lists.openwall.com
Subject: Re: [patch] add ether_(aton, ntoa)
Date: Sun, 5 May 2013 09:11:12 -0500 [thread overview]
Message-ID: <CAL3m8eAkutia2mxJqzi+RiW4BfQcYCTzi5jwkSSS99xkfOxZjg@mail.gmail.com> (raw)
In-Reply-To: <20130429020757.GV20323@brightrain.aerifal.cx>
On 28/04/2013, Rich Felker <dalias@aerifal.cx> wrote:
> On Sun, Apr 14, 2013 at 11:10:55PM -0500, Strake wrote:
>> > Could you compare and see if it generates smaller code if we use a
>> > single snprintf/sscanf to implement these functions rather than a
>> > loop? I'm not sure which is better, but since they're not widely used,
>> > my main interest is keeping them small.
>>
>> ntoa: same size
>> aton: mine is smaller
>
> This doesn't seem to match my results. I compared against the
> following version of aton and it was half the size of yours:
>
> struct ether_addr *ether_aton_r (const char *x, struct ether_addr *p_a)
> {
> unsigned char *y = p_a->ether_addr_octet;
> char c;
> if (sscanf(x, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx%c",
> y,y+1,y+2,y+3,y+4,y+5,y+6,&c)!=6)
> return 0;
> return p_a;
> }
>
> Rich
My method:
$ cat test.c
#include <netinet/ether.h>
int main (int argc, char *argu[]) {
struct ether_addr *p_a;
p_a = ether_aton (argu[1]);
return (*p_a).ether_addr_octet[0];
}
$ cc -I $MUSL/include -L $MUSL/lib -o test test.c && strip test && wc -c <test
Mine: 6200
Yours: 15504
next prev parent reply other threads:[~2013-05-05 14:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-14 21:27 Strake
2013-04-15 1:40 ` Rich Felker
2013-04-15 4:10 ` Strake
2013-04-20 1:49 ` Rich Felker
2013-05-05 14:02 ` Strake
2013-05-05 16:24 ` Szabolcs Nagy
2013-05-05 16:40 ` Rich Felker
2013-05-08 3:29 ` Strake
2013-04-29 2:07 ` Rich Felker
2013-05-05 14:11 ` Strake [this message]
2013-05-05 15:15 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAL3m8eAkutia2mxJqzi+RiW4BfQcYCTzi5jwkSSS99xkfOxZjg@mail.gmail.com \
--to=strake888@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).