diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-21 14:26:38 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-02-23 10:44:58 -0700 |
commit | c990e16bb4754e17a4858274ebd59f1e0859b16f (patch) | |
tree | e64814bf4c5e2630c92ca0a7a9bb78930203f0c5 /lib9p/tests | |
parent | a1883e93c1094ed34c21e018d34993e2a9e80506 (diff) |
lib9p_util: Pull utility macros into static.h
Diffstat (limited to 'lib9p/tests')
-rw-r--r-- | lib9p/tests/test_server/main.c | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index 2c64cd4..c60dd71 100644 --- a/lib9p/tests/test_server/main.c +++ b/lib9p/tests/test_server/main.c @@ -73,8 +73,8 @@ static struct lib9p_stat api_stat(struct api_file *self, struct lib9p_srv_ctx *c .kern_dev = 0, .file_qid = api_qid(self), .file_mode = 0222, - .file_atime = 1728337905, - .file_mtime = 1728337904, + .file_atime = UTIL9P_ATIME, + .file_mtime = UTIL9P_MTIME, .file_size = 0, .file_name = lib9p_str("shutdown"), .file_owner_uid = lib9p_str("root"), @@ -113,45 +113,19 @@ static uint32_t api_pread(struct api_file *, struct lib9p_srv_ctx *, void *, uin assert_notreached("not readable"); } -/* file tree ******************************************************************/ +#define lo_box_api_as_lib9p_srv_file(obj) util9p_box(api, obj) -#define _box(nam, obj) \ - ((struct lib9p_srv_file){ \ - .self = obj, \ - .vtable = (void*)&_lo_##nam##_lib9p_srv_file_vtable, \ - }) -#define lo_box_util9p_static_file_as_lib9p_srv_file(obj) _box(util9p_static_file, obj) -#define lo_box_util9p_static_dir_as_lib9p_srv_file(obj) _box(util9p_static_dir, obj) -#define lo_box_api_as_lib9p_srv_file(obj) _box(api, obj) +/* file tree ******************************************************************/ enum { PATH_BASE = __COUNTER__ }; #define PATH_COUNTER __COUNTER__ - PATH_BASE -#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 = 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 = STATIC_COMMON(STRNAME, 0555), \ - .members = { __VA_ARGS__ LO_NULL(lib9p_srv_file) }, \ - })) +#define STATIC_FILE(STRNAME, SYMNAME) \ + UTIL9P_STATIC_FILE(PATH_COUNTER, STRNAME, \ + .data_start = _binary_static_##SYMNAME##_start, \ + .data_end = _binary_static_##SYMNAME##_end) +#define STATIC_DIR(STRNAME, ...) \ + UTIL9P_STATIC_DIR(PATH_COUNTER, STRNAME, __VA_ARGS__) struct lib9p_srv_file root = STATIC_DIR("", |