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

@@ -40,9 +40,9 @@ typedef struct __ucontext ucontext_t;
struct __ucontext {
unsigned int uc_flags; /* properties */
ucontext_t * uc_link; /* context to resume */
mcontext_t uc_mcontext; /* machine state */
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
@@ -52,16 +52,81 @@ struct __ucontext {
#define _UC_UCONTEXT_ALIGN (~0)
#endif
#define UCF_SWAPPED 001 /* Context has been swapped in by swapcontext(3) */
#define UCF_IGNFPU 002 /* Ignore FPU context by get or setcontext(3) */
#define UCF_IGNSIGM 004 /* Ignore signal mask by get or setcontext(3) */
/* uc_flags */
#define _UC_SIGMASK 0x01 /* valid uc_sigmask */
#define _UC_STACK 0x02 /* valid uc_stack */
#define _UC_CPU 0x04 /* valid GPR context in uc_mcontext */
#define _UC_FPU 0x08 /* valid FPU context in uc_mcontext */
#ifdef __minix
#define _UC_SWAPPED 0x10000
#define _UC_IGNFPU 0x20000
#define _UC_IGNSIGM 0x40000
#endif
#define _UC_MD 0x400f0020 /* MD bits. see below */
#define NCARGS 6
/*
* if your port needs more MD bits, please try to choose bits from _UC_MD
* first, rather than picking random unused bits.
*
* _UC_MD details
*
* _UC_TLSBASE Context contains valid pthread private pointer
* All ports must define this MD flag
* 0x00040000 hppa, mips
* 0x00000020 alpha
* 0x00080000 all other ports
*
* _UC_SETSTACK Context uses signal stack
* 0x00020000 arm
* [undefined] alpha, powerpc and vax
* 0x00010000 other ports
*
* _UC_CLRSTACK Context does not use signal stack
* 0x00040000 arm
* [undefined] alpha, powerpc and vax
* 0x00020000 other ports
*
* _UC_POWERPC_VEC Context does not use signal stack
* 0x00010000 powerpc only
*
* _UC_POWERPC_SPE Context contains valid SPE context
* 0x00020000 powerpc only
*
* _UC_M68K_UC_USER Used by m68k machdep code, but undocumented
* 0x40000000 m68k only
*
* _UC_ARM_VFP Unused
* 0x00010000 arm only
*
* _UC_VM Context contains valid virtual 8086 context
* 0x00040000 i386, amd64 only
*
* _UC_FXSAVE Context contains FPU context in that
* is in FXSAVE format in XMM space
* 0x00000020 i386, amd64 only
*/
#ifdef _KERNEL
struct lwp;
#ifdef __UCONTEXT_SIZE
__CTASSERT(sizeof(ucontext_t) == __UCONTEXT_SIZE);
#endif
void getucontext(struct lwp *, ucontext_t *);
int setucontext(struct lwp *, const ucontext_t *);
void cpu_getmcontext(struct lwp *, mcontext_t *, unsigned int *);
int cpu_setmcontext(struct lwp *, const mcontext_t *, unsigned int);
int cpu_mcontext_validate(struct lwp *, const mcontext_t *);
#endif /* _KERNEL */
#ifdef __minix
__BEGIN_DECLS
void resumecontext(ucontext_t *ucp);
#ifdef __UCONTEXT_SIZE
__CTASSERT(sizeof(ucontext_t) == __UCONTEXT_SIZE);
#endif
/* These functions get and set ucontext structure through PM/kernel. They don't
* manipulate the stack. */
int getuctx(ucontext_t *ucp);

View File

@@ -34,6 +34,12 @@
#ifndef _SYS_UIO_H_
#define _SYS_UIO_H_
#ifdef _KERNEL
#ifndef __UIO_EXPOSE
#define __UIO_EXPOSE
#endif
#endif
#include <machine/ansi.h>
#include <sys/featuretest.h>
@@ -53,6 +59,37 @@ struct iovec {
};
#if defined(_NETBSD_SOURCE)
#include <sys/ansi.h>
#ifndef off_t
typedef __off_t off_t; /* file offset */
#define off_t __off_t
#endif
enum uio_rw { UIO_READ, UIO_WRITE };
/* Segment flag values. */
enum uio_seg {
UIO_USERSPACE, /* from user data space */
UIO_SYSSPACE /* from system space */
};
#ifdef __UIO_EXPOSE
struct vmspace;
struct uio {
struct iovec *uio_iov; /* pointer to array of iovecs */
int uio_iovcnt; /* number of iovecs in array */
off_t uio_offset; /* offset into file this uio corresponds to */
size_t uio_resid; /* residual i/o count */
enum uio_rw uio_rw; /* see above */
struct vmspace *uio_vmspace;
};
#define UIO_SETUP_SYSSPACE(uio) uio_setup_sysspace(uio)
#endif /* __UIO_EXPOSE */
/*
* Limits
*/
@@ -60,11 +97,27 @@ struct iovec {
#define UIO_MAXIOV 1024 /* max 1K of iov's */
#endif /* _NETBSD_SOURCE */
#ifdef _KERNEL
/* 8 on stack, more will be dynamically allocated. */
#define UIO_SMALLIOV 8
void uio_setup_sysspace(struct uio *);
#endif
#ifndef _KERNEL
#include <sys/cdefs.h>
__BEGIN_DECLS
#if defined(_NETBSD_SOURCE)
ssize_t preadv(int, const struct iovec *, int, off_t);
ssize_t pwritev(int, const struct iovec *, int, off_t);
#endif /* _NETBSD_SOURCE */
ssize_t readv(int, const struct iovec *, int);
ssize_t writev(int, const struct iovec *, int);
__END_DECLS
#else
int ureadc(int, struct uio *);
#endif /* !_KERNEL */
#endif /* !_SYS_UIO_H_ */

View File

@@ -1,3 +1,36 @@
/* $NetBSD: un.h,v 1.46 2011/06/26 16:43:12 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)un.h 8.3 (Berkeley) 2/19/95
*/
#ifndef _SYS_UN_H_
#define _SYS_UN_H_
@@ -10,26 +43,68 @@ typedef __sa_family_t sa_family_t;
#define sa_family_t __sa_family_t
#endif
#define UNIX_PATH_MAX 127
/*
* Definitions for UNIX IPC domain.
*/
struct sockaddr_un {
uint8_t sun_len;
sa_family_t sun_family;
char sun_path[UNIX_PATH_MAX];
uint8_t sun_len; /* total sockaddr length */
sa_family_t sun_family; /* AF_LOCAL */
char sun_path[104]; /* path name (gag) */
};
#include <string.h>
/* Compute the actual length of a struct sockaddr_un pointed
* to by 'unp'. sun_path must be NULL terminated. Length does
* not include the NULL byte. This is not a POSIX standard
* definition, but BSD and Linux have it, so it is here for
* compatibility.
/*
* Socket options for UNIX IPC domain.
*/
#define SUN_LEN(unp) \
((size_t)((sizeof(*(unp)) - sizeof((unp)->sun_path)) + strlen((unp)->sun_path)))
#if defined(_NETBSD_SOURCE)
#define LOCAL_CREDS 0x0001 /* pass credentials to receiver */
#define LOCAL_CONNWAIT 0x0002 /* connects block until accepted */
#define LOCAL_PEEREID 0x0003 /* get peer identification */
#endif
#endif /* _SYS_UN_H_ */
/*
* Data automatically stored inside connect() for use by LOCAL_PEEREID
*/
struct unpcbid {
pid_t unp_pid; /* process id */
uid_t unp_euid; /* effective user id */
gid_t unp_egid; /* effective group id */
};
#ifdef _KERNEL
struct unpcb;
struct socket;
struct sockopt;
int uipc_usrreq(struct socket *, int, struct mbuf *,
struct mbuf *, struct mbuf *, struct lwp *);
int uipc_ctloutput(int, struct socket *, struct sockopt *);
void uipc_init (void);
kmutex_t *uipc_dgramlock (void);
kmutex_t *uipc_streamlock (void);
kmutex_t *uipc_rawlock (void);
int unp_attach (struct socket *);
int unp_bind (struct socket *, struct mbuf *, struct lwp *);
int unp_connect (struct socket *, struct mbuf *, struct lwp *);
int unp_connect2 (struct socket *, struct socket *, int);
void unp_detach (struct unpcb *);
void unp_discard (struct file *);
void unp_disconnect (struct unpcb *);
bool unp_drop (struct unpcb *, int);
void unp_shutdown (struct unpcb *);
int unp_externalize (struct mbuf *, struct lwp *, int);
int unp_internalize (struct mbuf **);
void unp_dispose (struct mbuf *);
int unp_output (struct mbuf *, struct mbuf *, struct unpcb *,
struct lwp *);
void unp_setaddr (struct socket *, struct mbuf *, bool);
#else /* !_KERNEL */
/* actual length of an initialized sockaddr_un */
#if defined(_NETBSD_SOURCE)
#define SUN_LEN(su) \
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
#endif /* !_NetBSD_SOURCE */
#endif /* _KERNEL */
#endif /* !_SYS_UN_H_ */