From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc:dcache: Cache line size aligned internal MMC buffers
Date: Mon, 29 Aug 2011 22:35:58 +0200 [thread overview]
Message-ID: <20110829203558.AB3B1203630@gemini.denx.de> (raw)
In-Reply-To: <CAF6FioWhhqbVQWWPrusb69S2mpfBtoiazxc8x56bkogJmzXZ3g@mail.gmail.com>
Dear Anton Staaf,
In message <CAF6FioWhhqbVQWWPrusb69S2mpfBtoiazxc8x56bkogJmzXZ3g@mail.gmail.com> you wrote:
>
> I would like to know, mainly for my education, why you do not want
> alloca, but are OK with dynamic array sizing (as in the first solution
> above). My understanding is that they pretty much equate to the same
> thing. What is it about alloca that is objectionable?
First, I've got bitten by alloca() before, when GCC misbehaved.
Admitted, that was in some _very_ old version, but such experience
sticks.
Second, the behaviour of alloca() depends on a number of non-obvious
settings and compiler flags, and results are not always obvious. rom
the man page:
Notes on the GNU Version
Normally, gcc(1) translates calls to alloca() with inlined
code. This is not done when either the -ansi, -std=c89,
-std=c99, or the -fno-builtin option is given (and the header
<alloca.h> is not included). But beware! By default the glibc
version of <stdlib.h> includes <alloca.h> and that contains
the line:
#define alloca(size) __builtin_alloca (size)
with messy consequences if one has a private version of this function.
This is nothing I want to have in any production software. OK, you
may argument that U-Boot has a strictly controlled environment, but
anyway.
Third, the man page says:
NOTES
The alloca() function is machine- and compiler-dependent. For
certain applications, its use can improve efficiency compared
to the use of malloc(3) plus free(3). In certain cases, it can
also simplify memory deallocation in applications that use
longjmp(3) or siglongjmp(3).
Otherwise, its use is discouraged.
In my opinion, U-Boot falls into the "otherwise" category...
> I think I agree with this not being a great solution. I do wonder if
> it would be useful to consider a dedicated buffer management API that
> could be used to allocate and free cache line aligned power of two
> buffers. Perhaps something like a buddy heap for simplicity.
The longer I read this thread, the less frightening Mikes's macro
becomes (compared tho the alternatives).
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Though a program be but three lines long,
someday it will have to be maintained."
- The Tao of Programming
next prev parent reply other threads:[~2011-08-29 20:35 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-19 9:25 [U-Boot] [PATCH] mmc:dcache: Cache line size aligned internal MMC buffers Lukasz Majewski
2011-08-19 13:57 ` Mike Frysinger
2011-08-19 15:28 ` Lukasz Majewski
2011-08-19 15:35 ` Mike Frysinger
2011-08-22 7:29 ` Lukasz Majewski
2011-08-22 16:08 ` Mike Frysinger
2011-08-22 16:42 ` Anton Staaf
2011-08-22 16:52 ` Marek Vasut
2011-08-22 17:17 ` Mike Frysinger
2011-08-22 18:15 ` Anton Staaf
2011-08-22 18:31 ` Mike Frysinger
2011-08-22 18:57 ` Anton Staaf
2011-08-23 9:19 ` Lukasz Majewski
2011-08-23 17:00 ` Anton Staaf
2011-08-23 17:30 ` Mike Frysinger
2011-08-23 18:12 ` Anton Staaf
2011-08-23 18:35 ` Mike Frysinger
2011-08-23 18:36 ` Mike Frysinger
2011-08-23 18:46 ` Anton Staaf
2011-08-23 20:12 ` Wolfgang Denk
2011-08-23 20:27 ` Anton Staaf
2011-08-23 20:37 ` Mike Frysinger
2011-08-23 21:06 ` Anton Staaf
2011-08-23 21:32 ` Mike Frysinger
2011-08-23 21:09 ` Wolfgang Denk
2011-08-23 21:32 ` Mike Frysinger
2011-08-23 21:48 ` Anton Staaf
2011-08-24 16:16 ` Mike Frysinger
2011-08-23 22:42 ` Wolfgang Denk
2011-08-24 3:00 ` Mike Frysinger
2011-08-24 10:07 ` Lukasz Majewski
2011-08-24 13:25 ` Wolfgang Denk
2011-08-24 14:31 ` Lukasz Majewski
2011-08-24 16:20 ` Mike Frysinger
2011-08-24 17:27 ` Anton Staaf
2011-08-24 18:06 ` Mike Frysinger
2011-08-24 18:12 ` Wolfgang Denk
2011-08-24 18:25 ` Anton Staaf
2011-08-24 19:04 ` Wolfgang Denk
2011-08-24 20:12 ` Anton Staaf
2011-08-24 19:18 ` Lukasz Majewski
2011-08-24 20:13 ` Anton Staaf
2011-08-29 20:12 ` Anton Staaf
2011-08-29 20:35 ` Wolfgang Denk [this message]
2011-08-29 21:08 ` Anton Staaf
2011-08-29 20:47 ` Scott Wood
2011-08-29 20:58 ` Anton Staaf
2011-08-29 21:23 ` Scott Wood
2011-08-29 21:54 ` Anton Staaf
2011-08-29 22:03 ` Scott Wood
2011-08-29 22:49 ` Anton Staaf
2011-08-29 23:01 ` Scott Wood
2011-08-29 23:05 ` Anton Staaf
2011-08-23 20:35 ` Mike Frysinger
2011-08-23 8:42 ` Lukasz Majewski
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=20110829203558.AB3B1203630@gemini.denx.de \
--to=wd@denx.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox