summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-25 22:44:59 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-01-25 22:49:23 -0700
commitc5c170bac070c1bbc0e008e05783109c2e49afab (patch)
treec6c9d867e914afd934fe557dc37488368ba1ae4b
parent9a31f282ae39fa4be34cab5dec3474bb74b18c94 (diff)
lib9p: idl.gen: Detect when we try to import a sym that doesn't exist
-rw-r--r--lib9p/9p.generated.c15
-rw-r--r--lib9p/idl/2010-9P2000.L.9p2
-rw-r--r--lib9p/idl/__init__.py6
-rw-r--r--lib9p/include/lib9p/9p.generated.h8
4 files changed, 10 insertions, 21 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index 353654c..af16084 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -153,6 +153,7 @@ const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = {
_MSG_NAME(Twrite),
_MSG_NAME(Rwrite),
_MSG_NAME(Tclunk),
+ _MSG_NAME(Rclunk),
_MSG_NAME(Tremove),
_MSG_NAME(Rremove),
},
@@ -526,8 +527,6 @@ LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) {
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -543,8 +542,6 @@ LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) {
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) {
uint32_t size;
uint8_t typ;
@@ -1958,8 +1955,6 @@ LM_FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_4(ctx, &out->count);
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rclunk *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -1967,8 +1962,6 @@ LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p
unmarshal_tag(ctx, &out->tag);
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static void unmarshal_Rremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rremove *out) {
memset(out, 0, sizeof(*out));
ctx->net_offset += 4;
@@ -2876,8 +2869,6 @@ LM_FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rclunk *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -2890,8 +2881,6 @@ LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg
;
}
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LM_FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_Rremove *val) {
uint32_t _size_offset;
uint32_t _typ_offset;
@@ -4125,6 +4114,7 @@ const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80] = {
_MSG_RECV(Rwalk),
_MSG_RECV(Rread),
_MSG_RECV(Rwrite),
+ _MSG_RECV(Rclunk),
_MSG_RECV(Rremove),
},
#endif /* CONFIG_9P_ENABLE_9P2000_L */
@@ -4313,6 +4303,7 @@ const struct _lib9p_send_tentry _lib9p_table_Rmsg_send[LIB9P_VER_NUM][0x80] = {
_MSG_SEND(Rwalk),
_MSG_SEND(Rread),
_MSG_SEND(Rwrite),
+ _MSG_SEND(Rclunk),
_MSG_SEND(Rremove),
},
#endif /* CONFIG_9P_ENABLE_9P2000_L */
diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p
index 3886265..8edf18d 100644
--- a/lib9p/idl/2010-9P2000.L.9p
+++ b/lib9p/idl/2010-9P2000.L.9p
@@ -9,7 +9,7 @@ version "9P2000.L"
from ./2002-9P2000.9p import tag, fid, s, d, qt, qid
from ./2002-9P2000.9p import Rerror
-from ./2002-9P2000.9p import Tversion, Rversion, Tflush, Rflush, Twalk, Rwalk, Tread, Rread, Twrite, Rwrite, Tclunk, RClunk, Tremove, Rremove
+from ./2002-9P2000.9p import Tversion, Rversion, Tflush, Rflush, Twalk, Rwalk, Tread, Rread, Twrite, Rwrite, Tclunk, Rclunk, Tremove, Rremove
from ./2005-9P2000.u.9p import nuid, Tauth, Rauth, Tattach, Rattach
bitfield getattr = 8
diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py
index fec6c41..41664f1 100644
--- a/lib9p/idl/__init__.py
+++ b/lib9p/idl/__init__.py
@@ -449,8 +449,10 @@ def parse_file(
other_version, other_typs = get_include(m.group("file"))
for symname in m.group("syms").split(sep=","):
symname = symname.strip()
+ found = False
for typ in other_typs:
if typ.name == symname or symname == "*":
+ found = True
match typ:
case Primitive():
pass
@@ -467,6 +469,10 @@ def parse_file(
if other_version in member.in_versions:
member.in_versions.add(version)
env[typ.name] = typ
+ if symname != "*" and not found:
+ raise ValueError(
+ f"import: {m.group('file')}: no symbol {repr(symname)}"
+ )
elif m := re.fullmatch(re_line_num, line):
num = Number()
num.name = m.group("name")
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index abc2686..c33ab26 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -113,11 +113,7 @@ enum lib9p_msg_type { /* uint8_t */
LIB9P_TYP_Twrite = 118,
LIB9P_TYP_Rwrite = 119,
LIB9P_TYP_Tclunk = 120,
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Rclunk = 121,
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
LIB9P_TYP_Tremove = 122,
LIB9P_TYP_Rremove = 123,
#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
@@ -436,15 +432,11 @@ struct lib9p_msg_Rwrite {
uint32_t count;
};
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* size = 7 */
struct lib9p_msg_Rclunk {
lib9p_tag_t tag;
};
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
/* size = 7 */
struct lib9p_msg_Rremove {
lib9p_tag_t tag;