From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] Optimise memset on i386
Date: Fri, 25 Jun 2010 20:27:20 +0200 [thread overview]
Message-ID: <4C24F508.6040501@gmail.com> (raw)
In-Reply-To: <20100623213838.GI21862@riva.ucam.org>
[-- Attachment #1.1: Type: text/plain, Size: 793 bytes --]
>
> +void *
> +grub_memset (void *s, int c, grub_size_t n)
> +{
> + unsigned char *p = (unsigned char *) s;
> +
> + while (n--)
> + *p++ = (unsigned char) c;
> +
> + return s;
> +}
>
Attached is a possible generic implementation. Not even compile-tested.
Could you test it and compare disasm of this version on i386 and glibc
i386 version. Perhaps they are equivalent. If they are for maintainance
reasons it's better to always use generic one.
> +
> +#ifndef APPLE_CC
> +void *memset (void *s, int c, grub_size_t n)
> + __attribute__ ((alias ("grub_memset")));
> +#else
> +void *memset (void *s, int c, grub_size_t n)
> +{
> + return grub_memset (s, c, n);
> +}
> +#endif
>
> Thanks,
>
>
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: memset.c --]
[-- Type: text/x-csrc; name="memset.c", Size: 684 bytes --]
void
grub_memset (void *p, int c, grub_size_t len)
{
grub_uint8_t pattern8 = c;
if (len >= 3 * sizeof (unsigned long))
{
unsigned long patternl = 0;
int i;
for (i = 0; i < sizeof (unsigned long); i++)
patternl |= ((unsigned long) pattern8) << (8 * i);
while (len > 0 && (((grub_addr_t) p) & (sizeof (unsigned long) - 1)))
{
*(grub_uint8_t *) p = pattern8;
p = (grub_uint8_t *) p + 1;
}
while (len >= sizeof (unsigned long))
{
*(unsigned long *) p = patternl;
p = (unsigned long *) p + 1;
}
}
while (len > 0)
{
*(grub_uint8_t *) p = pattern8;
p = (grub_uint8_t *) p + 1;
}
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
next prev parent reply other threads:[~2010-06-25 18:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-23 21:38 [PATCH] Optimise memset on i386 Colin Watson
2010-06-25 18:04 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-06-25 18:27 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2010-07-23 11:14 ` Colin Watson
2010-07-23 15:56 ` richardvoigt
2010-07-23 17:34 ` Christian Franke
2010-07-23 19:48 ` richardvoigt
2010-07-23 20:09 ` richardvoigt
2010-07-24 22:40 ` Colin Watson
2010-07-28 14:21 ` Vladimir 'φ-coder/phcoder' Serbinenko
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=4C24F508.6040501@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.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.