aboutgitcodelistschat:MatrixIRC
path: root/cooker/call.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-06-08 20:05:18 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-06-08 20:05:18 +0200
commit15b54482241083d52b6e9857a66fecbf915d467d (patch)
tree2c10f8cfb05a2e534b0a8176f9c7c1cd0b486b14 /cooker/call.c
parentc38fccbc867019d6c063be1c1d8137edfe52f8de (diff)
downloadseitan-15b54482241083d52b6e9857a66fecbf915d467d.tar
seitan-15b54482241083d52b6e9857a66fecbf915d467d.tar.gz
seitan-15b54482241083d52b6e9857a66fecbf915d467d.tar.bz2
seitan-15b54482241083d52b6e9857a66fecbf915d467d.tar.lz
seitan-15b54482241083d52b6e9857a66fecbf915d467d.tar.xz
seitan-15b54482241083d52b6e9857a66fecbf915d467d.tar.zst
seitan-15b54482241083d52b6e9857a66fecbf915d467d.zip
cooker: Full support for flags and masks, assorted fixes
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/call.c')
-rw-r--r--cooker/call.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/cooker/call.c b/cooker/call.c
index 7ae3d48..e2a5777 100644
--- a/cooker/call.c
+++ b/cooker/call.c
@@ -149,14 +149,19 @@ static union value parse_field(struct gluten_ctx *g, struct arg *args,
case U32:
case GNU_DEV_MAJOR:
case GNU_DEV_MINOR:
- if (f->flags == SIZE) {
+ if (json_value_get_type(jvalue) == JSONArray) {
+ JSON_Array *array = json_value_get_array(jvalue);
+ unsigned i;
+
+ if (!(f->flags & FLAGS))
+ die("multiple values for non-FLAGS argument");
+
+ for (i = 0; i < json_array_get_count(array); i++) {
+ jvalue = json_array_get_value(array, i);
+ v.v_num |= value_get_num(f->desc.d_num, jvalue);
+ }
+ } else if (f->flags == SIZE) {
v.v_num = value_get_size(g, f->desc.d_size);
- } else if (f->flags == FLAGS) {
- /* fetch/combine expr algebra loop */
- v.v_num = value_get_num(f->desc.d_num, jvalue);
- } else if (f->flags == MASK) {
- /* calculate mask first */
- v.v_num = value_get_num(f->desc.d_num, jvalue);
} else {
v.v_num = value_get_num(f->desc.d_num, jvalue);
}
@@ -164,12 +169,14 @@ static union value parse_field(struct gluten_ctx *g, struct arg *args,
if (dry_run)
break;
- if (base_offset->type == OFFSET_NULL)
- *base_offset = emit_data(g, f->type, 0, &v);
- else if (add)
+ if (base_offset->type == OFFSET_NULL) {
+ *base_offset = gluten_ro_alloc_type(g, U64);
+ emit_data_at(g, *base_offset, f->type, &v);
+ } else if (add) {
emit_data_or(g, offset, f->type, &v);
- else
+ } else {
emit_data_at(g, offset, f->type, &v);
+ }
break;
case SELECT: