Messages in this thread Patch in this message | | | Date | Fri, 02 Jul 1999 04:26:33 +0000 | From | Tom Leete <> | Subject | [PATCH] linux/signal.h siginit*() optimization |
| |
Hello,
The thread "linux headers and C++" begun by Ronnie Misra got me looking at include/linux/signal.h. I noticed that the optimizations for the siginit* functions may not work as intended. I'm enclosing a patch which I believe fixes them. As a bonus they become legal ANSI C.
To be specific: in each of sigfillset(), sigemptyset(), siginitset(), and siginitsetinv(), a "default: memset();break;" combination was the first case examined. Since the default case is always satisfied, memset() was always called. The optimization for small sigsets was never seen. This patch rearranges things and puts breaks in the proper places.
Cheers, Tom--- linux/include/linux/signal.h.orig Fri May 14 01:36:05 1999 +++ linux/include/linux/signal.h Thu Jul 1 23:24:32 1999 @@ -141,24 +141,22 @@ extern inline void sigemptyset(sigset_t *set) { switch (_NSIG_WORDS) { - default: - memset(set, 0, sizeof(sigset_t)); - break; case 2: set->sig[1] = 0; case 1: set->sig[0] = 0; break; + default: + memset(set, 0, sizeof(sigset_t)); } } extern inline void sigfillset(sigset_t *set) { switch (_NSIG_WORDS) { - default: - memset(set, -1, sizeof(sigset_t)); - break; case 2: set->sig[1] = -1; case 1: set->sig[0] = -1; break; + default: + memset(set, -1, sizeof(sigset_t)); } } @@ -185,11 +183,10 @@ { set->sig[0] = mask; switch (_NSIG_WORDS) { + case 2: set->sig[1] = 0; + case 1: break; default: memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1)); - break; - case 2: set->sig[1] = 0; - case 1: } } @@ -197,11 +194,10 @@ { set->sig[0] = ~mask; switch (_NSIG_WORDS) { + case 2: set->sig[1] = -1; + case 1: break; default: memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1)); - break; - case 2: set->sig[1] = -1; - case 1: } }
| |