diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-28 10:03:44 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-28 11:40:22 -0600 |
commit | a492c4a31f1c8b2a0d58e24ab957ef3c8f9edfd2 (patch) | |
tree | 3af2acfb87cec927da720d1541bac89730cd45b5 /lib9p | |
parent | d67db573786da4780653e72879033b9e24e83e28 (diff) |
lib9p: idl: Touch up the *.9p files
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/9p.generated.c | 18 | ||||
-rw-r--r-- | lib9p/idl/1992-9P0.9p.wip | 9 | ||||
-rw-r--r-- | lib9p/idl/1995-9P1.9p.wip | 2 | ||||
-rw-r--r-- | lib9p/idl/1996-Styx.9p.wip | 2 | ||||
-rw-r--r-- | lib9p/idl/2002-9P2000.9p | 6 | ||||
-rw-r--r-- | lib9p/idl/2005-9P2000.u.9p | 2 | ||||
-rw-r--r-- | lib9p/idl/2010-9P2000.L.9p | 36 | ||||
-rw-r--r-- | lib9p/include/lib9p/9p.generated.h | 188 | ||||
-rw-r--r-- | lib9p/protogen/h.py | 10 | ||||
-rw-r--r-- | lib9p/tests/test_compile.c | 12 |
10 files changed, 145 insertions, 140 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index 6726084..8819458 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -275,19 +275,19 @@ const char *const _lib9p_table_msg_name[LIB9P_VER_NUM][0x100] = { #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u static const lib9p_dm_t dm_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b11101100000000000000000111111111, + [LIB9P_VER_9P2000] = 0b11111100000000000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L [LIB9P_VER_9P2000_L] = 0b00000000000000000000000000000000, #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b11101100000000000000000111111111, + [LIB9P_VER_9P2000_e] = 0b11111100000000000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b11101100000000000000000111111111, + [LIB9P_VER_9P2000_p9p] = 0b11111100000000000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b11101100101111000000000111111111, + [LIB9P_VER_9P2000_u] = 0b11111100101111000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; @@ -295,19 +295,19 @@ static const lib9p_dm_t dm_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u static const lib9p_qt_t qt_masks[LIB9P_VER_NUM] = { #if CONFIG_9P_ENABLE_9P2000 - [LIB9P_VER_9P2000] = 0b11101100, + [LIB9P_VER_9P2000] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000 */ #if CONFIG_9P_ENABLE_9P2000_L - [LIB9P_VER_9P2000_L] = 0b11101100, + [LIB9P_VER_9P2000_L] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e - [LIB9P_VER_9P2000_e] = 0b11101100, + [LIB9P_VER_9P2000_e] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000_e */ #if CONFIG_9P_ENABLE_9P2000_p9p - [LIB9P_VER_9P2000_p9p] = 0b11101100, + [LIB9P_VER_9P2000_p9p] = 0b11111100, #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_u - [LIB9P_VER_9P2000_u] = 0b11101110, + [LIB9P_VER_9P2000_u] = 0b11111110, #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; diff --git a/lib9p/idl/1992-9P0.9p.wip b/lib9p/idl/1992-9P0.9p.wip index 086e8e4..968e887 100644 --- a/lib9p/idl/1992-9P0.9p.wip +++ b/lib9p/idl/1992-9P0.9p.wip @@ -37,12 +37,12 @@ struct errstr = "64*(txt[1])" # "O"pen flags (flags to pass to Topen and Tcreate) # Unused bits are *ignored*. bitfield o = 1 - "0=mode_0" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum - "1=mode_1" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum + "0=subfield(mode)" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum + "1=subfield(mode)" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum #"2=unused" #"3=unused" "4=TRUNC" - #"5=_reserved_CEXEC" # close-on-exec + "5=reserved(CEXEC)" # close-on-exec "6=RCLOSE" # remove-on-close #"7=unused" @@ -54,7 +54,8 @@ bitfield o = 1 "MODE_MASK = 0b00000011" "FLAG_MASK = 0b11111100" -# "C"??? "H"??? - file permissions and attributes +# "CH"annel flags - file permissions and attributes (a "channel" is +# what a file handle is called inside of the Plan 9 kernel). bitfield ch = 4 "31=DIR" "30=APPEND" diff --git a/lib9p/idl/1995-9P1.9p.wip b/lib9p/idl/1995-9P1.9p.wip index 2caf39d..765356c 100644 --- a/lib9p/idl/1995-9P1.9p.wip +++ b/lib9p/idl/1995-9P1.9p.wip @@ -43,7 +43,7 @@ from ./1992-9P0.9p import tag, fid, qid, name, errstr, o, ch, stat # draft RFC). As I understand it, CHMOUNT indicates that the file is # mounted by the kernel as a 9P transport; that the kernel has a lock # on doing I/O on it, so userspace can't do I/O on it. -bitfield ch += "28=MOUNT" +bitfield ch += "28=_PLAN9_MOUNT" # Authentication uses DES encryption. The client obtains a ticket and # a nonce-key from a separate auth-server; how it does this is beyond diff --git a/lib9p/idl/1996-Styx.9p.wip b/lib9p/idl/1996-Styx.9p.wip index 6ba4509..3cb3774 100644 --- a/lib9p/idl/1996-Styx.9p.wip +++ b/lib9p/idl/1996-Styx.9p.wip @@ -40,7 +40,7 @@ msg Ropen = "typ[1,val=11] tag[tag] fid[fid] qid[qid]" msg Tcreate = "typ[1,val=12] tag[tag] fid[fid] name[name] perm[ch] mode[o]" msg Rcreate = "typ[1,val=13] tag[tag] fid[fid] qid[qid]" # For `offset:max`, see `fs.c` `f_read()` and `f_write()`. -# For `count:max`, see `styx.h:MAXFDATA'. +# For `count:max`, see `styx.h:MAXFDATA`. msg Tread = "typ[1,val=14] tag[tag] fid[fid] offset[8,max=s64_max] count[2,max=8192]" msg Rread = "typ[1,val=15] tag[tag] fid[fid] count[2,max=8192] pad[1] count*(data[1])" msg Twrite = "typ[1,val=16] tag[tag] fid[fid] offset[8,max=s64_max] count[2,max=8192] pad[1] count*(data[1])" diff --git a/lib9p/idl/2002-9P2000.9p b/lib9p/idl/2002-9P2000.9p index 2a4f7ed..c569c74 100644 --- a/lib9p/idl/2002-9P2000.9p +++ b/lib9p/idl/2002-9P2000.9p @@ -36,13 +36,13 @@ bitfield dm = 4 "31=DIR" "30=APPEND" "29=EXCL" - # DMMOUNT has been around in Plan 9 forever (CHMOUNT in <4e), + # DMMOUNT has been around in Plan 9 since 2e (CHMOUNT in <4e), # but is undocumented, and is explicitly excluded from the # 9P2000 draft RFC. As I understand it, DMMOUNT indicates # that the file is mounted by the kernel as a 9P transport; # that the kernel has a lock on doing I/O on it, so userspace # can't do I/O on it. - "28=reserved(PLAN9_MOUNT)" + "28=_PLAN9_MOUNT" "27=AUTH" "26=TMP" #... @@ -63,7 +63,7 @@ bitfield qt = 1 "7=DIR" "6=APPEND" "5=EXCL" - "4=reserved(PLAN9_MOUNT)" # See "PLAN9_MOUNT" in "dm" above. + "4=_PLAN9_MOUNT" # See "_PLAN9_MOUNT" in "dm" above. "3=AUTH" # Fun historical fact: QTTMP was a relatively late addition to # Plan 9, in 2003-12. diff --git a/lib9p/idl/2005-9P2000.u.9p b/lib9p/idl/2005-9P2000.u.9p index fefe3e9..1bf5070 100644 --- a/lib9p/idl/2005-9P2000.u.9p +++ b/lib9p/idl/2005-9P2000.u.9p @@ -28,7 +28,7 @@ msg Tattach += "n_uid[nuid]" msg Rerror += "errno[errno]" bitfield dm += "23=DEVICE" - "21=NAMEDPIPE" + "21=PIPE" "20=SOCKET" "19=SETUID" "18=SETGID" diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p index 7ac86a6..89af6a5 100644 --- a/lib9p/idl/2010-9P2000.L.9p +++ b/lib9p/idl/2010-9P2000.L.9p @@ -73,15 +73,15 @@ bitfield lo = 4 # # These match the Linux kernel's values. num dt = 1 - "UNKNOWN = 0" - "NAMED_PIPE = 1" - "CHAR_DEV = 2" - "DIRECTORY = 4" - "BLOCK_DEV = 6" - "REGULAR = 8" - "SYMLINK = 10" - "SOCKET = 12" - "WHITEOUT = 14" + "UNKNOWN = 0" + "PIPE = 1" + "CHAR_DEV = 2" + "DIRECTORY = 4" + "BLOCK_DEV = 6" + "REGULAR = 8" + "SYMLINK = 10" + "SOCKET = 12" + "_WHITEOUT = 14" # Mode # @@ -107,16 +107,16 @@ bitfield mode = 4 "1=PERM_OTHER_W" "0=PERM_OTHER_X" - "FMT_NAMED_PIPE = LIB9P_DT_NAMED_PIPE<<12" - "FMT_CHAR_DEV = LIB9P_DT_CHAR_DEV<<12" - "FMT_DIRECTORY = LIB9P_DT_DIRECTORY<<12" - "FMT_BLOCK_DEV = LIB9P_DT_BLOCK_DEV<<12" - "FMT_REGULAR = LIB9P_DT_REGULAR<<12" - "FMT_SYMLINK = LIB9P_DT_SYMLINK<<12" - "FMT_SOCKET = LIB9P_DT_SOCKET<<12" + "FMT_PIPE = LIB9P_DT_PIPE<<12" + "FMT_CHAR_DEV = LIB9P_DT_CHAR_DEV<<12" + "FMT_DIRECTORY = LIB9P_DT_DIRECTORY<<12" + "FMT_BLOCK_DEV = LIB9P_DT_BLOCK_DEV<<12" + "FMT_REGULAR = LIB9P_DT_REGULAR<<12" + "FMT_SYMLINK = LIB9P_DT_SYMLINK<<12" + "FMT_SOCKET = LIB9P_DT_SOCKET<<12" - "PERM_MASK = 0000777" # PERM_* - "FMT_MASK = 0170000" # _fmt_* + "PERM_MASK = 0000777" # PERM_* + "FMT_MASK = 0170000" # _fmt_* # A boolean value that is for some reason 4 bytes wide. num b4 = 4 diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h index 7a50537..94ee89d 100644 --- a/lib9p/include/lib9p/9p.generated.h +++ b/lib9p/include/lib9p/9p.generated.h @@ -176,62 +176,62 @@ struct lib9p_s { /* size = 4 ; max_iov = 1 ; max_copy = 4 */ typedef uint32_t lib9p_dm_t; -#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31)) -#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30)) -#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29)) -#define _LIB9P_DM_RESERVED_PLAN9_MOUNT ((lib9p_dm_t)(1<<28)) -#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27)) -#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26)) -/* unused ((lib9p_dm_t)(1<<25)) */ -/* unused ((lib9p_dm_t)(1<<24)) */ +#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31)) +#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30)) +#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29)) +#define _LIB9P_DM_PLAN9_MOUNT ((lib9p_dm_t)(1<<28)) +#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27)) +#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26)) +/* unused ((lib9p_dm_t)(1<<25)) */ +/* unused ((lib9p_dm_t)(1<<24)) */ #if CONFIG_9P_ENABLE_9P2000_u -# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23)) +# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23)) #endif /* CONFIG_9P_ENABLE_9P2000_u */ -/* unused ((lib9p_dm_t)(1<<22)) */ +/* unused ((lib9p_dm_t)(1<<22)) */ #if CONFIG_9P_ENABLE_9P2000_u -# define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21)) -# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20)) -# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19)) -# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18)) +# define LIB9P_DM_PIPE ((lib9p_dm_t)(1<<21)) +# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20)) +# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19)) +# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18)) #endif /* CONFIG_9P_ENABLE_9P2000_u */ -/* unused ((lib9p_dm_t)(1<<17)) */ -/* unused ((lib9p_dm_t)(1<<16)) */ -/* unused ((lib9p_dm_t)(1<<15)) */ -/* unused ((lib9p_dm_t)(1<<14)) */ -/* unused ((lib9p_dm_t)(1<<13)) */ -/* unused ((lib9p_dm_t)(1<<12)) */ -/* unused ((lib9p_dm_t)(1<<11)) */ -/* unused ((lib9p_dm_t)(1<<10)) */ -/* unused ((lib9p_dm_t)(1<<9)) */ -#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8)) -#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7)) -#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6)) -#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5)) -#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4)) -#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3)) -#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2)) -#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1)) -#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0)) - -#define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0777)) +/* unused ((lib9p_dm_t)(1<<17)) */ +/* unused ((lib9p_dm_t)(1<<16)) */ +/* unused ((lib9p_dm_t)(1<<15)) */ +/* unused ((lib9p_dm_t)(1<<14)) */ +/* unused ((lib9p_dm_t)(1<<13)) */ +/* unused ((lib9p_dm_t)(1<<12)) */ +/* unused ((lib9p_dm_t)(1<<11)) */ +/* unused ((lib9p_dm_t)(1<<10)) */ +/* unused ((lib9p_dm_t)(1<<9)) */ +#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8)) +#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7)) +#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6)) +#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5)) +#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4)) +#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3)) +#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2)) +#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1)) +#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0)) + +#define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0777)) #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u /* size = 1 ; max_iov = 1 ; max_copy = 1 */ typedef uint8_t lib9p_qt_t; -#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7)) -#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6)) -#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5)) -#define _LIB9P_QT_RESERVED_PLAN9_MOUNT ((lib9p_qt_t)(1<<4)) -#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3)) -#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2)) +#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7)) +#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6)) +#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5)) +#define _LIB9P_QT_PLAN9_MOUNT ((lib9p_qt_t)(1<<4)) +#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3)) +#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2)) #if CONFIG_9P_ENABLE_9P2000_u -# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1)) +# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1)) #endif /* CONFIG_9P_ENABLE_9P2000_u */ -/* unused ((lib9p_qt_t)(1<<0)) */ +/* unused ((lib9p_qt_t)(1<<0)) */ -#define LIB9P_QT_FILE ((lib9p_qt_t)(0)) +#define LIB9P_QT_FILE ((lib9p_qt_t)(0)) #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u @@ -317,61 +317,61 @@ typedef uint32_t lib9p_lo_t; /* size = 1 ; max_iov = 1 ; max_copy = 1 */ typedef uint8_t lib9p_dt_t; -#define LIB9P_DT_UNKNOWN ((lib9p_dt_t)UINT8_C(0)) -#define LIB9P_DT_NAMED_PIPE ((lib9p_dt_t)UINT8_C(1)) -#define LIB9P_DT_CHAR_DEV ((lib9p_dt_t)UINT8_C(2)) -#define LIB9P_DT_DIRECTORY ((lib9p_dt_t)UINT8_C(4)) -#define LIB9P_DT_BLOCK_DEV ((lib9p_dt_t)UINT8_C(6)) -#define LIB9P_DT_REGULAR ((lib9p_dt_t)UINT8_C(8)) -#define LIB9P_DT_SYMLINK ((lib9p_dt_t)UINT8_C(10)) -#define LIB9P_DT_SOCKET ((lib9p_dt_t)UINT8_C(12)) -#define LIB9P_DT_WHITEOUT ((lib9p_dt_t)UINT8_C(14)) +#define LIB9P_DT_UNKNOWN ((lib9p_dt_t)UINT8_C(0)) +#define LIB9P_DT_PIPE ((lib9p_dt_t)UINT8_C(1)) +#define LIB9P_DT_CHAR_DEV ((lib9p_dt_t)UINT8_C(2)) +#define LIB9P_DT_DIRECTORY ((lib9p_dt_t)UINT8_C(4)) +#define LIB9P_DT_BLOCK_DEV ((lib9p_dt_t)UINT8_C(6)) +#define LIB9P_DT_REGULAR ((lib9p_dt_t)UINT8_C(8)) +#define LIB9P_DT_SYMLINK ((lib9p_dt_t)UINT8_C(10)) +#define LIB9P_DT_SOCKET ((lib9p_dt_t)UINT8_C(12)) +#define _LIB9P_DT_WHITEOUT ((lib9p_dt_t)UINT8_C(14)) /* size = 4 ; max_iov = 1 ; max_copy = 4 */ typedef uint32_t lib9p_mode_t; -/* unused ((lib9p_mode_t)(1<<31)) */ -/* unused ((lib9p_mode_t)(1<<30)) */ -/* unused ((lib9p_mode_t)(1<<29)) */ -/* unused ((lib9p_mode_t)(1<<28)) */ -/* unused ((lib9p_mode_t)(1<<27)) */ -/* unused ((lib9p_mode_t)(1<<26)) */ -/* unused ((lib9p_mode_t)(1<<25)) */ -/* unused ((lib9p_mode_t)(1<<24)) */ -/* unused ((lib9p_mode_t)(1<<23)) */ -/* unused ((lib9p_mode_t)(1<<22)) */ -/* unused ((lib9p_mode_t)(1<<21)) */ -/* unused ((lib9p_mode_t)(1<<20)) */ -/* unused ((lib9p_mode_t)(1<<19)) */ -/* unused ((lib9p_mode_t)(1<<18)) */ -/* unused ((lib9p_mode_t)(1<<17)) */ -/* unused ((lib9p_mode_t)(1<<16)) */ -#define _LIB9P_MODE_fmt_3 ((lib9p_mode_t)(1<<15)) -#define _LIB9P_MODE_fmt_2 ((lib9p_mode_t)(1<<14)) -#define _LIB9P_MODE_fmt_1 ((lib9p_mode_t)(1<<13)) -#define _LIB9P_MODE_fmt_0 ((lib9p_mode_t)(1<<12)) -#define LIB9P_MODE_PERM_SETGROUP ((lib9p_mode_t)(1<<11)) -#define LIB9P_MODE_PERM_SETUSER ((lib9p_mode_t)(1<<10)) -#define LIB9P_MODE_PERM_STICKY ((lib9p_mode_t)(1<<9)) -#define LIB9P_MODE_PERM_OWNER_R ((lib9p_mode_t)(1<<8)) -#define LIB9P_MODE_PERM_OWNER_W ((lib9p_mode_t)(1<<7)) -#define LIB9P_MODE_PERM_OWNER_X ((lib9p_mode_t)(1<<6)) -#define LIB9P_MODE_PERM_GROUP_R ((lib9p_mode_t)(1<<5)) -#define LIB9P_MODE_PERM_GROUP_W ((lib9p_mode_t)(1<<4)) -#define LIB9P_MODE_PERM_GROUP_X ((lib9p_mode_t)(1<<3)) -#define LIB9P_MODE_PERM_OTHER_R ((lib9p_mode_t)(1<<2)) -#define LIB9P_MODE_PERM_OTHER_W ((lib9p_mode_t)(1<<1)) -#define LIB9P_MODE_PERM_OTHER_X ((lib9p_mode_t)(1<<0)) - -#define LIB9P_MODE_FMT_NAMED_PIPE ((lib9p_mode_t)(LIB9P_DT_NAMED_PIPE<<12)) -#define LIB9P_MODE_FMT_CHAR_DEV ((lib9p_mode_t)(LIB9P_DT_CHAR_DEV<<12)) -#define LIB9P_MODE_FMT_DIRECTORY ((lib9p_mode_t)(LIB9P_DT_DIRECTORY<<12)) -#define LIB9P_MODE_FMT_BLOCK_DEV ((lib9p_mode_t)(LIB9P_DT_BLOCK_DEV<<12)) -#define LIB9P_MODE_FMT_REGULAR ((lib9p_mode_t)(LIB9P_DT_REGULAR<<12)) -#define LIB9P_MODE_FMT_SYMLINK ((lib9p_mode_t)(LIB9P_DT_SYMLINK<<12)) -#define LIB9P_MODE_FMT_SOCKET ((lib9p_mode_t)(LIB9P_DT_SOCKET<<12)) -#define LIB9P_MODE_PERM_MASK ((lib9p_mode_t)(0000777)) -#define LIB9P_MODE_FMT_MASK ((lib9p_mode_t)(0170000)) +/* unused ((lib9p_mode_t)(1<<31)) */ +/* unused ((lib9p_mode_t)(1<<30)) */ +/* unused ((lib9p_mode_t)(1<<29)) */ +/* unused ((lib9p_mode_t)(1<<28)) */ +/* unused ((lib9p_mode_t)(1<<27)) */ +/* unused ((lib9p_mode_t)(1<<26)) */ +/* unused ((lib9p_mode_t)(1<<25)) */ +/* unused ((lib9p_mode_t)(1<<24)) */ +/* unused ((lib9p_mode_t)(1<<23)) */ +/* unused ((lib9p_mode_t)(1<<22)) */ +/* unused ((lib9p_mode_t)(1<<21)) */ +/* unused ((lib9p_mode_t)(1<<20)) */ +/* unused ((lib9p_mode_t)(1<<19)) */ +/* unused ((lib9p_mode_t)(1<<18)) */ +/* unused ((lib9p_mode_t)(1<<17)) */ +/* unused ((lib9p_mode_t)(1<<16)) */ +#define _LIB9P_MODE_fmt_3 ((lib9p_mode_t)(1<<15)) +#define _LIB9P_MODE_fmt_2 ((lib9p_mode_t)(1<<14)) +#define _LIB9P_MODE_fmt_1 ((lib9p_mode_t)(1<<13)) +#define _LIB9P_MODE_fmt_0 ((lib9p_mode_t)(1<<12)) +#define LIB9P_MODE_PERM_SETGROUP ((lib9p_mode_t)(1<<11)) +#define LIB9P_MODE_PERM_SETUSER ((lib9p_mode_t)(1<<10)) +#define LIB9P_MODE_PERM_STICKY ((lib9p_mode_t)(1<<9)) +#define LIB9P_MODE_PERM_OWNER_R ((lib9p_mode_t)(1<<8)) +#define LIB9P_MODE_PERM_OWNER_W ((lib9p_mode_t)(1<<7)) +#define LIB9P_MODE_PERM_OWNER_X ((lib9p_mode_t)(1<<6)) +#define LIB9P_MODE_PERM_GROUP_R ((lib9p_mode_t)(1<<5)) +#define LIB9P_MODE_PERM_GROUP_W ((lib9p_mode_t)(1<<4)) +#define LIB9P_MODE_PERM_GROUP_X ((lib9p_mode_t)(1<<3)) +#define LIB9P_MODE_PERM_OTHER_R ((lib9p_mode_t)(1<<2)) +#define LIB9P_MODE_PERM_OTHER_W ((lib9p_mode_t)(1<<1)) +#define LIB9P_MODE_PERM_OTHER_X ((lib9p_mode_t)(1<<0)) + +#define LIB9P_MODE_FMT_PIPE ((lib9p_mode_t)(LIB9P_DT_PIPE<<12)) +#define LIB9P_MODE_FMT_CHAR_DEV ((lib9p_mode_t)(LIB9P_DT_CHAR_DEV<<12)) +#define LIB9P_MODE_FMT_DIRECTORY ((lib9p_mode_t)(LIB9P_DT_DIRECTORY<<12)) +#define LIB9P_MODE_FMT_BLOCK_DEV ((lib9p_mode_t)(LIB9P_DT_BLOCK_DEV<<12)) +#define LIB9P_MODE_FMT_REGULAR ((lib9p_mode_t)(LIB9P_DT_REGULAR<<12)) +#define LIB9P_MODE_FMT_SYMLINK ((lib9p_mode_t)(LIB9P_DT_SYMLINK<<12)) +#define LIB9P_MODE_FMT_SOCKET ((lib9p_mode_t)(LIB9P_DT_SOCKET<<12)) +#define LIB9P_MODE_PERM_MASK ((lib9p_mode_t)(0000777)) +#define LIB9P_MODE_FMT_MASK ((lib9p_mode_t)(0170000)) /* size = 4 ; max_iov = 1 ; max_copy = 4 */ typedef uint32_t lib9p_b4_t; diff --git a/lib9p/protogen/h.py b/lib9p/protogen/h.py index c84ff02..a9f0b39 100644 --- a/lib9p/protogen/h.py +++ b/lib9p/protogen/h.py @@ -361,10 +361,14 @@ enum {c9util.ident('version')} {{ def gen_number(typ: idl.Number) -> str: ret = f"typedef {c9util.typename(typ.prim)} {c9util.typename(typ)};\n" - prefix = f"{c9util.IDENT(typ.typname)}_" - namewidth = max(len(name) for name in typ.vals) + + def cname(base: str) -> str: + prefix = f"{typ.typname}_".upper() + return c9util.Ident(c9util.add_prefix(prefix, base)) + + namewidth = max(len(cname(name)) for name in typ.vals) for name, val in typ.vals.items(): - ret += f"#define {prefix}{name:<{namewidth}} (({c9util.typename(typ)})UINT{typ.static_size*8}_C({val}))\n" + ret += f"#define {cname(name):<{namewidth}} (({c9util.typename(typ)})UINT{typ.static_size*8}_C({val}))\n" return ret diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c index 6abee05..b1fa7c9 100644 --- a/lib9p/tests/test_compile.c +++ b/lib9p/tests/test_compile.c @@ -8,11 +8,11 @@ int main(void) { x = LIB9P_DM_DIR; x = LIB9P_DM_APPEND; x = LIB9P_DM_EXCL; - x = _LIB9P_DM_RESERVED_PLAN9_MOUNT; + x = _LIB9P_DM_PLAN9_MOUNT; x = LIB9P_DM_AUTH; x = LIB9P_DM_TMP; x = LIB9P_DM_DEVICE; - x = LIB9P_DM_NAMEDPIPE; + x = LIB9P_DM_PIPE; x = LIB9P_DM_SOCKET; x = LIB9P_DM_SETUID; x = LIB9P_DM_SETGID; @@ -29,7 +29,7 @@ int main(void) { x = LIB9P_QT_DIR; x = LIB9P_QT_APPEND; x = LIB9P_QT_EXCL; - x = _LIB9P_QT_RESERVED_PLAN9_MOUNT; + x = _LIB9P_QT_PLAN9_MOUNT; x = LIB9P_QT_AUTH; x = LIB9P_QT_TMP; x = LIB9P_QT_SYMLINK; @@ -72,14 +72,14 @@ int main(void) { x = LIB9P_LO_MODE_MASK; x = LIB9P_LO_FLAG_MASK; x = LIB9P_DT_UNKNOWN; - x = LIB9P_DT_NAMED_PIPE; + x = LIB9P_DT_PIPE; x = LIB9P_DT_CHAR_DEV; x = LIB9P_DT_DIRECTORY; x = LIB9P_DT_BLOCK_DEV; x = LIB9P_DT_REGULAR; x = LIB9P_DT_SYMLINK; x = LIB9P_DT_SOCKET; - x = LIB9P_DT_WHITEOUT; + x = _LIB9P_DT_WHITEOUT; x = _LIB9P_MODE_fmt_3; x = _LIB9P_MODE_fmt_2; x = _LIB9P_MODE_fmt_1; @@ -96,7 +96,7 @@ int main(void) { x = LIB9P_MODE_PERM_OTHER_R; x = LIB9P_MODE_PERM_OTHER_W; x = LIB9P_MODE_PERM_OTHER_X; - x = LIB9P_MODE_FMT_NAMED_PIPE; + x = LIB9P_MODE_FMT_PIPE; x = LIB9P_MODE_FMT_CHAR_DEV; x = LIB9P_MODE_FMT_DIRECTORY; x = LIB9P_MODE_FMT_BLOCK_DEV; |