|
From: David G. <dga...@gm...> - 2018-04-19 08:10:41
|
Hi Thorsten, I did some research about this, below what I've found out.
2018-04-07 16:25 GMT+02:00 Thorsten Otto <ad...@th...>:
> While experimenting with some code, i noticed that our struct ucontext in sys/
> ucontext_h is similar, but not identical to the one from linux/m68k.
>
> The main differences are that, in the general registers, R_PC/R_PS (i think
> that should be the status register?) are reversed, the sigmask is at a
> different location (maybe because on linux a complete set it is more than just
> a long), and the layout of the floating point register set is different. Would
> it be a problem to reorder them? That could make porting some software much
> easier. As far as i can tell, although that structure is defined, it is
> nowhere used: {get,set,make,swap}context are not implemented, and SA_SIGINFO
> isn't either.
>
I've seen that sigmask is in a different position only in Linux-m68k
kernel headers files, but in glibc and NetBSD
is in the same location than in MiNTlib:
glibc:
/* Userlevel context. */
typedef struct ucontext_t
{
unsigned long int __ctx(uc_flags);
struct ucontext_t *uc_link;
sigset_t uc_sigmask;
stack_t uc_stack;
mcontext_t uc_mcontext;
long int __glibc_reserved1[201];
} ucontext_t;
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/m68k/sys/ucontext.h;h=14232d268ae7147239bfb7c4c9681036240e8d0b;hb=f55a4fdefb00837f2e2a77c04792e69e888ead3e#l112
NetBSD:
typedef struct __ucontext ucontext_t;
struct __ucontext {
unsigned int uc_flags; /* properties */
ucontext_t * uc_link; /* context to resume */
sigset_t uc_sigmask; /* signals blocked in this context */
stack_t uc_stack; /* the stack used by this context */
mcontext_t uc_mcontext; /* machine state */
#if defined(_UC_MACHINE_PAD)
long __uc_pad[_UC_MACHINE_PAD];
#endif
};
https://github.com/NetBSD/src/blob/4a985cb82ed80063a586ae42790a829e2ec7a59b/sys/sys/ucontext.h#L38
My guess is that portable software is using glibc instead the Linux
kernel headers file.
So I wouldn't change anything regarding the sigmask position in the
ucontext struct.
The PC and PS registers are switched in MiNTlib in relation with glibc
and NetBSD,
also fpregset differs in MiNTlib from glibc and NetBSD but I've found
this in the GNU C lib documentation:
"mcontext_t uc_mcontext
This element contains the actual state of the process. The mcontext_t
type is also defined in this header but
the definition should be treated as opaque. Any use of knowledge of
the type makes applications less portable."
http://www.gnu.org/software/libc/manual/html_node/System-V-contexts.html
So I think I wouldn't change anything. Do you have in mind an example
of a possible situation where having the registers
in different positions in the struct would affect portability.
By the way as a curiosity during my research I've read that all these
things are deprecated in the POSIX specification:
"POSIX.1-2004 obsoleted these functions, and in POSIX.1-2008 they were
removed, with POSIX Threads indicated as a possible replacement"
|