=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/kdump/mksubr,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/kdump/mksubr 2013/07/01 17:16:46 1.16 --- src/usr.bin/kdump/mksubr 2013/07/03 23:04:34 1.17 *************** *** 1,5 **** #!/bin/sh ! # $OpenBSD: mksubr,v 1.16 2013/07/01 17:16:46 guenther Exp $ # # Copyright (c) 2006 David Kirchner # --- 1,5 ---- #!/bin/sh ! # $OpenBSD: mksubr,v 1.17 2013/07/03 23:04:34 guenther Exp $ # # Copyright (c) 2006 David Kirchner # *************** *** 277,462 **** #include #include "kdump_subr.h" - - /* - * These are simple support macros. print_or utilizes a variable - * defined in the calling function to track whether or not it should - * print a logical-OR character ('|') before a string. if_print_or - * simply handles the necessary "if" statement used in many lines - * of this file. - */ - #define print_or(str,orflag) do { \\ - if (orflag) putchar('|'); else orflag = 1; \\ - printf ("%s", str); } \\ - while (0) - #define if_print_or(i,flag,orflag) do { \\ - if ((i & flag) == flag) \\ - print_or(#flag,orflag); } \\ - while (0) - - /* MANUAL */ - extern const char *const sys_signame[NSIG]; - void - signame (int sig) - { - if (sig > 0 && sig < NSIG) - (void)printf("SIG%s", sys_signame[sig]); - else - (void)printf("SIG %d", sig); - } - - /* MANUAL */ - 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) - { - switch (cmd) { - case GETNCNT: - (void)printf("GETNCNT"); - break; - case GETPID: - (void)printf("GETPID"); - break; - case GETVAL: - (void)printf("GETVAL"); - break; - case GETALL: - (void)printf("GETALL"); - break; - case GETZCNT: - (void)printf("GETZCNT"); - break; - case SETVAL: - (void)printf("SETVAL"); - break; - case SETALL: - (void)printf("SETALL"); - break; - case IPC_RMID: - (void)printf("IPC_RMID"); - break; - case IPC_SET: - (void)printf("IPC_SET"); - break; - case IPC_STAT: - (void)printf("IPC_STAT"); - break; - default: /* Should not reach */ - (void)printf("", (long)cmd); - } - } - - /* MANUAL */ - void - shmctlname (int cmd) { - switch (cmd) { - case IPC_RMID: - (void)printf("IPC_RMID"); - break; - case IPC_SET: - (void)printf("IPC_SET"); - break; - case IPC_STAT: - (void)printf("IPC_STAT"); - break; - default: /* Should not reach */ - (void)printf("", (long)cmd); - } - } - - /* MANUAL */ - void - semgetname (int flag) { - int or = 0; - if_print_or(flag, IPC_CREAT, or); - if_print_or(flag, IPC_EXCL, or); - if_print_or(flag, SEM_R, or); - if_print_or(flag, SEM_A, or); - if_print_or(flag, (SEM_R>>3), or); - if_print_or(flag, (SEM_A>>3), or); - if_print_or(flag, (SEM_R>>6), or); - if_print_or(flag, (SEM_A>>6), or); - } - - /* - * MANUAL - * - * Only used by SYS_open. Unless O_CREAT is set in flags, the - * mode argument is unused (and often bogus and misleading). - */ - void - flagsandmodename (int flags, int mode) { - flagsname (flags); - if ((flags & O_CREAT) == O_CREAT) { - (void)putchar(','); - modename (mode); - } else if (!fancy) { - (void)putchar(','); - if (decimal) { - (void)printf("%ld", (long)mode); - } else { - (void)printf("%#lx", (long)mode); - } - } - } - - void - clockname (int clockid) - { - clocktypename(__CLOCK_TYPE(clockid)); - if (__CLOCK_PTID(clockid) != 0) - printf("(%d)", __CLOCK_PTID(clockid)); - } - - /* - * MANUAL - * - * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value - * referring to a line in /etc/protocols . It might be appropriate - * to use getprotoent(3) here. - */ - void - sockoptlevelname (int level) - { - if (level == SOL_SOCKET) { - (void)printf("SOL_SOCKET"); - } else { - if (decimal) { - (void)printf("%ld", (long)level); - } else { - (void)printf("%#lx", (long)level); - } - } - } _EOF_ --- 277,282 ----