[lkml]   [1999]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] linux/signal.h siginit*() optimization
On Fri, 02 Jul 1999 04:26:33 +0000, 
Tom Leete <> wrote:
>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.

On the contrary, in C you can put the default case anywhere you like,
it does not have to be last. Although it tends to make more sense to
humans when it is last. To quote from K&R second edition, section 3.4
"Cases and the default clause can occur in any order".

Just to make absolutely sure, look at the generated code.

kernel/signal.c, lines 53-55.

t->sigpending = 0;
q = t->sigqueue;

Generated code when compiling kernel/signal.c with the normal flags
plus -S -g.

.stabn 68,0,53,.LM6-flush_signals
movl $0,8(%eax)
.stabs "/usr/src/2.2.9/include/linux/signal.h",132,0,0,.Ltext1
.stabn 68,0,147,.LM7-flush_signals
movl $0,932(%eax)
.stabn 68,0,148,.LM8-flush_signals
movl $0,928(%eax)
.stabs "signal.c",132,0,0,.Ltext2
.stabn 68,0,55,.LM9-flush_signals
movl 944(%eax),%edx

The compiler has used <linux/signal.h>, lines 147-148 for the expansion
of sigemptyset. That is the optimized case for two words of signals,
not the default memset() code.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:52    [W:0.031 / U:2.336 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site