diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2023-05-02 09:48:50 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-05-02 10:39:32 +0200 |
commit | 82b77505f9420f11d614c2ae0f74153ca4ee3cb5 (patch) | |
tree | ec93abd39cd8c7ff2818c7446da6cc01864b2ae1 /cooker/cooker.h | |
parent | a2c20b2caf4e9cedb32b0930ffd7ca2e9ec72086 (diff) | |
download | seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.gz seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.bz2 seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.lz seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.xz seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.tar.zst seitan-82b77505f9420f11d614c2ae0f74153ca4ee3cb5.zip |
cooker updates spilling all over the place
Only tangentially related:
- make seitan C99 again, so that I can build cooker without warnings
- make Makefiles make use of the usual conventions about assigning
directory paths in variables, drop numbers.h as requirement for
cooker and make it convenient to run stand-alone Makefiles
- fix up nr_syscalls.sh to be POSIX, otherwise it will give syntax
errors on my system
- define a single, common way to refer to offsets in gluten, and
functions to use those offsets in a safe way. Immediates are gone:
cooker will write any bit of "data" to the read-only section
- call const what has to be const
- define on-disk layout for gluten
- add OP_NR (to check syscall numbers), rename OP_COPY_ARGS to
OP_LOAD (it loads _selected_ stuff from arguments)
As for cooker itself:
- drop ARG_ and arg_ prefixes from struct names, and similar
- add/rework functions to build OP_NR, OP_LOAD, OP_CMP, and to
write constant data to gluten
- add parsing for "compound" arguments, but that's not completely
hooked into evaluation for numeric arguments yet
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/cooker.h')
-rw-r--r-- | cooker/cooker.h | 97 |
1 files changed, 57 insertions, 40 deletions
diff --git a/cooker/cooker.h b/cooker/cooker.h index 53aa0db..a1cc360 100644 --- a/cooker/cooker.h +++ b/cooker/cooker.h @@ -11,78 +11,95 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> +#include <arpa/inet.h> #define REFS_MAX 256 +#define REF_NAMEMAX 256 #define CALL_ARGS 6 -struct arg_num; -struct arg_struct; -struct arg_select; +struct num; +struct field; +struct select; -union arg_value { - struct arg_num *d_num; - struct arg_struct *d_struct; - struct arg_select *d_select; +union desc { + struct num *d_num; + struct field *d_struct; + struct select *d_select; }; -enum arg_type { - ARG_INT, - ARG_INTMASK, - ARG_INTFLAGS, +union value { + int v_int; + uint32_t v_u32; + long long v_num; +}; + +enum type { + INT, + INTMASK, + INTFLAGS, - ARG_U32, - ARG_U32MASK, - ARG_U32FLAGS, + U32, + U32MASK, + U32FLAGS, - ARG_LONG, - ARG_LONGMASK, - ARG_LONGFLAGS, + LONG, + LONGMASK, + LONGFLAGS, - ARG_STRING, + STRING, - ARG_STRUCT, - ARG_SELECT, + STRUCT, + SELECT, - ARG_PID, + PID, - ARG_PORT, - ARG_IPV4, - ARG_IPV6, + PORT, + IPV4, + IPV6, - ARG_FDPATH, + FDPATH, - ARG_TYPE_END, + TYPE_END, }; -#define ARG_TYPE_COUNT (ARG_TYPE_END - 1) +#define TYPE_COUNT (TYPE_END - 1) + +#define TYPE_IS_COMPOUND(t) ((t) == STRUCT || (t) == SELECT) +#define TYPE_IS_NUM(t) ((t) == INT || (t) == U32 || (t) == LONG) + +enum jump_type { + NEXT_BLOCK, + END, +}; -struct arg_num { +struct num { char *name; long long value; }; -struct arg_struct { +struct field { char *name; - enum arg_type type; - size_t offset; + enum type type; + off_t offset; size_t strlen; - union arg_value desc; + union desc desc; }; -struct arg_select_num { +struct select_num { long long value; - enum arg_type type; - union arg_value desc; + enum type type; + union desc desc; }; -struct arg_select { - struct arg_struct *field; +struct select { + struct field *field; union { - struct arg_select_num *d_num; + struct select_num *d_num; } desc; }; @@ -90,10 +107,10 @@ struct arg { int pos; char *name; - enum arg_type type; + enum type type; size_t size; - union arg_value desc; + union desc desc; }; #endif /* COOKER_H */ |