From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3287 Path: news.gmane.org!not-for-mail From: Strake Newsgroups: gmane.linux.lib.musl.general Subject: Re: [patch] add ether_(aton, ntoa) Date: Sun, 5 May 2013 09:11:12 -0500 Message-ID: References: <20130415014005.GR20323@brightrain.aerifal.cx> <20130429020757.GV20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1367763088 1744 80.91.229.3 (5 May 2013 14:11:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 5 May 2013 14:11:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3291-gllmg-musl=m.gmane.org@lists.openwall.com Sun May 05 16:11:28 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UYzeu-0005SB-NU for gllmg-musl@plane.gmane.org; Sun, 05 May 2013 16:11:24 +0200 Original-Received: (qmail 17712 invoked by uid 550); 5 May 2013 14:11:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 17704 invoked from network); 5 May 2013 14:11:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=yL6mmsVccBDtK9s9txWcrreq1FB3GO4BqRm6JXUNXUU=; b=rKsOji3JOMIjC2wCsDsoMfp8TS1+ncBlbZEhF+UtVmvCuGLeWnLCNS/gye5cGGt3MK aXHlv1B2BhkkBlRLYKhOoHAwZAhBuKAOqO7EO1WXPdMunn68ZxkNTej0Bn+yGVHp8rrc IAeef9elxRQZ2Vw5YBeVQEMxg9h0cZaERv7HFfquBKSV6Z9PKSZcZO1q7obbqmtyXSf8 lSvBcyauplO0sMlaOD7ldBMtlcP/KN+32MxfoF97UtkdQ784ua/Wlqcd0kDJM2N9gc/P Uky8q7GVy4i8qPzZ7/UvkLCxbcaxnWB3KRcVnyy4Q+EBiiYEWPyIL45XsVWRGDJRGY6a BV9Q== X-Received: by 10.194.11.70 with SMTP id o6mr21292591wjb.29.1367763072457; Sun, 05 May 2013 07:11:12 -0700 (PDT) In-Reply-To: <20130429020757.GV20323@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:3287 Archived-At: On 28/04/2013, Rich Felker 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 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