Re: [PATCH] Remove extra shift in __SI_CODE macro

From: Robert H. de Vries (rhdv@rhdv.cistron.nl)
Date: Thu Jul 27 2000 - 17:16:10 EST


On Sun, 23 Jul 2000, Linus Torvalds wrote:
>On Sun, 23 Jul 2000, Robert H. de Vries wrote:
>> The __SI_CODE macro shifts its argument 16 bits to the left while the only
>> argument used is already shifted 16 bits to the left. In this way no bits
>> are left on a 32 bit architecture.
>> Hence this patch, which removes the superfluous shift.
>
>Sounds like the _users_ of __SI_CODE should be fixed, rather than
>__SI_CODE. The new definition of __SI_CODE doesn't make much sense, in my
>opinion.

If I would change the user, that would trigger an avalanche of changes, while
my proposition is limited to just one definition.
Let me illustrate:
Suppose I change the user of __SI_CODE: __SI_TIMER. This would imply changing
it from (1<<16) to 1.
That would imply changing the entire family for consistency:
#define __SI_KILL (0 << 16)
#define __SI_TIMER (1 << 16)
#define __SI_POLL (2 << 16)
#define __SI_FAULT (3 << 16)
#define __SI_CHLD (4 << 16)
#define __SI_RT (5 << 16)

That would require the change of the following set of definitions:
/*
 * SIGILL si_codes
 */
#define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */
#define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */
#define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */
#define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */
#define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */
#define ILL_PRVREG (__SI_FAULT|6) /* privileged register */
#define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */
#define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */
#define NSIGILL 8
 
/*
 * SIGFPE si_codes
 */
#define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */
#define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */
#define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */
#define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */
#define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */
#define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */
#define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */
#define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */
#define NSIGFPE 8
 
/*
 * SIGSEGV si_codes
 */
#define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */
#define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped
object */
#define NSIGSEGV 2
 
/*
 * SIGBUS si_codes
 */
#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */
#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */
#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */
#define NSIGBUS 3
 
/*
 * SIGTRAP si_codes
 */
#define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */
#define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */
#define NSIGTRAP 2
                                  
/*
 * SIGCHLD si_codes
 */
#define CLD_EXITED (__SI_CHLD|1) /* child has exited */
#define CLD_KILLED (__SI_CHLD|2) /* child was killed */
#define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */
#define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */
#define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */
#define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */
#define NSIGCHLD 6
 
/*
 * SIGPOLL si_codes
 */
#define POLL_IN (__SI_POLL|1) /* data input available */
#define POLL_OUT (__SI_POLL|2) /* output buffers available */
#define POLL_MSG (__SI_POLL|3) /* input message available */
#define POLL_ERR (__SI_POLL|4) /* i/o error */
#define POLL_PRI (__SI_POLL|5) /* high priority input available */
#define POLL_HUP (__SI_POLL|6) /* device disconnected */
#define NSIGPOLL 6
                                  

Plus some 60 changes in various C files (arch/*/kernel/signal*.c).

I thought I was being clever in finding the simplest patch. But then again
you decide.

        Robert

-- 
Robert de Vries
rhdv@rhdv.cistron.nl

- 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/



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:25 EST