From: David Gibson <david@gibson.dropbear.id.au>
To: Alexander Graf <agraf@suse.de>
Cc: Scott Wood <scottwood@freescale.com>,
Peter Crosthwaite <peter.crosthwaite@petalogix.com>,
qemu-ppc Mailing List <qemu-ppc@nongnu.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 02/31] dt: add helpers for 2, 3 and 4 cell adds
Date: Sat, 9 Jun 2012 00:15:02 +1000 [thread overview]
Message-ID: <20120608141502.GG6614@truffala.fritz.box> (raw)
In-Reply-To: <61CC6CB0-DBA1-4EF3-9F5E-09F076048AE1@suse.de>
On Fri, Jun 08, 2012 at 03:00:56PM +0200, Alexander Graf wrote:
>
> On 07.06.2012, at 14:13, David Gibson wrote:
>
> > On Thu, Jun 07, 2012 at 01:27:56PM +0200, Alexander Graf wrote:
> >>
> >> On 07.06.2012, at 01:45, David Gibson wrote:
> >>
> >>> [snip]
> >>>>> You mean internally? Yeah, probably. Externally? The point of these
> >>>>> helpers is to make the code look less cluttered. We can already pass in
> >>>>> an array just fine, but C is quite annoying about generating those on
> >>>>> the fly, while it's easy to pass in ints as parameters :)
> >>>>
> >>>> Varargs?
> >>>
> >>> Ugly and risky with standard C varargs (because an explicit length
> >>> would be needed). Could be done neatly with gcc macro varargs.
> >>
> >> Could a combination of both like this work?
> >>
> >> #include <stdio.h>
> >> #include <stdarg.h>
> >>
> >> #define __VA_NARG__(...) \
> >> (__VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N()) - 1)
> >> #define __VA_NARG_(...) \
> >> __VA_ARG_N(__VA_ARGS__)
> >> #define __VA_ARG_N( \
> >> _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
> >> _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
> >> _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
> >> _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
> >> _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
> >> _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
> >> _61,_62,_63,N,...) N
> >> #define __RSEQ_N() \
> >> 63, 62, 61, 60, \
> >> 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
> >> 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
> >> 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
> >> 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
> >> 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
> >> 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
> >>
> >> #define PRINT_ELEMS(fdt, ...) print_elems(fdt, __VA_NARG__(__VA_ARGS__), __VA_ARGS__)
> >
> > Um.. that might work, but it's ludicrously complicated. If we're
> > prepared to use the gcc statement expression extension and we're just
> > going to abort on errors like findnode_nofail, it can be done much
> > more easily using c99 variadic macros:
> >
> > #define setprop_ints(fdt, path, prop, ...) \
> > do { \
> > uint32_t tmp[] = {__VA_ARGS__}; \
> >
> > if (fdt_setprop(findnode_nofail(fdt, path), prop, \
> > tmp, sizeof(tmp)) != 0) { \
> > /* error message */ \
> > abort(); \
> > } \
> > } while (0)
>
> Hrm. But here we'd be overloading the name space, no? If anyone
> passes in tmp[3] as parameter to setprop_ints, it would conflict
> with the internal variable tmp, right?
Standard macro problem. So, call it _tmp, whatever.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
next prev parent reply other threads:[~2012-06-08 15:01 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-05 23:52 [Qemu-devel] [PATCH 00/31] PPC: mpc8544ds: Create device tree dynamically Alexander Graf
2012-06-05 23:52 ` [Qemu-devel] [PATCH 01/31] dt: allow add_subnode to create root subnodes Alexander Graf
2012-06-06 5:30 ` Peter Crosthwaite
2012-06-05 23:52 ` [Qemu-devel] [PATCH 02/31] dt: add helpers for 2, 3 and 4 cell adds Alexander Graf
2012-06-06 5:01 ` Peter Crosthwaite
2012-06-06 15:55 ` Alexander Graf
2012-06-06 21:52 ` Scott Wood
2012-06-06 23:45 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2012-06-07 11:27 ` Alexander Graf
2012-06-07 12:13 ` David Gibson
2012-06-08 13:00 ` Alexander Graf
2012-06-08 14:15 ` David Gibson [this message]
2012-06-05 23:52 ` [Qemu-devel] [PATCH 03/31] dt: add helper for phandle references Alexander Graf
2012-06-06 5:06 ` Peter Crosthwaite
2012-06-05 23:52 ` [Qemu-devel] [PATCH 04/31] dt: temporarily disable subtree creation failure check Alexander Graf
2012-06-06 5:32 ` Peter Crosthwaite
2012-06-06 15:58 ` Alexander Graf
2012-06-05 23:52 ` [Qemu-devel] [PATCH 05/31] dt: add helper for phandle enumeration Alexander Graf
2012-06-06 5:11 ` Peter Crosthwaite
2012-06-06 15:58 ` Alexander Graf
2012-06-07 0:28 ` Peter Crosthwaite
2012-06-08 12:46 ` Alexander Graf
2012-06-09 1:02 ` Peter Crosthwaite
2012-06-19 14:03 ` Alexander Graf
2012-06-05 23:52 ` [Qemu-devel] [PATCH 06/31] dt: add helper for empty dt creation Alexander Graf
2012-06-06 5:34 ` Peter Crosthwaite
2012-06-05 23:52 ` [Qemu-devel] [PATCH 07/31] dt: add helper for phandle allocation Alexander Graf
2012-06-06 5:18 ` Peter Crosthwaite
2012-06-06 16:00 ` Alexander Graf
2012-06-06 16:55 ` Scott Wood
2012-06-07 0:15 ` Peter Crosthwaite
2012-06-07 0:31 ` Scott Wood
2012-06-05 23:52 ` [Qemu-devel] [PATCH 08/31] dt: add helper for 64bit cell adds Alexander Graf
2012-06-06 5:20 ` Peter Crosthwaite
2012-06-05 23:53 ` [Qemu-devel] [PATCH 09/31] PPC: e500: require libfdt Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 10/31] PPC: e500: dt: create memory node dynamically Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 11/31] PPC: e500: dt: create /cpus " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 12/31] PPC: e500: dt: create /hypervisor " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 13/31] PPC: e500: dt: create / " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 14/31] PPC: e500: dt: create /chosen " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 15/31] PPC: e500: dt: create /soc8544 " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 16/31] PPC: e500: dt: create serial nodes dynamically Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 17/31] PPC: e500: dt: create mpic node dynamically Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 18/31] PPC: e500: dt: create global-utils " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 19/31] PPC: e500: dt: create pci " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 20/31] PPC: e500: dt: start with empty device tree Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 21/31] dt: Add -machine dumpdtb option to dump the current dtb Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 22/31] PPC: e500: dt: use 64bit cell helper Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 23/31] PPC: e500: dt: use target_phys_addr_t for ramsize Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 24/31] PPC: e500: enable manual loading of dtb blob Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 25/31] Revert "dt: temporarily disable subtree creation failure check" Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 26/31] PPC: e500: Use new MPIC dt format Alexander Graf
2012-06-07 21:08 ` [Qemu-devel] [Qemu-ppc] " Blue Swirl
2012-06-05 23:53 ` [Qemu-devel] [PATCH 27/31] PPC: e500: Use new SOC " Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 28/31] PPC: e500: Define addresses as always 64bit Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 29/31] PPC: e500: Extend address/size of / to 64bit Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 30/31] dt: Add global option to set phandle start offset Alexander Graf
2012-06-05 23:53 ` [Qemu-devel] [PATCH 31/31] PPC: e500: Refactor serial dt generation Alexander Graf
2012-06-07 21:09 ` [Qemu-devel] [PATCH 00/31] PPC: mpc8544ds: Create device tree dynamically Blue Swirl
2012-06-19 12:54 ` Alexander Graf
2012-06-19 18:39 ` Blue Swirl
2012-06-19 19:14 ` Alexander Graf
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=20120608141502.GG6614@truffala.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=peter.crosthwaite@petalogix.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=scottwood@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).