diff options
author | Jon Loeliger <jdl@freescale.com> | 2007-02-15 10:59:27 -0600 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-02-15 10:59:27 -0600 |
commit | af0278a3a04fabe8349cae89613274da196509ca (patch) | |
tree | ba74a8c677097a342c42f7755295444f25d8efb8 /data.c | |
parent | c226ddcabc4272b0734d237d3aee2c21a2fe2387 (diff) | |
download | dtc-af0278a3a04fabe8349cae89613274da196509ca.tar.gz |
Add support for decimal, octal and binary based cell values.
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 <jdl@freescale.com>
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -19,6 +19,7 @@ */ #include "dtc.h" +#include "dtc-parser.tab.h" void fixup_free(struct fixup *f) { @@ -224,6 +225,26 @@ struct data data_merge(struct data d1, struct data d2) return d; } +/* + * Convert a string representation of a numberic cell + * in the given base into a cell. + */ +cell_t data_convert_cell(char *s, unsigned int base) +{ + cell_t c; + extern YYLTYPE yylloc; + + 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); + } + + return c; +} + + struct data data_append_cell(struct data d, cell_t word) { cell_t beword = cpu_to_be32(word); |