Furquan Shaikh has uploaded this change for review. ( https://review.coreboot.org/26737
Change subject: util/sconfig: Change chip_queue to be more generic ......................................................................
util/sconfig: Change chip_queue to be more generic
This CL changes chip_queue to be more generic to allow any data to be added/removed to/from queue.
BUG=b:80081934
Change-Id: I4c094e5bb53cb1f8e6aebba2df0df7a2bb05f3ef Signed-off-by: Furquan Shaikh furquan@google.com --- M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.y 4 files changed, 22 insertions(+), 22 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/37/26737/1
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 41e850c..0659ecd 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -53,29 +53,29 @@ .enabled = 1 };
-static struct chip_queue { - struct chip *ptr; - struct chip_queue *next; - struct chip_queue *prev; +static struct queue { + void *data; + struct queue *next; + struct queue *prev; } *q;
-struct chip_queue *new_chip_queue_entry(struct chip *c) +struct queue *new_entry(void *data) { - struct chip_queue *e = malloc(sizeof(*e)); + struct queue *e = malloc(sizeof(*e));
if (!e) { fprintf(stderr, "%s: malloc failure!\n", __func__); exit(1); }
- e->ptr = c; + e->data = data; e->next = e->prev = e; return e; }
-void push_chip(struct chip *c) +void enqueue(void *data) { - struct chip_queue *tmp = new_chip_queue_entry(c); + struct queue *tmp = new_entry(data);
if (!q) { q = tmp; @@ -88,10 +88,10 @@ tmp->next = q; }
-struct chip *pop_chip(void) +void *dequeue(void) { - struct chip_queue *tmp = q->prev; - struct chip *c; + struct queue *tmp = q->prev; + void *data;
if (tmp == q) q = NULL; @@ -100,10 +100,10 @@ q->prev = tmp->prev; }
- c = tmp->ptr; + data = tmp->data; free(tmp);
- return c; + return data; }
static struct device *new_dev(struct device *parent) diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h index 49e22ad..b9df91e 100644 --- a/util/sconfig/sconfig.h +++ b/util/sconfig/sconfig.h @@ -122,5 +122,5 @@
void yyrestart(FILE *input_file);
-void push_chip(struct chip *chip); -struct chip *pop_chip(void); +void enqueue(void *data); +void *dequeue(void); diff --git a/util/sconfig/sconfig.tab.c_shipped b/util/sconfig/sconfig.tab.c_shipped index e001b31..17bb31f 100644 --- a/util/sconfig/sconfig.tab.c_shipped +++ b/util/sconfig/sconfig.tab.c_shipped @@ -86,7 +86,7 @@ void yyerror(const char *s);
static struct device *cur_parent; - static struct chip *cur_chip; +static struct chip *cur_chip;
@@ -1301,7 +1301,7 @@
{ (yyval.chip) = new_chip((yyvsp[0].string)); - push_chip(cur_chip); + enqueue(cur_chip); cur_chip = (yyval.chip); }
@@ -1310,7 +1310,7 @@ case 15:
{ - cur_chip = pop_chip(); + cur_chip = dequeue(); }
break; diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y index 67cc6d3..01ce92d 100755 --- a/util/sconfig/sconfig.y +++ b/util/sconfig/sconfig.y @@ -21,7 +21,7 @@ void yyerror(const char *s);
static struct device *cur_parent; - static struct chip *cur_chip; +static struct chip *cur_chip;
%} %union { @@ -41,11 +41,11 @@
chip: CHIP STRING /* == path */ { $<chip>$ = new_chip($<string>2); - push_chip(cur_chip); + enqueue(cur_chip); cur_chip = $<chip>$; } chipchildren END { - cur_chip = pop_chip(); + cur_chip = dequeue(); };
device: DEVICE BUS NUMBER /* == devnum */ BOOL {