From: Franck Bui-Huu <vagabon.xyz@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Franck Bui-Huu <fbuihuu@gmail.com>,
linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH] Kill __bzero()
Date: Mon, 05 Nov 2007 22:51:43 +0100 [thread overview]
Message-ID: <472F906F.7080205@gmail.com> (raw)
In-Reply-To: <20071105112429.GC27893@linux-mips.org>
Ralf Baechle wrote:
>
> Memset is almost always only ever invoked with a zero argument. So the
> idea was to have something like this:
>
> extern void *__memset(void *__s, int __c, size_t __count);
> extern void *bzero(void *__s, size_t __count);
>
> static inline void *memset(void *s, int c, size_t count)
> {
> if (__builtin_constant_p(c) && c == 0) {
> bzero(s, count);
> return s;
> } else
> return __memset(s, __c, count);
> }
>
> But that was never quite implemented like this as you noticed.
Well I'm not sure we really need this. bzero() is not part of the
Linux string API, so it can only be used by MIPS specific code. And
with the current implementation of bzero(), $a1 needs to be setup to 0
anyway. That's why I simply killed it...
BTW, can memset() be an inlined function ?
>
> As for the differences in the return value, they're because of of
> clear_user and __clear_user which return the number of bytes that could
> _not_ be cleared in $a2. Memset being invoked through the normal C calling
> conventions ignores this value while it's the actual result of interest for
> __clear_user.
>
Yes I noticed this. Actually I'm wondering if we couldn't add a new
function, fill_user() like the following:
extern size_t fill_user(void __user *to, int c, size_t len);
This could be used by both memset() and clear_user():
#define memset(s,c,l) ({ (void)fill(s,c,l); s; })
#define clear_user(t,l) fill_user(t,0,l)
Therefore the definition of clear_user() could be saner.
What do you think ?
Franck
next prev parent reply other threads:[~2007-11-05 21:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-04 8:18 [PATCH] Kill __bzero() Franck Bui-Huu
2007-11-04 15:42 ` Atsushi Nemoto
2007-11-04 20:02 ` Franck Bui-Huu
2007-11-05 11:24 ` Ralf Baechle
2007-11-05 21:51 ` Franck Bui-Huu [this message]
2007-11-05 23:18 ` Ralf Baechle
2007-11-06 7:42 ` Franck Bui-Huu
2007-11-06 10:36 ` Ralf Baechle
2007-11-06 16:18 ` Franck Bui-Huu
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=472F906F.7080205@gmail.com \
--to=vagabon.xyz@gmail.com \
--cc=fbuihuu@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.