diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-21 10:34:00 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-21 10:34:00 -0700 |
commit | 19a41387633e53d64d8a0ae69f3d3d3e35641c8d (patch) | |
tree | a89dead6dd34f95b3e644edeb02fe1ca70a28784 /lib9p | |
parent | 4ba0b95dc825a83748b7cb2aa528411026d5bada (diff) | |
parent | 5dab625d981e0039a5d874f5d8a6f795472785bc (diff) |
Merge branch 'lukeshu/misc'
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/9p.generated.c | 4 | ||||
-rwxr-xr-x | lib9p/idl.gen | 4 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.h | 7 | ||||
-rw-r--r-- | lib9p/internal.h | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/config/config.h | 4 | ||||
-rw-r--r-- | lib9p/tests/test_server/main.c | 51 |
6 files changed, 38 insertions, 36 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index eca0666..fe042e6 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -48,7 +48,7 @@ /* strings ********************************************************************/ -const char *_lib9p_table_ver_name[LIB9P_VER_NUM] = { +const char *const _lib9p_table_ver_name[LIB9P_VER_NUM] = { [LIB9P_VER_unknown] = "unknown", #if CONFIG_9P_ENABLE_9P2000 [LIB9P_VER_9P2000] = "9P2000", @@ -68,7 +68,7 @@ const char *_lib9p_table_ver_name[LIB9P_VER_NUM] = { }; #define _MSG_NAME(typ) [LIB9P_TYP_##typ] = #typ -const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = { +const char *const _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = { [LIB9P_VER_unknown] = { _MSG_NAME(Tversion), _MSG_NAME(Rversion), diff --git a/lib9p/idl.gen b/lib9p/idl.gen index f2b4f13..db5f37d 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -693,7 +693,7 @@ def gen_c(versions: set[str], typs: list[idl.Type]) -> str: ret += f""" /* strings ********************************************************************/ -const char *_{idprefix}table_ver_name[{c_ver_enum('NUM')}] = {{ +const char *const _{idprefix}table_ver_name[{c_ver_enum('NUM')}] = {{ """ for ver in ["unknown", *sorted(versions)]: if ver in versions: @@ -704,7 +704,7 @@ const char *_{idprefix}table_ver_name[{c_ver_enum('NUM')}] = {{ ret += "\n" ret += f"#define _MSG_NAME(typ) [{idprefix.upper()}TYP_##typ] = #typ\n" - ret += msg_table("msg", "name", "char *", (0, 0x100, 1)) + ret += msg_table("msg", "name", "char *const", (0, 0x100, 1)) # bitmasks ################################################################# ret += f""" diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h index 68e007f..f743afb 100644 --- a/lib9p/include/lib9p/9p.h +++ b/lib9p/include/lib9p/9p.h @@ -19,6 +19,13 @@ #error config.h must define CONFIG_9P_MAX_ERR_SIZE #endif +/* constants ******************************************************************/ + +enum { + LIB9P_DEFAULT_PORT_9FS = 564, + LIB9P_DEFAULT_PORT_STYX = 6666, +}; + /* strings ********************************************************************/ const char *lib9p_version_str(enum lib9p_version); diff --git a/lib9p/internal.h b/lib9p/internal.h index d27348e..1f4975f 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -88,8 +88,8 @@ struct _lib9p_send_tentry { _marshal_fn_t marshal; }; -extern const char * _lib9p_table_ver_name[LIB9P_VER_NUM]; -extern const char * _lib9p_table_msg_name[LIB9P_VER_NUM][0x100]; +extern const char *const _lib9p_table_ver_name[LIB9P_VER_NUM]; +extern const char *const _lib9p_table_msg_name[LIB9P_VER_NUM][0x100]; extern const uint32_t _lib9p_table_msg_min_size[LIB9P_VER_NUM]; extern const struct _lib9p_recv_tentry _lib9p_table_Tmsg_recv[LIB9P_VER_NUM][0x80]; extern const struct _lib9p_recv_tentry _lib9p_table_Rmsg_recv[LIB9P_VER_NUM][0x80]; diff --git a/lib9p/tests/test_server/config/config.h b/lib9p/tests/test_server/config/config.h index d852470..201cfd0 100644 --- a/lib9p/tests/test_server/config/config.h +++ b/lib9p/tests/test_server/config/config.h @@ -11,7 +11,7 @@ /* 9P *************************************************************************/ -#define CONFIG_9P_PORT 564 +#define CONFIG_9P_PORT LIB9P_DEFAULT_PORT_9FS /** * This max-msg-size is sized so that a Twrite message can return * 8KiB of data. @@ -48,7 +48,7 @@ /* COROUTINE ******************************************************************/ -#define CONFIG_COROUTINE_DEFAULT_STACK_SIZE (32*1024) +#define CONFIG_COROUTINE_STACK_SIZE_DEFAULT (32*1024) #define CONFIG_COROUTINE_NAME_LEN 16 #define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */ #define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */ diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index 10f67a3..2c64cd4 100644 --- a/lib9p/tests/test_server/main.c +++ b/lib9p/tests/test_server/main.c @@ -127,45 +127,40 @@ static uint32_t api_pread(struct api_file *, struct lib9p_srv_ctx *, void *, uin enum { PATH_BASE = __COUNTER__ }; #define PATH_COUNTER __COUNTER__ - PATH_BASE -#define STATIC_FILE(STRNAME, SYMNAME) \ +#define STATIC_COMMON(STRNAME, MODE) \ + { \ + .u_name = "root", .u_num = 0, /* owner user */ \ + .g_name = "root", .g_num = 0, /* owner group */ \ + .m_name = "root", .m_num = 0, /* last-modified-by user */ \ + \ + .pathnum = PATH_COUNTER, \ + .name = STRNAME, \ + .perm = MODE, \ + .atime = 1728337905, \ + .mtime = 1728337904, \ + } + +#define STATIC_FILE(STRNAME, SYMNAME) \ lo_box_util9p_static_file_as_lib9p_srv_file(&((struct util9p_static_file){ \ - ._util9p_static_common = { \ - .u_name = "root", .u_num = 0, /* owner user */ \ - .g_name = "root", .g_num = 0, /* owner group */ \ - .m_name = "root", .m_num = 0, /* last-modified-by user */ \ - \ - .pathnum = PATH_COUNTER, \ - .name = STRNAME, \ - .perm = 0444, \ - .atime = 1728337905, \ - .mtime = 1728337904, \ - }, \ - .data_start = _binary_static_##SYMNAME##_start, \ - .data_end = _binary_static_##SYMNAME##_end, \ + ._util9p_static_common = STATIC_COMMON(STRNAME, 0444), \ + .data_start = _binary_static_##SYMNAME##_start, \ + .data_end = _binary_static_##SYMNAME##_end, \ })) #define STATIC_DIR(STRNAME, ...) \ lo_box_util9p_static_dir_as_lib9p_srv_file(&((struct util9p_static_dir){ \ - ._util9p_static_common = { \ - .u_name = "root", .u_num = 0, /* owner user */ \ - .g_name = "root", .g_num = 0, /* owner group */ \ - .m_name = "root", .m_num = 0, /* last-modified-by user */ \ - \ - .pathnum = PATH_COUNTER, \ - .name = STRNAME, \ - .perm = 0555, \ - .atime = 1728337905, \ - .mtime = 1728337904, \ - }, \ - .members = { __VA_ARGS__ __VA_OPT__(,) LO_NULL(lib9p_srv_file) }, \ + ._util9p_static_common = STATIC_COMMON(STRNAME, 0555), \ + .members = { __VA_ARGS__ LO_NULL(lib9p_srv_file) }, \ })) struct lib9p_srv_file root = STATIC_DIR("", STATIC_DIR("Documentation", - STATIC_FILE("x", Documentation_x)), + STATIC_FILE("x", Documentation_x), + ), STATIC_FILE("README.md", README_md), - lo_box_api_as_lib9p_srv_file(&(struct api_file){.pathnum = PATH_COUNTER})); + lo_box_api_as_lib9p_srv_file(&(struct api_file){.pathnum = PATH_COUNTER}), + ); static lo_interface lib9p_srv_file get_root(struct lib9p_srv_ctx *LM_UNUSED(ctx), struct lib9p_s LM_UNUSED(treename)) { return root; |