mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Separate siginfo_t for MIPS
Date: Wed, 27 Jan 2016 02:03:57 +0100	[thread overview]
Message-ID: <20160127010356.GP9621@port70.net> (raw)
In-Reply-To: <20160126233231.GO9621@port70.net>

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

* Szabolcs Nagy <nsz@port70.net> [2016-01-27 00:32:32 +0100]:
> * Rich Felker <dalias@libc.org> [2016-01-26 17:57:57 -0500]:
> > On Tue, Jan 26, 2016 at 11:24:54PM +0100, Szabolcs Nagy wrote:
> > > * Rich Felker <dalias@libc.org> [2015-12-15 23:34:28 -0500]:
> > > > On Thu, Dec 10, 2015 at 01:36:33PM +0100, Szabolcs Nagy wrote:
> > > > > * Dmitry Ivanov <dmitrijs.ivanovs@ubnt.com> [2015-12-10 12:47:12 +0200]:
> > > > > > MIPS has non-default siginfo_t structure. Also, some si_code values are
> > > > > > different. This patch is required for POSIX timers to work.
> > > ....
> > 
> > #define si_errno si_code
> > #define si_code  si_errno

instead of such confusing hack reorder the bits inclusion in signal.h


[-- Attachment #2: 0001-move-bits-signal.h-include-close-to-the-top-of-signa.patch --]
[-- Type: text/x-diff, Size: 1698 bytes --]

From 680ee704efddb07f1b79e92f1dbf25b25f6fdc70 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Wed, 27 Jan 2016 00:40:32 +0000
Subject: [PATCH 1/2] move bits/signal.h include close to the top of signal.h

only have code above the bits/signal.h include that is necessary.
(some types are used for the ucontext struct and mips has to
override a few macro definitions)

this way mips bits/signal.h will be able to affect siginfo_t.
---
 include/signal.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/signal.h b/include/signal.h
index 559362f..8df725d 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -27,8 +27,6 @@ extern "C" {
 
 #include <bits/alltypes.h>
 
-#define SIG_HOLD ((void (*)(int)) 2)
-
 #define SIG_BLOCK     0
 #define SIG_UNBLOCK   1
 #define SIG_SETMASK   2
@@ -43,6 +41,18 @@ extern "C" {
 #define SI_USER 0
 #define SI_KERNEL 128
 
+typedef struct sigaltstack stack_t;
+
+#endif
+
+#include <bits/signal.h>
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+
+#define SIG_HOLD ((void (*)(int)) 2)
+
 #define FPE_INTDIV 1
 #define FPE_INTOVF 2
 #define FPE_FLTDIV 3
@@ -78,8 +88,6 @@ extern "C" {
 #define CLD_STOPPED 5
 #define CLD_CONTINUED 6
 
-typedef struct sigaltstack stack_t;
-
 union sigval {
 	int sival_int;
 	void *sival_ptr;
@@ -240,8 +248,6 @@ int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
 #define SA_ONESHOT SA_RESETHAND
 #endif
 
-#include <bits/signal.h>
-
 #define SIG_ERR  ((void (*)(int))-1)
 #define SIG_DFL  ((void (*)(int)) 0)
 #define SIG_IGN  ((void (*)(int)) 1)
-- 
2.7.0


[-- Attachment #3: 0002-fix-siginfo_t-for-mips.patch --]
[-- Type: text/x-diff, Size: 1322 bytes --]

From 3365723da2b4aa3f82f101f63649b3c03ee1898c Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Wed, 27 Jan 2016 00:54:25 +0000
Subject: [PATCH 2/2] fix siginfo_t for mips

si_errno and si_code are swapped in mips siginfo_t compared to other
archs and some si_code values are different.  This fix is required
for POSIX timers to work.

based on patch by Dmitry Ivanov.
---
 arch/mips/bits/signal.h | 9 +++++++++
 include/signal.h        | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/arch/mips/bits/signal.h b/arch/mips/bits/signal.h
index 818e0a7..889f77e 100644
--- a/arch/mips/bits/signal.h
+++ b/arch/mips/bits/signal.h
@@ -73,6 +73,15 @@ typedef struct __ucontext {
 #define SIG_UNBLOCK   2
 #define SIG_SETMASK   3
 
+#undef SI_ASYNCIO
+#undef SI_MESGQ
+#undef SI_TIMER
+#define SI_ASYNCIO (-2)
+#define SI_MESGQ (-4)
+#define SI_TIMER (-3)
+
+#define __SI_SWAP_ERRNO_CODE
+
 #endif
 
 #define SIGHUP    1
diff --git a/include/signal.h b/include/signal.h
index 8df725d..c6323c6 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -94,7 +94,11 @@ union sigval {
 };
 
 typedef struct {
+#ifdef __SI_SWAP_ERRNO_CODE
+	int si_signo, si_code, si_errno;
+#else
 	int si_signo, si_errno, si_code;
+#endif
 	union {
 		char __pad[128 - 2*sizeof(int) - sizeof(long)];
 		struct {
-- 
2.7.0


  reply	other threads:[~2016-01-27  1:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 10:47 Dmitry Ivanov
2015-12-10 12:36 ` Szabolcs Nagy
2015-12-10 13:49   ` [PATCH v2] Different " Dmitry Ivanov
2015-12-16  4:34   ` [PATCH] Separate " Rich Felker
2016-01-26 22:24     ` Szabolcs Nagy
2016-01-26 22:57       ` Rich Felker
2016-01-26 23:32         ` Szabolcs Nagy
2016-01-27  1:03           ` Szabolcs Nagy [this message]
2016-01-27  3:33             ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160127010356.GP9621@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).