[PATCH] linux/signal.h siginit*() optimization

Tom Leete (tleete@access.mountain.net)
Fri, 02 Jul 1999 04:26:33 +0000


This is a multi-part message in MIME format.
--------------A4C9FCAF3F4E74D188E0C186
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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
--------------A4C9FCAF3F4E74D188E0C186
Content-Type: text/plain; charset=us-ascii;
name="signal.h.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="signal.h.patch"

--- 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:
}
}

--------------A4C9FCAF3F4E74D188E0C186--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/