mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
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>
This commit is contained in:
parent
c226ddcabc
commit
af0278a3a0
4 changed files with 51 additions and 8 deletions
21
data.c
21
data.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue