[Mono-dev] [RFC] Handle lack of SA_SIGINFO

Paolo Molaro lupus at ximian.com
Mon Mar 22 06:27:19 EDT 2010


On 03/22/10 Andreas Färber wrote:
> SA_SIGINFO and sigaction are part of the optional POSIX XSI feature.
> In mini, there's MONO_ARCH_USE_SIGACTION but it doesn't cover everything
[...]
> +#ifdef SA_SIGINFO
> +	if (save_sigcont.sa_flags & SA_SIGINFO) {
>  	if (save_sigcont.sa_sigaction != NULL &&
>  	    save_sigcont.sa_sigaction != (void *)SIG_DFL &&
>  	    save_sigcont.sa_sigaction != (void *)SIG_IGN)
>  		(*save_sigcont.sa_sigaction) (signo, the_siginfo, data);
> +	} else
> +#else
> +	if (save_sigcont.sa_handler != NULL &&
> +	    save_sigcont.sa_handler != (void *)SIG_DFL &&
> +	    save_sigcont.sa_handler != (void *)SIG_IGN)
> +		(*save_sigcont.sa_handler) (signo);
> +#endif
>  }

These kind of changes are quite ugly. Please introduce a cpp macro
that handles this stuff, so that the code doesn't become a forest of
#ifdefs.
Something like:
#define INVOKE_SIGHANDLER_IF_VALID (siga,signo,sinfo,data)	do {\
	if (((siga)->sa_flags & SA_SIGINFO) && (siga)->sa_sigaction != NULL && ...)	\
		(siga)->sa_sigaction ((signo), (sinfo), (data));	\
	} while (0)
and the equialent for the non-SA_SIGINFO case.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better


More information about the Mono-devel-list mailing list