From: Jon Loeliger <hidden> Date: 2007-02-15 17:13:09
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
---
Beginnings of test cases in the next patch.
Don't stress the yylloc too much. We'll eventually
work to make that better and more general later.
data.c | 21 +++++++++++++++++++++
dtc-lexer.l | 21 +++++++++++++++------
dtc-parser.y | 16 ++++++++++++++--
dtc.h | 1 +
4 files changed, 51 insertions(+), 8 deletions(-)
@@ -224,6 +225,26 @@ struct data data_merge(struct data d1, struct data d2)returnd;}+/*+*Convertastringrepresentationofanumbericcell+*inthegivenbaseintoacell.+*/+cell_tdata_convert_cell(char*s,unsignedintbase)+{+cell_tc;+externYYLTYPEyylloc;++c=strtoul(s,NULL,base);+if(errno==EINVAL||errno==ERANGE){+fprintf(stderr,+"Line %d: Invalid cell value '%s'; %d assumed\n",+yylloc.first_line,s,c);+}++returnc;+}++structdatadata_append_cell(structdatad,cell_tword){cell_tbeword=cpu_to_be32(word);
@@ -118,6 +118,7 @@ struct data data_copy_mem(char *mem, int len);structdatadata_copy_escape_string(char*s,intlen);structdatadata_copy_file(FILE*f,size_tlen);+cell_tdata_convert_cell(char*s,unsignedintbase);structdatadata_append_data(structdatad,void*p,intlen);structdatadata_merge(structdatad1,structdatad2);structdatadata_append_cell(structdatad,cell_tword);
From: Kumar Gala <hidden> Date: 2007-02-15 17:31:04
On Feb 15, 2007, at 11:13 AM, Jon Loeliger wrote:
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
---
What are people's thoughts on supporting '0x' and '0X' for hex?
- k
-----Original Message-----
From: linuxppc-dev-bounces+b08248=3Dfreescale.com@ozlabs.org=20
[mailto:linuxppc-dev-bounces+b08248=3Dfreescale.com@ozlabs.org]=20
On Behalf Of Kumar Gala
[snip]
quoted
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
---
=20
What are people's thoughts on supporting '0x' and '0X' for hex?
Are you saying allow d#1234, h#5678, and 0x5678? Or use 0x instead
of h#?
Stuart
From: Olof Johansson <hidden> Date: 2007-02-15 17:51:05
On Thu, Feb 15, 2007 at 10:45:54AM -0700, Yoder Stuart-B08248 wrote:
I like to see no space between the d#, h#, etc and the
numeric value.
Does anyone see a good reason to keep whitespace there?
Does it really matter what color the bike shed is?
http://www.unixguide.net/freebsd/faq/16.19.shtml
(I've seen 0x<hex> <decimal> or 0d<decimal> and 0b<binary> been used
sometimes and work well, but I really don't care if it's what the dtc
uses or not.)
-Olof
-----Original Message-----
From: Olof Johansson [mailto:olof@lixom.net]=20
Sent: Thursday, February 15, 2007 12:00 PM
To: Yoder Stuart-B08248
Cc: Jon Loeliger; linuxppc-dev@ozlabs.org
Subject: Re: [DTC PATCH] Add support for decimal, octal and=20
binary based cell values.
=20
On Thu, Feb 15, 2007 at 10:45:54AM -0700, Yoder Stuart-B08248 wrote:
quoted
=20
I like to see no space between the d#, h#, etc and the
numeric value.
=20
Does anyone see a good reason to keep whitespace there?
=20
Does it really matter what color the bike shed is?
In this case I think it does matter (a little :)). If
you represent a number as <#h5678> it's clear that the
#h and 5678 are related.
If you represent it as <#h 5678> the relation between
the two is not as clear-- of course once you read the=20
spec you figure it out.
It's not a huge deal, but while we're adding a feature
to dtc why not make the syntax as clear as we can?
Stuart
From: Scott Wood <hidden> Date: 2007-02-15 18:03:29
Yoder Stuart-B08248 wrote:
In this case I think it does matter (a little :)). If
you represent a number as <#h5678> it's clear that the
#h and 5678 are related.
If you represent it as <#h 5678> the relation between
the two is not as clear-- of course once you read the
spec you figure it out.
It's not a huge deal, but while we're adding a feature
to dtc why not make the syntax as clear as we can?
It should be noted that the patch Jon posted should accept it either
with or without the space.
-Scott
From: Kumar Gala <hidden> Date: 2007-02-15 18:42:48
On Feb 15, 2007, at 11:49 AM, Yoder Stuart-B08248 wrote:
quoted
-----Original Message-----
From: linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org
[mailto:linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org]
On Behalf Of Kumar Gala
[snip]
quoted
quoted
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
---
What are people's thoughts on supporting '0x' and '0X' for hex?
Are you saying allow d#1234, h#5678, and 0x5678? Or use 0x instead
of h#?
I'm saying in addition to supporting the d#, h# notation.
The reason I'm suggesting support '0x' is its pretty natural from C
and I know there have been a number of times when I forget that all
int constants in .dts are hex.
- k
From: David Gibson <hidden> Date: 2007-02-15 22:14:12
On Thu, Feb 15, 2007 at 12:41:50PM -0600, Kumar Gala wrote:
On Feb 15, 2007, at 11:49 AM, Yoder Stuart-B08248 wrote:
quoted
quoted
-----Original Message-----
From: linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org
[mailto:linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org]
On Behalf Of Kumar Gala
[snip]
quoted
quoted
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
---
What are people's thoughts on supporting '0x' and '0X' for hex?
Are you saying allow d#1234, h#5678, and 0x5678? Or use 0x instead
of h#?
I'm saying in addition to supporting the d#, h# notation.
The reason I'm suggesting support '0x' is its pretty natural from C
and I know there have been a number of times when I forget that all
int constants in .dts are hex.
I'd prefer not to do this. I agree it would be nice in some ways, but
I'm worried that if people see 0x all over the place, they'll assume
that things without an 0x are decimal, which they can't be for
compatibility.
--
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
From: David Gibson <hidden> Date: 2007-02-15 22:19:07
On Thu, Feb 15, 2007 at 11:13:05AM -0600, Jon Loeliger wrote:
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
[snip]
quoted hunk
---
Beginnings of test cases in the next patch.
Don't stress the yylloc too much. We'll eventually
work to make that better and more general later.
data.c | 21 +++++++++++++++++++++
dtc-lexer.l | 21 +++++++++++++++------
dtc-parser.y | 16 ++++++++++++++--
dtc.h | 1 +
4 files changed, 51 insertions(+), 8 deletions(-)
@@ -224,6 +225,26 @@ struct data data_merge(struct data d1, struct data d2)returnd;}+/*+*Convertastringrepresentationofanumbericcell+*inthegivenbaseintoacell.+*/+cell_tdata_convert_cell(char*s,unsignedintbase)
I'd prefer a different name for this - and possibly it should go in a
different file. The data_* prefix should be for functions that
actually manipulate struct data objects.
And I'd really prefer to keep the yyblah junk confined to the parser
code. I think it would be better to move this function into
dtc-parser.y
Otherwise looks pretty good.
--
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
From: Dan Malek <hidden> Date: 2007-02-15 22:40:35
On Feb 15, 2007, at 9:13 AM, Jon Loeliger wrote:
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Why do we need yet another syntax? Everyone
else, including most silicon documentation, uses
the standard "C" syntax 0x for hex, 0 for octal, and
nothing for decimal. If really needed binary, we
could us the '0b'. Of the few dts files I've done,
anything to make this easier, rather than inventing
something new, would be appreciated.
Thanks.
-- Dan
From: David Gibson <hidden> Date: 2007-02-15 22:57:39
On Thu, Feb 15, 2007 at 02:33:47PM -0800, Dan Malek wrote:
On Feb 15, 2007, at 9:13 AM, Jon Loeliger wrote:
quoted
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Why do we need yet another syntax? Everyone
else, including most silicon documentation, uses
the standard "C" syntax 0x for hex, 0 for octal, and
nothing for decimal. If really needed binary, we
could us the '0b'. Of the few dts files I've done,
anything to make this easier, rather than inventing
something new, would be appreciated.
Yes, but hex-by-default is already implemented and out there. We
can't change it without breaking compatibility horribly.
--
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
From: Dan Malek <hidden> Date: 2007-02-15 23:37:44
On Feb 15, 2007, at 2:57 PM, David Gibson wrote:
Yes, but hex-by-default is already implemented and out there. We
can't change it without breaking compatibility horribly.
Compatibility with what? The few dts files that exist
that are still all changing frequently due to other
tool modifications? I'd prefer to change them now,
rather than propagate this new syntax.
Thanks.
-- Dan
From: Kumar Gala <hidden> Date: 2007-02-16 00:05:29
On Feb 15, 2007, at 4:14 PM, David Gibson wrote:
On Thu, Feb 15, 2007 at 12:41:50PM -0600, Kumar Gala wrote:
quoted
On Feb 15, 2007, at 11:49 AM, Yoder Stuart-B08248 wrote:
quoted
quoted
-----Original Message-----
From: linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org
[mailto:linuxppc-dev-bounces+b08248=freescale.com@ozlabs.org]
On Behalf Of Kumar Gala
[snip]
quoted
quoted
New syntax d#, b#, o# and h# allow for an explicit prefix
on cell values to specify their base. Eg: <d# 123>
Signed-off-by: Jon Loeliger <redacted>
---
What are people's thoughts on supporting '0x' and '0X' for hex?
Are you saying allow d#1234, h#5678, and 0x5678? Or use 0x instead
of h#?
I'm saying in addition to supporting the d#, h# notation.
The reason I'm suggesting support '0x' is its pretty natural from C
and I know there have been a number of times when I forget that all
int constants in .dts are hex.
I'd prefer not to do this. I agree it would be nice in some ways, but
I'm worried that if people see 0x all over the place, they'll assume
that things without an 0x are decimal, which they can't be for
compatibility.
People don't know what to assume, I know I've made a number of errors
when I forget that all numbers where hex.
I think we should change dtc to follow standard C conventions and do
it now rather than later.
We've already introduced dtc version compatibilities issues. I agree
with Dan that we should fix this now while there are a small handful
of .dts in existence and we can provide a compat mode flag that
treats non-prefixed numbers as hex instead of decimal.
(in theory with that we can use dtc to convert old .dts into new .dts)
- k
From: David Gibson <hidden> Date: 2007-02-16 00:09:12
On Thu, Feb 15, 2007 at 03:37:36PM -0800, Dan Malek wrote:
On Feb 15, 2007, at 2:57 PM, David Gibson wrote:
quoted
Yes, but hex-by-default is already implemented and out there. We
can't change it without breaking compatibility horribly.
Compatibility with what? The few dts files that exist
that are still all changing frequently due to other
tool modifications? I'd prefer to change them now,
rather than propagate this new syntax.
Nonetheless there are enough dts files out there - some of them within
vendors where I can't see them - that I absolutely do not want to
change something som fundamental in the format.
I have considered defining a "new-style" cell format, with delimiters
different from < > that uses C style literals. But that idea's fairly
ugly too.
--
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
Why do we need yet another syntax? Everyone
else, including most silicon documentation, uses
the standard "C" syntax 0x for hex, 0 for octal, and
nothing for decimal.
[Completely off-topic]
You're joking, right? Many docs use 1234h for hex and
1011b for binary; or $1234 for hex and %1011 for binary;
or x'1234 and b'1011; or 1234_{(16)} and 1011_{(2)} (TeX
notation -- base as decimal in a parenthesised subscript);
etc. etc. etc.
Almost all computer languages use something more sane
than the C-family stuff too (esp. the dreaded "0 is
octal" thing is not exactly great).
Anyway, really off-topic :-)
Segher
I think we should change dtc to follow standard C conventions and do
it now rather than later.
We've already introduced dtc version compatibilities issues. I agree
with Dan that we should fix this now while there are a small handful
of .dts in existence and we can provide a compat mode flag that
treats non-prefixed numbers as hex instead of decimal.
(in theory with that we can use dtc to convert old .dts into new .dts)
May I suggest every DTS file start with a version statement?
That way, you can change its format easily whenever you
want. This would be version of the source language, not the
same thing as version of the generated blob.
Segher