Re: Suggested dual human/binary interface for proc/devfs

From: H. Peter Anvin (hpa@transmeta.com)
Date: Tue Apr 04 2000 - 18:02:05 EST


Followup to: <Pine.GSO.4.10.10004041801380.12544-100000@weyl.math.psu.edu>
By author: Alexander Viro <viro@math.psu.edu>
In newsgroup: linux.dev.kernel
>
> Richard, it's a pure bullshit.
> int foo(char **p) {
> char *s=*p;
> int i;
> for(i=0;isdigit(*s);i*=10,i+=*s++-'0')
> ;
> *p=s;
> return i;
> }
> And yes, isdigit() is there. It's _one_ function. If you think that it's
> hard - tough luck, it isn't. Comparison with Perl is somewhat, erm,
> strained. We are talking about 64 bytes - compile with normal kernel flags
> and use size(1). 4 cache lines. Eh, wait - what was that thing in lib/*.c?
> <grepping> Aha, simple_strtoul(). In lib/vsprintf.c. So it's _ZERO_ extra
> code. Where's the bloat in question? Sure, we can copy it into every
> source file. The other question being, why would we do that?
>

If it's in kernel memory, you can use simple_stroul(). If not, you
have to go get_user() and check the return code for every byte.

I do think we need some canned functions to parse standard ASCII
formats *in user memory*. With standard formats I mean integer arrays
and escapable strings.

   -hpa

-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."

- 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/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:13 EST