Date: Fri, 12 Feb 2016 13:22:04 +0000 From: Ruslan Bukin <br@bsdpad.com> To: Konstantin Belousov <kib@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r295561 - in head: include sys/mips/include sys/powerpc/include sys/sparc64/include sys/sys sys/x86/include Message-ID: <20160212132204.GA33648@bsdpad.com> In-Reply-To: <201602120738.u1C7cKpq093956@repo.freebsd.org> References: <201602120738.u1C7cKpq093956@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On RISC-V it fails with __uint128_t: struct fpregs { __uint128_t fp_x[32]; how to fix? Ruslan On Fri, Feb 12, 2016 at 07:38:20AM +0000, Konstantin Belousov wrote: > Author: kib > Date: Fri Feb 12 07:38:19 2016 > New Revision: 295561 > URL: https://svnweb.freebsd.org/changeset/base/295561 > > Log: > POSIX states that #include <signal.h> shall make both mcontext_t and > ucontext_t available. Our code even has XXX comment about this. > > Add a bit of compliance by moving struct __ucontext definition into > sys/_ucontext.h and including it into signal.h and sys/ucontext.h. > > Several machine/ucontext.h headers were changed to use namespace-safe > types (like uint64_t->__uint64_t) to not depend on sys/types.h. > struct __stack_t from sys/signal.h is made always visible in private > namespace to satisfy sys/_ucontext.h requirements. > > Apparently mips _types.h pollutes global namespace with f_register_t > type definition. This commit does not try to fix the issue. > > PR: 207079 > Reported and tested by: Ting-Wei Lan <lantw44@gmail.com> > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > > Added: > head/sys/sys/_ucontext.h > - copied, changed from r295560, head/sys/sys/ucontext.h > Modified: > head/include/signal.h > head/sys/mips/include/ucontext.h > head/sys/powerpc/include/ucontext.h > head/sys/sparc64/include/ucontext.h > head/sys/sys/signal.h > head/sys/sys/ucontext.h > head/sys/x86/include/ucontext.h > > Modified: head/include/signal.h > ============================================================================== > --- head/include/signal.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/include/signal.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -36,6 +36,8 @@ > #include <sys/cdefs.h> > #include <sys/_types.h> > #include <sys/signal.h> > +#include <machine/ucontext.h> > +#include <sys/_ucontext.h> > > #if __BSD_VISIBLE > /* > @@ -114,7 +116,6 @@ void psignal(unsigned int, const char *) > > #if __BSD_VISIBLE > int sigblock(int); > -struct __ucontext; /* XXX spec requires a complete declaration. */ > int sigreturn(const struct __ucontext *); > int sigsetmask(int); > int sigstack(const struct sigstack *, struct sigstack *); > > Modified: head/sys/mips/include/ucontext.h > ============================================================================== > --- head/sys/mips/include/ucontext.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/sys/mips/include/ucontext.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -50,13 +50,13 @@ typedef struct __mcontext { > * struct sigcontext and ucontext_t at the same time. > */ > int mc_onstack; /* sigstack state to restore */ > - register_t mc_pc; /* pc at time of signal */ > - register_t mc_regs[32]; /* processor regs 0 to 31 */ > - register_t sr; /* status register */ > - register_t mullo, mulhi; /* mullo and mulhi registers... */ > + __register_t mc_pc; /* pc at time of signal */ > + __register_t mc_regs[32]; /* processor regs 0 to 31 */ > + __register_t sr; /* status register */ > + __register_t mullo, mulhi; /* mullo and mulhi registers... */ > int mc_fpused; /* fp has been used */ > f_register_t mc_fpregs[33]; /* fp regs 0 to 31 and csr */ > - register_t mc_fpc_eir; /* fp exception instruction reg */ > + __register_t mc_fpc_eir; /* fp exception instruction reg */ > void *mc_tls; /* pointer to TLS area */ > int __spare__[8]; /* XXX reserved */ > } mcontext_t; > > Modified: head/sys/powerpc/include/ucontext.h > ============================================================================== > --- head/sys/powerpc/include/ucontext.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/sys/powerpc/include/ucontext.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -42,11 +42,11 @@ typedef struct __mcontext { > #define _MC_AV_VALID 0x02 > int mc_onstack; /* saved onstack flag */ > int mc_len; /* sizeof(__mcontext) */ > - uint64_t mc_avec[32*2]; /* vector register file */ > - uint32_t mc_av[2]; > - register_t mc_frame[42]; > - uint64_t mc_fpreg[33]; > - uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ > + __uint64_t mc_avec[32*2]; /* vector register file */ > + __uint32_t mc_av[2]; > + __register_t mc_frame[42]; > + __uint64_t mc_fpreg[33]; > + __uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ > } mcontext_t __aligned(16); > > #if defined(_KERNEL) && defined(__powerpc64__) > > Modified: head/sys/sparc64/include/ucontext.h > ============================================================================== > --- head/sys/sparc64/include/ucontext.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/sys/sparc64/include/ucontext.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -33,11 +33,11 @@ > #define _MACHINE_UCONTEXT_H_ > > struct __mcontext { > - uint64_t mc_global[8]; > - uint64_t mc_out[8]; > - uint64_t mc_local[8]; > - uint64_t mc_in[8]; > - uint32_t mc_fp[64]; > + __uint64_t mc_global[8]; > + __uint64_t mc_out[8]; > + __uint64_t mc_local[8]; > + __uint64_t mc_in[8]; > + __uint32_t mc_fp[64]; > } __aligned(64); > > typedef struct __mcontext mcontext_t; > > Copied and modified: head/sys/sys/_ucontext.h (from r295560, head/sys/sys/ucontext.h) > ============================================================================== > --- head/sys/sys/ucontext.h Fri Feb 12 07:27:24 2016 (r295560, copy source) > +++ head/sys/sys/_ucontext.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -28,11 +28,8 @@ > * $FreeBSD$ > */ > > -#ifndef _SYS_UCONTEXT_H_ > -#define _SYS_UCONTEXT_H_ > - > -#include <sys/signal.h> > -#include <machine/ucontext.h> > +#ifndef _SYS__UCONTEXT_H_ > +#define _SYS__UCONTEXT_H_ > > typedef struct __ucontext { > /* > @@ -43,64 +40,13 @@ typedef struct __ucontext { > * support them both at the same time. > * note: the union is not defined, though. > */ > - sigset_t uc_sigmask; > + __sigset_t uc_sigmask; > mcontext_t uc_mcontext; > > struct __ucontext *uc_link; > - stack_t uc_stack; > + struct __stack_t uc_stack; > int uc_flags; > -#define UCF_SWAPPED 0x00000001 /* Used by swapcontext(3). */ > int __spare__[4]; > } ucontext_t; > > -#if defined(_KERNEL) && defined(COMPAT_FREEBSD4) > -#if defined(__i386__) > -struct ucontext4 { > - sigset_t uc_sigmask; > - struct mcontext4 uc_mcontext; > - struct ucontext4 *uc_link; > - stack_t uc_stack; > - int __spare__[8]; > -}; > -#else /* __i386__ */ > -#define ucontext4 ucontext > -#endif /* __i386__ */ > -#endif /* _KERNEL */ > - > -#ifndef _KERNEL > - > -__BEGIN_DECLS > - > -int getcontext(ucontext_t *) __returns_twice; > -ucontext_t *getcontextx(void); > -int setcontext(const ucontext_t *); > -void makecontext(ucontext_t *, void (*)(void), int, ...); > -int signalcontext(ucontext_t *, int, __sighandler_t *); > -int swapcontext(ucontext_t *, const ucontext_t *); > - > -#if __BSD_VISIBLE > -int __getcontextx_size(void); > -int __fillcontextx(char *ctx) __returns_twice; > -int __fillcontextx2(char *ctx); > -#endif > - > -__END_DECLS > - > -#else /* _KERNEL */ > - > -struct thread; > - > -/* > - * Flags for get_mcontext(). The low order 4 bits (i.e a mask of 0x0f) are > - * reserved for use by machine independent code. All other bits are for use > - * by machine dependent code. > - */ > -#define GET_MC_CLEAR_RET 1 > - > -/* Machine-dependent functions: */ > -int get_mcontext(struct thread *, mcontext_t *, int); > -int set_mcontext(struct thread *, mcontext_t *); > - > -#endif /* !_KERNEL */ > - > -#endif /* !_SYS_UCONTEXT_H_ */ > +#endif /* _SYS__UCONTEXT_H */ > > Modified: head/sys/sys/signal.h > ============================================================================== > --- head/sys/sys/signal.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/sys/sys/signal.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -354,18 +354,10 @@ typedef void __siginfohandler_t(int, str > #endif > > #if __XSI_VISIBLE > -/* > - * Structure used in sigaltstack call. > - */ > #if __BSD_VISIBLE > -typedef struct sigaltstack { > -#else > -typedef struct { > +#define __stack_t sigaltstack > #endif > - void *ss_sp; /* signal stack base */ > - __size_t ss_size; /* signal stack length */ > - int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ > -} stack_t; > +typedef struct __stack_t stack_t; > > #define SS_ONSTACK 0x0001 /* take signal on alternate stack */ > #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ > @@ -373,6 +365,17 @@ typedef struct { > #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ > #endif > > +/* > + * Structure used in sigaltstack call. Its definition is always > + * needed for __ucontext. If __BSD_VISIBLE is defined, the structure > + * tag is actually sigaltstack. > + */ > +struct __stack_t { > + void *ss_sp; /* signal stack base */ > + __size_t ss_size; /* signal stack length */ > + int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ > +}; > + > #if __BSD_VISIBLE > /* > * 4.3 compatibility: > > Modified: head/sys/sys/ucontext.h > ============================================================================== > --- head/sys/sys/ucontext.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/sys/sys/ucontext.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -33,25 +33,9 @@ > > #include <sys/signal.h> > #include <machine/ucontext.h> > +#include <sys/_ucontext.h> > > -typedef struct __ucontext { > - /* > - * Keep the order of the first two fields. Also, > - * keep them the first two fields in the structure. > - * This way we can have a union with struct > - * sigcontext and ucontext_t. This allows us to > - * support them both at the same time. > - * note: the union is not defined, though. > - */ > - sigset_t uc_sigmask; > - mcontext_t uc_mcontext; > - > - struct __ucontext *uc_link; > - stack_t uc_stack; > - int uc_flags; > #define UCF_SWAPPED 0x00000001 /* Used by swapcontext(3). */ > - int __spare__[4]; > -} ucontext_t; > > #if defined(_KERNEL) && defined(COMPAT_FREEBSD4) > #if defined(__i386__) > > Modified: head/sys/x86/include/ucontext.h > ============================================================================== > --- head/sys/x86/include/ucontext.h Fri Feb 12 07:27:24 2016 (r295560) > +++ head/sys/x86/include/ucontext.h Fri Feb 12 07:38:19 2016 (r295561) > @@ -162,4 +162,9 @@ typedef struct __mcontext { > } mcontext_t; > #endif /* __amd64__ */ > > +#ifdef __LINT__ > +typedef struct __mcontext { > +} mcontext_t; > +#endif /* __LINT__ */ > + > #endif /* !_X86_UCONTEXT_H_ */ >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160212132204.GA33648>