* [PATCH] Separate siginfo_t for MIPS @ 2015-12-10 10:47 Dmitry Ivanov 2015-12-10 12:36 ` Szabolcs Nagy 0 siblings, 1 reply; 9+ messages in thread From: Dmitry Ivanov @ 2015-12-10 10:47 UTC (permalink / raw) To: musl MIPS has non-default siginfo_t structure. Also, some si_code values are different. This patch is required for POSIX timers to work. --- arch/aarch64/bits/siginfo.h | 0 arch/arm/bits/siginfo.h | 0 arch/i386/bits/siginfo.h | 0 arch/microblaze/bits/siginfo.h | 0 arch/mips/bits/siginfo.h | 52 ++++++++++++++++++++++++++++++++++++++++++ arch/or1k/bits/siginfo.h | 0 arch/powerpc/bits/siginfo.h | 0 arch/sh/bits/siginfo.h | 0 arch/x32/bits/siginfo.h | 0 arch/x86_64/bits/siginfo.h | 0 include/signal.h | 7 ++++++ 11 files changed, 59 insertions(+) create mode 100644 arch/aarch64/bits/siginfo.h create mode 100644 arch/arm/bits/siginfo.h create mode 100644 arch/i386/bits/siginfo.h create mode 100644 arch/microblaze/bits/siginfo.h create mode 100644 arch/mips/bits/siginfo.h create mode 100644 arch/or1k/bits/siginfo.h create mode 100644 arch/powerpc/bits/siginfo.h create mode 100644 arch/sh/bits/siginfo.h create mode 100644 arch/x32/bits/siginfo.h create mode 100644 arch/x86_64/bits/siginfo.h diff --git a/arch/aarch64/bits/siginfo.h b/arch/aarch64/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/arm/bits/siginfo.h b/arch/arm/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/i386/bits/siginfo.h b/arch/i386/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/microblaze/bits/siginfo.h b/arch/microblaze/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/mips/bits/siginfo.h b/arch/mips/bits/siginfo.h new file mode 100644 index 0000000..42dbdf5 --- /dev/null +++ b/arch/mips/bits/siginfo.h @@ -0,0 +1,52 @@ +#define HAVE_ARCH_SIGINFO_T + +#undef SI_ASYNCIO +#undef SI_TIMER +#undef SI_MESGQ +#define SI_ASYNCIO -2 /* sent by AIO completion */ +#define SI_TIMER -3 /* sent by timer expiration */ +#define SI_MESGQ -4 /* sent by real time mesq state change */ + +/* We can't use generic siginfo_t, because our si_code and si_errno are swapped */ +typedef struct { + int si_signo, si_code, si_errno; + union { + char __pad[128 - 2*sizeof(int) - sizeof(long)]; + struct { + union { + struct { + pid_t si_pid; + uid_t si_uid; + } __piduid; + struct { + int si_timerid; + int si_overrun; + } __timer; + } __first; + union { + union sigval si_value; + struct { + int si_status; + clock_t si_utime, si_stime; + } __sigchld; + } __second; + } __si_common; + struct { + void *si_addr; + short si_addr_lsb; + struct { + void *si_lower; + void *si_upper; + } __addr_bnd; + } __sigfault; + struct { + long si_band; + int si_fd; + } __sigpoll; + struct { + void *si_call_addr; + int si_syscall; + unsigned si_arch; + } __sigsys; + } __si_fields; +} siginfo_t; diff --git a/arch/or1k/bits/siginfo.h b/arch/or1k/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/powerpc/bits/siginfo.h b/arch/powerpc/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/sh/bits/siginfo.h b/arch/sh/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/x32/bits/siginfo.h b/arch/x32/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/arch/x86_64/bits/siginfo.h b/arch/x86_64/bits/siginfo.h new file mode 100644 index 0000000..e69de29 diff --git a/include/signal.h b/include/signal.h index 559362f..087657b 100644 --- a/include/signal.h +++ b/include/signal.h @@ -85,6 +85,11 @@ union sigval { void *sival_ptr; }; +#undef HAVE_ARCH_SIGINFO_T + +#include <bits/siginfo.h> + +#ifndef HAVE_ARCH_SIGINFO_T typedef struct { int si_signo, si_errno, si_code; union { @@ -127,6 +132,8 @@ typedef struct { } __sigsys; } __si_fields; } siginfo_t; +#endif + #define si_pid __si_fields.__si_common.__first.__piduid.si_pid #define si_uid __si_fields.__si_common.__first.__piduid.si_uid #define si_status __si_fields.__si_common.__second.__sigchld.si_status -- 2.1.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2015-12-10 10:47 [PATCH] Separate siginfo_t for MIPS 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 0 siblings, 2 replies; 9+ messages in thread From: Szabolcs Nagy @ 2015-12-10 12:36 UTC (permalink / raw) To: musl * 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. > > --- > arch/aarch64/bits/siginfo.h | 0 > arch/arm/bits/siginfo.h | 0 > arch/i386/bits/siginfo.h | 0 > arch/microblaze/bits/siginfo.h | 0 > arch/mips/bits/siginfo.h | 52 ++++++++++++++++++++++++++++++++++++++++++ > arch/or1k/bits/siginfo.h | 0 > arch/powerpc/bits/siginfo.h | 0 > arch/sh/bits/siginfo.h | 0 > arch/x32/bits/siginfo.h | 0 > arch/x86_64/bits/siginfo.h | 0 > include/signal.h | 7 ++++++ > 11 files changed, 59 insertions(+) > create mode 100644 arch/aarch64/bits/siginfo.h > create mode 100644 arch/arm/bits/siginfo.h > create mode 100644 arch/i386/bits/siginfo.h > create mode 100644 arch/microblaze/bits/siginfo.h > create mode 100644 arch/mips/bits/siginfo.h > create mode 100644 arch/or1k/bits/siginfo.h > create mode 100644 arch/powerpc/bits/siginfo.h > create mode 100644 arch/sh/bits/siginfo.h > create mode 100644 arch/x32/bits/siginfo.h > create mode 100644 arch/x86_64/bits/siginfo.h > > diff --git a/arch/aarch64/bits/siginfo.h b/arch/aarch64/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/arm/bits/siginfo.h b/arch/arm/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/i386/bits/siginfo.h b/arch/i386/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/microblaze/bits/siginfo.h b/arch/microblaze/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/mips/bits/siginfo.h b/arch/mips/bits/siginfo.h > new file mode 100644 > index 0000000..42dbdf5 > --- /dev/null > +++ b/arch/mips/bits/siginfo.h > @@ -0,0 +1,52 @@ > +#define HAVE_ARCH_SIGINFO_T > + HAVE_... is not in the reserved namespace of the implementation > +#undef SI_ASYNCIO > +#undef SI_TIMER > +#undef SI_MESGQ > +#define SI_ASYNCIO -2 /* sent by AIO completion */ > +#define SI_TIMER -3 /* sent by timer expiration */ > +#define SI_MESGQ -4 /* sent by real time mesq state change */ > + negative numbers must be parethesized. and musl doesn't use such comments in public headers (they might be copyrightable). > +/* We can't use generic siginfo_t, because our si_code and si_errno are swapped */ > +typedef struct { > + int si_signo, si_code, si_errno; is this reordering the only change? (other than the SI_ macros) the ifdef and empty siginfo.h files are not nice, there are some plans to change bits/* to make this kind of arch specific changes less painful. until then i think it's enough to fix it in signal.h with some dirty ifdef around these members. > + union { > + char __pad[128 - 2*sizeof(int) - sizeof(long)]; > + struct { > + union { > + struct { > + pid_t si_pid; > + uid_t si_uid; > + } __piduid; > + struct { > + int si_timerid; > + int si_overrun; > + } __timer; > + } __first; > + union { > + union sigval si_value; > + struct { > + int si_status; > + clock_t si_utime, si_stime; > + } __sigchld; > + } __second; > + } __si_common; > + struct { > + void *si_addr; > + short si_addr_lsb; > + struct { > + void *si_lower; > + void *si_upper; > + } __addr_bnd; > + } __sigfault; > + struct { > + long si_band; > + int si_fd; > + } __sigpoll; > + struct { > + void *si_call_addr; > + int si_syscall; > + unsigned si_arch; > + } __sigsys; > + } __si_fields; > +} siginfo_t; > diff --git a/arch/or1k/bits/siginfo.h b/arch/or1k/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/powerpc/bits/siginfo.h b/arch/powerpc/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/sh/bits/siginfo.h b/arch/sh/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/x32/bits/siginfo.h b/arch/x32/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/arch/x86_64/bits/siginfo.h b/arch/x86_64/bits/siginfo.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/include/signal.h b/include/signal.h > index 559362f..087657b 100644 > --- a/include/signal.h > +++ b/include/signal.h > @@ -85,6 +85,11 @@ union sigval { > void *sival_ptr; > }; > > +#undef HAVE_ARCH_SIGINFO_T > + > +#include <bits/siginfo.h> > + > +#ifndef HAVE_ARCH_SIGINFO_T > typedef struct { > int si_signo, si_errno, si_code; > union { > @@ -127,6 +132,8 @@ typedef struct { > } __sigsys; > } __si_fields; > } siginfo_t; > +#endif > + ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] Different siginfo_t for MIPS 2015-12-10 12:36 ` Szabolcs Nagy @ 2015-12-10 13:49 ` Dmitry Ivanov 2015-12-16 4:34 ` [PATCH] Separate " Rich Felker 1 sibling, 0 replies; 9+ messages in thread From: Dmitry Ivanov @ 2015-12-10 13:49 UTC (permalink / raw) To: musl Linux for MIPS has different siginfo_t structure. Also, some si_code values are different. This patch is required for POSIX timers to work. --- include/signal.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/signal.h b/include/signal.h index 559362f..c026e23 100644 --- a/include/signal.h +++ b/include/signal.h @@ -36,9 +36,15 @@ extern "C" { #define SI_ASYNCNL (-60) #define SI_TKILL (-6) #define SI_SIGIO (-5) +#ifdef __mips__ +#define SI_ASYNCIO (-2) +#define SI_MESGQ (-4) +#define SI_TIMER (-3) +#else #define SI_ASYNCIO (-4) #define SI_MESGQ (-3) #define SI_TIMER (-2) +#endif #define SI_QUEUE (-1) #define SI_USER 0 #define SI_KERNEL 128 @@ -86,7 +92,11 @@ union sigval { }; typedef struct { +#ifdef __mips__ + 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.1.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2015-12-10 12:36 ` Szabolcs Nagy 2015-12-10 13:49 ` [PATCH v2] Different " Dmitry Ivanov @ 2015-12-16 4:34 ` Rich Felker 2016-01-26 22:24 ` Szabolcs Nagy 1 sibling, 1 reply; 9+ messages in thread From: Rich Felker @ 2015-12-16 4:34 UTC (permalink / raw) To: musl 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. > > > > --- > > arch/aarch64/bits/siginfo.h | 0 > > arch/arm/bits/siginfo.h | 0 > > arch/i386/bits/siginfo.h | 0 > > arch/microblaze/bits/siginfo.h | 0 > > arch/mips/bits/siginfo.h | 52 ++++++++++++++++++++++++++++++++++++++++++ > > arch/or1k/bits/siginfo.h | 0 > > arch/powerpc/bits/siginfo.h | 0 > > arch/sh/bits/siginfo.h | 0 > > arch/x32/bits/siginfo.h | 0 > > arch/x86_64/bits/siginfo.h | 0 > > include/signal.h | 7 ++++++ > > 11 files changed, 59 insertions(+) > > create mode 100644 arch/aarch64/bits/siginfo.h > > create mode 100644 arch/arm/bits/siginfo.h > > create mode 100644 arch/i386/bits/siginfo.h > > create mode 100644 arch/microblaze/bits/siginfo.h > > create mode 100644 arch/mips/bits/siginfo.h > > create mode 100644 arch/or1k/bits/siginfo.h > > create mode 100644 arch/powerpc/bits/siginfo.h > > create mode 100644 arch/sh/bits/siginfo.h > > create mode 100644 arch/x32/bits/siginfo.h > > create mode 100644 arch/x86_64/bits/siginfo.h > > > > diff --git a/arch/aarch64/bits/siginfo.h b/arch/aarch64/bits/siginfo.h > > new file mode 100644 > > index 0000000..e69de29 > > diff --git a/arch/arm/bits/siginfo.h b/arch/arm/bits/siginfo.h > > new file mode 100644 > > index 0000000..e69de29 > > diff --git a/arch/i386/bits/siginfo.h b/arch/i386/bits/siginfo.h > > new file mode 100644 > > index 0000000..e69de29 > > diff --git a/arch/microblaze/bits/siginfo.h b/arch/microblaze/bits/siginfo.h > > new file mode 100644 > > index 0000000..e69de29 > > diff --git a/arch/mips/bits/siginfo.h b/arch/mips/bits/siginfo.h > > new file mode 100644 > > index 0000000..42dbdf5 > > --- /dev/null > > +++ b/arch/mips/bits/siginfo.h > > @@ -0,0 +1,52 @@ > > +#define HAVE_ARCH_SIGINFO_T > > + > > HAVE_... is not in the reserved namespace of the implementation > > > +#undef SI_ASYNCIO > > +#undef SI_TIMER > > +#undef SI_MESGQ > > +#define SI_ASYNCIO -2 /* sent by AIO completion */ > > +#define SI_TIMER -3 /* sent by timer expiration */ > > +#define SI_MESGQ -4 /* sent by real time mesq state change */ > > + > > negative numbers must be parethesized. > > and musl doesn't use such comments in public headers > (they might be copyrightable). > > > +/* We can't use generic siginfo_t, because our si_code and si_errno are swapped */ > > +typedef struct { > > + int si_signo, si_code, si_errno; > > is this reordering the only change? > (other than the SI_ macros) > > the ifdef and empty siginfo.h files are not nice, > there are some plans to change bits/* to make > this kind of arch specific changes less painful. Either way there's no need to add a new bits header. bits/signal.h would be a perfectly good place for this. > until then i think it's enough to fix it in signal.h > with some dirty ifdef around these members. Indeed, I think a makeshift solution could work okay here and avoid moving this large, redundant structure into bits/signal.h. However I'd rather not depend on compiler-predefined macros (like __mips__ in Dmitry's second patch) in public headers, since we don't assume particular compilers for compiling applications. Ideally bits/signal.h would define something in the reserved namespace to change the behavior of the top-level signal.h. However bits/signal.h needs to be towards the bottom of signal.h for other reasons, so I don't see a really clean solution. Ideas? One principle this is suggesting to me for the bits deduplication & refactoring is that perhaps _all_ ABI-level definitions should be in bits/*.h rather than the top-level headers. Although if we go this way, we need a way for bits/%.h to be generated from multiple templates since some parts of a given bits file will be fairly generic while others vary on almost every arch. Rich ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2015-12-16 4:34 ` [PATCH] Separate " Rich Felker @ 2016-01-26 22:24 ` Szabolcs Nagy 2016-01-26 22:57 ` Rich Felker 0 siblings, 1 reply; 9+ messages in thread From: Szabolcs Nagy @ 2016-01-26 22:24 UTC (permalink / raw) To: musl [-- Attachment #1: Type: text/plain, Size: 1099 bytes --] * 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. ... > > until then i think it's enough to fix it in signal.h > > with some dirty ifdef around these members. > > Indeed, I think a makeshift solution could work okay here and avoid > moving this large, redundant structure into bits/signal.h. However I'd > rather not depend on compiler-predefined macros (like __mips__ in > Dmitry's second patch) in public headers, since we don't assume > particular compilers for compiling applications. > > Ideally bits/signal.h would define something in the reserved namespace > to change the behavior of the top-level signal.h. However > bits/signal.h needs to be towards the bottom of signal.h for other > reasons, so I don't see a really clean solution. Ideas? workaround solution attached, only build tested [-- Attachment #2: sig.diff --] [-- Type: text/x-diff, Size: 1183 bytes --] diff --git a/arch/mips/bits/signal.h b/arch/mips/bits/signal.h index 818e0a7..50a0061 100644 --- a/arch/mips/bits/signal.h +++ b/arch/mips/bits/signal.h @@ -73,6 +73,18 @@ 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) + +#undef si_errno +#undef si_code +#define si_errno __si_code +#define si_code __si_errno + #endif #define SIGHUP 1 diff --git a/include/signal.h b/include/signal.h index 559362f..3496942 100644 --- a/include/signal.h +++ b/include/signal.h @@ -86,7 +86,7 @@ union sigval { }; typedef struct { - int si_signo, si_errno, si_code; + int si_signo, __si_errno, __si_code; union { char __pad[128 - 2*sizeof(int) - sizeof(long)]; struct { @@ -127,6 +127,8 @@ typedef struct { } __sigsys; } __si_fields; } siginfo_t; +#define si_errno __si_errno +#define si_code __si_code #define si_pid __si_fields.__si_common.__first.__piduid.si_pid #define si_uid __si_fields.__si_common.__first.__piduid.si_uid #define si_status __si_fields.__si_common.__second.__sigchld.si_status ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2016-01-26 22:24 ` Szabolcs Nagy @ 2016-01-26 22:57 ` Rich Felker 2016-01-26 23:32 ` Szabolcs Nagy 0 siblings, 1 reply; 9+ messages in thread From: Rich Felker @ 2016-01-26 22:57 UTC (permalink / raw) To: musl 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. > .... > > > until then i think it's enough to fix it in signal.h > > > with some dirty ifdef around these members. > > > > Indeed, I think a makeshift solution could work okay here and avoid > > moving this large, redundant structure into bits/signal.h. However I'd > > rather not depend on compiler-predefined macros (like __mips__ in > > Dmitry's second patch) in public headers, since we don't assume > > particular compilers for compiling applications. > > > > Ideally bits/signal.h would define something in the reserved namespace > > to change the behavior of the top-level signal.h. However > > bits/signal.h needs to be towards the bottom of signal.h for other > > reasons, so I don't see a really clean solution. Ideas? > > workaround solution attached, only build tested Why not just: > diff --git a/arch/mips/bits/signal.h b/arch/mips/bits/signal.h > index 818e0a7..50a0061 100644 > --- a/arch/mips/bits/signal.h > +++ b/arch/mips/bits/signal.h > @@ -73,6 +73,18 @@ 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) > + > +#undef si_errno > +#undef si_code > +#define si_errno __si_code > +#define si_code __si_errno #define si_errno si_code #define si_code si_errno > diff --git a/include/signal.h b/include/signal.h > index 559362f..3496942 100644 > --- a/include/signal.h > +++ b/include/signal.h > @@ -86,7 +86,7 @@ union sigval { > }; > > typedef struct { > - int si_signo, si_errno, si_code; > + int si_signo, __si_errno, __si_code; > union { > char __pad[128 - 2*sizeof(int) - sizeof(long)]; > struct { > @@ -127,6 +127,8 @@ typedef struct { > } __sigsys; > } __si_fields; > } siginfo_t; > +#define si_errno __si_errno > +#define si_code __si_code And omit this part entirely? Rich ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2016-01-26 22:57 ` Rich Felker @ 2016-01-26 23:32 ` Szabolcs Nagy 2016-01-27 1:03 ` Szabolcs Nagy 0 siblings, 1 reply; 9+ messages in thread From: Szabolcs Nagy @ 2016-01-26 23:32 UTC (permalink / raw) To: musl * 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. > > .... > > > > until then i think it's enough to fix it in signal.h > > > > with some dirty ifdef around these members. > > > > > > Indeed, I think a makeshift solution could work okay here and avoid > > > moving this large, redundant structure into bits/signal.h. However I'd > > > rather not depend on compiler-predefined macros (like __mips__ in > > > Dmitry's second patch) in public headers, since we don't assume > > > particular compilers for compiling applications. > > > > > > Ideally bits/signal.h would define something in the reserved namespace > > > to change the behavior of the top-level signal.h. However > > > bits/signal.h needs to be towards the bottom of signal.h for other > > > reasons, so I don't see a really clean solution. Ideas? > > > > workaround solution attached, only build tested > > Why not just: > > > diff --git a/arch/mips/bits/signal.h b/arch/mips/bits/signal.h > > index 818e0a7..50a0061 100644 > > --- a/arch/mips/bits/signal.h > > +++ b/arch/mips/bits/signal.h > > @@ -73,6 +73,18 @@ 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) > > + > > +#undef si_errno > > +#undef si_code > > +#define si_errno __si_code > > +#define si_code __si_errno > > #define si_errno si_code > #define si_code si_errno true, that's better ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2016-01-26 23:32 ` Szabolcs Nagy @ 2016-01-27 1:03 ` Szabolcs Nagy 2016-01-27 3:33 ` Rich Felker 0 siblings, 1 reply; 9+ messages in thread From: Szabolcs Nagy @ 2016-01-27 1:03 UTC (permalink / raw) To: musl [-- 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Separate siginfo_t for MIPS 2016-01-27 1:03 ` Szabolcs Nagy @ 2016-01-27 3:33 ` Rich Felker 0 siblings, 0 replies; 9+ messages in thread From: Rich Felker @ 2016-01-27 3:33 UTC (permalink / raw) To: musl On Wed, Jan 27, 2016 at 02:03:57AM +0100, Szabolcs Nagy wrote: > * 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 Thanks! Applied. Rich ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-01-27 3:33 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-12-10 10:47 [PATCH] Separate siginfo_t for MIPS 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 2016-01-27 3:33 ` Rich Felker
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).