align <sys/ucontext.h> <sys/uio.h> <sys/un.h>

Change-Id: I70adf01fddf931a3a6931083adaa4bbe647ea6a3
This commit is contained in:
Ben Gras
2013-12-10 09:57:38 +01:00
committed by Lionel Sambuc
parent 01624e6f86
commit 17587738d3
15 changed files with 274 additions and 85 deletions

View File

@@ -7,18 +7,6 @@ IMPORT(setuctx)
IMPORT(resumecontext)
/* MCF_MAGIC value from <mcontext.h> */
#define MCF_MAGIC 0xc0ffee
/* Values from <sys/ucontext.h> */
#define UCF_IGNFPU 0x002
#define UCF_IGNSIGM 0x004
/* EINVAL from errno.h */
#define EFAULT 14
#define EINVAL 22
/* int getcontext(ucontext_t *ucp)
* Initialise the structure pointed to by ucp to the current user context
* of the calling thread. */
@@ -45,9 +33,9 @@ ENTRY(getcontext)
3: /* Check flags */
ldr r1, [r0, #UC_FLAGS] /* r1 = ucp->uc_flags */
mov r2, #(UCF_IGNFPU | UCF_IGNSIGM)
cmp r1, r2 /* is UCF_IGNFPU or UCF_IGNSIGM set? */
beq 1f /* Both are set, skip getuctx */
and r1, r1, #[_UC_IGNFPU|_UC_IGNSIGM]
cmp r1, #[_UC_IGNFPU|_UC_IGNSIGM] /* Allowed to ignore both? */
beq 1f /* If so, skip getuctx */
0:
push {r0, r3}
@@ -116,9 +104,9 @@ ENTRY(setcontext)
4: ldr r1, [r0, #UC_FLAGS] /* r1 = ucp->uc_flags */
mov r2, #(UCF_IGNFPU | UCF_IGNSIGM)
cmp r1, r2 /* Are UCF_IGNFPU and UCF_IGNSIGM flags set? */
beq 1f /* Both are set, so don't bother restoring FPU
and r1, r1, #[_UC_IGNFPU|_UC_IGNSIGM]
cmp r1, #[_UC_IGNFPU|_UC_IGNSIGM] /* Allowed to ignore both? */
beq 1f /* Neither are set, so don't bother restoring FPU
* state and signal mask */
push {r0, r3}

View File

@@ -1,6 +1,8 @@
include <minix/type.h>
include <sys/ucontext.h>
include <sys/errno.h>
include <machine/mcontext.h>
struct __ucontext
member UC_FLAGS uc_flags
@@ -22,4 +24,8 @@ member REG12 uc_mcontext.mc_p_reg.r12
member SPREG uc_mcontext.mc_p_reg.sp
member LRREG uc_mcontext.mc_p_reg.lr
member PCREG uc_mcontext.mc_p_reg.pc
define EFAULT EFAULT
define EINVAL EINVAL
define MCF_MAGIC MCF_MAGIC
define _UC_IGNFPU _UC_IGNFPU
define _UC_IGNSIGM _UC_IGNSIGM

View File

@@ -7,19 +7,6 @@ IMPORT(resumecontext)
.globl _C_LABEL(__errno)
/* MCF_MAGIC value from <mcontext.h> */
#define MCF_MAGIC 0xc0ffee
/* Values from <sys/ucontext.h> */
#define UCF_IGNFPU 0x002
#define UCF_IGNSIGM 0x004
/* EINVAL from errno.h */
#define EFAULT 14
#define EINVAL 22
/* int getcontext(ucontext_t *ucp)
* Initialise the structure pointed to by ucp to the current user context
* of the calling thread. */
@@ -42,8 +29,9 @@ ENTRY(getcontext)
3: /* Check flags */
mov UC_FLAGS(%edx), %eax /* eax = ucp->uc_flags */
xor $[UCF_IGNFPU|UCF_IGNSIGM], %eax /* toggle both flags */
jz 5f /* Both were set, skip getuctx */
and $[_UC_IGNFPU|_UC_IGNSIGM], %eax
cmp $[_UC_IGNFPU|_UC_IGNSIGM], %eax
jz 5f /* Ignore both, skip getuctx */
PIC_PROLOGUE
push %edx
call PIC_PLT(_C_LABEL(getuctx)) /* getuctx(ucp) */
@@ -101,8 +89,9 @@ ENTRY(setcontext)
4: mov UC_FLAGS(%edx), %eax /* eax = ucp->uc_flags */
xor $[UCF_IGNFPU|UCF_IGNSIGM], %eax /* toggle both flags */
jz 5f /* Both are set, so don't bother restoring FPU
and $[_UC_IGNFPU|_UC_IGNSIGM], %eax
cmp $[_UC_IGNFPU|_UC_IGNSIGM], %eax
jz 5f /* Ignore both, so don't bother restoring FPU
* state and signal mask */
PIC_PROLOGUE

View File

@@ -1,6 +1,8 @@
include <minix/type.h>
include <sys/ucontext.h>
include <sys/errno.h>
include <machine/mcontext.h>
struct __ucontext
member UC_FLAGS uc_flags
@@ -15,4 +17,8 @@ member CX uc_mcontext.mc_p_reg.cx
member DX uc_mcontext.mc_p_reg.dx
member PC uc_mcontext.mc_p_reg.pc
member SP uc_mcontext.mc_p_reg.sp
define EFAULT EFAULT
define EINVAL EINVAL
define MCF_MAGIC MCF_MAGIC
define _UC_IGNFPU _UC_IGNFPU
define _UC_IGNSIGM _UC_IGNSIGM

View File

@@ -25,13 +25,13 @@ int setuctx(const ucontext_t *ucp)
return(-1);
}
if (!(ucp->uc_flags & UCF_IGNSIGM)) {
if (!(ucp->uc_flags & _UC_IGNSIGM)) {
/* Set signal mask */
if ((r = sigprocmask(SIG_SETMASK, &ucp->uc_sigmask, NULL)) == -1)
return(r);
}
if (!(ucp->uc_flags & UCF_IGNFPU)) {
if (!(ucp->uc_flags & _UC_IGNFPU)) {
if ((r = setmcontext(&(ucp->uc_mcontext))) == -1)
return(r);
}
@@ -52,13 +52,13 @@ int getuctx(ucontext_t *ucp)
return(-1);
}
if (!(ucp->uc_flags & UCF_IGNSIGM)) {
if (!(ucp->uc_flags & _UC_IGNSIGM)) {
/* Get signal mask */
if ((r = sigprocmask(0, NULL, &ucp->uc_sigmask)) == -1)
return(r);
}
if (!(ucp->uc_flags & UCF_IGNFPU)) {
if (!(ucp->uc_flags & _UC_IGNFPU)) {
if ((r = getmcontext(&(ucp->uc_mcontext))) != 0)
return(r);
}
@@ -232,10 +232,10 @@ int swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
return(-1);
}
oucp->uc_flags &= ~UCF_SWAPPED;
oucp->uc_flags &= ~_UC_SWAPPED;
r = getcontext(oucp);
if ((r == 0) && !(oucp->uc_flags & UCF_SWAPPED)) {
oucp->uc_flags |= UCF_SWAPPED;
if ((r == 0) && !(oucp->uc_flags & _UC_SWAPPED)) {
oucp->uc_flags |= _UC_SWAPPED;
r = setcontext(ucp);
}

View File

@@ -4,6 +4,9 @@
#undef NDEBUG
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/ioc_net.h>
#include <sys/socket.h>

View File

@@ -20,7 +20,7 @@ ucontext_t *ctx;
/* We're not interested in FPU state nor signals, so ignore them.
* Coincidentally, this significantly speeds up performance.
*/
ctx->uc_flags |= (UCF_IGNFPU | UCF_IGNSIGM);
ctx->uc_flags |= _UC_IGNSIGM | _UC_IGNFPU;
return getcontext(ctx);
}