Page MenuHomeFreeBSD

D57993.id181168.diff
No OneTemporary

D57993.id181168.diff

diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables
--- a/lib/libsysdecode/mktables
+++ b/lib/libsysdecode/mktables
@@ -48,17 +48,13 @@
all_headers=
#
-# Generate a table C #definitions. The including file can define the
-# TABLE_NAME(n), TABLE_ENTRY(x), and TABLE_END macros to define what
-# the tables map to.
+# Generate a table from C preprocessor symbol definitions. The
+# including file can define the TABLE_NAME(n), TABLE_ENTRY(x), and
+# TABLE_END macros to define what the tables map to.
#
gen_table()
{
- local name grep file excl filter
- name=$1
- grep=$2
- file=$3
- excl=$4
+ local name=$1 grep=$2 file=$3 excl=$4
if [ -z "$excl" ]; then
filter="cat"
@@ -84,6 +80,45 @@
_EOF_
}
+#
+# Generate a table from C enum definitions. The including file can
+# define the TABLE_NAME(n), TABLE_ENTRY(x), and TABLE_END macros to
+# define what the tables map to. Works with most enum definitions as
+# long as each constant is on a line by itself.
+#
+gen_table_enum()
+{
+ local name=$1 grep=$2 file=$3 excl=$4
+
+ cat <<_EOF_
+TABLE_START(${name})
+_EOF_
+ if [ -e "${include_dir}/${file}" ]; then
+ all_headers="${all_headers:+${all_headers} }${file}"
+ # preprocess the header and strip directives
+ ${CPP:=cpp} $include_dir/$file | sed -ne '/^[^#]/p' |
+ # move comma, equal, semicolon away from words
+ sed -e 's/\([0-9A-Za-z_]\)\([=,;]\)/\1 \2/g' |
+ awk ${excl:+"/$excl/ { next }"}'
+ # identify the start of an enum
+ /^enum([[:space:]]+[^[:space:]]+)?[[:space:]]*\{/ {
+ inenum++
+ }
+ # identify enum constants that match our regex
+ inenum && $1 ~ /^'"${grep}"'$/ {
+ printf "TABLE_ENTRY(%s)\n", $1
+ }
+ # identify the end of an enum
+ inenum && /^[[:space:]]*\}/ {
+ inenum--
+ }'
+ fi
+cat <<_EOF_
+TABLE_END
+
+_EOF_
+}
+
cat <<_EOF_
/* This file is auto-generated. */
@@ -127,7 +162,7 @@
gen_table "schedpolicy" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sys/sched.h"
gen_table "sendfileflags" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
gen_table "shmatflags" "SHM_[A-Z]+[[:space:]]+[0-9]{6}" "sys/shm.h"
-gen_table "shutdownhow" "SHUT_[A-Z]+[[:space:]]+SHUT_[A-Z]+" "sys/socket.h"
+gen_table_enum "shutdownhow" "SHUT_[A-Z]+" "sys/socket.h"
gen_table "sigbuscode" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigchldcode" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigfpecode" "FPE_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"

File Metadata

Mime Type
text/plain
Expires
Sat, Jul 11, 7:07 AM (10 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34594505
Default Alt Text
D57993.id181168.diff (2 KB)

Event Timeline