From e9862e9b9eaa16ac487faba90c35e496fd9c9eda Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 9 Nov 2011 18:25:50 +0000 Subject: [PATCH] Attempt to improve formatting and content of several comments for amd64 and i386 MD code. Based on suggestions by: bde MFC after: 1 week --- sys/amd64/amd64/trap.c | 6 +++--- sys/amd64/include/signal.h | 14 +++++--------- sys/amd64/include/ucontext.h | 11 ++++++----- sys/i386/i386/trap.c | 5 ++--- sys/i386/include/signal.h | 15 ++++++++------- sys/i386/include/ucontext.h | 6 +++--- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index c5f0a71eef25..16b9c1a1f63b 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -900,9 +900,9 @@ cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa) #include "../../kern/subr_syscall.c" /* - * syscall - system call request C handler - * - * A system call is essentially treated as a trap. + * System call handler for native binaries. The trap frame is already + * set up by the assembler trampoline and a pointer to it is saved in + * td_frame. */ void amd64_syscall(struct thread *td, int traced) diff --git a/sys/amd64/include/signal.h b/sys/amd64/include/signal.h index 228e2d924bd1..0374339ab64b 100644 --- a/sys/amd64/include/signal.h +++ b/sys/amd64/include/signal.h @@ -46,19 +46,15 @@ typedef long sig_atomic_t; #if __BSD_VISIBLE #include /* codes for SIGILL, SIGFPE */ -/* - * Only the kernel should need these old type definitions. - */ /* * Information pushed on stack when a signal is delivered. * This is used by the kernel to restore state following * execution of the signal handler. It is also made available * to the handler to allow it to restore state properly if * a non-standard exit is performed. - */ -/* - * The sequence of the fields/registers in struct sigcontext should match - * those in mcontext_t. + * + * The sequence of the fields/registers after sc_mask in struct + * sigcontext must match those in mcontext_t and struct trapframe. */ struct sigcontext { struct __sigset sc_mask; /* signal mask to restore */ @@ -93,8 +89,8 @@ struct sigcontext { long sc_ss; long sc_len; /* sizeof(mcontext_t) */ /* - * XXX - See and for - * the following fields. + * See and for the following + * fields. */ long sc_fpformat; long sc_ownedfp; diff --git a/sys/amd64/include/ucontext.h b/sys/amd64/include/ucontext.h index c5bbd65b5a30..75b7bd2c0b32 100644 --- a/sys/amd64/include/ucontext.h +++ b/sys/amd64/include/ucontext.h @@ -41,12 +41,13 @@ typedef struct __mcontext { /* - * The first 24 fields must match the definition of - * sigcontext. So that we can support sigcontext - * and ucontext_t at the same time. + * The definition of mcontext_t must match the layout of + * struct sigcontext after the sc_mask member. This is so + * that we can support sigcontext and ucontext_t at the same + * time. */ - __register_t mc_onstack; /* XXX - sigcontext compat. */ - __register_t mc_rdi; /* machine state (struct trapframe) */ + __register_t mc_onstack; /* XXX - sigcontext compat. */ + __register_t mc_rdi; /* machine state (struct trapframe) */ __register_t mc_rsi; __register_t mc_rdx; __register_t mc_rcx; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index b241757e74ae..6e7f1d900473 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -1065,9 +1065,8 @@ cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa) #include "../../kern/subr_syscall.c" /* - * syscall - system call request C handler - * - * A system call is essentially treated as a trap. + * syscall - system call request C handler. A system call is + * essentially treated as a trap by reusing the frame layout. */ void syscall(struct trapframe *frame) diff --git a/sys/i386/include/signal.h b/sys/i386/include/signal.h index 7a5f87670e56..c636c2c6884a 100644 --- a/sys/i386/include/signal.h +++ b/sys/i386/include/signal.h @@ -45,10 +45,6 @@ typedef int sig_atomic_t; #if __BSD_VISIBLE #include /* codes for SIGILL, SIGFPE */ -/* - * Only the kernel should need these old type definitions. - */ -#if defined(_KERNEL) && defined(COMPAT_43) /* * Information pushed on stack when a signal is delivered. * This is used by the kernel to restore state following @@ -56,6 +52,11 @@ typedef int sig_atomic_t; * to the handler to allow it to restore state properly if * a non-standard exit is performed. */ + +#if defined(_KERNEL) && defined(COMPAT_43) +/* + * Only the kernel should need these old type definitions. + */ struct osigcontext { int sc_onstack; /* sigstack state to restore */ osigset_t sc_mask; /* signal mask to restore */ @@ -83,7 +84,7 @@ struct osigcontext { /* * The sequence of the fields/registers in struct sigcontext should match - * those in mcontext_t. + * those in mcontext_t and struct trapframe. */ struct sigcontext { struct __sigset sc_mask; /* signal mask to restore */ @@ -109,8 +110,8 @@ struct sigcontext { int sc_ss; int sc_len; /* sizeof(mcontext_t) */ /* - * XXX - See and for - * the following fields. + * See and for + * the following fields. */ int sc_fpformat; int sc_ownedfp; diff --git a/sys/i386/include/ucontext.h b/sys/i386/include/ucontext.h index d8657d3e6f6d..d9f8344b898a 100644 --- a/sys/i386/include/ucontext.h +++ b/sys/i386/include/ucontext.h @@ -33,9 +33,9 @@ typedef struct __mcontext { /* - * The first 20 fields must match the definition of - * sigcontext. So that we can support sigcontext - * and ucontext_t at the same time. + * The definition of mcontext_t shall match the layout of + * struct sigcontext after the sc_mask member. So that we can + * support sigcontext and ucontext_t at the same time. */ __register_t mc_onstack; /* XXX - sigcontext compat. */ __register_t mc_gs; /* machine state (struct trapframe) */