All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessandro Rubini <rubini-list@gnudd.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible
Date: Thu, 8 Oct 2009 09:41:15 +0200	[thread overview]
Message-ID: <20091008074114.GA30203@mail.gnudd.com> (raw)
In-Reply-To: <200910070452.02225.vapier@gentoo.org>

I was making my v2, and I found a problem wrt:

> while 64bit isnt in today, might as well avoid unclean code from the start
> when possible.  in other words, used "unsigned int" rather than "u32" and cast
> to "unsigned long" rather than "int".

Since int is 32 also on 64bit systems, I used unsigned long.
For memcpy all is well, for memset I have this problem:

    void * memset(void * s,int c,size_t count)
    {
    	char *xs = (char *) s;
    	unsigned long *sl = (unsigned long *) s;
    	unsigned long cl;

    	/* do it one word at a time (32 bits or 64 bits) if possible */
    	if ( ((count | (int)s) & (sizeof(long) - 1)) == 0) {
    		count /= sizeof(long);
    		cl = (c & 0xff) | ((c & 0xff) << 8);
    		cl |= cl << 16;
    		if (sizeof(long) > 4)
    			cl |= cl << 32;
    		while (count--)
    			*sl++ = cl;
    		return s;
    	}
    	/* else, fill 8 bits@a time */
    	while (count--)
    		*xs++ = c;

    	return s;
    }

string.c:416: warning: left shift count >= width of type

(obviously there is no such shift in the generated code,
since the condition is false at compile time).

I think I'll stick to u32 for memset, unless I get better suggestions.

/alessandro

  parent reply	other threads:[~2009-10-08  7:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07  8:44 [U-Boot] [PATCH 0/3] make memcpy and memset 32-bit copies Alessandro Rubini
2009-10-07  8:44 ` [U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible Alessandro Rubini
2009-10-07  8:52   ` Mike Frysinger
2009-10-07  8:59     ` Alessandro Rubini
2009-10-07  9:30     ` Wolfgang Denk
2009-10-08  7:41     ` Alessandro Rubini [this message]
2009-10-08  8:37       ` Wolfgang Denk
2009-10-08  9:05         ` Joakim Tjernlund
2009-10-08 12:49           ` Wolfgang Denk
2009-10-08 13:29             ` Joakim Tjernlund
2009-10-08 13:47               ` Wolfgang Denk
2009-10-10 16:09       ` Eric Lammerts
2009-10-07 14:35   ` Peter Tyser
2009-10-07 17:04     ` Mike Frysinger
2009-10-07  8:44 ` [U-Boot] [PATCH 2/3] memset: " Alessandro Rubini
2009-10-07  9:27   ` Wolfgang Denk
2009-10-07  8:44 ` [U-Boot] [PATCH 3/3] lcd: remove '#if 0' 32-bit scroll, now memcpy does it Alessandro Rubini
     [not found] ` <b03f28d4c4afa0c5c9f2421b7d260a0f3890cdcd.1254904388.git.rubini@unipv.it>
2009-10-08  5:23   ` [U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible Chris Moore
2009-10-08  6:05     ` Mike Frysinger

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=20091008074114.GA30203@mail.gnudd.com \
    --to=rubini-list@gnudd.com \
    --cc=u-boot@lists.denx.de \
    /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.