From: Tom Hughes Date: Mon, 14 Nov 2005 14:37:02 +0000 (+0000) Subject: Document sign extension of si_code by the kernel. X-Git-Tag: svn/VALGRIND_3_1_0~109 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=204dd5138c34c87a0d8bb4629d12dc65ece81458;p=thirdparty%2Fvalgrind.git Document sign extension of si_code by the kernel. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5123 --- diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index f11269bee4..438262dde7 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -1358,7 +1358,11 @@ void async_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext * /* The linux kernel uses the top 16 bits of si_code for it's own use and only exports the bottom 16 bits to user space - at least that is the theory, but it turns out that there are some kernels - around that forget to mask out the top 16 bits so we do it here. */ + around that forget to mask out the top 16 bits so we do it here. + + The kernel treats the bottom 16 bits as signed and (when it does + mask them off) sign extends them when exporting to user space so + we do the same thing here. */ info->si_code = (Short)info->si_code; #endif @@ -1475,7 +1479,11 @@ void sync_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext *u /* The linux kernel uses the top 16 bits of si_code for it's own use and only exports the bottom 16 bits to user space - at least that is the theory, but it turns out that there are some kernels - around that forget to mask out the top 16 bits so we do it here. */ + around that forget to mask out the top 16 bits so we do it here. + + The kernel treats the bottom 16 bits as signed and (when it does + mask them off) sign extends them when exporting to user space so + we do the same thing here. */ info->si_code = (Short)info->si_code; #endif