version 1.7, 2011/09/19 22:00:37 |
version 1.8, 2012/02/20 21:04:35 |
|
|
} |
} |
|
|
# |
# |
|
# Like auto_or_type(), but a zero value is valid and prints as "0<>" |
|
# |
|
auto_orz_type () { |
|
local name grep file |
|
name=$1 |
|
grep=$2 |
|
file=$3 |
|
|
|
cat <<_EOF_ |
|
/* AUTO */ |
|
void |
|
$name (int arg) |
|
{ |
|
int or = 0; |
|
if (arg == 0) { |
|
printf("0<>"); |
|
return; |
|
} |
|
printf("%#x<", arg); |
|
_EOF_ |
|
egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ |
|
$include_dir/$file | \ |
|
awk '{ for (i = 1; i <= NF; i++) \ |
|
if ($i ~ /define/) \ |
|
break; \ |
|
++i; \ |
|
printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' |
|
cat <<_EOF_ |
|
printf(">"); |
|
if (or == 0) |
|
(void)printf("<invalid>%ld", (long)arg); |
|
} |
|
|
|
_EOF_ |
|
} |
|
|
|
# |
# Automatically generates a C function used when the argument |
# Automatically generates a C function used when the argument |
# maps to a single, specific #definition |
# maps to a single, specific #definition |
# |
# |
|
|
*/ |
*/ |
#define print_or(str,orflag) do { \\ |
#define print_or(str,orflag) do { \\ |
if (orflag) putchar('|'); else orflag = 1; \\ |
if (orflag) putchar('|'); else orflag = 1; \\ |
printf (str); } \\ |
printf ("%s", str); } \\ |
while (0) |
while (0) |
#define if_print_or(i,flag,orflag) do { \\ |
#define if_print_or(i,flag,orflag) do { \\ |
if ((i & flag) == flag) \\ |
if ((i & flag) == flag) \\ |
|
|
|
|
/* MANUAL */ |
/* MANUAL */ |
void |
void |
|
sigset (int ss) |
|
{ |
|
int or = 0; |
|
int cnt = 0; |
|
int i; |
|
|
|
for (i = 1; i < NSIG; i++) |
|
if (sigismember(&ss, i)) |
|
cnt++; |
|
if (cnt > (NSIG-1)/2) { |
|
ss = ~ss; |
|
putchar('~'); |
|
} |
|
|
|
if (ss == 0) { |
|
(void)printf("0<>"); |
|
return; |
|
} |
|
|
|
printf("%#x<", ss); |
|
for (i = 1; i < NSIG; i++) |
|
if (sigismember(&ss, i)) { |
|
if (or) putchar('|'); else or=1; |
|
signame(i); |
|
} |
|
printf(">"); |
|
} |
|
|
|
/* MANUAL */ |
|
void |
semctlname (int cmd) |
semctlname (int cmd) |
{ |
{ |
switch (cmd) { |
switch (cmd) { |
|
|
|
|
_EOF_ |
_EOF_ |
|
|
auto_or_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h" |
auto_orz_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h" |
auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" |
auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" |
auto_or_type "atflagsname" "AT_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" |
auto_orz_type "atflagsname" "AT_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" |
auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h" |
auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h" |
auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" |
auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" |
auto_or_type "mmapflagsname" "MAP_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" |
auto_or_type "mmapflagsname" "MAP_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" |
auto_or_type "wait4optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" |
auto_orz_type "wait4optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" |
|
#auto_or_type "timerflagsname" "TIMER_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/time.h" |
#auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h" |
#auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h" |
#auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h" |
#auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h" |
#auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h" |
#auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h" |
auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h" |
auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h" |
#auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" |
#auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" |
auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h" |
auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h" |
auto_or_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}" "sys/shm.h" |
auto_orz_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}" "sys/shm.h" |
#auto_or_type "rforkname" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h" |
#auto_or_type "rforkname" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h" |
#auto_or_type "nfssvcname" "NFSSVC_[A-Z]+[[:space:]]+0x[0-9]+" "nfsserver/nfs.h" |
#auto_or_type "nfssvcname" "NFSSVC_[A-Z]+[[:space:]]+0x[0-9]+" "nfsserver/nfs.h" |
# |
# |
|
|
#auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h" |
#auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h" |
auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h" |
auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h" |
auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h" |
auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h" |
|
auto_switch_type "clockname" "CLOCK_[A-Z]+[[:space:]]+[0-9]+" "sys/time.h" |
#auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h" |
#auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h" |
#auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" |
#auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" |
#auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h" |
#auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h" |