[parisc-linux] Re: gcc-3.2 -> gcc-3.3 transition on hppa

John David Anglin dave@hiauly1.hia.nrc.ca
Thu, 20 Mar 2003 13:13:49 -0500 (EST)


> >> 
> >> these are definitely kernel addresses....
> >
> >Right.  I see the code that's causing the problem in kernel/signal.c:
> >
> >                if (k->sa.sa_handler == SIG_IGN
> >		    || (k->sa.sa_handler == SIG_DFL
> >
> >
> >You don't want to canonicalize k->sa.sa_handler here, so a cast to
> >void * or something is needed.  The PA is the only port that I am
> >aware of that needs to canonicalize function pointers.
> >
> Well I try to test some:
> --- signal.h.orig       2003-03-20 15:12:24.000000000 +0100
> +++ signal.h    2003-03-20 15:11:47.000000000 +0100
> @@ -106,9 +106,15 @@
>  #define SIG_UNBLOCK        1   /* for unblocking signals */
>  #define SIG_SETMASK        2   /* for setting the signal mask */
>  
> +#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
> +#define SIG_DFL        (0)                     /* default signal handling
> */
> +#define SIG_IGN        (1)                     /* ignore signal */
> +#define SIG_ERR        (-1)                    /* error return from signal
> */
> +#else
>  #define SIG_DFL        ((__sighandler_t)0)     /* default signal handling
> */
>  #define SIG_IGN        ((__sighandler_t)1)     /* ignore signal */
>  #define SIG_ERR        ((__sighandler_t)-1)    /* error return from signal
> */
> +#endif

No, don't do that.  SIG_DFL, SIG_IGN and SIG_ERR expand to compound
literals.  Look at the assembly output from the following little
program (gcc -S) with and without the "void *" cast.

typedef int (*__sighandler_t)(void);
#define SIG_IGN        ((__sighandler_t)1)
int foo (__sighandler_t g)
{
  return g == (void *)SIG_IGN;
}

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)