Add NBSD-like Minix system includes.
This commit is contained in:
63
nbsd_include/sys/Makefile
Normal file
63
nbsd_include/sys/Makefile
Normal file
@@ -0,0 +1,63 @@
|
||||
# $NetBSD: Makefile,v 1.126 2010/03/01 21:10:13 darran Exp $
|
||||
|
||||
NETBSDINCSDIR= /usr/netbsd/include
|
||||
INCSDIR= /usr/netbsd/include/sys
|
||||
|
||||
.include <bsd.sys.mk>
|
||||
|
||||
|
||||
# Present only in minix
|
||||
INCS+= ioc_net.h
|
||||
|
||||
INCS+= ansi.h atomic.h \
|
||||
bitops.h bswap.h \
|
||||
cdefs.h cdefs_aout.h ctype_bits.h ctype_inline.h \
|
||||
dirent.h \
|
||||
endian.h errno.h \
|
||||
fcntl.h fd_set.h featuretest.h file.h \
|
||||
float_ieee754.h gcq.h gmon.h hash.h \
|
||||
ieee754.h inttypes.h ioctl.h ipc.h \
|
||||
localedef.h \
|
||||
md4.h md5.h \
|
||||
mman.h mount.h \
|
||||
null.h \
|
||||
param.h poll.h ptrace.h \
|
||||
ptree.h \
|
||||
queue.h \
|
||||
rbtree.h resource.h rmd160.h \
|
||||
select.h sha1.h \
|
||||
sha2.h siginfo.h signal.h sigtypes.h \
|
||||
reboot.h sem.h shm.h socket.h \
|
||||
stat.h statvfs.h \
|
||||
sysctl.h stdint.h \
|
||||
syslimits.h syslog.h \
|
||||
termios.h time.h times.h \
|
||||
tree.h ttycom.h ttydefaults.h \
|
||||
types.h \
|
||||
ucontext.h ucred.h uio.h un.h unistd.h utsname.h uuid.h \
|
||||
wait.h
|
||||
|
||||
INCSYMLINKS=\
|
||||
${NETBSDINCSDIR}/sys/fcntl.h ${NETBSDINCSDIR}/fcntl.h \
|
||||
${NETBSDINCSDIR}/sys/poll.h ${NETBSDINCSDIR}/poll.h \
|
||||
${NETBSDINCSDIR}/sys/stdint.h ${NETBSDINCSDIR}/stdint.h \
|
||||
${NETBSDINCSDIR}/sys/syslog.h ${NETBSDINCSDIR}/syslog.h \
|
||||
${NETBSDINCSDIR}/sys/termios.h ${NETBSDINCSDIR}/termios.h \
|
||||
${NETBSDINCSDIR}/sys/rmd160.h ${NETBSDINCSDIR}/rmd160.h \
|
||||
${NETBSDINCSDIR}/sys/sha1.h ${NETBSDINCSDIR}/sha1.h \
|
||||
${NETBSDINCSDIR}/sys/sha2.h ${NETBSDINCSDIR}/sha2.h \
|
||||
${NETBSDINCSDIR}/sys/md4.h ${NETBSDINCSDIR}/md4.h \
|
||||
${NETBSDINCSDIR}/sys/md5.h ${NETBSDINCSDIR}/md5.h
|
||||
# sys/exec_elf.h /usr/include/elf.h \
|
||||
|
||||
|
||||
#INCSYMLINKS+= ../soundcard.h ${INCSDIR}/soundcard.h
|
||||
|
||||
namei: namei.src gennameih.awk
|
||||
${TOOL_AWK} -f gennameih.awk < namei.src
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include "${MINIXSRCDIR}/common/include/sys/Makefile.inc"
|
||||
|
||||
.include <bsd.files.mk>
|
||||
.include <bsd.kinc.mk>
|
||||
69
nbsd_include/sys/ansi.h
Normal file
69
nbsd_include/sys/ansi.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* $NetBSD: ansi.h,v 1.13 2010/03/27 22:14:10 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jun-ichiro itojun Hagino and by Klaus Klein.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ANSI_H_
|
||||
#define _SYS_ANSI_H_
|
||||
|
||||
#include <machine/ansi.h>
|
||||
|
||||
typedef char * __caddr_t; /* core address */
|
||||
typedef char __gid_t; /* group id */
|
||||
typedef __uint32_t __in_addr_t; /* IP(v4) address */
|
||||
typedef __uint16_t __in_port_t; /* "Internet" port number */
|
||||
typedef unsigned short __mode_t; /* file permissions */
|
||||
typedef long __off_t; /* file offset */
|
||||
typedef int __pid_t; /* process id */
|
||||
typedef __uint8_t __sa_family_t; /* socket address family */
|
||||
typedef __int32_t __socklen_t; /* socket-related datum length */
|
||||
typedef short __uid_t; /* user id */
|
||||
typedef unsigned long __fsblkcnt_t; /* fs block count (statvfs) */
|
||||
typedef unsigned long __fsfilcnt_t; /* fs file count */
|
||||
|
||||
struct __tag_wctrans_t;
|
||||
typedef struct __tag_wctrans_t *__wctrans_t;
|
||||
|
||||
struct __tag_wctype_t;
|
||||
typedef struct __tag_wctype_t *__wctype_t;
|
||||
|
||||
/*
|
||||
* mbstate_t is an opaque object to keep conversion state, during multibyte
|
||||
* stream conversions. The content must not be referenced by user programs.
|
||||
*/
|
||||
typedef union {
|
||||
__int64_t __mbstateL; /* for alignment */
|
||||
char __mbstate8[128];
|
||||
} __mbstate_t;
|
||||
|
||||
#define _BSD_WCTRANS_T_ __wctrans_t /* wctrans_t */
|
||||
#define _BSD_WCTYPE_T_ __wctype_t /* wctype_t */
|
||||
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
|
||||
|
||||
#endif /* !_SYS_ANSI_H_ */
|
||||
154
nbsd_include/sys/atomic.h
Normal file
154
nbsd_include/sys/atomic.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/* $NetBSD: atomic.h,v 1.11 2009/11/20 02:17:07 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ATOMIC_H_
|
||||
#define _SYS_ATOMIC_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
/*
|
||||
* Atomic ADD
|
||||
*/
|
||||
void atomic_add_32(volatile uint32_t *, int32_t);
|
||||
void atomic_add_int(volatile unsigned int *, int);
|
||||
void atomic_add_long(volatile unsigned long *, long);
|
||||
void atomic_add_ptr(volatile void *, ssize_t);
|
||||
void atomic_add_64(volatile uint64_t *, int64_t);
|
||||
|
||||
uint32_t atomic_add_32_nv(volatile uint32_t *, int32_t);
|
||||
unsigned int atomic_add_int_nv(volatile unsigned int *, int);
|
||||
unsigned long atomic_add_long_nv(volatile unsigned long *, long);
|
||||
void * atomic_add_ptr_nv(volatile void *, ssize_t);
|
||||
uint64_t atomic_add_64_nv(volatile uint64_t *, int64_t);
|
||||
|
||||
/*
|
||||
* Atomic AND
|
||||
*/
|
||||
void atomic_and_32(volatile uint32_t *, uint32_t);
|
||||
void atomic_and_uint(volatile unsigned int *, unsigned int);
|
||||
void atomic_and_ulong(volatile unsigned long *, unsigned long);
|
||||
void atomic_and_64(volatile uint64_t *, uint64_t);
|
||||
|
||||
uint32_t atomic_and_32_nv(volatile uint32_t *, uint32_t);
|
||||
unsigned int atomic_and_uint_nv(volatile unsigned int *, unsigned int);
|
||||
unsigned long atomic_and_ulong_nv(volatile unsigned long *, unsigned long);
|
||||
uint64_t atomic_and_64_nv(volatile uint64_t *, uint64_t);
|
||||
|
||||
/*
|
||||
* Atomic OR
|
||||
*/
|
||||
void atomic_or_32(volatile uint32_t *, uint32_t);
|
||||
void atomic_or_uint(volatile unsigned int *, unsigned int);
|
||||
void atomic_or_ulong(volatile unsigned long *, unsigned long);
|
||||
void atomic_or_64(volatile uint64_t *, uint64_t);
|
||||
|
||||
uint32_t atomic_or_32_nv(volatile uint32_t *, uint32_t);
|
||||
unsigned int atomic_or_uint_nv(volatile unsigned int *, unsigned int);
|
||||
unsigned long atomic_or_ulong_nv(volatile unsigned long *, unsigned long);
|
||||
uint64_t atomic_or_64_nv(volatile uint64_t *, uint64_t);
|
||||
|
||||
/*
|
||||
* Atomic COMPARE-AND-SWAP
|
||||
*/
|
||||
uint32_t atomic_cas_32(volatile uint32_t *, uint32_t, uint32_t);
|
||||
unsigned int atomic_cas_uint(volatile unsigned int *, unsigned int,
|
||||
unsigned int);
|
||||
unsigned long atomic_cas_ulong(volatile unsigned long *, unsigned long,
|
||||
unsigned long);
|
||||
void * atomic_cas_ptr(volatile void *, void *, void *);
|
||||
uint64_t atomic_cas_64(volatile uint64_t *, uint64_t, uint64_t);
|
||||
|
||||
/*
|
||||
* Non-interlocked atomic COMPARE-AND-SWAP.
|
||||
*/
|
||||
uint32_t atomic_cas_32_ni(volatile uint32_t *, uint32_t, uint32_t);
|
||||
unsigned int atomic_cas_uint_ni(volatile unsigned int *, unsigned int,
|
||||
unsigned int);
|
||||
unsigned long atomic_cas_ulong_ni(volatile unsigned long *, unsigned long,
|
||||
unsigned long);
|
||||
void * atomic_cas_ptr_ni(volatile void *, void *, void *);
|
||||
uint64_t atomic_cas_64_ni(volatile uint64_t *, uint64_t, uint64_t);
|
||||
|
||||
/*
|
||||
* Atomic SWAP
|
||||
*/
|
||||
uint32_t atomic_swap_32(volatile uint32_t *, uint32_t);
|
||||
unsigned int atomic_swap_uint(volatile unsigned int *, unsigned int);
|
||||
unsigned long atomic_swap_ulong(volatile unsigned long *, unsigned long);
|
||||
void * atomic_swap_ptr(volatile void *, void *);
|
||||
uint64_t atomic_swap_64(volatile uint64_t *, uint64_t);
|
||||
|
||||
/*
|
||||
* Atomic DECREMENT
|
||||
*/
|
||||
void atomic_dec_32(volatile uint32_t *);
|
||||
void atomic_dec_uint(volatile unsigned int *);
|
||||
void atomic_dec_ulong(volatile unsigned long *);
|
||||
void atomic_dec_ptr(volatile void *);
|
||||
void atomic_dec_64(volatile uint64_t *);
|
||||
|
||||
uint32_t atomic_dec_32_nv(volatile uint32_t *);
|
||||
unsigned int atomic_dec_uint_nv(volatile unsigned int *);
|
||||
unsigned long atomic_dec_ulong_nv(volatile unsigned long *);
|
||||
void * atomic_dec_ptr_nv(volatile void *);
|
||||
uint64_t atomic_dec_64_nv(volatile uint64_t *);
|
||||
|
||||
/*
|
||||
* Atomic INCREMENT
|
||||
*/
|
||||
void atomic_inc_32(volatile uint32_t *);
|
||||
void atomic_inc_uint(volatile unsigned int *);
|
||||
void atomic_inc_ulong(volatile unsigned long *);
|
||||
void atomic_inc_ptr(volatile void *);
|
||||
void atomic_inc_64(volatile uint64_t *);
|
||||
|
||||
uint32_t atomic_inc_32_nv(volatile uint32_t *);
|
||||
unsigned int atomic_inc_uint_nv(volatile unsigned int *);
|
||||
unsigned long atomic_inc_ulong_nv(volatile unsigned long *);
|
||||
void * atomic_inc_ptr_nv(volatile void *);
|
||||
uint64_t atomic_inc_64_nv(volatile uint64_t *);
|
||||
|
||||
/*
|
||||
* Memory barrier operations
|
||||
*/
|
||||
void membar_enter(void);
|
||||
void membar_exit(void);
|
||||
void membar_producer(void);
|
||||
void membar_consumer(void);
|
||||
void membar_sync(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* ! _SYS_ATOMIC_H_ */
|
||||
294
nbsd_include/sys/bitops.h
Normal file
294
nbsd_include/sys/bitops.h
Normal file
@@ -0,0 +1,294 @@
|
||||
/* $NetBSD: bitops.h,v 1.7 2010/03/21 14:28:15 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas and Joerg Sonnenberger.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
#ifndef _SYS_BITOPS_H_
|
||||
#define _SYS_BITOPS_H_
|
||||
|
||||
#include <sys/stdint.h>
|
||||
|
||||
/*
|
||||
* Find First Set functions
|
||||
*/
|
||||
#ifndef ffs32
|
||||
static __inline int __unused
|
||||
ffs32(uint32_t _n)
|
||||
{
|
||||
int _v;
|
||||
|
||||
if (!_n)
|
||||
return 0;
|
||||
|
||||
_v = 1;
|
||||
if ((_n & 0x0000FFFFU) == 0) {
|
||||
_n >>= 16;
|
||||
_v += 16;
|
||||
}
|
||||
if ((_n & 0x000000FFU) == 0) {
|
||||
_n >>= 8;
|
||||
_v += 8;
|
||||
}
|
||||
if ((_n & 0x0000000FU) == 0) {
|
||||
_n >>= 4;
|
||||
_v += 4;
|
||||
}
|
||||
if ((_n & 0x00000003U) == 0) {
|
||||
_n >>= 2;
|
||||
_v += 2;
|
||||
}
|
||||
if ((_n & 0x00000001U) == 0) {
|
||||
_n >>= 1;
|
||||
_v += 1;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef ffs64
|
||||
static __inline int __unused
|
||||
ffs64(uint64_t _n)
|
||||
{
|
||||
int _v;
|
||||
|
||||
if (!_n)
|
||||
return 0;
|
||||
|
||||
_v = 1;
|
||||
if ((_n & 0x00000000FFFFFFFFULL) == 0) {
|
||||
_n >>= 32;
|
||||
_v += 32;
|
||||
}
|
||||
if ((_n & 0x000000000000FFFFULL) == 0) {
|
||||
_n >>= 16;
|
||||
_v += 16;
|
||||
}
|
||||
if ((_n & 0x00000000000000FFULL) == 0) {
|
||||
_n >>= 8;
|
||||
_v += 8;
|
||||
}
|
||||
if ((_n & 0x000000000000000FULL) == 0) {
|
||||
_n >>= 4;
|
||||
_v += 4;
|
||||
}
|
||||
if ((_n & 0x0000000000000003ULL) == 0) {
|
||||
_n >>= 2;
|
||||
_v += 2;
|
||||
}
|
||||
if ((_n & 0x0000000000000001ULL) == 0) {
|
||||
_n >>= 1;
|
||||
_v += 1;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find Last Set functions
|
||||
*/
|
||||
#ifndef fls32
|
||||
static __inline int __unused
|
||||
fls32(uint32_t _n)
|
||||
{
|
||||
int _v;
|
||||
|
||||
if (!_n)
|
||||
return 0;
|
||||
|
||||
_v = 32;
|
||||
if ((_n & 0xFFFF0000U) == 0) {
|
||||
_n <<= 16;
|
||||
_v -= 16;
|
||||
}
|
||||
if ((_n & 0xFF000000U) == 0) {
|
||||
_n <<= 8;
|
||||
_v -= 8;
|
||||
}
|
||||
if ((_n & 0xF0000000U) == 0) {
|
||||
_n <<= 4;
|
||||
_v -= 4;
|
||||
}
|
||||
if ((_n & 0xC0000000U) == 0) {
|
||||
_n <<= 2;
|
||||
_v -= 2;
|
||||
}
|
||||
if ((_n & 0x80000000U) == 0) {
|
||||
_n <<= 1;
|
||||
_v -= 1;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef fls64
|
||||
static __inline int __unused
|
||||
fls64(uint64_t _n)
|
||||
{
|
||||
int _v;
|
||||
|
||||
if (!_n)
|
||||
return 0;
|
||||
|
||||
_v = 64;
|
||||
if ((_n & 0xFFFFFFFF00000000ULL) == 0) {
|
||||
_n <<= 32;
|
||||
_v -= 32;
|
||||
}
|
||||
if ((_n & 0xFFFF000000000000ULL) == 0) {
|
||||
_n <<= 16;
|
||||
_v -= 16;
|
||||
}
|
||||
if ((_n & 0xFF00000000000000ULL) == 0) {
|
||||
_n <<= 8;
|
||||
_v -= 8;
|
||||
}
|
||||
if ((_n & 0xF000000000000000ULL) == 0) {
|
||||
_n <<= 4;
|
||||
_v -= 4;
|
||||
}
|
||||
if ((_n & 0xC000000000000000ULL) == 0) {
|
||||
_n <<= 2;
|
||||
_v -= 2;
|
||||
}
|
||||
if ((_n & 0x8000000000000000ULL) == 0) {
|
||||
_n <<= 1;
|
||||
_v -= 1;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Integer logarithm, returns -1 on error. Inspired by the linux
|
||||
* version written by David Howells.
|
||||
*/
|
||||
#define _ilog2_helper(_n, _x) ((_n) & (1ULL << (_x))) ? _x :
|
||||
#define ilog2(_n) \
|
||||
( \
|
||||
__builtin_constant_p(_n) ? ( \
|
||||
_ilog2_helper(_n, 63) \
|
||||
_ilog2_helper(_n, 62) \
|
||||
_ilog2_helper(_n, 61) \
|
||||
_ilog2_helper(_n, 60) \
|
||||
_ilog2_helper(_n, 59) \
|
||||
_ilog2_helper(_n, 58) \
|
||||
_ilog2_helper(_n, 57) \
|
||||
_ilog2_helper(_n, 56) \
|
||||
_ilog2_helper(_n, 55) \
|
||||
_ilog2_helper(_n, 54) \
|
||||
_ilog2_helper(_n, 53) \
|
||||
_ilog2_helper(_n, 52) \
|
||||
_ilog2_helper(_n, 51) \
|
||||
_ilog2_helper(_n, 50) \
|
||||
_ilog2_helper(_n, 49) \
|
||||
_ilog2_helper(_n, 48) \
|
||||
_ilog2_helper(_n, 47) \
|
||||
_ilog2_helper(_n, 46) \
|
||||
_ilog2_helper(_n, 45) \
|
||||
_ilog2_helper(_n, 44) \
|
||||
_ilog2_helper(_n, 43) \
|
||||
_ilog2_helper(_n, 42) \
|
||||
_ilog2_helper(_n, 41) \
|
||||
_ilog2_helper(_n, 40) \
|
||||
_ilog2_helper(_n, 39) \
|
||||
_ilog2_helper(_n, 38) \
|
||||
_ilog2_helper(_n, 37) \
|
||||
_ilog2_helper(_n, 36) \
|
||||
_ilog2_helper(_n, 35) \
|
||||
_ilog2_helper(_n, 34) \
|
||||
_ilog2_helper(_n, 33) \
|
||||
_ilog2_helper(_n, 32) \
|
||||
_ilog2_helper(_n, 31) \
|
||||
_ilog2_helper(_n, 30) \
|
||||
_ilog2_helper(_n, 29) \
|
||||
_ilog2_helper(_n, 28) \
|
||||
_ilog2_helper(_n, 27) \
|
||||
_ilog2_helper(_n, 26) \
|
||||
_ilog2_helper(_n, 25) \
|
||||
_ilog2_helper(_n, 24) \
|
||||
_ilog2_helper(_n, 23) \
|
||||
_ilog2_helper(_n, 22) \
|
||||
_ilog2_helper(_n, 21) \
|
||||
_ilog2_helper(_n, 20) \
|
||||
_ilog2_helper(_n, 19) \
|
||||
_ilog2_helper(_n, 18) \
|
||||
_ilog2_helper(_n, 17) \
|
||||
_ilog2_helper(_n, 16) \
|
||||
_ilog2_helper(_n, 15) \
|
||||
_ilog2_helper(_n, 14) \
|
||||
_ilog2_helper(_n, 13) \
|
||||
_ilog2_helper(_n, 12) \
|
||||
_ilog2_helper(_n, 11) \
|
||||
_ilog2_helper(_n, 10) \
|
||||
_ilog2_helper(_n, 9) \
|
||||
_ilog2_helper(_n, 8) \
|
||||
_ilog2_helper(_n, 7) \
|
||||
_ilog2_helper(_n, 6) \
|
||||
_ilog2_helper(_n, 5) \
|
||||
_ilog2_helper(_n, 4) \
|
||||
_ilog2_helper(_n, 3) \
|
||||
_ilog2_helper(_n, 2) \
|
||||
_ilog2_helper(_n, 1) \
|
||||
_ilog2_helper(_n, 0) \
|
||||
-1) : ((sizeof(_n) >= 4 ? fls64(_n) : fls32(_n)) - 1) \
|
||||
)
|
||||
|
||||
static __inline void
|
||||
fast_divide32_prepare(uint32_t _div, uint32_t * __restrict _m,
|
||||
uint8_t *__restrict _s1, uint8_t *__restrict _s2)
|
||||
{
|
||||
uint64_t _mt;
|
||||
int _l;
|
||||
|
||||
_l = fls32(_div - 1);
|
||||
_mt = 0x100000000ULL * ((1ULL << _l) - _div);
|
||||
*_m = (uint32_t)(_mt / _div + 1);
|
||||
*_s1 = (_l > 1) ? 1 : _l;
|
||||
*_s2 = (_l == 0) ? 0 : _l - 1;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static __inline uint32_t
|
||||
fast_divide32(uint32_t _v, uint32_t _div, uint32_t _m, uint8_t _s1,
|
||||
uint8_t _s2)
|
||||
{
|
||||
uint32_t _t;
|
||||
|
||||
_t = (uint32_t)(((uint64_t)_v * _m) >> 32);
|
||||
return (_t + ((_v - _t) >> _s1)) >> _s2;
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
fast_remainder32(uint32_t _v, uint32_t _div, uint32_t _m, uint8_t _s1,
|
||||
uint8_t _s2)
|
||||
{
|
||||
|
||||
return _v - _div * fast_divide32(_v, _div, _m, _s1, _s2);
|
||||
}
|
||||
|
||||
#endif /* _SYS_BITOPS_H_ */
|
||||
79
nbsd_include/sys/bswap.h
Normal file
79
nbsd_include/sys/bswap.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* $NetBSD: bswap.h,v 1.16 2009/08/08 21:23:15 christos Exp $ */
|
||||
|
||||
/* Written by Manuel Bouyer. Public domain */
|
||||
|
||||
#ifndef _SYS_BSWAP_H_
|
||||
#define _SYS_BSWAP_H_
|
||||
|
||||
#ifndef _LOCORE
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/bswap.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
/* Always declare the functions in case their address is taken (etc) */
|
||||
#if defined(_KERNEL) || defined(_STANDALONE) || !defined(__BSWAP_RENAME)
|
||||
uint16_t bswap16(uint16_t) __constfunc;
|
||||
uint32_t bswap32(uint32_t) __constfunc;
|
||||
#else
|
||||
uint16_t bswap16(uint16_t) __RENAME(__bswap16) __constfunc;
|
||||
uint32_t bswap32(uint32_t) __RENAME(__bswap32) __constfunc;
|
||||
#endif
|
||||
uint64_t bswap64(uint64_t) __constfunc;
|
||||
__END_DECLS
|
||||
|
||||
#if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__lint__)
|
||||
|
||||
/* machine/byte_swap.h might have defined inline versions */
|
||||
#ifndef __BYTE_SWAP_U64_VARIABLE
|
||||
#define __BYTE_SWAP_U64_VARIABLE bswap64
|
||||
#endif
|
||||
|
||||
#ifndef __BYTE_SWAP_U32_VARIABLE
|
||||
#define __BYTE_SWAP_U32_VARIABLE bswap32
|
||||
#endif
|
||||
|
||||
#ifndef __BYTE_SWAP_U16_VARIABLE
|
||||
#define __BYTE_SWAP_U16_VARIABLE bswap16
|
||||
#endif
|
||||
|
||||
#define __byte_swap_u64_constant(x) \
|
||||
(__CAST(uint64_t, \
|
||||
((((x) & 0xff00000000000000ull) >> 56) | \
|
||||
(((x) & 0x00ff000000000000ull) >> 40) | \
|
||||
(((x) & 0x0000ff0000000000ull) >> 24) | \
|
||||
(((x) & 0x000000ff00000000ull) >> 8) | \
|
||||
(((x) & 0x00000000ff000000ull) << 8) | \
|
||||
(((x) & 0x0000000000ff0000ull) << 24) | \
|
||||
(((x) & 0x000000000000ff00ull) << 40) | \
|
||||
(((x) & 0x00000000000000ffull) << 56))))
|
||||
|
||||
#define __byte_swap_u32_constant(x) \
|
||||
(__CAST(uint32_t, \
|
||||
((((x) & 0xff000000) >> 24) | \
|
||||
(((x) & 0x00ff0000) >> 8) | \
|
||||
(((x) & 0x0000ff00) << 8) | \
|
||||
(((x) & 0x000000ff) << 24))))
|
||||
|
||||
#define __byte_swap_u16_constant(x) \
|
||||
(__CAST(uint16_t, \
|
||||
((((x) & 0xff00) >> 8) | \
|
||||
(((x) & 0x00ff) << 8))))
|
||||
|
||||
#define bswap64(x) \
|
||||
(__builtin_constant_p((x)) ? \
|
||||
__byte_swap_u64_constant(x) : __BYTE_SWAP_U64_VARIABLE(x))
|
||||
|
||||
#define bswap32(x) \
|
||||
(__builtin_constant_p((x)) ? \
|
||||
__byte_swap_u32_constant(x) : __BYTE_SWAP_U32_VARIABLE(x))
|
||||
|
||||
#define bswap16(x) \
|
||||
(__builtin_constant_p((x)) ? \
|
||||
__byte_swap_u16_constant(x) : __BYTE_SWAP_U16_VARIABLE(x))
|
||||
|
||||
#endif /* __GNUC__ && __OPTIMIZE__ */
|
||||
#endif /* !_LOCORE */
|
||||
|
||||
#endif /* !_SYS_BSWAP_H_ */
|
||||
485
nbsd_include/sys/cdefs.h
Normal file
485
nbsd_include/sys/cdefs.h
Normal file
@@ -0,0 +1,485 @@
|
||||
/* $NetBSD: cdefs.h,v 1.81 2010/12/25 22:30:52 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Berkeley Software Design, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)cdefs.h 8.8 (Berkeley) 1/9/95
|
||||
*/
|
||||
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#define _SYS_CDEFS_H_
|
||||
|
||||
/*
|
||||
* Macro to test if we're using a GNU C compiler of a specific vintage
|
||||
* or later, for e.g. features that appeared in a particular version
|
||||
* of GNU C. Usage:
|
||||
*
|
||||
* #if __GNUC_PREREQ__(major, minor)
|
||||
* ...cool feature...
|
||||
* #else
|
||||
* ...delete feature...
|
||||
* #endif
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define __GNUC_PREREQ__(x, y) \
|
||||
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
|
||||
(__GNUC__ > (x)))
|
||||
#else
|
||||
#define __GNUC_PREREQ__(x, y) 0
|
||||
#endif
|
||||
|
||||
#include <machine/cdefs.h>
|
||||
#ifdef __ELF__
|
||||
#include <sys/cdefs_elf.h>
|
||||
#else
|
||||
#include <sys/cdefs_aout.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
|
||||
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
|
||||
* The __CONCAT macro is a bit tricky -- make sure you don't put spaces
|
||||
* in between its arguments. __CONCAT can also concatenate double-quoted
|
||||
* strings produced by the __STRING macro, but this only works with ANSI C.
|
||||
*/
|
||||
|
||||
#define ___STRING(x) __STRING(x)
|
||||
#define ___CONCAT(x,y) __CONCAT(x,y)
|
||||
|
||||
#if __STDC__ || defined(__cplusplus)
|
||||
#define __P(protos) protos /* full-blown ANSI C */
|
||||
#define __CONCAT(x,y) x ## y
|
||||
#define __STRING(x) #x
|
||||
|
||||
#define __const const /* define reserved names to standard */
|
||||
#define __signed signed
|
||||
#define __volatile volatile
|
||||
#if defined(__cplusplus) || defined(__PCC__)
|
||||
#define __inline inline /* convert to C++/C99 keyword */
|
||||
#else
|
||||
#if !defined(__GNUC__) && !defined(__lint__)
|
||||
#define __inline /* delete GCC keyword */
|
||||
#endif /* !__GNUC__ && !__lint__ */
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#else /* !(__STDC__ || __cplusplus) */
|
||||
#define __P(protos) () /* traditional C preprocessor */
|
||||
#define __CONCAT(x,y) x/**/y
|
||||
#define __STRING(x) "x"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __const /* delete pseudo-ANSI C keywords */
|
||||
#define __inline
|
||||
#define __signed
|
||||
#define __volatile
|
||||
#endif /* !__GNUC__ */
|
||||
|
||||
/*
|
||||
* In non-ANSI C environments, new programs will want ANSI-only C keywords
|
||||
* deleted from the program and old programs will want them left alone.
|
||||
* Programs using the ANSI C keywords const, inline etc. as normal
|
||||
* identifiers should define -DNO_ANSI_KEYWORDS.
|
||||
*/
|
||||
#ifndef NO_ANSI_KEYWORDS
|
||||
#define const __const /* convert ANSI C keywords */
|
||||
#define inline __inline
|
||||
#define signed __signed
|
||||
#define volatile __volatile
|
||||
#endif /* !NO_ANSI_KEYWORDS */
|
||||
#endif /* !(__STDC__ || __cplusplus) */
|
||||
|
||||
/*
|
||||
* Used for internal auditing of the NetBSD source tree.
|
||||
*/
|
||||
#ifdef __AUDIT__
|
||||
#define __aconst __const
|
||||
#else
|
||||
#define __aconst
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following macro is used to remove const cast-away warnings
|
||||
* from gcc -Wcast-qual; it should be used with caution because it
|
||||
* can hide valid errors; in particular most valid uses are in
|
||||
* situations where the API requires it, not to cast away string
|
||||
* constants. We don't use *intptr_t on purpose here and we are
|
||||
* explicit about unsigned long so that we don't have additional
|
||||
* dependencies.
|
||||
*/
|
||||
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
|
||||
/*
|
||||
* The following macro is used to remove the volatile cast-away warnings
|
||||
* from gcc -Wcast-qual; as above it should be used with caution
|
||||
* because it can hide valid errors or warnings. Valid uses include
|
||||
* making it possible to pass a volatile pointer to memset().
|
||||
* For the same reasons as above, we use unsigned long and not intptr_t.
|
||||
*/
|
||||
#define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a))
|
||||
|
||||
/*
|
||||
* GCC2 provides __extension__ to suppress warnings for various GNU C
|
||||
* language extensions under "-ansi -pedantic".
|
||||
*/
|
||||
#if !__GNUC_PREREQ__(2, 0)
|
||||
#define __extension__ /* delete __extension__ if non-gcc or gcc1 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GCC1 and some versions of GCC2 declare dead (non-returning) and
|
||||
* pure (no side effects) functions using "volatile" and "const";
|
||||
* unfortunately, these then cause warnings under "-ansi -pedantic".
|
||||
* GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
|
||||
* these work for GNU C++ (modulo a slight glitch in the C++ grammar
|
||||
* in the distribution version of 2.5.5).
|
||||
*
|
||||
* GCC defines a pure function as depending only on its arguments and
|
||||
* global variables. Typical examples are strlen and sqrt.
|
||||
*
|
||||
* GCC defines a const function as depending only on its arguments.
|
||||
* Therefore calling a const function again with identical arguments
|
||||
* will always produce the same result.
|
||||
*
|
||||
* Rounding modes for floating point operations are considered global
|
||||
* variables and prevent sqrt from being a const function.
|
||||
*
|
||||
* Calls to const functions can be optimised away and moved around
|
||||
* without limitations.
|
||||
*/
|
||||
#if !__GNUC_PREREQ__(2, 0)
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(2, 5)
|
||||
#define __dead __attribute__((__noreturn__))
|
||||
#elif defined(__GNUC__)
|
||||
#define __dead __volatile
|
||||
#else
|
||||
#define __dead
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(2, 96)
|
||||
#define __pure __attribute__((__pure__))
|
||||
#elif defined(__GNUC__)
|
||||
#define __pure __const
|
||||
#else
|
||||
#define __pure
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(2, 5)
|
||||
#define __constfunc __attribute__((__const__))
|
||||
#else
|
||||
#define __constfunc
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 0)
|
||||
#define __noinline __attribute__((__noinline__))
|
||||
#else
|
||||
#define __noinline /* nothing */
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(2, 7)
|
||||
#define __unused __attribute__((__unused__))
|
||||
#else
|
||||
#define __unused /* delete */
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 1)
|
||||
#define __used __attribute__((__used__))
|
||||
#else
|
||||
#define __used __unused
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_EXTERN_C extern "C" {
|
||||
#define __END_EXTERN_C }
|
||||
#define __static_cast(x,y) static_cast<x>(y)
|
||||
#else
|
||||
#define __BEGIN_EXTERN_C
|
||||
#define __END_EXTERN_C
|
||||
#define __static_cast(x,y) (x)y
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 0)
|
||||
# define __dso_public __attribute__((__visibility__("default")))
|
||||
# define __dso_hidden __attribute__((__visibility__("hidden")))
|
||||
# define __BEGIN_PUBLIC_DECLS \
|
||||
_Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C
|
||||
# define __END_PUBLIC_DECLS __END_EXTERN_C _Pragma("GCC visibility pop")
|
||||
# define __BEGIN_HIDDEN_DECLS \
|
||||
_Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C
|
||||
# define __END_HIDDEN_DECLS __END_EXTERN_C _Pragma("GCC visibility pop")
|
||||
#else
|
||||
# define __dso_public
|
||||
# define __dso_hidden
|
||||
# define __BEGIN_PUBLIC_DECLS __BEGIN_EXTERN_C
|
||||
# define __END_PUBLIC_DECLS __END_EXTERN_C
|
||||
# define __BEGIN_HIDDEN_DECLS __BEGIN_EXTERN_C
|
||||
# define __END_HIDDEN_DECLS __END_EXTERN_C
|
||||
#endif
|
||||
|
||||
#define __BEGIN_DECLS __BEGIN_PUBLIC_DECLS
|
||||
#define __END_DECLS __END_PUBLIC_DECLS
|
||||
|
||||
/*
|
||||
* Non-static C99 inline functions are optional bodies. They don't
|
||||
* create global symbols if not used, but can be replaced if desirable.
|
||||
* This differs from the behavior of GCC before version 4.3. The nearest
|
||||
* equivalent for older GCC is `extern inline'. For newer GCC, use the
|
||||
* gnu_inline attribute additionally to get the old behavior.
|
||||
*
|
||||
* For C99 compilers other than GCC, the C99 behavior is expected.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__GNUC_STDC_INLINE__)
|
||||
#define __c99inline extern __attribute__((__gnu_inline__)) __inline
|
||||
#elif defined(__GNUC__)
|
||||
#define __c99inline extern __inline
|
||||
#elif defined(__STDC_VERSION__)
|
||||
#define __c99inline __inline
|
||||
#endif
|
||||
|
||||
#if defined(__lint__)
|
||||
#define __packed __packed
|
||||
#define __aligned(x) /* delete */
|
||||
#define __section(x) /* delete */
|
||||
#elif __GNUC_PREREQ__(2, 7)
|
||||
#define __packed __attribute__((__packed__))
|
||||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#define __section(x) __attribute__((__section__(x)))
|
||||
#elif defined(__PCC__)
|
||||
#define __packed _Pragma("packed 1")
|
||||
#define __aligned(x) _Pragma("aligned " __STRING(x))
|
||||
#define __section(x) _Pragma("section " ## x)
|
||||
#else
|
||||
#define __packed error: no __packed for this compiler
|
||||
#define __aligned(x) error: no __aligned for this compiler
|
||||
#define __section(x) error: no __section for this compiler
|
||||
#endif
|
||||
|
||||
/*
|
||||
* C99 defines the restrict type qualifier keyword, which was made available
|
||||
* in GCC 2.92.
|
||||
*/
|
||||
#if defined(__lint__)
|
||||
#define __restrict /* delete __restrict when not supported */
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
#define __restrict restrict
|
||||
#elif !__GNUC_PREREQ__(2, 92)
|
||||
#define __restrict /* delete __restrict when not supported */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* C99 defines __func__ predefined identifier, which was made available
|
||||
* in GCC 2.95.
|
||||
*/
|
||||
#if !(__STDC_VERSION__ >= 199901L)
|
||||
#if __GNUC_PREREQ__(2, 6)
|
||||
#define __func__ __PRETTY_FUNCTION__
|
||||
#elif __GNUC_PREREQ__(2, 4)
|
||||
#define __func__ __FUNCTION__
|
||||
#else
|
||||
#define __func__ ""
|
||||
#endif
|
||||
#endif /* !(__STDC_VERSION__ >= 199901L) */
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#if defined(NO_KERNEL_RCSIDS)
|
||||
#undef __KERNEL_RCSID
|
||||
#define __KERNEL_RCSID(_n, _s) /* nothing */
|
||||
#endif /* NO_KERNEL_RCSIDS */
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#if !defined(_STANDALONE) && !defined(_KERNEL)
|
||||
#if defined(__GNUC__) || defined(__PCC__)
|
||||
#define __RENAME(x) ___RENAME(x)
|
||||
#else
|
||||
#ifdef __lint__
|
||||
#define __RENAME(x) __symbolrename(x)
|
||||
#else
|
||||
#error "No function renaming possible"
|
||||
#endif /* __lint__ */
|
||||
#endif /* __GNUC__ */
|
||||
#else /* _STANDALONE || _KERNEL */
|
||||
#define __RENAME(x) no renaming in kernel or standalone environment
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A barrier to stop the optimizer from moving code or assume live
|
||||
* register values. This is gcc specific, the version is more or less
|
||||
* arbitrary, might work with older compilers.
|
||||
*/
|
||||
#if __GNUC_PREREQ__(2, 95)
|
||||
#define __insn_barrier() __asm __volatile("":::"memory")
|
||||
#else
|
||||
#define __insn_barrier() /* */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GNU C version 2.96 adds explicit branch prediction so that
|
||||
* the CPU back-end can hint the processor and also so that
|
||||
* code blocks can be reordered such that the predicted path
|
||||
* sees a more linear flow, thus improving cache behavior, etc.
|
||||
*
|
||||
* The following two macros provide us with a way to use this
|
||||
* compiler feature. Use __predict_true() if you expect the expression
|
||||
* to evaluate to true, and __predict_false() if you expect the
|
||||
* expression to evaluate to false.
|
||||
*
|
||||
* A few notes about usage:
|
||||
*
|
||||
* * Generally, __predict_false() error condition checks (unless
|
||||
* you have some _strong_ reason to do otherwise, in which case
|
||||
* document it), and/or __predict_true() `no-error' condition
|
||||
* checks, assuming you want to optimize for the no-error case.
|
||||
*
|
||||
* * Other than that, if you don't know the likelihood of a test
|
||||
* succeeding from empirical or other `hard' evidence, don't
|
||||
* make predictions.
|
||||
*
|
||||
* * These are meant to be used in places that are run `a lot'.
|
||||
* It is wasteful to make predictions in code that is run
|
||||
* seldomly (e.g. at subsystem initialization time) as the
|
||||
* basic block reordering that this affects can often generate
|
||||
* larger code.
|
||||
*/
|
||||
#if __GNUC_PREREQ__(2, 96)
|
||||
#define __predict_true(exp) __builtin_expect((exp) != 0, 1)
|
||||
#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
|
||||
#else
|
||||
#define __predict_true(exp) (exp)
|
||||
#define __predict_false(exp) (exp)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compiler-dependent macros to declare that functions take printf-like
|
||||
* or scanf-like arguments. They are null except for versions of gcc
|
||||
* that are known to support the features properly (old versions of gcc-2
|
||||
* didn't permit keeping the keywords out of the application namespace).
|
||||
*/
|
||||
#if __GNUC_PREREQ__(2, 7)
|
||||
#define __printflike(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
|
||||
#define __scanflike(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
|
||||
#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
|
||||
#else
|
||||
#define __printflike(fmtarg, firstvararg) /* nothing */
|
||||
#define __scanflike(fmtarg, firstvararg) /* nothing */
|
||||
#define __format_arg(fmtarg) /* nothing */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for manipulating "link sets". Link sets are arrays of pointers
|
||||
* to objects, which are gathered up by the linker.
|
||||
*
|
||||
* Object format-specific code has provided us with the following macros:
|
||||
*
|
||||
* __link_set_add_text(set, sym)
|
||||
* Add a reference to the .text symbol `sym' to `set'.
|
||||
*
|
||||
* __link_set_add_rodata(set, sym)
|
||||
* Add a reference to the .rodata symbol `sym' to `set'.
|
||||
*
|
||||
* __link_set_add_data(set, sym)
|
||||
* Add a reference to the .data symbol `sym' to `set'.
|
||||
*
|
||||
* __link_set_add_bss(set, sym)
|
||||
* Add a reference to the .bss symbol `sym' to `set'.
|
||||
*
|
||||
* __link_set_decl(set, ptype)
|
||||
* Provide an extern declaration of the set `set', which
|
||||
* contains an array of the pointer type `ptype'. This
|
||||
* macro must be used by any code which wishes to reference
|
||||
* the elements of a link set.
|
||||
*
|
||||
* __link_set_start(set)
|
||||
* This points to the first slot in the link set.
|
||||
*
|
||||
* __link_set_end(set)
|
||||
* This points to the (non-existent) slot after the last
|
||||
* entry in the link set.
|
||||
*
|
||||
* __link_set_count(set)
|
||||
* Count the number of entries in link set `set'.
|
||||
*
|
||||
* In addition, we provide the following macros for accessing link sets:
|
||||
*
|
||||
* __link_set_foreach(pvar, set)
|
||||
* Iterate over the link set `set'. Because a link set is
|
||||
* an array of pointers, pvar must be declared as "type **pvar",
|
||||
* and the actual entry accessed as "*pvar".
|
||||
*
|
||||
* __link_set_entry(set, idx)
|
||||
* Access the link set entry at index `idx' from set `set'.
|
||||
*/
|
||||
#define __link_set_foreach(pvar, set) \
|
||||
for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++)
|
||||
|
||||
#define __link_set_entry(set, idx) (__link_set_begin(set)[idx])
|
||||
|
||||
/*
|
||||
* Return the number of elements in a statically-allocated array,
|
||||
* __x.
|
||||
*/
|
||||
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
|
||||
|
||||
/* __BIT(n): nth bit, where __BIT(0) == 0x1. */
|
||||
#define __BIT(__n) \
|
||||
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
|
||||
|
||||
/* __BITS(m, n): bits m through n, m < n. */
|
||||
#define __BITS(__m, __n) \
|
||||
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
|
||||
|
||||
/* find least significant bit that is set */
|
||||
#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))
|
||||
|
||||
#define __PRIuBIT PRIuMAX
|
||||
#define __PRIuBITS __PRIuBIT
|
||||
|
||||
#define __PRIxBIT PRIxMAX
|
||||
#define __PRIxBITS __PRIxBIT
|
||||
|
||||
#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
|
||||
#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))
|
||||
#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask))
|
||||
|
||||
/*
|
||||
* Only to be used in other headers that are included from both c or c++
|
||||
* NOT to be used in code.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#define __CAST(__dt, __st) static_cast<__dt>(__st)
|
||||
#else
|
||||
#define __CAST(__dt, __st) ((__dt)(__st))
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_CDEFS_H_ */
|
||||
131
nbsd_include/sys/cdefs_aout.h
Normal file
131
nbsd_include/sys/cdefs_aout.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/* $NetBSD: cdefs_aout.h,v 1.20 2006/05/18 17:55:38 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@wimsey.com> 01/17/95.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_CDEFS_AOUT_H_
|
||||
#define _SYS_CDEFS_AOUT_H_
|
||||
|
||||
#define _C_LABEL(x) __CONCAT(_,x)
|
||||
#define _C_LABEL_STRING(x) "_"x
|
||||
|
||||
#if __STDC__
|
||||
#define ___RENAME(x) __asm(___STRING(_C_LABEL(x)))
|
||||
#else
|
||||
#define ___RENAME(x) ____RENAME(_/**/x)
|
||||
#define ____RENAME(x) __asm(___STRING(x))
|
||||
#endif
|
||||
|
||||
#define __indr_reference(sym,alias) /* nada, since we do weak refs */
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if __STDC__
|
||||
#define __strong_alias(alias,sym) \
|
||||
__asm(".global " _C_LABEL_STRING(#alias) "\n" \
|
||||
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
|
||||
#define __weak_alias(alias,sym) \
|
||||
__asm(".weak " _C_LABEL_STRING(#alias) "\n" \
|
||||
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
|
||||
|
||||
/* Do not use __weak_extern, use __weak_reference instead */
|
||||
#define __weak_extern(sym) \
|
||||
__asm(".weak " _C_LABEL_STRING(#sym));
|
||||
|
||||
#if __GNUC_PREREQ__(4, 0)
|
||||
#define __weak_reference(sym) __attribute__((__weakref__))
|
||||
#else
|
||||
#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym))
|
||||
#endif
|
||||
|
||||
#define __warn_references(sym,msg) \
|
||||
__asm(".stabs \"" msg "\",30,0,0,0"); \
|
||||
__asm(".stabs \"_" #sym "\",1,0,0,0");
|
||||
#else /* __STDC__ */
|
||||
#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym)
|
||||
#define ___weak_alias(alias,sym) \
|
||||
__asm(".weak alias\nalias = sym");
|
||||
/* Do not use __weak_extern, use __weak_reference instead */
|
||||
#define __weak_extern(sym) ___weak_extern(_/**/sym)
|
||||
#define ___weak_extern(sym) \
|
||||
__asm(".weak sym");
|
||||
|
||||
#if __GNUC_PREREQ__(4, 0)
|
||||
#define __weak_reference(sym) __attribute__((__weakref__))
|
||||
#else
|
||||
#define ___weak_reference(sym) ; __asm(".weak sym");
|
||||
#define __weak_reference(sym) ___weak_reference(_/**/sym)
|
||||
#endif
|
||||
|
||||
#define __warn_references(sym,msg) \
|
||||
__asm(".stabs msg,30,0,0,0"); \
|
||||
__asm(".stabs \"_/**/sym\",1,0,0,0");
|
||||
#endif /* __STDC__ */
|
||||
#else /* __GNUC__ */
|
||||
#define __warn_references(sym,msg)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#if defined(__sh__) /* XXX SH COFF */
|
||||
#undef __indr_reference(sym,alias)
|
||||
#undef __warn_references(sym,msg)
|
||||
#define __warn_references(sym,msg)
|
||||
#endif
|
||||
|
||||
#define __IDSTRING(_n,_s) \
|
||||
__asm(".data ; .asciz \"" _s "\" ; .text")
|
||||
|
||||
#undef __KERNEL_RCSID
|
||||
|
||||
#define __RCSID(_s) __IDSTRING(rcsid,_s)
|
||||
#define __SCCSID(_s)
|
||||
#define __SCCSID2(_s)
|
||||
#if 0 /* XXX userland __COPYRIGHTs have \ns in them */
|
||||
#define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
|
||||
#else
|
||||
#define __COPYRIGHT(_s) \
|
||||
static const char copyright[] __attribute__((__unused__)) = _s
|
||||
#endif
|
||||
|
||||
#if defined(USE_KERNEL_RCSIDS) || !defined(_KERNEL)
|
||||
#define __KERNEL_RCSID(_n,_s) __IDSTRING(__CONCAT(rcsid,_n),_s)
|
||||
#else
|
||||
#define __KERNEL_RCSID(_n,_s)
|
||||
#endif
|
||||
#define __KERNEL_SCCSID(_n,_s)
|
||||
#define __KERNEL_COPYRIGHT(_n, _s) __IDSTRING(__CONCAT(copyright,_n),_s)
|
||||
|
||||
#ifndef __lint__
|
||||
#define __link_set_make_entry(set, sym, type) \
|
||||
static void const * const \
|
||||
__link_set_##set##_sym_##sym __used = &sym; \
|
||||
__asm(".stabs \"___link_set_" #set "\", " #type ", 0, 0, _" #sym)
|
||||
#else
|
||||
#define __link_set_make_entry(set, sym, type) \
|
||||
extern void const * const __link_set_##set##_sym_##sym
|
||||
#endif /* __lint__ */
|
||||
|
||||
#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym, 23)
|
||||
#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym, 23)
|
||||
#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym, 25)
|
||||
#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym, 27)
|
||||
|
||||
#ifdef __minix
|
||||
/* GNU binutils 2.x doesn't support a.out link sets. We need to workaround
|
||||
* this by explicitely creating the N_SETV structure. */
|
||||
#define __link_set_decl(set, ptype)
|
||||
#else
|
||||
#define __link_set_decl(set, ptype) \
|
||||
extern struct { \
|
||||
int __ls_length; \
|
||||
ptype *__ls_items[1]; \
|
||||
} __link_set_##set
|
||||
#endif /* !__minix */
|
||||
|
||||
#define __link_set_start(set) (&(__link_set_##set).__ls_items[0])
|
||||
#define __link_set_end(set) \
|
||||
(&(__link_set_##set).__ls_items[(__link_set_##set).__ls_length])
|
||||
|
||||
#define __link_set_count(set) ((__link_set_##set).__ls_length)
|
||||
|
||||
#endif /* !_SYS_CDEFS_AOUT_H_ */
|
||||
56
nbsd_include/sys/ctype_bits.h
Normal file
56
nbsd_include/sys/ctype_bits.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* $NetBSD: ctype_bits.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ctype.h 5.3 (Berkeley) 4/3/91
|
||||
* NetBSD: ctype.h,v 1.30 2010/05/22 06:38:15 tnozaki Exp
|
||||
*/
|
||||
|
||||
#ifndef _SYS_CTYPE_BITS_H_
|
||||
#define _SYS_CTYPE_BITS_H_
|
||||
|
||||
#define _CTYPE_U 0x01
|
||||
#define _CTYPE_L 0x02
|
||||
#define _CTYPE_N 0x04
|
||||
#define _CTYPE_S 0x08
|
||||
#define _CTYPE_P 0x10
|
||||
#define _CTYPE_C 0x20
|
||||
#define _CTYPE_X 0x40
|
||||
#define _CTYPE_B 0x80
|
||||
|
||||
extern const unsigned char *_ctype_;
|
||||
extern const short *_tolower_tab_;
|
||||
extern const short *_toupper_tab_;
|
||||
|
||||
#endif /* !_SYS_CTYPE_BITS_H_ */
|
||||
82
nbsd_include/sys/ctype_inline.h
Normal file
82
nbsd_include/sys/ctype_inline.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* $NetBSD: ctype_inline.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ctype.h 5.3 (Berkeley) 4/3/91
|
||||
* NetBSD: ctype.h,v 1.30 2010/05/22 06:38:15 tnozaki Exp
|
||||
*/
|
||||
|
||||
#ifndef _CTYPE_INLINE_H_
|
||||
#define _CTYPE_INLINE_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#include <sys/ctype_bits.h>
|
||||
|
||||
#define isdigit(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_N))
|
||||
#define islower(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_L))
|
||||
#define isspace(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_S))
|
||||
#define ispunct(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_P))
|
||||
#define isupper(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_U))
|
||||
#define isalpha(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_U|_CTYPE_L)))
|
||||
#define isxdigit(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_N|_CTYPE_X)))
|
||||
#define isalnum(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_U|_CTYPE_L|_CTYPE_N)))
|
||||
#define isprint(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)))
|
||||
#define isgraph(c) ((int)((_ctype_ + 1)[(c)] & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N)))
|
||||
#define iscntrl(c) ((int)((_ctype_ + 1)[(c)] & _CTYPE_C))
|
||||
#define tolower(c) ((int)((_tolower_tab_ + 1)[(c)]))
|
||||
#define toupper(c) ((int)((_toupper_tab_ + 1)[(c)]))
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#define isascii(c) ((unsigned)(c) <= 0177)
|
||||
#define toascii(c) ((c) & 0177)
|
||||
#define _tolower(c) ((c) - 'A' + 'a')
|
||||
#define _toupper(c) ((c) - 'a' + 'A')
|
||||
#endif
|
||||
|
||||
#if defined(_ISO_C99_SOURCE) || (_POSIX_C_SOURCE - 0) > 200112L || \
|
||||
(_XOPEN_SOURCE - 0) > 600 || defined(_NETBSD_SOURCE)
|
||||
|
||||
/*
|
||||
* isblank() is implemented as C function, due to insufficient bitwidth in
|
||||
* _ctype_. Note that _B does not mean isblank - it means isprint && !isgraph.
|
||||
*/
|
||||
#if 0
|
||||
#define isblank(c) ((int)((_ctype_ + 1)[(c)] & _B))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_CTYPE_INLINE_H_ */
|
||||
66
nbsd_include/sys/dirent.h
Normal file
66
nbsd_include/sys/dirent.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef _SYS_DIRENT_H_
|
||||
#define _SYS_DIRENT_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/* Redefine d_ino here. */
|
||||
#define d_ino d_fileno
|
||||
|
||||
/*
|
||||
* The dirent structure defines the format of directory entries returned by
|
||||
* the getdents(2) system call.
|
||||
*/
|
||||
|
||||
struct dirent { /* Largest entry (8 slots) */
|
||||
ino_t d_ino; /* I-node number */
|
||||
off_t d_off; /* Offset in directory */
|
||||
unsigned short d_reclen; /* Length of this record */
|
||||
char d_name[1]; /* Null terminated name */
|
||||
};
|
||||
|
||||
#define _DIRENT_NAME_LEN 61 /* Backward compatibility with Minix. */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define MAXNAMLEN _DIRENT_NAME_LEN
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The _DIRENT_ALIGN macro returns the alignment of struct dirent. It
|
||||
* is used to check for bogus pointers and to calculate in advance the
|
||||
* memory required to store a dirent.
|
||||
* Unfortunately Minix doesn't use any standard alignment in dirents
|
||||
* at the moment, so, in order to calculate a safe dirent size, we add
|
||||
* an arbitrary number of bytes to the structure (_DIRENT_PAD), and we
|
||||
* set _DIRENT_ALIGN to zero to pass the pointers checks.
|
||||
* Please, FIXME.
|
||||
*/
|
||||
#define _DIRENT_ALIGN(dp) 0
|
||||
#define _DIRENT_PAD 64
|
||||
/*
|
||||
* The _DIRENT_NAMEOFF macro returns the offset of the d_name field in
|
||||
* struct dirent
|
||||
*/
|
||||
#define _DIRENT_NAMEOFF(dp) \
|
||||
((char *)(void *)&(dp)->d_name - (char *)(void *)dp)
|
||||
/*
|
||||
* The _DIRENT_RECLEN macro gives the minimum record length which will hold
|
||||
* a name of size "namlen".
|
||||
*/
|
||||
#define _DIRENT_RECLEN(dp, namlen) \
|
||||
((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_PAD + _DIRENT_ALIGN(dp)) & \
|
||||
~_DIRENT_ALIGN(dp))
|
||||
/*
|
||||
* The _DIRENT_SIZE macro returns the minimum record length required for
|
||||
* name name stored in the current record.
|
||||
*/
|
||||
#define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, strlen(dp->d_name))
|
||||
/*
|
||||
* The _DIRENT_NEXT macro advances to the next dirent record.
|
||||
*/
|
||||
#define _DIRENT_NEXT(dp) ((void *)((char *)(void *)(dp) + (dp)->d_reclen))
|
||||
/*
|
||||
* The _DIRENT_MINSIZE returns the size of an empty (invalid) record.
|
||||
*/
|
||||
#define _DIRENT_MINSIZE(dp) _DIRENT_RECLEN(dp, 0)
|
||||
|
||||
#endif /* !_SYS_DIRENT_H_ */
|
||||
340
nbsd_include/sys/endian.h
Normal file
340
nbsd_include/sys/endian.h
Normal file
@@ -0,0 +1,340 @@
|
||||
/* $NetBSD: endian.h,v 1.28 2009/08/08 21:23:15 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1991, 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.
|
||||
*
|
||||
* @(#)endian.h 8.1 (Berkeley) 6/11/93
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ENDIAN_H_
|
||||
#define _SYS_ENDIAN_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/*
|
||||
* Definitions for byte order, according to byte significance from low
|
||||
* address to high.
|
||||
*/
|
||||
#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
|
||||
#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
|
||||
#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
|
||||
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#ifndef _LOCORE
|
||||
|
||||
/* C-family endian-ness definitions */
|
||||
|
||||
#include <sys/ansi.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef in_addr_t
|
||||
typedef __in_addr_t in_addr_t;
|
||||
#define in_addr_t __in_addr_t
|
||||
#endif
|
||||
|
||||
#ifndef in_port_t
|
||||
typedef __in_port_t in_port_t;
|
||||
#define in_port_t __in_port_t
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
uint32_t htonl(uint32_t) __constfunc;
|
||||
uint16_t htons(uint16_t) __constfunc;
|
||||
uint32_t ntohl(uint32_t) __constfunc;
|
||||
uint16_t ntohs(uint16_t) __constfunc;
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_LOCORE */
|
||||
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
|
||||
|
||||
#include <machine/endian_machdep.h>
|
||||
|
||||
/*
|
||||
* Define the order of 32-bit words in 64-bit words.
|
||||
*/
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define _QUAD_HIGHWORD 1
|
||||
#define _QUAD_LOWWORD 0
|
||||
#endif
|
||||
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define _QUAD_HIGHWORD 0
|
||||
#define _QUAD_LOWWORD 1
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
/*
|
||||
* Traditional names for byteorder. These are defined as the numeric
|
||||
* sequences so that third party code can "#define XXX_ENDIAN" and not
|
||||
* cause errors.
|
||||
*/
|
||||
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
|
||||
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
|
||||
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
|
||||
#define BYTE_ORDER _BYTE_ORDER
|
||||
|
||||
#ifndef _LOCORE
|
||||
|
||||
#include <machine/bswap.h>
|
||||
|
||||
/*
|
||||
* Macros for network/external number representation conversion.
|
||||
*/
|
||||
#if BYTE_ORDER == BIG_ENDIAN && !defined(__lint__)
|
||||
#define ntohl(x) (x)
|
||||
#define ntohs(x) (x)
|
||||
#define htonl(x) (x)
|
||||
#define htons(x) (x)
|
||||
|
||||
#define NTOHL(x) (void) (x)
|
||||
#define NTOHS(x) (void) (x)
|
||||
#define HTONL(x) (void) (x)
|
||||
#define HTONS(x) (void) (x)
|
||||
|
||||
#else /* LITTLE_ENDIAN || !defined(__lint__) */
|
||||
|
||||
#define ntohl(x) bswap32(__CAST(uint32_t, (x)))
|
||||
#define ntohs(x) bswap16(__CAST(uint16_t, (x)))
|
||||
#define htonl(x) bswap32(__CAST(uint32_t, (x)))
|
||||
#define htons(x) bswap16(__CAST(uint16_t, (x)))
|
||||
|
||||
#define NTOHL(x) (x) = ntohl(__CAST(uint32_t, (x)))
|
||||
#define NTOHS(x) (x) = ntohs(__CAST(uint16_t, (x)))
|
||||
#define HTONL(x) (x) = htonl(__CAST(uint32_t, (x)))
|
||||
#define HTONS(x) (x) = htons(__CAST(uint16_t, (x)))
|
||||
#endif /* LITTLE_ENDIAN || !defined(__lint__) */
|
||||
|
||||
/*
|
||||
* Macros to convert to a specific endianness.
|
||||
*/
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
|
||||
#define htobe16(x) (x)
|
||||
#define htobe32(x) (x)
|
||||
#define htobe64(x) (x)
|
||||
#define htole16(x) bswap16(__CAST(uint16_t, (x)))
|
||||
#define htole32(x) bswap32(__CAST(uint32_t, (x)))
|
||||
#define htole64(x) bswap64(__CAST(uint64_t, (x)))
|
||||
|
||||
#define HTOBE16(x) __CAST(void, (x))
|
||||
#define HTOBE32(x) __CAST(void, (x))
|
||||
#define HTOBE64(x) __CAST(void, (x))
|
||||
#define HTOLE16(x) (x) = bswap16(__CAST(uint16_t, (x)))
|
||||
#define HTOLE32(x) (x) = bswap32(__CAST(uint32_t, (x)))
|
||||
#define HTOLE64(x) (x) = bswap64(__CAST(uint64_t, (x)))
|
||||
|
||||
#else /* LITTLE_ENDIAN */
|
||||
|
||||
#define htobe16(x) bswap16(__CAST(uint16_t, (x)))
|
||||
#define htobe32(x) bswap32(__CAST(uint32_t, (x)))
|
||||
#define htobe64(x) bswap64(__CAST(uint64_t, (x)))
|
||||
#define htole16(x) (x)
|
||||
#define htole32(x) (x)
|
||||
#define htole64(x) (x)
|
||||
|
||||
#define HTOBE16(x) (x) = bswap16(__CAST(uint16_t, (x)))
|
||||
#define HTOBE32(x) (x) = bswap32(__CAST(uint32_t, (x)))
|
||||
#define HTOBE64(x) (x) = bswap64(__CAST(uint64_t, (x)))
|
||||
#define HTOLE16(x) __CAST(void, (x))
|
||||
#define HTOLE32(x) __CAST(void, (x))
|
||||
#define HTOLE64(x) __CAST(void, (x))
|
||||
|
||||
#endif /* LITTLE_ENDIAN */
|
||||
|
||||
#define be16toh(x) htobe16(x)
|
||||
#define be32toh(x) htobe32(x)
|
||||
#define be64toh(x) htobe64(x)
|
||||
#define le16toh(x) htole16(x)
|
||||
#define le32toh(x) htole32(x)
|
||||
#define le64toh(x) htole64(x)
|
||||
|
||||
#define BE16TOH(x) HTOBE16(x)
|
||||
#define BE32TOH(x) HTOBE32(x)
|
||||
#define BE64TOH(x) HTOBE64(x)
|
||||
#define LE16TOH(x) HTOLE16(x)
|
||||
#define LE32TOH(x) HTOLE32(x)
|
||||
#define LE64TOH(x) HTOLE64(x)
|
||||
|
||||
/*
|
||||
* Routines to encode/decode big- and little-endian multi-octet values
|
||||
* to/from an octet stream.
|
||||
*/
|
||||
|
||||
#if __GNUC_PREREQ__(2, 95)
|
||||
|
||||
#define __GEN_ENDIAN_ENC(bits, endian) \
|
||||
static __inline __unused void \
|
||||
endian ## bits ## enc(void *dst, uint ## bits ## _t u) \
|
||||
{ \
|
||||
u = hto ## endian ## bits (u); \
|
||||
__builtin_memcpy(dst, &u, sizeof(u)); \
|
||||
}
|
||||
|
||||
__GEN_ENDIAN_ENC(16, be)
|
||||
__GEN_ENDIAN_ENC(32, be)
|
||||
__GEN_ENDIAN_ENC(64, be)
|
||||
__GEN_ENDIAN_ENC(16, le)
|
||||
__GEN_ENDIAN_ENC(32, le)
|
||||
__GEN_ENDIAN_ENC(64, le)
|
||||
#undef __GEN_ENDIAN_ENC
|
||||
|
||||
#define __GEN_ENDIAN_DEC(bits, endian) \
|
||||
static __inline __unused uint ## bits ## _t \
|
||||
endian ## bits ## dec(const void *buf) \
|
||||
{ \
|
||||
uint ## bits ## _t u; \
|
||||
__builtin_memcpy(&u, buf, sizeof(u)); \
|
||||
return endian ## bits ## toh (u); \
|
||||
}
|
||||
|
||||
__GEN_ENDIAN_DEC(16, be)
|
||||
__GEN_ENDIAN_DEC(32, be)
|
||||
__GEN_ENDIAN_DEC(64, be)
|
||||
__GEN_ENDIAN_DEC(16, le)
|
||||
__GEN_ENDIAN_DEC(32, le)
|
||||
__GEN_ENDIAN_DEC(64, le)
|
||||
#undef __GEN_ENDIAN_DEC
|
||||
|
||||
#else /* !(GCC >= 2.95) */
|
||||
|
||||
static __inline void __unused
|
||||
be16enc(void *buf, uint16_t u)
|
||||
{
|
||||
uint8_t *p = __CAST(uint8_t *, buf);
|
||||
|
||||
p[0] = __CAST(uint8_t, ((__CAST(unsigned, u) >> 8) & 0xff));
|
||||
p[1] = __CAST(uint8_t, (u & 0xff));
|
||||
}
|
||||
|
||||
static __inline void __unused
|
||||
le16enc(void *buf, uint16_t u)
|
||||
{
|
||||
uint8_t *p = __CAST(uint8_t *, buf);
|
||||
|
||||
p[0] = __CAST(uint8_t, (u & 0xff));
|
||||
p[1] = __CAST(uint8_t, ((__CAST(unsigned, u) >> 8) & 0xff));
|
||||
}
|
||||
|
||||
static __inline uint16_t __unused
|
||||
be16dec(const void *buf)
|
||||
{
|
||||
const uint8_t *p = __CAST(const uint8_t *, buf);
|
||||
|
||||
return __CAST(uint16_t, ((p[0] << 8) | p[1]));
|
||||
}
|
||||
|
||||
static __inline uint16_t __unused
|
||||
le16dec(const void *buf)
|
||||
{
|
||||
const uint8_t *p = __CAST(const uint8_t *, buf);
|
||||
|
||||
return __CAST(uint16_t, ((p[1] << 8) | p[0]));
|
||||
}
|
||||
|
||||
static __inline void __unused
|
||||
be32enc(void *buf, uint32_t u)
|
||||
{
|
||||
uint8_t *p = __CAST(uint8_t *, buf);
|
||||
|
||||
p[0] = __CAST(uint8_t, ((u >> 24) & 0xff));
|
||||
p[1] = __CAST(uint8_t, ((u >> 16) & 0xff));
|
||||
p[2] = __CAST(uint8_t, ((u >> 8) & 0xff));
|
||||
p[3] = __CAST(uint8_t, (u & 0xff));
|
||||
}
|
||||
|
||||
static __inline void __unused
|
||||
le32enc(void *buf, uint32_t u)
|
||||
{
|
||||
uint8_t *p = __CAST(uint8_t *, buf);
|
||||
|
||||
p[0] = __CAST(uint8_t, (u & 0xff));
|
||||
p[1] = __CAST(uint8_t, ((u >> 8) & 0xff));
|
||||
p[2] = __CAST(uint8_t, ((u >> 16) & 0xff));
|
||||
p[3] = __CAST(uint8_t, ((u >> 24) & 0xff));
|
||||
}
|
||||
|
||||
static __inline uint32_t __unused
|
||||
be32dec(const void *buf)
|
||||
{
|
||||
const uint8_t *p = __CAST(const uint8_t *, buf);
|
||||
|
||||
return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
}
|
||||
|
||||
static __inline uint32_t __unused
|
||||
le32dec(const void *buf)
|
||||
{
|
||||
const uint8_t *p = __CAST(const uint8_t *, buf);
|
||||
|
||||
return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
||||
}
|
||||
|
||||
static __inline void __unused
|
||||
be64enc(void *buf, uint64_t u)
|
||||
{
|
||||
uint8_t *p = __CAST(uint8_t *, buf);
|
||||
|
||||
be32enc(p, __CAST(uint32_t, (u >> 32)));
|
||||
be32enc(p + 4, __CAST(uint32_t, (u & 0xffffffffULL)));
|
||||
}
|
||||
|
||||
static __inline void __unused
|
||||
le64enc(void *buf, uint64_t u)
|
||||
{
|
||||
uint8_t *p = __CAST(uint8_t *, buf);
|
||||
|
||||
le32enc(p, __CAST(uint32_t, (u & 0xffffffffULL)));
|
||||
le32enc(p + 4, __CAST(uint32_t, (u >> 32)));
|
||||
}
|
||||
|
||||
static __inline uint64_t __unused
|
||||
be64dec(const void *buf)
|
||||
{
|
||||
const uint8_t *p = (const uint8_t *)buf;
|
||||
|
||||
return ((__CAST(uint64_t, be32dec(p)) << 32) | be32dec(p + 4));
|
||||
}
|
||||
|
||||
static __inline uint64_t __unused
|
||||
le64dec(const void *buf)
|
||||
{
|
||||
const uint8_t *p = (const uint8_t *)buf;
|
||||
|
||||
return (le32dec(p) | (__CAST(uint64_t, le32dec(p + 4)) << 32));
|
||||
}
|
||||
|
||||
#endif /* GCC >= 2.95 */
|
||||
|
||||
#endif /* !_LOCORE */
|
||||
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
#endif /* !_SYS_ENDIAN_H_ */
|
||||
173
nbsd_include/sys/errno.h
Normal file
173
nbsd_include/sys/errno.h
Normal file
@@ -0,0 +1,173 @@
|
||||
/* The <errno.h> header defines the numbers of the various errors that can
|
||||
* occur during program execution. They are visible to user programs and
|
||||
* should be small positive integers. However, they are also used within
|
||||
* MINIX, where they must be negative. For example, the READ system call is
|
||||
* executed internally by calling do_read(). This function returns either a
|
||||
* (negative) error number or a (positive) number of bytes actually read.
|
||||
*
|
||||
* To solve the problem of having the error numbers be negative inside the
|
||||
* the system and positive outside, the following mechanism is used. All the
|
||||
* definitions are are the form:
|
||||
*
|
||||
* <define> EPERM (_SIGN 1 )
|
||||
*
|
||||
* If the macro _SYSTEM is defined, then _SIGN is set to "-", otherwise it is
|
||||
* set to "". Thus when compiling the operating system, the macro _SYSTEM
|
||||
* will be defined, setting EPERM to (- 1), whereas when when this
|
||||
* file is included in an ordinary user program, EPERM has the value ( 1).
|
||||
*/
|
||||
|
||||
#ifndef _ERRNO_H /* check if <errno.h> is already included */
|
||||
# define _ERRNO_H /* it is not included; note that fact */
|
||||
|
||||
/* Now define _SIGN as "" or "-" depending on _SYSTEM. */
|
||||
#ifdef _SYSTEM
|
||||
# define _SIGN -
|
||||
# define OK 0
|
||||
#else
|
||||
# define _SIGN
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define EGENERIC (_SIGN 99 ) /* generic error */
|
||||
#define EPERM (_SIGN 1 ) /* operation not permitted */
|
||||
#define ENOENT (_SIGN 2 ) /* no such file or directory */
|
||||
#define ESRCH (_SIGN 3 ) /* no such process */
|
||||
#define EINTR (_SIGN 4 ) /* interrupted function call */
|
||||
#define EIO (_SIGN 5 ) /* input/output error */
|
||||
#define ENXIO (_SIGN 6 ) /* no such device or address */
|
||||
#define E2BIG (_SIGN 7 ) /* arg list too long */
|
||||
#define ENOEXEC (_SIGN 8 ) /* exec format error */
|
||||
#define EBADF (_SIGN 9 ) /* bad file descriptor */
|
||||
#define ECHILD (_SIGN 10 ) /* no child process */
|
||||
#define EAGAIN (_SIGN 11 ) /* resource temporarily unavailable */
|
||||
#define ENOMEM (_SIGN 12 ) /* not enough space */
|
||||
#define EACCES (_SIGN 13 ) /* permission denied */
|
||||
#define EFAULT (_SIGN 14 ) /* bad address */
|
||||
#define ENOTBLK (_SIGN 15 ) /* Extension: not a block special file */
|
||||
#define EBUSY (_SIGN 16 ) /* resource busy */
|
||||
#define EEXIST (_SIGN 17 ) /* file exists */
|
||||
#define EXDEV (_SIGN 18 ) /* improper link */
|
||||
#define ENODEV (_SIGN 19 ) /* no such device */
|
||||
#define ENOTDIR (_SIGN 20 ) /* not a directory */
|
||||
#define EISDIR (_SIGN 21 ) /* is a directory */
|
||||
#define EINVAL (_SIGN 22 ) /* invalid argument */
|
||||
#define ENFILE (_SIGN 23 ) /* too many open files in system */
|
||||
#define EMFILE (_SIGN 24 ) /* too many open files */
|
||||
#define ENOTTY (_SIGN 25 ) /* inappropriate I/O control operation */
|
||||
#define ETXTBSY (_SIGN 26 ) /* no longer used */
|
||||
#define EFBIG (_SIGN 27 ) /* file too large */
|
||||
#define ENOSPC (_SIGN 28 ) /* no space left on device */
|
||||
#define ESPIPE (_SIGN 29 ) /* invalid seek */
|
||||
#define EROFS (_SIGN 30 ) /* read-only file system */
|
||||
#define EMLINK (_SIGN 31 ) /* too many links */
|
||||
#define EPIPE (_SIGN 32 ) /* broken pipe */
|
||||
#define EDOM (_SIGN 33 ) /* domain error (from ANSI C std ) */
|
||||
#define ERANGE (_SIGN 34 ) /* result too large (from ANSI C std ) */
|
||||
#define EDEADLK (_SIGN 35 ) /* resource deadlock avoided */
|
||||
#define ENAMETOOLONG (_SIGN 36 ) /* file name too long */
|
||||
#define ENOLCK (_SIGN 37 ) /* no locks available */
|
||||
#define ENOSYS (_SIGN 38 ) /* function not implemented */
|
||||
#define ENOTEMPTY (_SIGN 39 ) /* directory not empty */
|
||||
#define ELOOP (_SIGN 40 ) /* too many levels of symlinks detected */
|
||||
#define ERESTART (_SIGN 41 ) /* service restarted */
|
||||
#define EIDRM (_SIGN 43 ) /* Identifier removed */
|
||||
#define EILSEQ (_SIGN 44 ) /* illegal byte sequence */
|
||||
#define ENOMSG (_SIGN 45 ) /* No message of desired type */
|
||||
#define EOVERFLOW (_SIGN 46 ) /* Value too large to be stored in data type */
|
||||
|
||||
/* The following errors relate to networking. */
|
||||
#define EPACKSIZE (_SIGN 50 ) /* invalid packet size for some protocol */
|
||||
#define ENOBUFS (_SIGN 51 ) /* not enough buffers left */
|
||||
#define EBADIOCTL (_SIGN 52 ) /* illegal ioctl for device */
|
||||
#define EBADMODE (_SIGN 53 ) /* badmode in ioctl */
|
||||
#define EWOULDBLOCK (_SIGN 54 ) /* call would block on nonblocking socket */
|
||||
#define ENETUNREACH (_SIGN 55 ) /* network unreachable */
|
||||
#define EHOSTUNREACH (_SIGN 56 ) /* host unreachable */
|
||||
#define EISCONN (_SIGN 57 ) /* already connected */
|
||||
#define EADDRINUSE (_SIGN 58 ) /* address in use */
|
||||
#define ECONNREFUSED (_SIGN 59 ) /* connection refused */
|
||||
#define ECONNRESET (_SIGN 60 ) /* connection reset */
|
||||
#define ETIMEDOUT (_SIGN 61 ) /* connection timed out */
|
||||
#define EURG (_SIGN 62 ) /* urgent data present */
|
||||
#define ENOURG (_SIGN 63 ) /* no urgent data present */
|
||||
#define ENOTCONN (_SIGN 64 ) /* no connection (yet or anymore ) */
|
||||
#define ESHUTDOWN (_SIGN 65 ) /* a write call to a shutdown connection */
|
||||
#define ENOCONN (_SIGN 66 ) /* no such connection */
|
||||
#define EAFNOSUPPORT (_SIGN 67 ) /* address family not supported */
|
||||
#define EPROTONOSUPPORT (_SIGN 68 ) /* protocol not supported by AF */
|
||||
#define EPROTOTYPE (_SIGN 69 ) /* Protocol wrong type for socket */
|
||||
#define EINPROGRESS (_SIGN 70 ) /* Operation now in progress */
|
||||
#define EADDRNOTAVAIL (_SIGN 71 ) /* Can't assign requested address */
|
||||
#define EALREADY (_SIGN 72 ) /* Connection already in progress */
|
||||
#define EMSGSIZE (_SIGN 73 ) /* Message too long */
|
||||
#define ENOTSOCK (_SIGN 74 ) /* Socket operation on non-socket */
|
||||
#define ENOPROTOOPT (_SIGN 75 ) /* Protocol not available */
|
||||
#define EOPNOTSUPP (_SIGN 76 ) /* Operation not supported */
|
||||
#define ENOTSUP EOPNOTSUPP /* Not supported */
|
||||
#define ENETDOWN (_SIGN 77 ) /* network is down */
|
||||
#define ECONNABORTED (_SIGN 78 ) /* Software caused connection abort */
|
||||
#define EDESTADDRREQ (_SIGN 79 ) /* Destination address required */
|
||||
#define EHOSTDOWN (_SIGN 80 ) /* Host is down */
|
||||
#define ENETRESET (_SIGN 81 ) /* Network dropped connection on reset */
|
||||
#define ESOCKTNOSUPPORT (_SIGN 82 ) /* Socket type not supported */
|
||||
#define EPFNOSUPPORT (_SIGN 83 ) /* Protocol family not supported */
|
||||
#define ETOOMANYREFS (_SIGN 84 ) /* Too many references: can't splice */
|
||||
|
||||
/* The following are not POSIX errors, but they can still happen.
|
||||
* All of these are generated by the kernel and relate to message passing.
|
||||
*/
|
||||
#define ELOCKED (_SIGN 101 ) /* can't send message due to deadlock */
|
||||
#define EBADCALL (_SIGN 102 ) /* illegal system call number */
|
||||
#define EBADSRCDST (_SIGN 103 ) /* bad source or destination process */
|
||||
#define ECALLDENIED (_SIGN 104 ) /* no permission for system call */
|
||||
#define EDEADSRCDST (_SIGN 105 ) /* source or destination is not alive */
|
||||
#define ENOTREADY (_SIGN 106 ) /* source or destination is not ready */
|
||||
#define EBADREQUEST (_SIGN 107 ) /* destination cannot handle request */
|
||||
#define ETRAPDENIED (_SIGN 110 ) /* IPC trap not allowed */
|
||||
#define EDONTREPLY (_SIGN 201 ) /* pseudo-code: don't send a reply */
|
||||
|
||||
/* The following errors are NetBSD errors. */
|
||||
#define EFTYPE (_SIGN 150 ) /* Inappropriate file type or format */
|
||||
#define EAUTH (_SIGN 151 ) /* Authentication error */
|
||||
#define ENEEDAUTH (_SIGN 152 ) /* Need authenticator */
|
||||
/* Realtime option errors */
|
||||
#define ECANCELED (_SIGN 153 ) /* Operation canceled */
|
||||
|
||||
/* Network File System */
|
||||
#define ESTALE (_SIGN 160 ) /* Stale NFS file handle */
|
||||
#define EREMOTE (_SIGN 161 ) /* Too many levels of remote in path */
|
||||
#define EBADRPC (_SIGN 162 ) /* RPC struct is bad */
|
||||
#define ERPCMISMATCH (_SIGN 163 ) /* RPC version wrong */
|
||||
#define EPROGUNAVAIL (_SIGN 164 ) /* RPC prog. not avail */
|
||||
#define EPROGMISMATCH (_SIGN 165 ) /* Program version wrong */
|
||||
#define EPROCUNAVAIL (_SIGN 166 ) /* Bad procedure for program */
|
||||
|
||||
/* Realtime, XSI STREAMS option errors */
|
||||
#define EBADMSG (_SIGN 170 ) /* Bad or Corrupt message */
|
||||
|
||||
/* quotas & mush */
|
||||
#define EPROCLIM (_SIGN 175 ) /* Too many processes */
|
||||
#define EUSERS (_SIGN 176 ) /* Too many users */
|
||||
#define EDQUOT (_SIGN 177 ) /* Disc quota exceeded */
|
||||
|
||||
/* Realtime, XSI STREAMS option errors */
|
||||
#define EMULTIHOP (_SIGN 180 ) /* Multihop attempted */
|
||||
#define ENOLINK (_SIGN 181 ) /* Link has been severed */
|
||||
#define EPROTO (_SIGN 182 ) /* Protocol error */
|
||||
|
||||
/* File system extended attribute errors */
|
||||
#define ENOATTR (_SIGN 185 ) /* Attribute not found */
|
||||
|
||||
/* XSI STREAMS option errors */
|
||||
#define ENODATA (_SIGN 190 ) /* No message available */
|
||||
#define ENOSR (_SIGN 191 ) /* No STREAM resources */
|
||||
#define ENOSTR (_SIGN 192 ) /* Not a STREAM */
|
||||
#define ETIME (_SIGN 193 ) /* STREAM ioctl timeout */
|
||||
|
||||
#define ELAST EDONTREPLY /* Must equal largest errno */
|
||||
|
||||
/* Here are the numerical values of the error numbers. */
|
||||
#define _NERROR 201 /* number of errors */
|
||||
#endif /* _ERRNO_H */
|
||||
137
nbsd_include/sys/fcntl.h
Normal file
137
nbsd_include/sys/fcntl.h
Normal file
@@ -0,0 +1,137 @@
|
||||
#ifndef _SYS_FCNTL_H_
|
||||
#define _SYS_FCNTL_H_
|
||||
|
||||
/*
|
||||
* This file includes the definitions for open and fcntl
|
||||
* described by POSIX for <fcntl.h>.
|
||||
*/
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#include <sys/stat.h>
|
||||
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
|
||||
/*
|
||||
* File status flags: these are used by open(2), fcntl(2).
|
||||
* They are also used (indirectly) in the kernel file structure f_flags,
|
||||
* which is a superset of the open/fcntl flags. Open flags and f_flags
|
||||
* are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
|
||||
* Open/fcntl flags begin with O_; kernel-internal flags begin with F.
|
||||
*/
|
||||
/* open-only flags */
|
||||
#define O_RDONLY 0x00000000 /* open for reading only */
|
||||
#define O_WRONLY 0x00000001 /* open for writing only */
|
||||
#define O_RDWR 0x00000002 /* open for reading and writing */
|
||||
#define O_ACCMODE 0x00000003 /* mask for above modes */
|
||||
|
||||
/* File status flags for open() and fcntl(). POSIX Table 6-5. */
|
||||
#define O_APPEND 02000 /* set append mode */
|
||||
#define O_NONBLOCK 04000 /* no delay */
|
||||
#define O_REOPEN 010000 /* automatically re-open device after driver
|
||||
* restart
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __minix /* NOT SUPPORTED! */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define O_SHLOCK 0x00000010 /* open with shared file lock */
|
||||
#define O_EXLOCK 0x00000020 /* open with exclusive file lock */
|
||||
#define O_ASYNC 0x00000040 /* signal pgrp when data ready */
|
||||
#endif
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || \
|
||||
(defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
||||
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
#define O_SYNC 0x00000080 /* synchronous writes */
|
||||
#endif
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define O_NOFOLLOW 0x00000100 /* don't follow symlinks on the last */
|
||||
/* path component */
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
/* Oflag values for open(). POSIX Table 6-4. */
|
||||
#define O_CREAT 00100 /* creat file if it doesn't exist */
|
||||
#define O_EXCL 00200 /* exclusive use flag */
|
||||
#define O_NOCTTY 00400 /* do not assign a controlling terminal */
|
||||
#define O_TRUNC 01000 /* truncate flag */
|
||||
|
||||
#ifndef __minix /* NOT SUPPORTED! */
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define O_DSYNC 0x00010000 /* write: I/O data completion */
|
||||
#define O_RSYNC 0x00020000 /* read: I/O completion as for write */
|
||||
#endif
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define O_ALT_IO 0x00040000 /* use alternate i/o semantics */
|
||||
#define O_DIRECT 0x00080000 /* direct I/O hint */
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
/*
|
||||
* Constants used for fcntl(2)
|
||||
*/
|
||||
|
||||
/* command values */
|
||||
/* These values are used for cmd in fcntl(). POSIX Table 6-1. */
|
||||
#define F_DUPFD 0 /* duplicate file descriptor */
|
||||
#define F_GETFD 1 /* get file descriptor flags */
|
||||
#define F_SETFD 2 /* set file descriptor flags */
|
||||
#define F_GETFL 3 /* get file status flags */
|
||||
#define F_SETFL 4 /* set file status flags */
|
||||
#define F_GETLK 5 /* get record locking information */
|
||||
#define F_SETLK 6 /* set record locking information */
|
||||
#define F_SETLKW 7 /* set record locking info; wait if blocked */
|
||||
#define F_FREESP 8 /* free a section of a regular file */
|
||||
|
||||
/* File descriptor flags used for fcntl(). POSIX Table 6-2. */
|
||||
#define FD_CLOEXEC 1 /* close on exec flag for third arg of fcntl */
|
||||
|
||||
/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
|
||||
#define F_RDLCK 1 /* shared or read lock */
|
||||
#define F_WRLCK 2 /* exclusive or write lock */
|
||||
#define F_UNLCK 3 /* unlock */
|
||||
|
||||
/*
|
||||
* Advisory file segment locking data type -
|
||||
* information passed to system by user
|
||||
*/
|
||||
struct flock {
|
||||
short l_type; /* type: F_RDLCK, F_WRLCK, or F_UNLCK */
|
||||
short l_whence; /* flag for starting offset */
|
||||
off_t l_start; /* relative offset in bytes */
|
||||
off_t l_len; /* size; if 0, then until EOF */
|
||||
pid_t l_pid; /* process id of the locks' owner */
|
||||
};
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
/* lock operations for flock(2) */
|
||||
#define LOCK_SH F_RDLCK /* Shared lock */
|
||||
#define LOCK_EX F_WRLCK /* Exclusive lock */
|
||||
#define LOCK_NB 0x0080 /* Do not block when locking */
|
||||
#define LOCK_UN F_UNLCK /* Unlock */
|
||||
#endif
|
||||
|
||||
/* Always ensure that these are consistent with <stdio.h> and <unistd.h>! */
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0 /* set file offset to offset */
|
||||
#endif
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
||||
#endif
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int open(const char *, int, ...);
|
||||
int creat(const char *, mode_t);
|
||||
int fcntl(int, int, ...);
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
int flock(int, int);
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_FCNTL_H_ */
|
||||
108
nbsd_include/sys/fd_set.h
Normal file
108
nbsd_include/sys/fd_set.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $NetBSD: fd_set.h,v 1.2 2005/12/11 12:25:20 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 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.
|
||||
*
|
||||
* from: @(#)types.h 8.4 (Berkeley) 1/21/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_FD_SET_H_
|
||||
#define _SYS_FD_SET_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
#include <machine/int_types.h>
|
||||
|
||||
/*
|
||||
* Implementation dependent defines, hidden from user space. X/Open does not
|
||||
* specify them.
|
||||
*/
|
||||
#define __NBBY 8 /* number of bits in a byte */
|
||||
typedef __int32_t __fd_mask;
|
||||
|
||||
/* bits per mask */
|
||||
#define __NFDBITS ((unsigned int)sizeof(__fd_mask) * __NBBY)
|
||||
|
||||
#define __howmany(x, y) (((x) + ((y) - 1)) / (y))
|
||||
|
||||
/*
|
||||
* Select uses bit masks of file descriptors in longs. These macros
|
||||
* manipulate such bit fields (the filesystem macros use chars).
|
||||
* FD_SETSIZE may be defined by the user, but the default here should
|
||||
* be enough for most uses.
|
||||
*/
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 256
|
||||
#endif
|
||||
|
||||
typedef struct fd_set {
|
||||
__fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)];
|
||||
} fd_set;
|
||||
|
||||
#define FD_SET(n, p) \
|
||||
((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS)))
|
||||
#define FD_CLR(n, p) \
|
||||
((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS)))
|
||||
#define FD_ISSET(n, p) \
|
||||
((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS)))
|
||||
#if __GNUC_PREREQ__(2, 95)
|
||||
#define FD_ZERO(p) (void)__builtin_memset((p), 0, sizeof(*(p)))
|
||||
#else
|
||||
#define FD_ZERO(p) do { \
|
||||
fd_set *__fds = (p); \
|
||||
unsigned int __i; \
|
||||
for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++) \
|
||||
__fds->fds_bits[__i] = 0; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#endif /* GCC 2.95 */
|
||||
|
||||
/*
|
||||
* Expose our internals if we are not required to hide them.
|
||||
*/
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
|
||||
#define fd_mask __fd_mask
|
||||
#define NFDBITS __NFDBITS
|
||||
#ifndef howmany
|
||||
#define howmany(a, b) __howmany(a, b)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(2, 95)
|
||||
#define FD_COPY(f, t) (void)__builtin_memcpy((t), (f), sizeof(*(f)))
|
||||
#else
|
||||
#define FD_COPY(f, t) do { \
|
||||
fd_set *__f = (f), *__t = (t); \
|
||||
unsigned int __i; \
|
||||
for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++) \
|
||||
__t->fds_bits[__i] = __f->fds_bits[__i]; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#endif /* GCC 2.95 */
|
||||
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
#endif /* _SYS_FD_SET_H_ */
|
||||
81
nbsd_include/sys/featuretest.h
Normal file
81
nbsd_include/sys/featuretest.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* $NetBSD: featuretest.h,v 1.9 2009/05/04 16:44:14 ginsbach Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Klaus Klein <kleink@NetBSD.org>, February 2, 1998.
|
||||
* Public domain.
|
||||
*
|
||||
* NOTE: Do not protect this header against multiple inclusion. Doing
|
||||
* so can have subtle side-effects due to header file inclusion order
|
||||
* and testing of e.g. _POSIX_SOURCE vs. _POSIX_C_SOURCE. Instead,
|
||||
* protect each CPP macro that we want to supply.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Feature-test macros are defined by several standards, and allow an
|
||||
* application to specify what symbols they want the system headers to
|
||||
* expose, and hence what standard they want them to conform to.
|
||||
* There are two classes of feature-test macros. The first class
|
||||
* specify complete standards, and if one of these is defined, header
|
||||
* files will try to conform to the relevant standard. They are:
|
||||
*
|
||||
* ANSI macros:
|
||||
* _ANSI_SOURCE ANSI C89
|
||||
*
|
||||
* POSIX macros:
|
||||
* _POSIX_SOURCE == 1 IEEE Std 1003.1 (version?)
|
||||
* _POSIX_C_SOURCE == 1 IEEE Std 1003.1-1990
|
||||
* _POSIX_C_SOURCE == 2 IEEE Std 1003.2-1992
|
||||
* _POSIX_C_SOURCE == 199309L IEEE Std 1003.1b-1993
|
||||
* _POSIX_C_SOURCE == 199506L ISO/IEC 9945-1:1996
|
||||
* _POSIX_C_SOURCE == 200112L IEEE Std 1003.1-2001
|
||||
* _POSIX_C_SOURCE == 200809L IEEE Std 1003.1-2008
|
||||
*
|
||||
* X/Open macros:
|
||||
* _XOPEN_SOURCE System Interfaces and Headers, Issue 4, Ver 2
|
||||
* _XOPEN_SOURCE_EXTENDED == 1 XSH4.2 UNIX extensions
|
||||
* _XOPEN_SOURCE == 500 System Interfaces and Headers, Issue 5
|
||||
* _XOPEN_SOURCE == 520 Networking Services (XNS), Issue 5.2
|
||||
* _XOPEN_SOURCE == 600 IEEE Std 1003.1-2001, XSI option
|
||||
* _XOPEN_SOURCE == 700 IEEE Std 1003.1-2008, XSI option
|
||||
*
|
||||
* NetBSD macros:
|
||||
* _NETBSD_SOURCE == 1 Make all NetBSD features available.
|
||||
*
|
||||
* If more than one of these "major" feature-test macros is defined,
|
||||
* then the set of facilities provided (and namespace used) is the
|
||||
* union of that specified by the relevant standards, and in case of
|
||||
* conflict, the earlier standard in the above list has precedence (so
|
||||
* if both _POSIX_C_SOURCE and _NETBSD_SOURCE are defined, the version
|
||||
* of rename() that's used is the POSIX one). If none of the "major"
|
||||
* feature-test macros is defined, _NETBSD_SOURCE is assumed.
|
||||
*
|
||||
* There are also "minor" feature-test macros, which enable extra
|
||||
* functionality in addition to some base standard. They should be
|
||||
* defined along with one of the "major" macros. The "minor" macros
|
||||
* are:
|
||||
*
|
||||
* _REENTRANT
|
||||
* _ISOC99_SOURCE
|
||||
* _LARGEFILE_SOURCE Large File Support
|
||||
* <http://ftp.sas.com/standards/large.file/x_open.20Mar96.html>
|
||||
*/
|
||||
|
||||
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
|
||||
#define _POSIX_C_SOURCE 1L
|
||||
#endif
|
||||
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
||||
!defined(_XOPEN_SOURCE) && !defined(_NETBSD_SOURCE)
|
||||
#define _NETBSD_SOURCE 1
|
||||
#endif
|
||||
|
||||
/* Never define _REENTRANT on Minix */
|
||||
|
||||
#ifdef __minix
|
||||
|
||||
#if ((_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500) && \
|
||||
!defined(_REENTRANT)
|
||||
#define _REENTRANT
|
||||
#endif
|
||||
|
||||
#endif /* __minix */
|
||||
169
nbsd_include/sys/file.h
Normal file
169
nbsd_include/sys/file.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/* $NetBSD: file.h,v 1.71 2009/12/24 19:01:12 elad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Doran.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 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.
|
||||
*
|
||||
* @(#)file.h 8.3 (Berkeley) 1/9/95
|
||||
*/
|
||||
|
||||
#ifndef _SYS_FILE_H_
|
||||
#define _SYS_FILE_H_
|
||||
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/unistd.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/mallocvar.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/condvar.h>
|
||||
|
||||
struct proc;
|
||||
struct lwp;
|
||||
struct uio;
|
||||
struct iovec;
|
||||
struct stat;
|
||||
struct knote;
|
||||
|
||||
/*
|
||||
* Kernel file descriptor. One entry for each open kernel vnode and
|
||||
* socket.
|
||||
*
|
||||
* This structure is exported via the KERN_FILE and KERN_FILE2 sysctl
|
||||
* calls. Only add members to the end, do not delete them.
|
||||
*/
|
||||
struct file {
|
||||
off_t f_offset; /* first, is 64-bit */
|
||||
kauth_cred_t f_cred; /* creds associated with descriptor */
|
||||
const struct fileops {
|
||||
int (*fo_read) (struct file *, off_t *, struct uio *,
|
||||
kauth_cred_t, int);
|
||||
int (*fo_write) (struct file *, off_t *, struct uio *,
|
||||
kauth_cred_t, int);
|
||||
int (*fo_ioctl) (struct file *, u_long, void *);
|
||||
int (*fo_fcntl) (struct file *, u_int, void *);
|
||||
int (*fo_poll) (struct file *, int);
|
||||
int (*fo_stat) (struct file *, struct stat *);
|
||||
int (*fo_close) (struct file *);
|
||||
int (*fo_kqfilter) (struct file *, struct knote *);
|
||||
void (*fo_restart) (struct file *);
|
||||
void (*fo_spare1) (void);
|
||||
void (*fo_spare2) (void);
|
||||
} *f_ops;
|
||||
void *f_data; /* descriptor data, e.g. vnode/socket */
|
||||
LIST_ENTRY(file) f_list; /* list of active files */
|
||||
kmutex_t f_lock; /* lock on structure */
|
||||
int f_flag; /* see fcntl.h */
|
||||
u_int f_marker; /* traversal marker (sysctl) */
|
||||
#define DTYPE_VNODE 1 /* file */
|
||||
#define DTYPE_SOCKET 2 /* communications endpoint */
|
||||
#define DTYPE_PIPE 3 /* pipe */
|
||||
#define DTYPE_KQUEUE 4 /* event queue */
|
||||
#define DTYPE_MISC 5 /* misc file descriptor type */
|
||||
#define DTYPE_CRYPTO 6 /* crypto */
|
||||
#define DTYPE_MQUEUE 7 /* message queue */
|
||||
#define DTYPE_NAMES \
|
||||
"0", "file", "socket", "pipe", "kqueue", "misc", "crypto", "mqueue"
|
||||
u_int f_type; /* descriptor type */
|
||||
u_int f_advice; /* access pattern hint; UVM_ADV_* */
|
||||
u_int f_count; /* reference count */
|
||||
u_int f_msgcount; /* references from message queue */
|
||||
u_int f_unpcount; /* deferred close: see uipc_usrreq.c */
|
||||
SLIST_ENTRY(file) f_unplist; /* deferred close: see uipc_usrreq.c */
|
||||
};
|
||||
|
||||
/*
|
||||
* Flags for fo_read and fo_write and do_fileread/write/v
|
||||
*/
|
||||
#define FOF_UPDATE_OFFSET 0x0001 /* update the file offset */
|
||||
#define FOF_IOV_SYSSPACE 0x0100 /* iov structure in kernel memory */
|
||||
|
||||
LIST_HEAD(filelist, file);
|
||||
extern struct filelist filehead; /* head of list of open files */
|
||||
extern u_int maxfiles; /* kernel limit on # of open files */
|
||||
extern u_int nfiles; /* actual number of open files */
|
||||
|
||||
extern const struct fileops vnops; /* vnode operations for files */
|
||||
|
||||
int dofileread(int, struct file *, void *, size_t,
|
||||
off_t *, int, register_t *);
|
||||
int dofilewrite(int, struct file *, const void *,
|
||||
size_t, off_t *, int, register_t *);
|
||||
|
||||
int do_filereadv(int, const struct iovec *, int, off_t *,
|
||||
int, register_t *);
|
||||
int do_filewritev(int, const struct iovec *, int, off_t *,
|
||||
int, register_t *);
|
||||
|
||||
int fsetown(pid_t *, u_long, const void *);
|
||||
int fgetown(pid_t, u_long, void *);
|
||||
void fownsignal(pid_t, int, int, int, void *);
|
||||
|
||||
/* Commonly used fileops */
|
||||
int fnullop_fcntl(struct file *, u_int, void *);
|
||||
int fnullop_poll(struct file *, int);
|
||||
int fnullop_kqfilter(struct file *, struct knote *);
|
||||
int fbadop_read(struct file *, off_t *, struct uio *, kauth_cred_t, int);
|
||||
int fbadop_write(struct file *, off_t *, struct uio *, kauth_cred_t, int);
|
||||
int fbadop_ioctl(struct file *, u_long, void *);
|
||||
int fbadop_close(struct file *);
|
||||
int fbadop_stat(struct file *, struct stat *);
|
||||
void fnullop_restart(struct file *);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_FILE_H_ */
|
||||
111
nbsd_include/sys/float_ieee754.h
Normal file
111
nbsd_include/sys/float_ieee754.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* $NetBSD: float_ieee754.h,v 1.8 2005/12/11 12:25:20 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 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.
|
||||
*
|
||||
* @(#)float.h 8.1 (Berkeley) 6/10/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTICE: This is not a standalone file. To use it, #include it in
|
||||
* your port's float.h header.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_FLOAT_IEEE754_H_
|
||||
#define _SYS_FLOAT_IEEE754_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#ifndef FLT_ROUNDS
|
||||
__BEGIN_DECLS
|
||||
extern int __flt_rounds(void);
|
||||
__END_DECLS
|
||||
#define FLT_ROUNDS __flt_rounds()
|
||||
#endif
|
||||
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
||||
!defined(_XOPEN_SOURCE) || \
|
||||
((__STDC_VERSION__ - 0) >= 199901L) || \
|
||||
((_POSIX_C_SOURCE - 0) >= 200112L) || \
|
||||
((_XOPEN_SOURCE - 0) >= 600) || \
|
||||
defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#ifndef FLT_EVAL_METHOD
|
||||
#if __GNUC_PREREQ__(3, 3)
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
#endif /* GCC >= 3.3 */
|
||||
#endif /* defined(FLT_EVAL_METHOD) */
|
||||
#endif /* !defined(_ANSI_SOURCE) && ... */
|
||||
|
||||
#define FLT_RADIX 2 /* b */
|
||||
|
||||
#define FLT_MANT_DIG 24 /* p */
|
||||
#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */
|
||||
#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
|
||||
#define FLT_MIN_EXP (-125) /* emin */
|
||||
#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
|
||||
#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
|
||||
#define FLT_MAX_EXP 128 /* emax */
|
||||
#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
|
||||
#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
|
||||
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_EPSILON 2.2204460492503131E-16
|
||||
#define DBL_DIG 15
|
||||
#define DBL_MIN_EXP (-1021)
|
||||
#define DBL_MIN 2.2250738585072014E-308
|
||||
#define DBL_MIN_10_EXP (-307)
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MAX 1.7976931348623157E+308
|
||||
#define DBL_MAX_10_EXP 308
|
||||
|
||||
/*
|
||||
* If no extended-precision type is defined by the machine-dependent
|
||||
* header including this, default to `long double' being double-precision.
|
||||
*/
|
||||
#ifndef LDBL_MANT_DIG
|
||||
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
#define LDBL_EPSILON DBL_EPSILON
|
||||
#define LDBL_DIG DBL_DIG
|
||||
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
#define LDBL_MIN DBL_MIN
|
||||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
#define LDBL_MAX DBL_MAX
|
||||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
||||
!defined(_XOPEN_SOURCE) || \
|
||||
((__STDC_VERSION__ - 0) >= 199901L) || \
|
||||
((_POSIX_C_SOURCE - 0) >= 200112L) || \
|
||||
((_XOPEN_SOURCE - 0) >= 600) || \
|
||||
defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */
|
||||
#endif /* !defined(_ANSI_SOURCE) && ... */
|
||||
#endif /* LDBL_MANT_DIG */
|
||||
|
||||
#endif /* _SYS_FLOAT_IEEE754_H_ */
|
||||
463
nbsd_include/sys/gcq.h
Normal file
463
nbsd_include/sys/gcq.h
Normal file
@@ -0,0 +1,463 @@
|
||||
/* $NetBSD: gcq.h,v 1.2 2007/08/19 07:35:32 kiyohara Exp $ */
|
||||
/*
|
||||
* Not (c) 2007 Matthew Orgass
|
||||
* This file is public domain, meaning anyone can make any use of part or all
|
||||
* of this file including copying into other works without credit. Any use,
|
||||
* modified or not, is solely the responsibility of the user. If this file is
|
||||
* part of a collection then use in the collection is governed by the terms of
|
||||
* the collection.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generic Circular Queues: Pointer arithmetic is used to recover the
|
||||
* enclosing object. Merge operation is provided. Items can be multiply
|
||||
* removed, but queue traversal requires separate knowledge of the queue head.
|
||||
*/
|
||||
|
||||
#ifndef _GCQ_H
|
||||
#define _GCQ_H
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/types.h>
|
||||
#include <sys/null.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#ifdef GCQ_USE_ASSERT
|
||||
#define GCQ_ASSERT(x) assert(x)
|
||||
#else
|
||||
#ifdef _KERNEL
|
||||
#define GCQ_ASSERT(x) KASSERT(x)
|
||||
#else
|
||||
#define GCQ_ASSERT(x) _DIAGASSERT(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct gcq {
|
||||
struct gcq *q_next;
|
||||
struct gcq *q_prev;
|
||||
};
|
||||
|
||||
struct gcq_head {
|
||||
struct gcq hq;
|
||||
};
|
||||
|
||||
#define GCQ_INIT(q) { &(q), &(q) }
|
||||
#define GCQ_INIT_HEAD(head) { GCQ_INIT((head).hq) }
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_init(struct gcq *q)
|
||||
{
|
||||
q->q_next = q->q_prev = q;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, const, warn_unused_result, always_inline))
|
||||
static inline struct gcq *
|
||||
gcq_q(struct gcq *q)
|
||||
{
|
||||
return q;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, const, warn_unused_result, always_inline))
|
||||
static inline struct gcq *
|
||||
gcq_hq(struct gcq_head *head)
|
||||
{
|
||||
return (struct gcq *)head;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, const, warn_unused_result, always_inline))
|
||||
static inline struct gcq_head *
|
||||
gcq_head(struct gcq *q)
|
||||
{
|
||||
return (struct gcq_head *)q;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_init_head(struct gcq_head *head)
|
||||
{
|
||||
gcq_init(gcq_hq(head));
|
||||
}
|
||||
|
||||
__attribute__((nonnull, pure, warn_unused_result, always_inline))
|
||||
static inline bool
|
||||
gcq_onlist(struct gcq *q)
|
||||
{
|
||||
return (q->q_next != q);
|
||||
}
|
||||
|
||||
__attribute__((nonnull, pure, warn_unused_result, always_inline))
|
||||
static inline bool
|
||||
gcq_empty(struct gcq_head *head)
|
||||
{
|
||||
return (!gcq_onlist(gcq_hq(head)));
|
||||
}
|
||||
|
||||
__attribute__((nonnull, pure, warn_unused_result, always_inline))
|
||||
static inline bool
|
||||
gcq_linked(struct gcq *prev, struct gcq *next)
|
||||
{
|
||||
return (prev->q_next == next && next->q_prev == prev);
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_insert_after(struct gcq *on, struct gcq *off)
|
||||
{
|
||||
struct gcq *on_next;
|
||||
GCQ_ASSERT(off->q_next == off && off->q_prev == off);
|
||||
on_next = on->q_next;
|
||||
|
||||
off->q_prev = on;
|
||||
off->q_next = on_next;
|
||||
on_next->q_prev = off;
|
||||
on->q_next = off;
|
||||
}
|
||||
|
||||
__attribute__((nonnull)) static inline void
|
||||
gcq_insert_before(struct gcq *on, struct gcq *off)
|
||||
{
|
||||
struct gcq *on_prev;
|
||||
GCQ_ASSERT(off->q_next == off && off->q_prev == off);
|
||||
on_prev = on->q_prev;
|
||||
|
||||
off->q_next = on;
|
||||
off->q_prev = on_prev;
|
||||
on_prev->q_next = off;
|
||||
on->q_prev = off;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_insert_head(struct gcq_head *head, struct gcq *q)
|
||||
{
|
||||
gcq_insert_after(gcq_hq(head), q);
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_insert_tail(struct gcq_head *head, struct gcq *q)
|
||||
{
|
||||
gcq_insert_before(gcq_hq(head), q);
|
||||
}
|
||||
|
||||
__attribute__((nonnull)) static inline void
|
||||
gcq_tie(struct gcq *dst, struct gcq *src)
|
||||
{
|
||||
struct gcq *dst_next, *src_prev;
|
||||
dst_next = dst->q_next;
|
||||
src_prev = src->q_prev;
|
||||
|
||||
src_prev->q_next = dst_next;
|
||||
dst_next->q_prev = src_prev;
|
||||
src->q_prev = dst;
|
||||
dst->q_next = src;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_tie_after(struct gcq *dst, struct gcq *src)
|
||||
{
|
||||
GCQ_ASSERT(dst != src && dst->q_prev != src);
|
||||
gcq_tie(dst, src);
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_tie_before(struct gcq *dst, struct gcq *src)
|
||||
{
|
||||
gcq_tie_after(dst->q_prev, src);
|
||||
}
|
||||
|
||||
__attribute__((nonnull)) static inline struct gcq *
|
||||
gcq_remove(struct gcq *q)
|
||||
{
|
||||
struct gcq *next, *prev;
|
||||
next = q->q_next;
|
||||
prev = q->q_prev;
|
||||
|
||||
prev->q_next = next;
|
||||
next->q_prev = prev;
|
||||
gcq_init(q);
|
||||
return q;
|
||||
}
|
||||
|
||||
#ifdef GCQ_UNCONDITIONAL_MERGE
|
||||
__attribute__((nonnull)) static inline void
|
||||
gcq_merge(struct gcq *dst, struct gcq *src)
|
||||
{
|
||||
GCQ_ASSERT(dst != src && dst->q_prev != src);
|
||||
gcq_tie(dst, src);
|
||||
gcq_tie(src, src);
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_merge_head(struct gcq_head *dst, struct gcq_head *src)
|
||||
{
|
||||
gcq_merge(gcq_hq(dst), gcq_hq(src));
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_merge_tail(struct gcq_head *dst, struct gcq_head *src)
|
||||
{
|
||||
gcq_merge(gcq_hq(dst)->q_prev, gcq_hq(src));
|
||||
}
|
||||
#else
|
||||
__attribute__((nonnull)) static inline void
|
||||
gcq_merge(struct gcq *dst, struct gcq *src)
|
||||
{
|
||||
struct gcq *dst_next, *src_prev, *src_next;
|
||||
GCQ_ASSERT(dst != src && dst->q_prev != src);
|
||||
|
||||
if (gcq_onlist(src)) {
|
||||
dst_next = dst->q_next;
|
||||
src_prev = src->q_prev;
|
||||
src_next = src->q_next;
|
||||
|
||||
dst_next->q_prev = src_prev;
|
||||
src_prev->q_next = dst_next;
|
||||
dst->q_next = src_next;
|
||||
src_next->q_prev = dst;
|
||||
gcq_init(src);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_merge_head(struct gcq_head *dst, struct gcq_head *src)
|
||||
{
|
||||
gcq_merge(gcq_hq(dst), gcq_hq(src));
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_merge_tail(struct gcq_head *dst, struct gcq_head *src)
|
||||
{
|
||||
gcq_merge(gcq_hq(dst)->q_prev, gcq_hq(src));
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((nonnull)) static inline void
|
||||
gcq_clear(struct gcq *q)
|
||||
{
|
||||
struct gcq *nq, *next;
|
||||
nq=q;
|
||||
do {
|
||||
next = nq->q_next;
|
||||
gcq_init(nq);
|
||||
nq = next;
|
||||
} while (next != q);
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline void
|
||||
gcq_remove_all(struct gcq_head *head)
|
||||
{
|
||||
gcq_clear(gcq_hq(head));
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline struct gcq *
|
||||
_gcq_next(struct gcq *current, struct gcq_head *head, struct gcq *start)
|
||||
{
|
||||
struct gcq *q, *hq;
|
||||
hq = gcq_hq(head);
|
||||
q = current->q_next;
|
||||
if (hq != start && q == hq)
|
||||
q = hq->q_next;
|
||||
if (current != start)
|
||||
GCQ_ASSERT(gcq_onlist(current));
|
||||
return q;
|
||||
}
|
||||
|
||||
__attribute__((nonnull, always_inline)) static inline struct gcq *
|
||||
_gcq_prev(struct gcq *current, struct gcq_head *head, struct gcq *start)
|
||||
{
|
||||
struct gcq *q, *hq;
|
||||
hq = gcq_hq(head);
|
||||
q = current->q_prev;
|
||||
if (hq != start && q == hq)
|
||||
q = hq->q_prev;
|
||||
if (current != start)
|
||||
GCQ_ASSERT(gcq_onlist(current));
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
#define GCQ_ITEM(q, type, name) \
|
||||
((type *)(void *)((uint8_t *)gcq_q(q) - offsetof(type, name)))
|
||||
|
||||
|
||||
#define _GCQ_GDQ(var, h, ptr, fn) (gcq_hq(h)->ptr != gcq_hq(h) ? \
|
||||
(var = fn(gcq_hq(h)->ptr), true) : (var = NULL, false))
|
||||
#define _GCQ_GDQ_TYPED(tvar, h, type, name, ptr, fn) \
|
||||
(gcq_hq(h)->ptr != gcq_hq(h) ? (tvar = GCQ_ITEM(fn(gcq_hq(h)->ptr), \
|
||||
type, name), true) : (tvar = NULL, false))
|
||||
#define _GCQ_NP(var, current, head, start, np, fn) \
|
||||
(np(current, head, start) != (start) ? \
|
||||
(var = fn(np(current, head, start)), true) : (var = NULL, false))
|
||||
#define _GCQ_NP_TYPED(tvar, current, head, start, type, name, np, fn) \
|
||||
(np(current, head, start) != (start) ? \
|
||||
(tvar = GCQ_ITEM(fn(np(current, head, start)), type, name), true) : \
|
||||
(tvar = NULL, false))
|
||||
|
||||
#define _GCQ_GDQ_COND(var, h, ptr, rem, cond) \
|
||||
(gcq_hq(h)->ptr != gcq_hq(h) ? (var = gcq_hq(h)->ptr, \
|
||||
((cond) ? (rem, true) : (var = NULL, false))) : \
|
||||
(var = NULL, false))
|
||||
#define _GCQ_GDQ_COND_TYPED(tvar, h, type, name, ptr, rem, cond) \
|
||||
(gcq_hq(h)->ptr != gcq_hq(h) ? (tvar = GCQ_ITEM(gcq_hq(h)->ptr, \
|
||||
type, name), ((cond) ? (rem, true) : (tvar = NULL, false))) : \
|
||||
(tvar = NULL, false))
|
||||
#define _GCQ_NP_COND(var, current, head, start, np, rem, cond) \
|
||||
(np(current, head, start) != (start) ? \
|
||||
(var = fn(np(current, head, start)), ((cond) ? (rem), true) : \
|
||||
(var = NULL, false))) : (var = NULL, false))
|
||||
#define _GCQ_NP_COND_TYPED(tvar, current, head, start, type, name, np, \
|
||||
rem, cond) (np(current, head, start) != (start) ? \
|
||||
(tvar = GCQ_ITEM(fn(np(current, head, start)), type, name), \
|
||||
((cond) ? (rem, true) : (var = NULL, false))) : \
|
||||
(tvar = NULL, false))
|
||||
|
||||
#define GCQ_GOT_FIRST(var, h) _GCQ_GDQ(var, h, q_next, gcq_q)
|
||||
#define GCQ_GOT_LAST(var, h) _GCQ_GDQ(var, h, q_prev, gcq_q)
|
||||
#define GCQ_DEQUEUED_FIRST(var, h) _GCQ_GDQ(var, h, q_next, gcq_remove)
|
||||
#define GCQ_DEQUEUED_LAST(var, h) _GCQ_GDQ(var, h, q_prev, gcq_remove)
|
||||
#define GCQ_GOT_FIRST_TYPED(tvar, h, type, name) \
|
||||
_GCQ_GDQ_TYPED(tvar, h, type, name, q_next, gcq_q)
|
||||
#define GCQ_GOT_LAST_TYPED(tvar, h, type, name) \
|
||||
_GCQ_GDQ_TYPED(tvar, h, type, name, q_prev, gcq_q)
|
||||
#define GCQ_DEQUEUED_FIRST_TYPED(tvar, h, type, name) \
|
||||
_GCQ_GDQ_TYPED(tvar, h, type, name, q_next, gcq_remove)
|
||||
#define GCQ_DEQUEUED_LAST_TYPED(tvar, h, type, name) \
|
||||
_GCQ_GDQ_TYPED(tvar, h, type, name, q_prev, gcq_remove)
|
||||
#define GCQ_GOT_NEXT(var, current, head, start) \
|
||||
_GCQ_NP(var, current, head, start, _gcq_next, gcq_q)
|
||||
#define GCQ_GOT_PREV(var, current, head, start) \
|
||||
_GCQ_NP(var, current, head, start, _gcq_prev, gcq_q)
|
||||
#define GCQ_DEQUEUED_NEXT(var, current, head, start) \
|
||||
_GCQ_NP(var, current, head, start, _gcq_next, gcq_remove)
|
||||
#define GCQ_DEQUEUED_PREV(var, current, head, start) \
|
||||
_GCQ_NP(var, current, head, start, _gcq_prev, gcq_remove)
|
||||
#define GCQ_GOT_NEXT_TYPED(tvar, current, head, start, type, name) \
|
||||
_GCQ_NP_TYPED(tvar, current, head, start, type, name, \
|
||||
_gcq_next, gcq_q)
|
||||
#define GCQ_GOT_PREV_TYPED(tvar, current, head, start, type, name) \
|
||||
_GCQ_NP_TYPED(tvar, current, head, start, type, name, \
|
||||
_gcq_prev, gcq_q)
|
||||
#define GCQ_DEQUEUED_NEXT_TYPED(tvar, current, head, start, type, name) \
|
||||
_GCQ_NP_TYPED(tvar, current, head, start, type, name, \
|
||||
_gcq_next, gcq_remove)
|
||||
#define GCQ_DEQUEUED_PREV_TYPED(tvar, current, head, start, type, name) \
|
||||
_GCQ_NP_TYPED(tvar, current, head, start, type, name, \
|
||||
_gcq_prev, gcq_remove)
|
||||
|
||||
#define GCQ_GOT_FIRST_COND(var, h, cond) \
|
||||
_GCQ_GDQ_COND(var, h, q_next, ((void)0), cond)
|
||||
#define GCQ_GOT_LAST_COND(var, h, cond) \
|
||||
_GCQ_GDQ_COND(var, h, q_prev, ((void)0), cond)
|
||||
#define GCQ_DEQUEUED_FIRST_COND(var, h, cond) \
|
||||
_GCQ_GDQ_COND(var, h, q_next, gcq_remove(var), cond)
|
||||
#define GCQ_DEQUEUED_LAST_COND(var, h, cond) \
|
||||
_GCQ_GDQ_COND(var, h, q_prev, gcq_remove(var), cond)
|
||||
#define GCQ_GOT_FIRST_COND_TYPED(tvar, h, type, name, cond) \
|
||||
_GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_next, ((void)0), cond)
|
||||
#define GCQ_GOT_LAST_COND_TYPED(tvar, h, type, name, cond) \
|
||||
_GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_prev, ((void)0), cond)
|
||||
#define GCQ_DEQUEUED_FIRST_COND_TYPED(tvar, h, type, name, cond) \
|
||||
_GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_next, \
|
||||
gcq_remove(&(tvar)->name), cond)
|
||||
#define GCQ_DEQUEUED_LAST_COND_TYPED(tvar, h, type, name, cond) \
|
||||
_GCQ_GDQ_COND_TYPED(tvar, h, type, name, q_prev, \
|
||||
gcq_remove(&(tvar)->name), cond)
|
||||
#define GCQ_GOT_NEXT_COND(var, current, head, start, cond) \
|
||||
_GCQ_NP_COND(var, current, head, start, _gcq_next, ((void)0), cond)
|
||||
#define GCQ_GOT_PREV_COND(var, current, head, start, cond) \
|
||||
_GCQ_NP_COND(var, current, head, start, _gcq_prev, ((void)0), cond)
|
||||
#define GCQ_DEQUEUED_NEXT_COND(var, current, head, start, cond) \
|
||||
_GCQ_NP_COND(var, current, head, start, _gcq_next, gcq_remove(var), \
|
||||
cond)
|
||||
#define GCQ_DEQUEUED_PREV_COND(var, current, head, start, cond) \
|
||||
_GCQ_NP_COND(var, current, head, start, _gcq_prev, gcq_remove(var), \
|
||||
cond)
|
||||
#define GCQ_GOT_NEXT_COND_TYPED(tvar, current, head, start, type, name, \
|
||||
cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, name, \
|
||||
_gcq_next, ((void)0), cond)
|
||||
#define GCQ_GOT_PREV_COND_TYPED(tvar, current, head, start, type, name, \
|
||||
cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, name, \
|
||||
_gcq_prev, ((void)0), cond)
|
||||
#define GCQ_DEQUEUED_NEXT_COND_TYPED(tvar, current, head, start, type, \
|
||||
name, cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, \
|
||||
name, _gcq_next, gcq_remove(&(tvar)->name), cond)
|
||||
#define GCQ_DEQUEUED_PREV_COND_TYPED(tvar, current, head, start, type, \
|
||||
name, cond) _GCQ_NP_COND_TYPED(tvar, current, head, start, type, \
|
||||
name, _gcq_prev, gcq_remove(&(tvar)->name), cond)
|
||||
|
||||
|
||||
#define _GCQ_FOREACH(var, h, tnull, item, ptr) \
|
||||
for ((var)=gcq_hq(h)->ptr; ((var) != gcq_hq(h) && \
|
||||
(GCQ_ASSERT(gcq_onlist(var)), item, true)) || \
|
||||
(tnull, false); (var)=(var)->ptr)
|
||||
#define _GCQ_FOREACH_NVAR(var, nvar, h, tnull, item, ptr, ol, rem, ro) \
|
||||
for ((nvar)=gcq_hq(h)->ptr; (((var)=(nvar), (nvar) != gcq_hq(h)) && \
|
||||
(ol, (nvar)=(nvar)->ptr, rem, item, true)) || (tnull, false); ro)
|
||||
|
||||
#define GCQ_FOREACH(var, h) \
|
||||
_GCQ_FOREACH(var, h, ((void)0), ((void)0), q_next)
|
||||
#define GCQ_FOREACH_REV(var, h) \
|
||||
_GCQ_FOREACH(var, h, ((void)0), ((void)0), q_prev)
|
||||
#define GCQ_FOREACH_NVAR(var, nvar, h) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \
|
||||
q_next, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0))
|
||||
#define GCQ_FOREACH_NVAR_REV(var, nvar, h) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \
|
||||
q_prev, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0))
|
||||
#define GCQ_FOREACH_RO(var, nvar, h) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \
|
||||
q_next, ((void)0), ((void)0), GCQ_ASSERT(gcq_linked(var, nvar)))
|
||||
#define GCQ_FOREACH_RO_REV(var, nvar, h) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \
|
||||
q_prev, ((void)0), ((void)0), GCQ_ASSERT(gcq_linked(nvar, var)))
|
||||
#define GCQ_FOREACH_DEQUEUED(var, nvar, h) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \
|
||||
q_next, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0)
|
||||
#define GCQ_FOREACH_DEQUEUED_REV(var, nvar, h) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, ((void)0), ((void)0), \
|
||||
q_prev, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0)
|
||||
|
||||
#define GCQ_FOREACH_TYPED(var, h, tvar, type, name) \
|
||||
_GCQ_FOREACH(var, h, (tvar)=NULL, (tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_next)
|
||||
#define GCQ_FOREACH_TYPED_REV(var, h, tvar, type, name) \
|
||||
_GCQ_FOREACH(var, h, (tvar)=NULL, (tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_prev)
|
||||
#define GCQ_FOREACH_NVAR_TYPED(var, nvar, h, tvar, type, name) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \
|
||||
(tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_next, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0))
|
||||
#define GCQ_FOREACH_NVAR_REV_TYPED(var, nvar, h, tvar, type, name) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \
|
||||
(tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_prev, GCQ_ASSERT(gcq_onlist(nvar)), ((void)0), ((void)0))
|
||||
#define GCQ_FOREACH_RO_TYPED(var, nvar, h, tvar, type, name) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \
|
||||
(tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_next, ((void)0), ((void)0), GCQ_ASSERT(gcq_lined(var, nvar)))
|
||||
#define GCQ_FOREACH_RO_REV_TYPED(var, nvar, h, tvar, type, name) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \
|
||||
(tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_prev, ((void)0), ((void)0), GCQ_ASSERT(gcq_linked(nvar, var)))
|
||||
#define GCQ_FOREACH_DEQUEUED_TYPED(var, nvar, h, tvar, type, name) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \
|
||||
(tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_next, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0))
|
||||
#define GCQ_FOREACH_DEQUEUED_REV_TYPED(var, nvar, h, tvar, type, name) \
|
||||
_GCQ_FOREACH_NVAR(var, nvar, h, (tvar)=NULL, \
|
||||
(tvar)=GCQ_ITEM(var, type, name), \
|
||||
q_prev, GCQ_ASSERT(gcq_onlist(nvar)), gcq_remove(var), ((void)0))
|
||||
|
||||
#define _GCQ_COND(fe, cond) do { fe { if (cond) break; } } while (0)
|
||||
|
||||
#define GCQ_FIND(var, h, cond) _GCQ_COND(GCQ_FOREACH(var, h), cond)
|
||||
#define GCQ_FIND_REV(var, h, cond) _GCQ_COND(GCQ_FOREACH_REV(var, h), cond)
|
||||
#define GCQ_FIND_TYPED(var, h, tvar, type, name, cond) \
|
||||
_GCQ_COND(GCQ_FOREACH_TYPED(var, h, tvar, type, name), cond)
|
||||
#define GCQ_FIND_TYPED_REV(var, h, tvar, type, name, cond) \
|
||||
_GCQ_COND(GCQ_FOREACH_REV_TYPED(var, h, tvar, type, name), cond)
|
||||
|
||||
#endif /* _GCQ_H */
|
||||
153
nbsd_include/sys/gmon.h
Normal file
153
nbsd_include/sys/gmon.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/* $NetBSD: gmon.h,v 1.9 2006/10/04 14:22:58 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1992, 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.
|
||||
*
|
||||
* @(#)gmon.h 8.2 (Berkeley) 1/4/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_GMON_H_
|
||||
#define _SYS_GMON_H_
|
||||
|
||||
#include <machine/profile.h>
|
||||
|
||||
/*
|
||||
* Structure prepended to gmon.out profiling data file.
|
||||
*/
|
||||
struct gmonhdr {
|
||||
u_long lpc; /* base pc address of sample buffer */
|
||||
u_long hpc; /* max pc address of sampled buffer */
|
||||
int ncnt; /* size of sample buffer (plus this header) */
|
||||
int version; /* version number */
|
||||
int profrate; /* profiling clock rate */
|
||||
int spare[3]; /* reserved */
|
||||
};
|
||||
#define GMONVERSION 0x00051879
|
||||
|
||||
/*
|
||||
* histogram counters are unsigned shorts (according to the kernel).
|
||||
*/
|
||||
#define HISTCOUNTER unsigned short
|
||||
|
||||
/*
|
||||
* fraction of text space to allocate for histogram counters here, 1/2
|
||||
*/
|
||||
#ifndef HISTFRACTION
|
||||
#define HISTFRACTION 2
|
||||
#endif /* HISTFRACTION */
|
||||
|
||||
/*
|
||||
* Fraction of text space to allocate for from hash buckets.
|
||||
* The value of HASHFRACTION is based on the minimum number of bytes
|
||||
* of separation between two subroutine call points in the object code.
|
||||
* Given MIN_SUBR_SEPARATION bytes of separation the value of
|
||||
* HASHFRACTION is calculated as:
|
||||
*
|
||||
* HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
|
||||
*
|
||||
* For example, on the VAX, the shortest two call sequence is:
|
||||
*
|
||||
* calls $0,(r0)
|
||||
* calls $0,(r0)
|
||||
*
|
||||
* which is separated by only three bytes, thus HASHFRACTION is
|
||||
* calculated as:
|
||||
*
|
||||
* HASHFRACTION = 3 / (2 * 2 - 1) = 1
|
||||
*
|
||||
* Note that the division above rounds down, thus if MIN_SUBR_FRACTION
|
||||
* is less than three, this algorithm will not work!
|
||||
*
|
||||
* In practice, however, call instructions are rarely at a minimal
|
||||
* distance. Hence, we will define HASHFRACTION to be 2 across all
|
||||
* architectures. This saves a reasonable amount of space for
|
||||
* profiling data structures without (in practice) sacrificing
|
||||
* any granularity.
|
||||
*/
|
||||
#define HASHFRACTION 2
|
||||
|
||||
/*
|
||||
* percent of text space to allocate for tostructs with a minimum.
|
||||
*/
|
||||
#define ARCDENSITY 2
|
||||
#define MINARCS 50
|
||||
#define MAXARCS ((1 << (8 * sizeof(HISTCOUNTER))) - 2)
|
||||
|
||||
struct tostruct {
|
||||
u_long selfpc;
|
||||
long count;
|
||||
u_short link;
|
||||
u_short pad;
|
||||
};
|
||||
|
||||
/*
|
||||
* a raw arc, with pointers to the calling site and
|
||||
* the called site and a count.
|
||||
*/
|
||||
struct rawarc {
|
||||
u_long raw_frompc;
|
||||
u_long raw_selfpc;
|
||||
long raw_count;
|
||||
};
|
||||
|
||||
/*
|
||||
* The profiling data structures are housed in this structure.
|
||||
*/
|
||||
struct gmonparam {
|
||||
int state;
|
||||
u_short *kcount;
|
||||
u_long kcountsize;
|
||||
u_short *froms;
|
||||
u_long fromssize;
|
||||
struct tostruct *tos;
|
||||
u_long tossize;
|
||||
long tolimit;
|
||||
u_long lowpc;
|
||||
u_long highpc;
|
||||
u_long textsize;
|
||||
u_long hashfraction;
|
||||
};
|
||||
extern struct gmonparam _gmonparam;
|
||||
|
||||
/*
|
||||
* Possible states of profiling.
|
||||
*/
|
||||
#define GMON_PROF_ON 0
|
||||
#define GMON_PROF_BUSY 1
|
||||
#define GMON_PROF_ERROR 2
|
||||
#define GMON_PROF_OFF 3
|
||||
|
||||
/*
|
||||
* Sysctl definitions for extracting profiling information from the kernel.
|
||||
*/
|
||||
#define GPROF_STATE 0 /* int: profiling enabling variable */
|
||||
#define GPROF_COUNT 1 /* struct: profile tick count buffer */
|
||||
#define GPROF_FROMS 2 /* struct: from location hash bucket */
|
||||
#define GPROF_TOS 3 /* struct: destination/count structure */
|
||||
#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */
|
||||
#endif /* !_SYS_GMON_H_ */
|
||||
103
nbsd_include/sys/hash.h
Normal file
103
nbsd_include/sys/hash.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* $NetBSD: hash.h,v 1.6 2008/04/28 20:24:10 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Luke Mewburn.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_HASH_H_
|
||||
#define _SYS_HASH_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef __HAVE_MACHINE_HASH_H
|
||||
#include <machine/hash.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __HAVE_HASH32_BUF /* not overridden by MD hash */
|
||||
|
||||
#define HASH32_BUF_INIT 5381
|
||||
|
||||
/*
|
||||
* uint32_t
|
||||
* hash32_buf(const void *bf, size_t len, uint32_t hash)
|
||||
* return a 32 bit hash of the binary buffer buf (size len),
|
||||
* seeded with an initial hash value of hash (usually HASH32_BUF_INIT).
|
||||
*/
|
||||
static __inline uint32_t
|
||||
hash32_buf(const void *bf, size_t len, uint32_t hash)
|
||||
{
|
||||
const uint8_t *s = bf;
|
||||
|
||||
while (len-- != 0) /* "nemesi": k=257, r=r*257 */
|
||||
hash = hash * 257 + *s++;
|
||||
return (hash * 257);
|
||||
}
|
||||
#endif /* __HAVE_HASH32_BUF */
|
||||
|
||||
|
||||
#ifndef __HAVE_HASH32_STR /* not overridden by MD hash */
|
||||
|
||||
#define HASH32_STR_INIT 5381
|
||||
/*
|
||||
* uint32_t
|
||||
* hash32_str(const void *bf, uint32_t hash)
|
||||
* return a 32 bit hash of NUL terminated ASCII string buf,
|
||||
* seeded with an initial hash value of hash (usually HASH32_STR_INIT).
|
||||
*/
|
||||
static __inline uint32_t
|
||||
hash32_str(const void *bf, uint32_t hash)
|
||||
{
|
||||
const uint8_t *s = bf;
|
||||
uint8_t c;
|
||||
|
||||
while ((c = *s++) != 0)
|
||||
hash = hash * 33 + c; /* "perl": k=33, r=r+r/32 */
|
||||
return (hash + (hash >> 5));
|
||||
}
|
||||
|
||||
/*
|
||||
* uint32_t
|
||||
* hash32_strn(const void *bf, size_t len, uint32_t hash)
|
||||
* return a 32 bit hash of NUL terminated ASCII string buf up to
|
||||
* a maximum of len bytes,
|
||||
* seeded with an initial hash value of hash (usually HASH32_STR_INIT).
|
||||
*/
|
||||
static __inline uint32_t
|
||||
hash32_strn(const void *bf, size_t len, uint32_t hash)
|
||||
{
|
||||
const uint8_t *s = bf;
|
||||
uint8_t c;
|
||||
|
||||
while ((c = *s++) != 0 && len-- != 0)
|
||||
hash = hash * 33 + c; /* "perl": k=33, r=r+r/32 */
|
||||
return (hash + (hash >> 5));
|
||||
}
|
||||
#endif /* __HAVE_HASH32_STR */
|
||||
|
||||
|
||||
#endif /* !_SYS_HASH_H_ */
|
||||
152
nbsd_include/sys/ieee754.h
Normal file
152
nbsd_include/sys/ieee754.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/* $NetBSD: ieee754.h,v 1.7 2007/02/02 23:08:22 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratory.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ieee.h 8.1 (Berkeley) 6/11/93
|
||||
*/
|
||||
#ifndef _SYS_IEEE754_H_
|
||||
#define _SYS_IEEE754_H_
|
||||
|
||||
/*
|
||||
* NOTICE: This is not a standalone file. To use it, #include it in
|
||||
* your port's ieee.h header.
|
||||
*/
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
/*
|
||||
* <sys/ieee754.h> defines the layout of IEEE 754 floating point types.
|
||||
* Only single-precision and double-precision types are defined here;
|
||||
* extended types, if available, are defined in the machine-dependent
|
||||
* header.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define the number of bits in each fraction and exponent.
|
||||
*
|
||||
* k k+1
|
||||
* Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented
|
||||
*
|
||||
* (-exp_bias+1)
|
||||
* as fractions that look like 0.fffff x 2 . This means that
|
||||
*
|
||||
* -126
|
||||
* the number 0.10000 x 2 , for instance, is the same as the normalized
|
||||
*
|
||||
* -127 -128
|
||||
* float 1.0 x 2 . Thus, to represent 2 , we need one leading zero
|
||||
*
|
||||
* -129
|
||||
* in the fraction; to represent 2 , we need two, and so on. This
|
||||
*
|
||||
* (-exp_bias-fracbits+1)
|
||||
* implies that the smallest denormalized number is 2
|
||||
*
|
||||
* for whichever format we are talking about: for single precision, for
|
||||
*
|
||||
* -126 -149
|
||||
* instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and
|
||||
*
|
||||
* -149 == -127 - 23 + 1.
|
||||
*/
|
||||
#define SNG_EXPBITS 8
|
||||
#define SNG_FRACBITS 23
|
||||
|
||||
struct ieee_single {
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
u_int sng_sign:1;
|
||||
u_int sng_exp:SNG_EXPBITS;
|
||||
u_int sng_frac:SNG_FRACBITS;
|
||||
#else
|
||||
u_int sng_frac:SNG_FRACBITS;
|
||||
u_int sng_exp:SNG_EXPBITS;
|
||||
u_int sng_sign:1;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define DBL_EXPBITS 11
|
||||
#define DBL_FRACHBITS 20
|
||||
#define DBL_FRACLBITS 32
|
||||
#define DBL_FRACBITS (DBL_FRACHBITS + DBL_FRACLBITS)
|
||||
|
||||
struct ieee_double {
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
u_int dbl_sign:1;
|
||||
u_int dbl_exp:DBL_EXPBITS;
|
||||
u_int dbl_frach:DBL_FRACHBITS;
|
||||
u_int dbl_fracl:DBL_FRACLBITS;
|
||||
#else
|
||||
u_int dbl_fracl:DBL_FRACLBITS;
|
||||
u_int dbl_frach:DBL_FRACHBITS;
|
||||
u_int dbl_exp:DBL_EXPBITS;
|
||||
u_int dbl_sign:1;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* Floats whose exponent is in [1..INFNAN) (of whatever type) are
|
||||
* `normal'. Floats whose exponent is INFNAN are either Inf or NaN.
|
||||
* Floats whose exponent is zero are either zero (iff all fraction
|
||||
* bits are zero) or subnormal values.
|
||||
*
|
||||
* At least one `signalling NaN' and one `quiet NaN' value must be
|
||||
* implemented. It is left to the architecture to specify how to
|
||||
* distinguish between these.
|
||||
*/
|
||||
#define SNG_EXP_INFNAN 255
|
||||
#define DBL_EXP_INFNAN 2047
|
||||
|
||||
/*
|
||||
* Exponent biases.
|
||||
*/
|
||||
#define SNG_EXP_BIAS 127
|
||||
#define DBL_EXP_BIAS 1023
|
||||
|
||||
/*
|
||||
* Convenience data structures.
|
||||
*/
|
||||
union ieee_single_u {
|
||||
float sngu_f;
|
||||
struct ieee_single sngu_sng;
|
||||
};
|
||||
|
||||
union ieee_double_u {
|
||||
double dblu_d;
|
||||
struct ieee_double dblu_dbl;
|
||||
};
|
||||
#endif /* _SYS_IEEE754_H_ */
|
||||
45
nbsd_include/sys/inttypes.h
Normal file
45
nbsd_include/sys/inttypes.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* $NetBSD: inttypes.h,v 1.5 2008/04/28 20:24:10 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus J. Klein.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_INTTYPES_H_
|
||||
#define _SYS_INTTYPES_H_
|
||||
|
||||
/*
|
||||
* 7.8 Format conversion of integer types
|
||||
*/
|
||||
|
||||
#include <sys/stdint.h>
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
|
||||
#include <machine/int_fmtio.h>
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_INTTYPES_H_ */
|
||||
99
nbsd_include/sys/ioc_net.h
Normal file
99
nbsd_include/sys/ioc_net.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/* sys/ioc_net.h - NetBSD-friendly version of Minix net/ioctl.h
|
||||
*/
|
||||
/* net/ioctl.h - Network ioctl() command codes. Author: Kees J. Bot
|
||||
* 23 Nov 2002
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IOC_NET_H_
|
||||
#define _SYS_IOC_NET_H_
|
||||
|
||||
#include <minix/ioctl.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <sys/ansi.h>
|
||||
#ifndef socklen_t
|
||||
typedef __socklen_t socklen_t;
|
||||
#define socklen_t __socklen_t
|
||||
#endif
|
||||
|
||||
#define MSG_CONTROL_MAX (1024 - sizeof(socklen_t))
|
||||
struct msg_control
|
||||
{
|
||||
char msg_control[MSG_CONTROL_MAX];
|
||||
socklen_t msg_controllen;
|
||||
};
|
||||
|
||||
|
||||
/* Network ioctls. */
|
||||
#define NWIOSETHOPT _IOW('n', 16, struct nwio_ethopt)
|
||||
#define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt)
|
||||
#define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat)
|
||||
|
||||
#define NWIOARPGIP _IORW('n',20, struct nwio_arp)
|
||||
#define NWIOARPGNEXT _IORW('n',21, struct nwio_arp)
|
||||
#define NWIOARPSIP _IOW ('n',22, struct nwio_arp)
|
||||
#define NWIOARPDIP _IOW ('n',23, struct nwio_arp)
|
||||
|
||||
#define NWIOSIPCONF2 _IOW('n', 32, struct nwio_ipconf2)
|
||||
#define NWIOSIPCONF _IOW('n', 32, struct nwio_ipconf)
|
||||
#define NWIOGIPCONF2 _IOR('n', 33, struct nwio_ipconf2)
|
||||
#define NWIOGIPCONF _IOR('n', 33, struct nwio_ipconf)
|
||||
#define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt)
|
||||
#define NWIOGIPOPT _IOR('n', 35, struct nwio_ipopt)
|
||||
|
||||
#define NWIOGIPOROUTE _IORW('n', 40, struct nwio_route)
|
||||
#define NWIOSIPOROUTE _IOW ('n', 41, struct nwio_route)
|
||||
#define NWIODIPOROUTE _IOW ('n', 42, struct nwio_route)
|
||||
#define NWIOGIPIROUTE _IORW('n', 43, struct nwio_route)
|
||||
#define NWIOSIPIROUTE _IOW ('n', 44, struct nwio_route)
|
||||
#define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route)
|
||||
|
||||
#define NWIOSTCPCONF _IOW('n', 48, struct nwio_tcpconf)
|
||||
#define NWIOGTCPCONF _IOR('n', 49, struct nwio_tcpconf)
|
||||
#define NWIOTCPCONN _IOW('n', 50, struct nwio_tcpcl)
|
||||
#define NWIOTCPLISTEN _IOW('n', 51, struct nwio_tcpcl)
|
||||
#define NWIOTCPATTACH _IOW('n', 52, struct nwio_tcpatt)
|
||||
#define NWIOTCPSHUTDOWN _IO ('n', 53)
|
||||
#define NWIOSTCPOPT _IOW('n', 54, struct nwio_tcpopt)
|
||||
#define NWIOGTCPOPT _IOR('n', 55, struct nwio_tcpopt)
|
||||
#define NWIOTCPPUSH _IO ('n', 56)
|
||||
#define NWIOTCPLISTENQ _IOW('n', 57, int)
|
||||
#define NWIOGTCPCOOKIE _IOR('n', 58, struct tcp_cookie)
|
||||
#define NWIOTCPACCEPTTO _IOW('n', 59, struct tcp_cookie)
|
||||
#define NWIOTCPGERROR _IOR('n', 60, int)
|
||||
|
||||
#define NWIOSUDPOPT _IOW('n', 64, struct nwio_udpopt)
|
||||
#define NWIOGUDPOPT _IOR('n', 65, struct nwio_udpopt)
|
||||
#define NWIOUDPPEEK _IOR('n', 66, struct udp_io_hdr)
|
||||
|
||||
#define NWIOGUDSFADDR _IOR ('n', 67, struct sockaddr_un) /* recvfrom() */
|
||||
#define NWIOSUDSTADDR _IOW ('n', 68, struct sockaddr_un) /* sendto() */
|
||||
#define NWIOSUDSADDR _IOW ('n', 69, struct sockaddr_un) /* bind() */
|
||||
#define NWIOGUDSADDR _IOR ('n', 70, struct sockaddr_un) /* getsockname() */
|
||||
#define NWIOGUDSPADDR _IOR ('n', 71, struct sockaddr_un) /* getpeername() */
|
||||
#define NWIOSUDSTYPE _IOW ('n', 72, int) /* socket() */
|
||||
#define NWIOSUDSBLOG _IOW ('n', 73, int) /* listen() */
|
||||
#define NWIOSUDSCONN _IOW ('n', 74, struct sockaddr_un) /* connect() */
|
||||
#define NWIOSUDSSHUT _IOW ('n', 75, int) /* shutdown() */
|
||||
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
|
||||
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
|
||||
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
|
||||
#define NWIOGUDSCTRL _IORW('n', 79, struct msg_control) /* recvmsg() */
|
||||
|
||||
#define NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt)
|
||||
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
|
||||
|
||||
/* setsockopt/setsockopt for unix domain sockets */
|
||||
#define NWIOGUDSSOTYPE _IOR('n', 90, int) /* SO_TYPE */
|
||||
#define NWIOGUDSPEERCRED _IOR('n', 91, struct ucred) /* SO_PEERCRED */
|
||||
#define NWIOGUDSSNDBUF _IOR('n', 92, size_t) /* SO_SNDBUF */
|
||||
#define NWIOSUDSSNDBUF _IOW('n', 93, size_t) /* SO_SNDBUF */
|
||||
#define NWIOGUDSRCVBUF _IOR('n', 94, size_t) /* SO_RCVBUF */
|
||||
#define NWIOSUDSRCVBUF _IOW('n', 95, size_t) /* SO_RCVBUF */
|
||||
|
||||
#endif /* _NET__IOCTL_H */
|
||||
|
||||
/*
|
||||
* $PchId: ioctl.h,v 1.2 2003/07/25 14:34:03 philip Exp $
|
||||
*/
|
||||
34
nbsd_include/sys/ioctl.h
Normal file
34
nbsd_include/sys/ioctl.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* sys/ioctl.h - All ioctl() command codes. Author: Kees J. Bot
|
||||
* 23 Nov 2002
|
||||
*
|
||||
* This header file includes all other ioctl command code headers.
|
||||
*/
|
||||
|
||||
#ifndef _S_IOCTL_H
|
||||
#define _S_IOCTL_H
|
||||
|
||||
/* A driver that uses ioctls claims a character for its series of commands.
|
||||
* For instance: #define TCGETS _IOR('T', 8, struct termios)
|
||||
* This is a terminal ioctl that uses the character 'T'. The character(s)
|
||||
* used in each header file are shown in the comment following.
|
||||
*/
|
||||
|
||||
#include <sys/ioc_tty.h> /* 'T' 't' 'k' */
|
||||
#include <sys/ioc_net.h> /* 'n' */
|
||||
#include <sys/ioc_disk.h> /* 'd' */
|
||||
#include <sys/ioc_file.h> /* 'f' */
|
||||
#include <sys/ioc_memory.h> /* 'm' */
|
||||
#include <sys/ioc_cmos.h> /* 'c' */
|
||||
#include <sys/ioc_tape.h> /* 'M' */
|
||||
#include <sys/ioc_scsi.h> /* 'S' */
|
||||
#include <sys/ioc_sound.h> /* 's' */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define TIOCDRAIN TCDRAIN
|
||||
#define TIOCGETA TCGETS
|
||||
#define TIOCSETA TCSETS
|
||||
#define TIOCSETAW TCSETSW
|
||||
#define TIOCSETAF TCSETSF
|
||||
#endif
|
||||
|
||||
#endif /* _S_IOCTL_H */
|
||||
51
nbsd_include/sys/ipc.h
Normal file
51
nbsd_include/sys/ipc.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* SVID compatible ipc.h file
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IPC_H_
|
||||
#define _SYS_IPC_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Data structure used to pass permission information to IPC operations. */
|
||||
struct ipc_perm
|
||||
{
|
||||
key_t key; /* Key. */
|
||||
uid_t uid; /* Owner's user ID. */
|
||||
gid_t gid; /* Owner's group ID. */
|
||||
uid_t cuid; /* Creator's user ID. */
|
||||
gid_t cgid; /* Creator's group ID. */
|
||||
unsigned short int mode; /* Reader/write permission. */
|
||||
unsigned short int __seq; /* Sequence number. */
|
||||
};
|
||||
|
||||
/* X/Open required constants (same values as system 5) */
|
||||
#define IPC_CREAT 001000 /* create entry if key does not exist */
|
||||
#define IPC_EXCL 002000 /* fail if key exists */
|
||||
#define IPC_NOWAIT 004000 /* error if request must wait */
|
||||
|
||||
#define IPC_PRIVATE (key_t)0 /* private key */
|
||||
|
||||
#define IPC_RMID 0 /* remove identifier */
|
||||
#define IPC_SET 1 /* set options */
|
||||
#define IPC_STAT 2 /* get options */
|
||||
|
||||
#ifdef __minix
|
||||
#define IPC_INFO 3 /* See ipcs. */
|
||||
#endif /* !__minix */
|
||||
|
||||
/*
|
||||
* Macro to convert between ipc ids and array indices or sequence ids.
|
||||
*/
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define IXSEQ_TO_IPCID(ix,perm) (((perm._seq) << 16) | (ix & 0xffff))
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
key_t ftok(const char *, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_IPC_H_ */
|
||||
100
nbsd_include/sys/localedef.h
Normal file
100
nbsd_include/sys/localedef.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* $NetBSD: localedef.h,v 1.9 2008/05/17 03:49:54 ginsbach Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Winning Strategies, Inc.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Winning Strategies, Inc.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_LOCALEDEF_H_
|
||||
#define _SYS_LOCALEDEF_H_
|
||||
|
||||
typedef struct {
|
||||
const char *yesexpr;
|
||||
const char *noexpr;
|
||||
const char *yesstr;
|
||||
const char *nostr;
|
||||
} _MessagesLocale;
|
||||
|
||||
extern const _MessagesLocale *_CurrentMessagesLocale;
|
||||
extern const _MessagesLocale _DefaultMessagesLocale;
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *int_curr_symbol;
|
||||
const char *currency_symbol;
|
||||
const char *mon_decimal_point;
|
||||
const char *mon_thousands_sep;
|
||||
const char *mon_grouping;
|
||||
const char *positive_sign;
|
||||
const char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char int_p_cs_precedes;
|
||||
char int_n_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
} _MonetaryLocale;
|
||||
|
||||
extern const _MonetaryLocale *_CurrentMonetaryLocale;
|
||||
extern const _MonetaryLocale _DefaultMonetaryLocale;
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *decimal_point;
|
||||
const char *thousands_sep;
|
||||
const char *grouping;
|
||||
} _NumericLocale;
|
||||
|
||||
extern const _NumericLocale *_CurrentNumericLocale;
|
||||
extern const _NumericLocale _DefaultNumericLocale;
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *abday[7];
|
||||
const char *day[7];
|
||||
const char *abmon[12];
|
||||
const char *mon[12];
|
||||
const char *am_pm[2];
|
||||
const char *d_t_fmt;
|
||||
const char *d_fmt;
|
||||
const char *t_fmt;
|
||||
const char *t_fmt_ampm;
|
||||
} _TimeLocale;
|
||||
|
||||
extern const _TimeLocale *_CurrentTimeLocale;
|
||||
extern const _TimeLocale _DefaultTimeLocale;
|
||||
|
||||
#endif /* !_SYS_LOCALEDEF_H_ */
|
||||
58
nbsd_include/sys/md4.h
Normal file
58
nbsd_include/sys/md4.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* $NetBSD: md4.h,v 1.7 2005/12/26 18:41:36 perry Exp $ */
|
||||
|
||||
/*
|
||||
* This file is derived from the RSA Data Security, Inc. MD4 Message-Digest
|
||||
* Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org>
|
||||
* for portability and formatting.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
* rights reserved.
|
||||
*
|
||||
* License to copy and use this software is granted provided that it
|
||||
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
||||
* Algorithm" in all material mentioning or referencing this software
|
||||
* or this function.
|
||||
*
|
||||
* License is also granted to make and use derivative works provided
|
||||
* that such works are identified as "derived from the RSA Data
|
||||
* Security, Inc. MD4 Message-Digest Algorithm" in all material
|
||||
* mentioning or referencing the derived work.
|
||||
*
|
||||
* RSA Data Security, Inc. makes no representations concerning either
|
||||
* the merchantability of this software or the suitability of this
|
||||
* software for any particular purpose. It is provided "as is"
|
||||
* without express or implied warranty of any kind.
|
||||
*
|
||||
* These notices must be retained in any copies of any part of this
|
||||
* documentation and/or software.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MD4_H_
|
||||
#define _SYS_MD4_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MD4_DIGEST_LENGTH 16
|
||||
|
||||
/* MD4 context. */
|
||||
typedef struct MD4Context {
|
||||
uint32_t state[4]; /* state (ABCD) */
|
||||
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} MD4_CTX;
|
||||
|
||||
__BEGIN_DECLS
|
||||
void MD4Init(MD4_CTX *);
|
||||
void MD4Update(MD4_CTX *, const unsigned char *, unsigned int);
|
||||
void MD4Final(unsigned char[MD4_DIGEST_LENGTH], MD4_CTX *);
|
||||
#ifndef _KERNEL
|
||||
char *MD4End(MD4_CTX *, char *);
|
||||
char *MD4File(const char *, char *);
|
||||
char *MD4Data(const unsigned char *, unsigned int, char *);
|
||||
#endif /* _KERNEL */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_MD4_H_ */
|
||||
58
nbsd_include/sys/md5.h
Normal file
58
nbsd_include/sys/md5.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* $NetBSD: md5.h,v 1.9 2005/12/26 18:41:36 perry Exp $ */
|
||||
|
||||
/*
|
||||
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
|
||||
* Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org>
|
||||
* for portability and formatting.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
* rights reserved.
|
||||
*
|
||||
* License to copy and use this software is granted provided that it
|
||||
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
* Algorithm" in all material mentioning or referencing this software
|
||||
* or this function.
|
||||
*
|
||||
* License is also granted to make and use derivative works provided
|
||||
* that such works are identified as "derived from the RSA Data
|
||||
* Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
* mentioning or referencing the derived work.
|
||||
*
|
||||
* RSA Data Security, Inc. makes no representations concerning either
|
||||
* the merchantability of this software or the suitability of this
|
||||
* software for any particular purpose. It is provided "as is"
|
||||
* without express or implied warranty of any kind.
|
||||
*
|
||||
* These notices must be retained in any copies of any part of this
|
||||
* documentation and/or software.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MD5_H_
|
||||
#define _SYS_MD5_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#define MD5_DIGEST_STRING_LENGTH 33
|
||||
|
||||
/* MD5 context. */
|
||||
typedef struct MD5Context {
|
||||
uint32_t state[4]; /* state (ABCD) */
|
||||
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} MD5_CTX;
|
||||
|
||||
__BEGIN_DECLS
|
||||
void MD5Init(MD5_CTX *);
|
||||
void MD5Update(MD5_CTX *, const unsigned char *, unsigned int);
|
||||
void MD5Final(unsigned char[MD5_DIGEST_LENGTH], MD5_CTX *);
|
||||
#ifndef _KERNEL
|
||||
char *MD5End(MD5_CTX *, char *);
|
||||
char *MD5File(const char *, char *);
|
||||
char *MD5Data(const unsigned char *, unsigned int, char *);
|
||||
#endif /* _KERNEL */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_MD5_H_ */
|
||||
76
nbsd_include/sys/mman.h
Normal file
76
nbsd_include/sys/mman.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef _SYS_MMAN_H_
|
||||
#define _SYS_MMAN_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#include <machine/ansi.h>
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
|
||||
#include <sys/ansi.h>
|
||||
|
||||
#ifndef mode_t
|
||||
typedef __mode_t mode_t;
|
||||
#define mode_t __mode_t
|
||||
#endif
|
||||
|
||||
#ifndef off_t
|
||||
typedef __off_t off_t; /* file offset */
|
||||
#define off_t __off_t
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Protections are chosen from these bits, or-ed together
|
||||
*/
|
||||
#define PROT_NONE 0x00 /* no permissions */
|
||||
#define PROT_READ 0x01 /* pages can be read */
|
||||
#define PROT_WRITE 0x02 /* pages can be written */
|
||||
#define PROT_EXEC 0x04 /* pages can be executed */
|
||||
|
||||
/*
|
||||
* Flags contain sharing type and options.
|
||||
* Sharing types; choose one.
|
||||
*/
|
||||
#define MAP_SHARED 0x0001 /* share changes */
|
||||
#define MAP_PRIVATE 0x0002 /* changes are private */
|
||||
|
||||
/*
|
||||
* Mapping type
|
||||
*/
|
||||
#define MAP_ANON 0x0004 /* anonymous memory */
|
||||
|
||||
/*
|
||||
* Minix specific flags.
|
||||
*/
|
||||
#define MAP_PREALLOC 0x0008 /* not on-demand */
|
||||
#define MAP_CONTIG 0x0010 /* contiguous in physical memory */
|
||||
#define MAP_LOWER16M 0x0020 /* physically below 16MB */
|
||||
#define MAP_ALIGN64K 0x0040 /* physically aligned at 64kB */
|
||||
#define MAP_LOWER1M 0x0080 /* physically below 16MB */
|
||||
#define MAP_ALIGNMENT_64KB MAP_ALIGN64K
|
||||
|
||||
/*
|
||||
* Error indicator returned by mmap(2)
|
||||
*/
|
||||
#define MAP_FAILED ((void *) -1) /* mmap() failed */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
void * mmap(void *, size_t, int, int, int, off_t);
|
||||
int munmap(void *, size_t);
|
||||
|
||||
#ifdef __minix
|
||||
int munmap_text(void *, size_t);
|
||||
void * vm_remap(int d, int s, void *da, void *sa, size_t si);
|
||||
int vm_unmap(int endpt, void *addr);
|
||||
unsigned long vm_getphys(int endpt, void *addr);
|
||||
u8_t vm_getrefcount(int endpt, void *addr);
|
||||
#endif /* __minix */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_MMAN_H_ */
|
||||
7
nbsd_include/sys/mount.h
Normal file
7
nbsd_include/sys/mount.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _SYS_MOUNT_H
|
||||
#define _SYS_MOUNT_H_
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
#include <minix/mount.h>
|
||||
|
||||
#endif /* !_SYS_MOUNT_H_ */
|
||||
16
nbsd_include/sys/null.h
Normal file
16
nbsd_include/sys/null.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/* $NetBSD: null.h,v 1.8 2009/10/13 17:19:00 dsl Exp $ */
|
||||
|
||||
#ifndef _SYS_NULL_H_
|
||||
#define _SYS_NULL_H_
|
||||
#ifndef NULL
|
||||
#if !defined(__GNUG__) || __GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 90)
|
||||
#if !defined(__cplusplus)
|
||||
#define NULL ((void *)0)
|
||||
#else
|
||||
#define NULL 0
|
||||
#endif /* !__cplusplus */
|
||||
#else
|
||||
#define NULL __null
|
||||
#endif
|
||||
#endif
|
||||
#endif /* _SYS_NULL_H_ */
|
||||
182
nbsd_include/sys/param.h
Normal file
182
nbsd_include/sys/param.h
Normal file
@@ -0,0 +1,182 @@
|
||||
#ifndef _SYS_PARAM_H_
|
||||
#define _SYS_PARAM_H_
|
||||
|
||||
/*
|
||||
* Historic BSD #defines -- probably will remain untouched for all time.
|
||||
*/
|
||||
#define BSD 199506 /* System version (year & month). */
|
||||
#define BSD4_3 1
|
||||
#define BSD4_4 1
|
||||
|
||||
/*
|
||||
* #define __NetBSD_Version__ MMmmrrpp00
|
||||
*
|
||||
* M = major version
|
||||
* m = minor version; a minor number of 99 indicates current.
|
||||
* r = 0 (*)
|
||||
* p = patchlevel
|
||||
*
|
||||
* When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local
|
||||
* needs to be updated and the changes sent back to the groff maintainers.
|
||||
*
|
||||
* (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric
|
||||
* e.g. NetBSD-1.2D = 102040000 ('D' == 4)
|
||||
* NetBSD-2.0H (200080000) was changed on 20041001 to:
|
||||
* 2.99.9 (299000900)
|
||||
*/
|
||||
|
||||
#define __NetBSD_Version__ 599002900 /* NetBSD 5.99.29 */
|
||||
|
||||
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
|
||||
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
|
||||
|
||||
/*
|
||||
* Historical NetBSD #define
|
||||
*
|
||||
* NetBSD 1.4 was the last release for which this value was incremented.
|
||||
* The value is now permanently fixed at 199905. It will never be
|
||||
* changed again.
|
||||
*
|
||||
* New code must use __NetBSD_Version__ instead, and should not even
|
||||
* count on NetBSD being defined.
|
||||
*
|
||||
*/
|
||||
|
||||
#define NetBSD 199905 /* NetBSD version (year & month). */
|
||||
|
||||
#include <sys/null.h>
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#include <sys/inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Machine-independent constants (some used in following include files).
|
||||
* Redefined constants are from POSIX 1003.1 limits file.
|
||||
*
|
||||
* MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
|
||||
* MAXHOSTNAMELEN should be >= (_POSIX_HOST_NAME_MAX + 1) (see <limits.h>)
|
||||
* MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
|
||||
*/
|
||||
#include <sys/syslimits.h>
|
||||
|
||||
|
||||
#define MAXCOMLEN 16 /* max command name remembered */
|
||||
#define MAXINTERP PATH_MAX /* max interpreter file name length */
|
||||
/* DEPRECATED: use LOGIN_NAME_MAX instead. */
|
||||
#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */
|
||||
#ifndef __minix
|
||||
#define NCARGS ARG_MAX /* max bytes for an exec function */
|
||||
#endif
|
||||
#define NGROUPS NGROUPS_MAX /* max number groups */
|
||||
#define NOGROUP 65535 /* marker for empty group set member */
|
||||
|
||||
#define MAXHOSTNAMELEN 256 /* max hostname size */
|
||||
|
||||
#ifndef NOFILE
|
||||
#define NOFILE OPEN_MAX /* max open files per process */
|
||||
#endif
|
||||
#ifndef MAXUPRC /* max simultaneous processes */
|
||||
#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */
|
||||
#else
|
||||
#if (MAXUPRC - 0) < CHILD_MAX
|
||||
#error MAXUPRC less than CHILD_MAX. See options(4) for details.
|
||||
#endif /* (MAXUPRC - 0) < CHILD_MAX */
|
||||
#endif /* !defined(MAXUPRC) */
|
||||
|
||||
/* Signals. */
|
||||
#include <sys/signal.h>
|
||||
|
||||
/* Machine type dependent parameters. */
|
||||
#include <machine/param.h>
|
||||
#include <machine/limits.h>
|
||||
|
||||
/* pages ("clicks") to disk blocks */
|
||||
#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
|
||||
#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
|
||||
|
||||
/* bytes to pages */
|
||||
#define ctob(x) ((x) << PGSHIFT)
|
||||
#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
|
||||
|
||||
/* bytes to disk blocks */
|
||||
#define dbtob(x) ((x) << DEV_BSHIFT)
|
||||
#define btodb(x) ((x) >> DEV_BSHIFT)
|
||||
|
||||
#ifndef COHERENCY_UNIT
|
||||
#define COHERENCY_UNIT 64
|
||||
#endif
|
||||
#ifndef CACHE_LINE_SIZE
|
||||
#define CACHE_LINE_SIZE 64
|
||||
#endif
|
||||
#ifndef MAXCPUS
|
||||
#define MAXCPUS 32
|
||||
#endif
|
||||
#ifndef MAX_LWP_PER_PROC
|
||||
#define MAX_LWP_PER_PROC 8000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Miscellaneous.
|
||||
*/
|
||||
#define NBPW sizeof(int) /* number of bytes per word (integer) */
|
||||
|
||||
#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
|
||||
#define NODEV (dev_t)(-1) /* non-existent device */
|
||||
|
||||
#define CBLOCK 64 /* Clist block size, must be a power of 2. */
|
||||
#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
|
||||
/* Data chars/clist. */
|
||||
#define CBSIZE (CBLOCK - (int)sizeof(struct cblock *) - CBQSIZE)
|
||||
#define CROUND (CBLOCK - 1) /* Clist rounding. */
|
||||
|
||||
/*
|
||||
* File system parameters and macros.
|
||||
*
|
||||
* The file system is made out of blocks of at most MAXBSIZE units, with
|
||||
* smaller units (fragments) only in the last direct block. MAXBSIZE
|
||||
* primarily determines the size of buffers in the buffer pool. It may be
|
||||
* made larger without any effect on existing file systems; however making
|
||||
* it smaller may make some file systems unmountable.
|
||||
*/
|
||||
#ifndef MAXBSIZE /* XXX */
|
||||
#define MAXBSIZE MAXPHYS
|
||||
#endif
|
||||
#define MAXFRAG 8
|
||||
|
||||
/*
|
||||
* MAXPATHLEN defines the longest permissible path length after expanding
|
||||
* symbolic links. It is used to allocate a temporary buffer from the buffer
|
||||
* pool in which to do the name expansion, hence should be a power of two,
|
||||
* and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
|
||||
* maximum number of symbolic links that may be expanded in a path name.
|
||||
* It should be set high enough to allow all legitimate uses, but halt
|
||||
* infinite loops reasonably quickly.
|
||||
*
|
||||
* MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>)
|
||||
*/
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#define MAXSYMLINKS 32
|
||||
|
||||
/* Bit map related macros. */
|
||||
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
||||
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
||||
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
||||
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
|
||||
/* Macros for counting and rounding. */
|
||||
#ifndef howmany
|
||||
#define howmany(x, y) (((x)+((y)-1))/(y))
|
||||
#endif
|
||||
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
|
||||
#define rounddown(x,y) (((x)/(y))*(y))
|
||||
#define roundup2(x, m) (((x) + (m) - 1) & ~((m) - 1))
|
||||
#define powerof2(x) ((((x)-1)&(x))==0)
|
||||
|
||||
/* Macros for min/max. */
|
||||
#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
|
||||
#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b))
|
||||
|
||||
#endif /* !__ASSEMBLER__ */
|
||||
|
||||
#endif /* !_SYS_PARAM_H_ */
|
||||
67
nbsd_include/sys/poll.h
Normal file
67
nbsd_include/sys/poll.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* $NetBSD: poll.h,v 1.3 2008/04/29 05:46:08 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _NBCOMPAT_POLL_H_
|
||||
#define _NBCOMPAT_POLL_H_
|
||||
|
||||
typedef unsigned int nfds_t;
|
||||
|
||||
#define INFTIM -1
|
||||
|
||||
struct pollfd {
|
||||
int fd; /* file descriptor */
|
||||
short events; /* events to look for */
|
||||
short revents; /* events returned */
|
||||
};
|
||||
|
||||
/*
|
||||
* Testable events (may be specified in events field).
|
||||
*/
|
||||
#define POLLIN 0x0001
|
||||
#define POLLPRI 0x0002
|
||||
#define POLLOUT 0x0004
|
||||
#define POLLRDNORM 0x0040
|
||||
#define POLLWRNORM POLLOUT
|
||||
#define POLLRDBAND 0x0080
|
||||
#define POLLWRBAND 0x0100
|
||||
|
||||
/*
|
||||
* Non-testable events (may not be specified in events field).
|
||||
*/
|
||||
#define POLLERR 0x0008
|
||||
#define POLLHUP 0x0010
|
||||
#define POLLNVAL 0x0020
|
||||
|
||||
__BEGIN_DECLS
|
||||
int poll (struct pollfd *, nfds_t, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_NBCOMPAT_POLL_H_ */
|
||||
58
nbsd_include/sys/ptrace.h
Normal file
58
nbsd_include/sys/ptrace.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* <sys/ptrace.h>
|
||||
* definitions for ptrace(2)
|
||||
*/
|
||||
|
||||
#ifndef _PTRACE_H
|
||||
#define _PTRACE_H
|
||||
|
||||
/* Trace requests. */
|
||||
#define T_STOP -1 /* stop the process */
|
||||
#define T_OK 0 /* enable tracing by parent for this process */
|
||||
#define T_GETINS 1 /* return value from instruction space */
|
||||
#define T_GETDATA 2 /* return value from data space */
|
||||
#define T_GETUSER 3 /* return value from user process table */
|
||||
#define T_SETINS 4 /* set value from instruction space */
|
||||
#define T_SETDATA 5 /* set value from data space */
|
||||
#define T_SETUSER 6 /* set value in user process table */
|
||||
#define T_RESUME 7 /* resume execution */
|
||||
#define T_EXIT 8 /* exit */
|
||||
#define T_STEP 9 /* set trace bit */
|
||||
#define T_SYSCALL 10 /* trace system call */
|
||||
#define T_ATTACH 11 /* attach to a running process */
|
||||
#define T_DETACH 12 /* detach from a traced process */
|
||||
#define T_SETOPT 13 /* set trace options */
|
||||
#define T_GETRANGE 14 /* get range of values */
|
||||
#define T_SETRANGE 15 /* set range of values */
|
||||
|
||||
#define T_READB_INS 100 /* Read a byte from the text segment of an
|
||||
* untraced process (only for root)
|
||||
*/
|
||||
#define T_WRITEB_INS 101 /* Write a byte in the text segment of an
|
||||
* untraced process (only for root)
|
||||
*/
|
||||
|
||||
/* Trace options. */
|
||||
#define TO_TRACEFORK 0x1 /* automatically attach to forked children */
|
||||
#define TO_ALTEXEC 0x2 /* send SIGSTOP on successful exec() */
|
||||
#define TO_NOEXEC 0x4 /* do not send signal on successful exec() */
|
||||
|
||||
/* Trace spaces. */
|
||||
#define TS_INS 0 /* text space */
|
||||
#define TS_DATA 1 /* data space */
|
||||
|
||||
/* Trance range structure. */
|
||||
struct ptrace_range {
|
||||
int pr_space; /* space in traced process */
|
||||
long pr_addr; /* address in traced process */
|
||||
void *pr_ptr; /* buffer in caller process */
|
||||
size_t pr_size; /* size of range, in bytes */
|
||||
};
|
||||
|
||||
/* Function Prototypes. */
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
long ptrace(int _req, pid_t _pid, long _addr, long _data);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _PTRACE_H */
|
||||
188
nbsd_include/sys/ptree.h
Normal file
188
nbsd_include/sys/ptree.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/* $NetBSD: ptree.h,v 1.3 2008/11/25 15:13:47 ad Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas <matt@3am-software.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
#ifndef _SYS_PTREE_H_
|
||||
#define _SYS_PTREE_H_
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PT_DESCENDING=-1,
|
||||
PT_ASCENDING=1
|
||||
} pt_direction_t;
|
||||
|
||||
typedef unsigned int pt_slot_t;
|
||||
typedef unsigned int pt_bitoff_t;
|
||||
typedef unsigned int pt_bitlen_t;
|
||||
|
||||
typedef struct pt_node {
|
||||
uintptr_t ptn_slots[2]; /* must be first */
|
||||
#define PT_SLOT_LEFT 0
|
||||
#define PT_SLOT_RIGHT 1
|
||||
#ifdef _PT_PRIVATE
|
||||
#define PT_SLOT_ROOT 0
|
||||
#define PT_SLOT_OTHER 1
|
||||
#define PT_SLOT_ODDMAN 1
|
||||
#define PT_TYPE_LEAF 0x00000000
|
||||
#define PT_TYPE_BRANCH 0x00000001
|
||||
#define PT_TYPE_MASK 0x00000001
|
||||
#endif /* _PT_PRIVATE */
|
||||
|
||||
uint32_t ptn_nodedata;
|
||||
#ifdef _PT_PRIVATE
|
||||
#define PTN_LEAF_POSITION_BITS 8
|
||||
#define PTN_LEAF_POSITION_SHIFT 0
|
||||
#define PTN_BRANCH_POSITION_BITS 8
|
||||
#define PTN_BRANCH_POSITION_SHIFT 8
|
||||
#ifndef PTNOMASK
|
||||
#define PTN_MASK_BITLEN_BITS 15
|
||||
#define PTN_MASK_BITLEN_SHIFT 16
|
||||
#define PTN_MASK_FLAG 0x80000000
|
||||
#endif
|
||||
#endif /* _PT_PRIVATE */
|
||||
|
||||
uint32_t ptn_branchdata;
|
||||
#ifdef _PT_PRIVATE
|
||||
#define PTN_BRANCH_BITOFF_BITS 15
|
||||
#define PTN_BRANCH_BITOFF_SHIFT 0
|
||||
#define PTN_BRANCH_BITLEN_BITS 8
|
||||
#define PTN_BRANCH_BITLEN_SHIFT 16
|
||||
#if 0
|
||||
#define PTN_ORIENTATION_BITS 1
|
||||
#define PTN_ORIENTATION_SHIFT 30
|
||||
#endif
|
||||
#define PTN_BRANCH_UNUSED 0x3f000000
|
||||
#define PTN_XBRANCH_FLAG 0x80000000
|
||||
#endif /* _PT_PRIVATE */
|
||||
} pt_node_t;
|
||||
|
||||
#ifdef _PT_PRIVATE
|
||||
#define PT_NODE(node) ((pt_node_t *)(node & ~PT_TYPE_MASK))
|
||||
#define PT_TYPE(node) ((node) & PT_TYPE_MASK)
|
||||
#define PT_NULL 0
|
||||
#define PT_NULL_P(node) ((node) == PT_NULL)
|
||||
#define PT_LEAF_P(node) (PT_TYPE(node) == PT_TYPE_LEAF)
|
||||
#define PT_BRANCH_P(node) (PT_TYPE(node) == PT_TYPE_BRANCH)
|
||||
#define PTN__TYPELESS(ptn) (((uintptr_t)ptn) & ~PT_TYPE_MASK)
|
||||
#define PTN_LEAF(ptn) (PTN__TYPELESS(ptn) | PT_TYPE_LEAF)
|
||||
#define PTN_BRANCH(ptn) (PTN__TYPELESS(ptn) | PT_TYPE_BRANCH)
|
||||
|
||||
#ifndef PTNOMASK
|
||||
#define PTN_MARK_MASK(ptn) ((ptn)->ptn_nodedata |= PTN_MASK_FLAG)
|
||||
#define PTN_ISMASK_P(ptn) (((ptn)->ptn_nodedata & PTN_MASK_FLAG) != 0)
|
||||
#endif
|
||||
#define PTN_MARK_XBRANCH(ptn) ((ptn)->ptn_branchdata |= PTN_XBRANCH_FLAG)
|
||||
#define PTN_ISXBRANCH_P(ptn) (((ptn)->ptn_branchdata & PTN_XBRANCH_FLAG) != 0)
|
||||
#define PTN_ISROOT_P(pt, ptn) ((ptn) == &(pt)->pt_rootnode)
|
||||
|
||||
#define PTN_BRANCH_SLOT(ptn,slot) ((ptn)->ptn_slots[slot])
|
||||
#define PTN_BRANCH_ROOT_SLOT(ptn) ((ptn)->ptn_slots[PT_SLOT_ROOT])
|
||||
#define PTN_BRANCH_ODDMAN_SLOT(ptn) ((ptn)->ptn_slots[PT_SLOT_ODDMAN])
|
||||
#define PTN_COPY_BRANCH_SLOTS(dst,src) \
|
||||
((dst)->ptn_slots[PT_SLOT_LEFT ] = (src)->ptn_slots[PT_SLOT_LEFT ], \
|
||||
(dst)->ptn_slots[PT_SLOT_RIGHT] = (src)->ptn_slots[PT_SLOT_RIGHT])
|
||||
#define PTN_ISSLOTVALID_P(ptn,slot) ((slot) < (1 << PTN_BRANCH_BITLEN(pt)))
|
||||
|
||||
#define PT__MASK(n) ((1 << n ## _BITS) - 1)
|
||||
#define PT__SHIFT(n) (n ## _SHIFT)
|
||||
#define PTN__EXTRACT(field, b) \
|
||||
(((field) >> PT__SHIFT(b)) & PT__MASK(b))
|
||||
#define PTN__INSERT2(field, v, shift, mask) \
|
||||
((field) = ((field) & ~((mask) << (shift))) | ((v) << (shift)))
|
||||
#define PTN__INSERT(field, b, v) \
|
||||
PTN__INSERT2(field, v, PT__SHIFT(b), PT__MASK(b))
|
||||
|
||||
#define PTN_BRANCH_BITOFF(ptn) \
|
||||
PTN__EXTRACT((ptn)->ptn_branchdata, PTN_BRANCH_BITOFF)
|
||||
#define PTN_BRANCH_BITLEN(ptn) \
|
||||
PTN__EXTRACT((ptn)->ptn_branchdata, PTN_BRANCH_BITLEN)
|
||||
#define PTN_SET_BRANCH_BITOFF(ptn,bitoff) \
|
||||
PTN__INSERT((ptn)->ptn_branchdata, PTN_BRANCH_BITOFF, bitoff)
|
||||
#define PTN_SET_BRANCH_BITLEN(ptn,bitlen) \
|
||||
PTN__INSERT((ptn)->ptn_branchdata, PTN_BRANCH_BITLEN, bitlen)
|
||||
|
||||
#define PTN_LEAF_POSITION(ptn) \
|
||||
PTN__EXTRACT((ptn)->ptn_nodedata, PTN_LEAF_POSITION)
|
||||
#define PTN_BRANCH_POSITION(ptn) \
|
||||
PTN__EXTRACT((ptn)->ptn_nodedata, PTN_BRANCH_POSITION)
|
||||
#define PTN_SET_LEAF_POSITION(ptn,slot) \
|
||||
PTN__INSERT((ptn)->ptn_nodedata, PTN_LEAF_POSITION, slot)
|
||||
#define PTN_SET_BRANCH_POSITION(ptn,slot) \
|
||||
PTN__INSERT((ptn)->ptn_nodedata, PTN_BRANCH_POSITION, slot)
|
||||
|
||||
#ifndef PTNOMASK
|
||||
#define PTN_MASK_BITLEN(ptn) \
|
||||
PTN__EXTRACT((ptn)->ptn_nodedata, PTN_MASK_BITLEN)
|
||||
#define PTN_SET_MASK_BITLEN(ptn,masklen) \
|
||||
PTN__INSERT((ptn)->ptn_nodedata, PTN_MASK_BITLEN, masklen)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define PTN_ORIENTATION(ptn) \
|
||||
PTN__EXTRACT((ptn)->ptn_branchdata, PTN_ORIENTATION)
|
||||
#define PTN_SET_ORIENTATION(ptn,slot) \
|
||||
PTN__INSERT((ptn)->ptn_branchdata, PTN_ORIENTATION, slot)
|
||||
#endif
|
||||
#endif /* _PT_PRIVATE */
|
||||
|
||||
typedef struct pt_tree_ops {
|
||||
bool (*ptto_matchnode)(const void *, const void *, pt_bitoff_t,
|
||||
pt_bitoff_t *, pt_slot_t *);
|
||||
bool (*ptto_matchkey)(const void *, const void *, pt_bitoff_t,
|
||||
pt_bitlen_t);
|
||||
pt_slot_t (*ptto_testnode)(const void *, pt_bitoff_t, pt_bitlen_t);
|
||||
pt_slot_t (*ptto_testkey)(const void *, pt_bitoff_t, pt_bitlen_t);
|
||||
} pt_tree_ops_t;
|
||||
|
||||
typedef struct pt_tree {
|
||||
pt_node_t pt_rootnode;
|
||||
#define pt_root pt_rootnode.ptn_slots[PT_SLOT_ROOT]
|
||||
#define pt_oddman pt_rootnode.ptn_slots[PT_SLOT_ODDMAN]
|
||||
const pt_tree_ops_t *pt_ops;
|
||||
size_t pt_node_offset;
|
||||
size_t pt_key_offset;
|
||||
uintptr_t pt_spare[4];
|
||||
} pt_tree_t;
|
||||
|
||||
#define PT_FILTER_MASK 0x00000001 /* node is a mask */
|
||||
typedef bool (*pt_filter_t)(void *, const void *, int);
|
||||
|
||||
void ptree_init(pt_tree_t *, const pt_tree_ops_t *, size_t, size_t);
|
||||
bool ptree_insert_node(pt_tree_t *, void *);
|
||||
bool ptree_insert_mask_node(pt_tree_t *, void *, pt_bitlen_t);
|
||||
void * ptree_find_filtered_node(pt_tree_t *, void *, pt_filter_t, void *);
|
||||
#define ptree_find_node(pt,key) \
|
||||
ptree_find_filtered_node((pt), (key), NULL, NULL)
|
||||
void ptree_remove_node(pt_tree_t *, void *);
|
||||
void * ptree_iterate(pt_tree_t *, const void *, pt_direction_t);
|
||||
|
||||
#endif /* _SYS_PTREE_H_ */
|
||||
739
nbsd_include/sys/queue.h
Normal file
739
nbsd_include/sys/queue.h
Normal file
@@ -0,0 +1,739 @@
|
||||
/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 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.
|
||||
*
|
||||
* @(#)queue.h 8.5 (Berkeley) 8/20/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_QUEUE_H_
|
||||
#define _SYS_QUEUE_H_
|
||||
|
||||
#include <sys/null.h>
|
||||
|
||||
/*
|
||||
* This file defines five types of data structures: singly-linked lists,
|
||||
* lists, simple queues, tail queues, and circular queues.
|
||||
*
|
||||
* A singly-linked list is headed by a single forward pointer. The
|
||||
* elements are singly linked for minimum space and pointer manipulation
|
||||
* overhead at the expense of O(n) removal for arbitrary elements. New
|
||||
* elements can be added to the list after an existing element or at the
|
||||
* head of the list. Elements being removed from the head of the list
|
||||
* should use the explicit macro for this purpose for optimum
|
||||
* efficiency. A singly-linked list may only be traversed in the forward
|
||||
* direction. Singly-linked lists are ideal for applications with large
|
||||
* datasets and few or no removals or for implementing a LIFO queue.
|
||||
*
|
||||
* A list is headed by a single forward pointer (or an array of forward
|
||||
* pointers for a hash table header). The elements are doubly linked
|
||||
* so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before
|
||||
* or after an existing element or at the head of the list. A list
|
||||
* may only be traversed in the forward direction.
|
||||
*
|
||||
* A simple queue is headed by a pair of pointers, one the head of the
|
||||
* list and the other to the tail of the list. The elements are singly
|
||||
* linked to save space, so elements can only be removed from the
|
||||
* head of the list. New elements can be added to the list after
|
||||
* an existing element, at the head of the list, or at the end of the
|
||||
* list. A simple queue may only be traversed in the forward direction.
|
||||
*
|
||||
* A tail queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before or
|
||||
* after an existing element, at the head of the list, or at the end of
|
||||
* the list. A tail queue may be traversed in either direction.
|
||||
*
|
||||
* A circle queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before or after
|
||||
* an existing element, at the head of the list, or at the end of the list.
|
||||
* A circle queue may be traversed in either direction, but has a more
|
||||
* complex end of list detection.
|
||||
*
|
||||
* For details on the use of these macros, see the queue(3) manual page.
|
||||
*/
|
||||
|
||||
/*
|
||||
* List definitions.
|
||||
*/
|
||||
#define LIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *lh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define LIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define LIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *le_next; /* next element */ \
|
||||
struct type **le_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* List functions.
|
||||
*/
|
||||
#if defined(_KERNEL) && defined(QUEUEDEBUG)
|
||||
#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \
|
||||
if ((head)->lh_first && \
|
||||
(head)->lh_first->field.le_prev != &(head)->lh_first) \
|
||||
panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_LIST_OP(elm, field) \
|
||||
if ((elm)->field.le_next && \
|
||||
(elm)->field.le_next->field.le_prev != \
|
||||
&(elm)->field.le_next) \
|
||||
panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
|
||||
if (*(elm)->field.le_prev != (elm)) \
|
||||
panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \
|
||||
(elm)->field.le_next = (void *)1L; \
|
||||
(elm)->field.le_prev = (void *)1L;
|
||||
#else
|
||||
#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field)
|
||||
#define QUEUEDEBUG_LIST_OP(elm, field)
|
||||
#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field)
|
||||
#endif
|
||||
|
||||
#define LIST_INIT(head) do { \
|
||||
(head)->lh_first = NULL; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
||||
QUEUEDEBUG_LIST_OP((listelm), field) \
|
||||
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
||||
(listelm)->field.le_next->field.le_prev = \
|
||||
&(elm)->field.le_next; \
|
||||
(listelm)->field.le_next = (elm); \
|
||||
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QUEUEDEBUG_LIST_OP((listelm), field) \
|
||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||
(elm)->field.le_next = (listelm); \
|
||||
*(listelm)->field.le_prev = (elm); \
|
||||
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \
|
||||
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
||||
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
|
||||
(head)->lh_first = (elm); \
|
||||
(elm)->field.le_prev = &(head)->lh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
QUEUEDEBUG_LIST_OP((elm), field) \
|
||||
if ((elm)->field.le_next != NULL) \
|
||||
(elm)->field.le_next->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = (elm)->field.le_next; \
|
||||
QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define LIST_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->lh_first); \
|
||||
(var); \
|
||||
(var) = ((var)->field.le_next))
|
||||
|
||||
/*
|
||||
* List access methods.
|
||||
*/
|
||||
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
|
||||
#define LIST_FIRST(head) ((head)->lh_first)
|
||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||
|
||||
|
||||
/*
|
||||
* Singly-linked List definitions.
|
||||
*/
|
||||
#define SLIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define SLIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define SLIST_INIT(head) do { \
|
||||
(head)->slh_first = NULL; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||
(slistelm)->field.sle_next = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
(elm)->field.sle_next = (head)->slh_first; \
|
||||
(head)->slh_first = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
if ((head)->slh_first == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = (head)->slh_first; \
|
||||
while(curelm->field.sle_next != (elm)) \
|
||||
curelm = curelm->field.sle_next; \
|
||||
curelm->field.sle_next = \
|
||||
curelm->field.sle_next->field.sle_next; \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_REMOVE_AFTER(slistelm, field) do { \
|
||||
(slistelm)->field.sle_next = \
|
||||
SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SLIST_FOREACH(var, head, field) \
|
||||
for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
|
||||
|
||||
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
/*
|
||||
* Singly-linked List access methods.
|
||||
*/
|
||||
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
|
||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue declarations.
|
||||
*/
|
||||
#define STAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *stqh_first; /* first element */ \
|
||||
struct type **stqh_last; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).stqh_first }
|
||||
|
||||
#define STAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue functions.
|
||||
*/
|
||||
#define STAILQ_INIT(head) do { \
|
||||
(head)->stqh_first = NULL; \
|
||||
(head)->stqh_last = &(head)->stqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
|
||||
(head)->stqh_last = &(elm)->field.stqe_next; \
|
||||
(head)->stqh_first = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
(elm)->field.stqe_next = NULL; \
|
||||
*(head)->stqh_last = (elm); \
|
||||
(head)->stqh_last = &(elm)->field.stqe_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
|
||||
(head)->stqh_last = &(elm)->field.stqe_next; \
|
||||
(listelm)->field.stqe_next = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
||||
if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
|
||||
(head)->stqh_last = &(head)->stqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
||||
if ((head)->stqh_first == (elm)) { \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} else { \
|
||||
struct type *curelm = (head)->stqh_first; \
|
||||
while (curelm->field.stqe_next != (elm)) \
|
||||
curelm = curelm->field.stqe_next; \
|
||||
if ((curelm->field.stqe_next = \
|
||||
curelm->field.stqe_next->field.stqe_next) == NULL) \
|
||||
(head)->stqh_last = &(curelm)->field.stqe_next; \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->stqh_first); \
|
||||
(var); \
|
||||
(var) = ((var)->field.stqe_next))
|
||||
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define STAILQ_CONCAT(head1, head2) do { \
|
||||
if (!STAILQ_EMPTY((head2))) { \
|
||||
*(head1)->stqh_last = (head2)->stqh_first; \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_INIT((head2)); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? \
|
||||
NULL : \
|
||||
((struct type *)(void *) \
|
||||
((char *)((head)->stqh_last) - offsetof(struct type, field))))
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue access methods.
|
||||
*/
|
||||
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
|
||||
#define STAILQ_FIRST(head) ((head)->stqh_first)
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
|
||||
/*
|
||||
* Simple queue definitions.
|
||||
*/
|
||||
#define SIMPLEQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *sqh_first; /* first element */ \
|
||||
struct type **sqh_last; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define SIMPLEQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).sqh_first }
|
||||
|
||||
#define SIMPLEQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple queue functions.
|
||||
*/
|
||||
#define SIMPLEQ_INIT(head) do { \
|
||||
(head)->sqh_first = NULL; \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(head)->sqh_first = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
(elm)->field.sqe_next = NULL; \
|
||||
*(head)->sqh_last = (elm); \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(listelm)->field.sqe_next = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
|
||||
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
|
||||
if ((head)->sqh_first == (elm)) { \
|
||||
SIMPLEQ_REMOVE_HEAD((head), field); \
|
||||
} else { \
|
||||
struct type *curelm = (head)->sqh_first; \
|
||||
while (curelm->field.sqe_next != (elm)) \
|
||||
curelm = curelm->field.sqe_next; \
|
||||
if ((curelm->field.sqe_next = \
|
||||
curelm->field.sqe_next->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(curelm)->field.sqe_next; \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->sqh_first); \
|
||||
(var); \
|
||||
(var) = ((var)->field.sqe_next))
|
||||
|
||||
#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \
|
||||
for ((var) = ((head)->sqh_first); \
|
||||
(var) && ((next = ((var)->field.sqe_next)), 1); \
|
||||
(var) = (next))
|
||||
|
||||
#define SIMPLEQ_CONCAT(head1, head2) do { \
|
||||
if (!SIMPLEQ_EMPTY((head2))) { \
|
||||
*(head1)->sqh_last = (head2)->sqh_first; \
|
||||
(head1)->sqh_last = (head2)->sqh_last; \
|
||||
SIMPLEQ_INIT((head2)); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define SIMPLEQ_LAST(head, type, field) \
|
||||
(SIMPLEQ_EMPTY((head)) ? \
|
||||
NULL : \
|
||||
((struct type *)(void *) \
|
||||
((char *)((head)->sqh_last) - offsetof(struct type, field))))
|
||||
|
||||
/*
|
||||
* Simple queue access methods.
|
||||
*/
|
||||
#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
|
||||
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
|
||||
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
|
||||
|
||||
|
||||
/*
|
||||
* Tail queue definitions.
|
||||
*/
|
||||
#define _TAILQ_HEAD(name, type, qual) \
|
||||
struct name { \
|
||||
qual type *tqh_first; /* first element */ \
|
||||
qual type *qual *tqh_last; /* addr of last next element */ \
|
||||
}
|
||||
#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
|
||||
|
||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).tqh_first }
|
||||
|
||||
#define _TAILQ_ENTRY(type, qual) \
|
||||
struct { \
|
||||
qual type *tqe_next; /* next element */ \
|
||||
qual type *qual *tqe_prev; /* address of previous next element */\
|
||||
}
|
||||
#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#if defined(_KERNEL) && defined(QUEUEDEBUG)
|
||||
#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \
|
||||
if ((head)->tqh_first && \
|
||||
(head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \
|
||||
panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \
|
||||
if (*(head)->tqh_last != NULL) \
|
||||
panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_TAILQ_OP(elm, field) \
|
||||
if ((elm)->field.tqe_next && \
|
||||
(elm)->field.tqe_next->field.tqe_prev != \
|
||||
&(elm)->field.tqe_next) \
|
||||
panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
|
||||
if (*(elm)->field.tqe_prev != (elm)) \
|
||||
panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \
|
||||
if ((elm)->field.tqe_next == NULL && \
|
||||
(head)->tqh_last != &(elm)->field.tqe_next) \
|
||||
panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \
|
||||
(head), (elm), __FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \
|
||||
(elm)->field.tqe_next = (void *)1L; \
|
||||
(elm)->field.tqe_prev = (void *)1L;
|
||||
#else
|
||||
#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field)
|
||||
#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field)
|
||||
#define QUEUEDEBUG_TAILQ_OP(elm, field)
|
||||
#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field)
|
||||
#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field)
|
||||
#endif
|
||||
|
||||
#define TAILQ_INIT(head) do { \
|
||||
(head)->tqh_first = NULL; \
|
||||
(head)->tqh_last = &(head)->tqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \
|
||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||
(head)->tqh_first->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(head)->tqh_first = (elm); \
|
||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \
|
||||
(elm)->field.tqe_next = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
QUEUEDEBUG_TAILQ_OP((listelm), field) \
|
||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(listelm)->field.tqe_next = (elm); \
|
||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QUEUEDEBUG_TAILQ_OP((listelm), field) \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
(elm)->field.tqe_next = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \
|
||||
QUEUEDEBUG_TAILQ_OP((elm), field) \
|
||||
if (((elm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||
QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define TAILQ_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->tqh_first); \
|
||||
(var); \
|
||||
(var) = ((var)->field.tqe_next))
|
||||
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, next) \
|
||||
for ((var) = ((head)->tqh_first); \
|
||||
(var) != NULL && ((next) = TAILQ_NEXT(var, field), 1); \
|
||||
(var) = (next))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||
for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
|
||||
(var); \
|
||||
(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var) && ((prev) = TAILQ_PREV((var), headname, field), 1);\
|
||||
(var) = (prev))
|
||||
|
||||
#define TAILQ_CONCAT(head1, head2, field) do { \
|
||||
if (!TAILQ_EMPTY(head2)) { \
|
||||
*(head1)->tqh_last = (head2)->tqh_first; \
|
||||
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
TAILQ_INIT((head2)); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
/*
|
||||
* Tail queue access methods.
|
||||
*/
|
||||
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
|
||||
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
||||
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
||||
|
||||
#define TAILQ_LAST(head, headname) \
|
||||
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
||||
#define TAILQ_PREV(elm, headname, field) \
|
||||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||
|
||||
|
||||
/*
|
||||
* Circular queue definitions.
|
||||
*/
|
||||
#if defined(_KERNEL) && defined(QUEUEDEBUG)
|
||||
#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \
|
||||
if ((head)->cqh_first != (void *)(head) && \
|
||||
(head)->cqh_first->field.cqe_prev != (void *)(head)) \
|
||||
panic("CIRCLEQ head forw %p %s:%d", (head), \
|
||||
__FILE__, __LINE__); \
|
||||
if ((head)->cqh_last != (void *)(head) && \
|
||||
(head)->cqh_last->field.cqe_next != (void *)(head)) \
|
||||
panic("CIRCLEQ head back %p %s:%d", (head), \
|
||||
__FILE__, __LINE__);
|
||||
#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \
|
||||
if ((elm)->field.cqe_next == (void *)(head)) { \
|
||||
if ((head)->cqh_last != (elm)) \
|
||||
panic("CIRCLEQ elm last %p %s:%d", (elm), \
|
||||
__FILE__, __LINE__); \
|
||||
} else { \
|
||||
if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \
|
||||
panic("CIRCLEQ elm forw %p %s:%d", (elm), \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
if ((elm)->field.cqe_prev == (void *)(head)) { \
|
||||
if ((head)->cqh_first != (elm)) \
|
||||
panic("CIRCLEQ elm first %p %s:%d", (elm), \
|
||||
__FILE__, __LINE__); \
|
||||
} else { \
|
||||
if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \
|
||||
panic("CIRCLEQ elm prev %p %s:%d", (elm), \
|
||||
__FILE__, __LINE__); \
|
||||
}
|
||||
#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \
|
||||
(elm)->field.cqe_next = (void *)1L; \
|
||||
(elm)->field.cqe_prev = (void *)1L;
|
||||
#else
|
||||
#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)
|
||||
#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)
|
||||
#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)
|
||||
#endif
|
||||
|
||||
#define CIRCLEQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *cqh_first; /* first element */ \
|
||||
struct type *cqh_last; /* last element */ \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_HEAD_INITIALIZER(head) \
|
||||
{ (void *)&head, (void *)&head }
|
||||
|
||||
#define CIRCLEQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *cqe_next; /* next element */ \
|
||||
struct type *cqe_prev; /* previous element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Circular queue functions.
|
||||
*/
|
||||
#define CIRCLEQ_INIT(head) do { \
|
||||
(head)->cqh_first = (void *)(head); \
|
||||
(head)->cqh_last = (void *)(head); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
|
||||
QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \
|
||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev = (listelm); \
|
||||
if ((listelm)->field.cqe_next == (void *)(head)) \
|
||||
(head)->cqh_last = (elm); \
|
||||
else \
|
||||
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
||||
(listelm)->field.cqe_next = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
|
||||
QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
|
||||
QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \
|
||||
(elm)->field.cqe_next = (listelm); \
|
||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||
if ((listelm)->field.cqe_prev == (void *)(head)) \
|
||||
(head)->cqh_first = (elm); \
|
||||
else \
|
||||
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
||||
(listelm)->field.cqe_prev = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
|
||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||
(elm)->field.cqe_prev = (void *)(head); \
|
||||
if ((head)->cqh_last == (void *)(head)) \
|
||||
(head)->cqh_last = (elm); \
|
||||
else \
|
||||
(head)->cqh_first->field.cqe_prev = (elm); \
|
||||
(head)->cqh_first = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
|
||||
(elm)->field.cqe_next = (void *)(head); \
|
||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||
if ((head)->cqh_first == (void *)(head)) \
|
||||
(head)->cqh_first = (elm); \
|
||||
else \
|
||||
(head)->cqh_last->field.cqe_next = (elm); \
|
||||
(head)->cqh_last = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define CIRCLEQ_REMOVE(head, elm, field) do { \
|
||||
QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
|
||||
QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \
|
||||
if ((elm)->field.cqe_next == (void *)(head)) \
|
||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||
else \
|
||||
(elm)->field.cqe_next->field.cqe_prev = \
|
||||
(elm)->field.cqe_prev; \
|
||||
if ((elm)->field.cqe_prev == (void *)(head)) \
|
||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||
else \
|
||||
(elm)->field.cqe_prev->field.cqe_next = \
|
||||
(elm)->field.cqe_next; \
|
||||
QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define CIRCLEQ_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->cqh_first); \
|
||||
(var) != (const void *)(head); \
|
||||
(var) = ((var)->field.cqe_next))
|
||||
|
||||
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
|
||||
for ((var) = ((head)->cqh_last); \
|
||||
(var) != (const void *)(head); \
|
||||
(var) = ((var)->field.cqe_prev))
|
||||
|
||||
/*
|
||||
* Circular queue access methods.
|
||||
*/
|
||||
#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
|
||||
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
|
||||
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
|
||||
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
|
||||
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
|
||||
|
||||
#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
|
||||
(((elm)->field.cqe_next == (void *)(head)) \
|
||||
? ((head)->cqh_first) \
|
||||
: (elm->field.cqe_next))
|
||||
#define CIRCLEQ_LOOP_PREV(head, elm, field) \
|
||||
(((elm)->field.cqe_prev == (void *)(head)) \
|
||||
? ((head)->cqh_last) \
|
||||
: (elm->field.cqe_prev))
|
||||
|
||||
#endif /* !_SYS_QUEUE_H_ */
|
||||
194
nbsd_include/sys/rbtree.h
Normal file
194
nbsd_include/sys/rbtree.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/* $NetBSD: rbtree.h,v 1.1 2010/09/25 01:42:40 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas <matt@3am-software.com>.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_RBTREE_H_
|
||||
#define _SYS_RBTREE_H_
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
#include <sys/types.h>
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#include <sys/queue.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef struct rb_node {
|
||||
struct rb_node *rb_nodes[2];
|
||||
#define RB_DIR_LEFT 0
|
||||
#define RB_DIR_RIGHT 1
|
||||
#define RB_DIR_OTHER 1
|
||||
#define rb_left rb_nodes[RB_DIR_LEFT]
|
||||
#define rb_right rb_nodes[RB_DIR_RIGHT]
|
||||
|
||||
/*
|
||||
* rb_info contains the two flags and the parent back pointer.
|
||||
* We put the two flags in the low two bits since we know that
|
||||
* rb_node will have an alignment of 4 or 8 bytes.
|
||||
*/
|
||||
uintptr_t rb_info;
|
||||
#define RB_FLAG_POSITION 0x2
|
||||
#define RB_FLAG_RED 0x1
|
||||
#define RB_FLAG_MASK (RB_FLAG_POSITION|RB_FLAG_RED)
|
||||
#define RB_FATHER(rb) \
|
||||
((struct rb_node *)((rb)->rb_info & ~RB_FLAG_MASK))
|
||||
#define RB_SET_FATHER(rb, father) \
|
||||
((void)((rb)->rb_info = (uintptr_t)(father)|((rb)->rb_info & RB_FLAG_MASK)))
|
||||
|
||||
#define RB_SENTINEL_P(rb) ((rb) == NULL)
|
||||
#define RB_LEFT_SENTINEL_P(rb) RB_SENTINEL_P((rb)->rb_left)
|
||||
#define RB_RIGHT_SENTINEL_P(rb) RB_SENTINEL_P((rb)->rb_right)
|
||||
#define RB_FATHER_SENTINEL_P(rb) RB_SENTINEL_P(RB_FATHER((rb)))
|
||||
#define RB_CHILDLESS_P(rb) \
|
||||
(RB_SENTINEL_P(rb) || (RB_LEFT_SENTINEL_P(rb) && RB_RIGHT_SENTINEL_P(rb)))
|
||||
#define RB_TWOCHILDREN_P(rb) \
|
||||
(!RB_SENTINEL_P(rb) && !RB_LEFT_SENTINEL_P(rb) && !RB_RIGHT_SENTINEL_P(rb))
|
||||
|
||||
#define RB_POSITION(rb) \
|
||||
(((rb)->rb_info & RB_FLAG_POSITION) ? RB_DIR_RIGHT : RB_DIR_LEFT)
|
||||
#define RB_RIGHT_P(rb) (RB_POSITION(rb) == RB_DIR_RIGHT)
|
||||
#define RB_LEFT_P(rb) (RB_POSITION(rb) == RB_DIR_LEFT)
|
||||
#define RB_RED_P(rb) (!RB_SENTINEL_P(rb) && ((rb)->rb_info & RB_FLAG_RED) != 0)
|
||||
#define RB_BLACK_P(rb) (RB_SENTINEL_P(rb) || ((rb)->rb_info & RB_FLAG_RED) == 0)
|
||||
#define RB_MARK_RED(rb) ((void)((rb)->rb_info |= RB_FLAG_RED))
|
||||
#define RB_MARK_BLACK(rb) ((void)((rb)->rb_info &= ~RB_FLAG_RED))
|
||||
#define RB_INVERT_COLOR(rb) ((void)((rb)->rb_info ^= RB_FLAG_RED))
|
||||
#define RB_ROOT_P(rbt, rb) ((rbt)->rbt_root == (rb))
|
||||
#define RB_SET_POSITION(rb, position) \
|
||||
((void)((position) ? ((rb)->rb_info |= RB_FLAG_POSITION) : \
|
||||
((rb)->rb_info &= ~RB_FLAG_POSITION)))
|
||||
#define RB_ZERO_PROPERTIES(rb) ((void)((rb)->rb_info &= ~RB_FLAG_MASK))
|
||||
#define RB_COPY_PROPERTIES(dst, src) \
|
||||
((void)((dst)->rb_info ^= ((dst)->rb_info ^ (src)->rb_info) & RB_FLAG_MASK))
|
||||
#define RB_SWAP_PROPERTIES(a, b) do { \
|
||||
uintptr_t xorinfo = ((a)->rb_info ^ (b)->rb_info) & RB_FLAG_MASK; \
|
||||
(a)->rb_info ^= xorinfo; \
|
||||
(b)->rb_info ^= xorinfo; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
#ifdef RBDEBUG
|
||||
TAILQ_ENTRY(rb_node) rb_link;
|
||||
#endif
|
||||
} rb_node_t;
|
||||
|
||||
#define RB_TREE_MIN(T) rb_tree_iterate((T), NULL, RB_DIR_LEFT)
|
||||
#define RB_TREE_MAX(T) rb_tree_iterate((T), NULL, RB_DIR_RIGHT)
|
||||
#define RB_TREE_FOREACH(N, T) \
|
||||
for ((N) = RB_TREE_MIN(T); (N); \
|
||||
(N) = rb_tree_iterate((T), (N), RB_DIR_RIGHT))
|
||||
#define RB_TREE_FOREACH_REVERSE(N, T) \
|
||||
for ((N) = RB_TREE_MAX(T); (N); \
|
||||
(N) = rb_tree_iterate((T), (N), RB_DIR_LEFT))
|
||||
|
||||
#ifdef RBDEBUG
|
||||
TAILQ_HEAD(rb_node_qh, rb_node);
|
||||
|
||||
#define RB_TAILQ_REMOVE(a, b, c) TAILQ_REMOVE(a, b, c)
|
||||
#define RB_TAILQ_INIT(a) TAILQ_INIT(a)
|
||||
#define RB_TAILQ_INSERT_HEAD(a, b, c) TAILQ_INSERT_HEAD(a, b, c)
|
||||
#define RB_TAILQ_INSERT_BEFORE(a, b, c) TAILQ_INSERT_BEFORE(a, b, c)
|
||||
#define RB_TAILQ_INSERT_AFTER(a, b, c, d) TAILQ_INSERT_AFTER(a, b, c, d)
|
||||
#else
|
||||
#define RB_TAILQ_REMOVE(a, b, c) do { } while (/*CONSTCOND*/0)
|
||||
#define RB_TAILQ_INIT(a) do { } while (/*CONSTCOND*/0)
|
||||
#define RB_TAILQ_INSERT_HEAD(a, b, c) do { } while (/*CONSTCOND*/0)
|
||||
#define RB_TAILQ_INSERT_BEFORE(a, b, c) do { } while (/*CONSTCOND*/0)
|
||||
#define RB_TAILQ_INSERT_AFTER(a, b, c, d) do { } while (/*CONSTCOND*/0)
|
||||
#endif /* RBDEBUG */
|
||||
|
||||
/*
|
||||
* rbto_compare_nodes_fn:
|
||||
* return a positive value if the first node > the second node.
|
||||
* return a negative value if the first node < the second node.
|
||||
* return 0 if they are considered same.
|
||||
*
|
||||
* rbto_compare_key_fn:
|
||||
* return a positive value if the node > the key.
|
||||
* return a negative value if the node < the key.
|
||||
* return 0 if they are considered same.
|
||||
*/
|
||||
|
||||
typedef signed int (*const rbto_compare_nodes_fn)(void *,
|
||||
const void *, const void *);
|
||||
typedef signed int (*const rbto_compare_key_fn)(void *,
|
||||
const void *, const void *);
|
||||
|
||||
typedef struct {
|
||||
rbto_compare_nodes_fn rbto_compare_nodes;
|
||||
rbto_compare_key_fn rbto_compare_key;
|
||||
size_t rbto_node_offset;
|
||||
void *rbto_context;
|
||||
} rb_tree_ops_t;
|
||||
|
||||
typedef struct rb_tree {
|
||||
struct rb_node *rbt_root;
|
||||
const rb_tree_ops_t *rbt_ops;
|
||||
struct rb_node *rbt_minmax[2];
|
||||
#ifdef RBDEBUG
|
||||
struct rb_node_qh rbt_nodes;
|
||||
#endif
|
||||
#ifdef RBSTATS
|
||||
unsigned int rbt_count;
|
||||
unsigned int rbt_insertions;
|
||||
unsigned int rbt_removals;
|
||||
unsigned int rbt_insertion_rebalance_calls;
|
||||
unsigned int rbt_insertion_rebalance_passes;
|
||||
unsigned int rbt_removal_rebalance_calls;
|
||||
unsigned int rbt_removal_rebalance_passes;
|
||||
#endif
|
||||
} rb_tree_t;
|
||||
|
||||
#ifdef RBSTATS
|
||||
#define RBSTAT_INC(v) ((void)((v)++))
|
||||
#define RBSTAT_DEC(v) ((void)((v)--))
|
||||
#else
|
||||
#define RBSTAT_INC(v) do { } while (/*CONSTCOND*/0)
|
||||
#define RBSTAT_DEC(v) do { } while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
void rb_tree_init(rb_tree_t *, const rb_tree_ops_t *);
|
||||
void * rb_tree_insert_node(rb_tree_t *, void *);
|
||||
void * rb_tree_find_node(rb_tree_t *, const void *);
|
||||
void * rb_tree_find_node_geq(rb_tree_t *, const void *);
|
||||
void * rb_tree_find_node_leq(rb_tree_t *, const void *);
|
||||
void rb_tree_remove_node(rb_tree_t *, void *);
|
||||
void * rb_tree_iterate(rb_tree_t *, void *, const unsigned int);
|
||||
#ifdef RBDEBUG
|
||||
void rb_tree_check(const rb_tree_t *, bool);
|
||||
#endif
|
||||
#ifdef RBSTATS
|
||||
void rb_tree_depths(const rb_tree_t *, size_t *);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_RBTREE_H_*/
|
||||
13
nbsd_include/sys/reboot.h
Normal file
13
nbsd_include/sys/reboot.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _SYS_REBOOT_H_
|
||||
#define _SYS_REBOOT_H_
|
||||
|
||||
/* How to exit the system or stop a server process. */
|
||||
#define RBT_HALT 0 /* shutdown and return to monitor */
|
||||
#define RBT_REBOOT 1 /* reboot the system through the monitor */
|
||||
#define RBT_PANIC 2 /* a server panics */
|
||||
#define RBT_MONITOR 3 /* let the monitor do this */
|
||||
#define RBT_RESET 4 /* hard reset the system */
|
||||
#define RBT_DEFAULT 5 /* return to monitor, reset if not possible */
|
||||
#define RBT_INVALID 6 /* first invalid reboot flag */
|
||||
|
||||
#endif
|
||||
51
nbsd_include/sys/resource.h
Normal file
51
nbsd_include/sys/resource.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _SYS_RESOURCE_H_
|
||||
#define _SYS_RESOURCE_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/*
|
||||
* Process priority specifications to get/setpriority.
|
||||
*/
|
||||
#define PRIO_MIN -20
|
||||
#define PRIO_MAX 20
|
||||
|
||||
#define PRIO_PROCESS 0
|
||||
#define PRIO_PGRP 1
|
||||
#define PRIO_USER 2
|
||||
|
||||
/*
|
||||
* Resource limits
|
||||
*/
|
||||
#define RLIMIT_CORE 1
|
||||
#define RLIMIT_CPU 2
|
||||
#define RLIMIT_DATA 3
|
||||
#define RLIMIT_FSIZE 4
|
||||
#define RLIMIT_NOFILE 5
|
||||
#define RLIMIT_STACK 6
|
||||
#define RLIMIT_AS 7
|
||||
#define RLIMIT_VMEM RLIMIT_AS /* common alias */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define RLIM_NLIMITS 8 /* number of resource limits */
|
||||
#endif
|
||||
|
||||
#define RLIM_INFINITY ((rlim_t) -1)
|
||||
#define RLIM_SAVED_CUR RLIM_INFINITY
|
||||
#define RLIM_SAVED_MAX RLIM_INFINITY
|
||||
|
||||
struct rlimit
|
||||
{
|
||||
rlim_t rlim_cur;
|
||||
rlim_t rlim_max;
|
||||
};
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int getpriority(int, int);
|
||||
int getrlimit(int, struct rlimit *);
|
||||
int setpriority(int, int, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_RESOURCE_H_ */
|
||||
56
nbsd_include/sys/rmd160.h
Normal file
56
nbsd_include/sys/rmd160.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* $NetBSD: rmd160.h,v 1.2 2008/02/16 17:37:13 apb Exp $ */
|
||||
/* $KAME: rmd160.h,v 1.2 2003/07/25 09:37:55 itojun Exp $ */
|
||||
/* $OpenBSD: rmd160.h,v 1.3 2002/03/14 01:26:51 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001 Markus Friedl. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
#ifndef _RMD160_H
|
||||
#define _RMD160_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define RMD160_DIGEST_LENGTH 20
|
||||
#define RMD160_DIGEST_STRING_LENGTH 41
|
||||
|
||||
/* RMD160 context. */
|
||||
typedef struct RMD160Context {
|
||||
uint32_t state[5]; /* state */
|
||||
uint64_t count; /* number of bits, modulo 2^64 */
|
||||
u_char buffer[64]; /* input buffer */
|
||||
} RMD160_CTX;
|
||||
|
||||
__BEGIN_DECLS
|
||||
void RMD160Init(RMD160_CTX *);
|
||||
void RMD160Transform(uint32_t [5], const u_char [64]);
|
||||
void RMD160Update(RMD160_CTX *, const u_char *, uint32_t);
|
||||
void RMD160Final(u_char [RMD160_DIGEST_LENGTH], RMD160_CTX *);
|
||||
#ifndef _KERNEL
|
||||
char *RMD160End(RMD160_CTX *, char *);
|
||||
char *RMD160FileChunk(const char *, char *, off_t, off_t);
|
||||
char *RMD160File(const char *, char *);
|
||||
char *RMD160Data(const u_char *, size_t, char *);
|
||||
#endif /* _KERNEL */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _RMD160_H */
|
||||
76
nbsd_include/sys/select.h
Normal file
76
nbsd_include/sys/select.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $NetBSD: select.h,v 1.36 2009/11/11 09:48:51 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 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.
|
||||
*
|
||||
* @(#)select.h 8.2 (Berkeley) 1/4/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SELECT_H_
|
||||
#define _SYS_SELECT_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/fd_set.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/selinfo.h> /* for struct selinfo */
|
||||
#include <sys/signal.h> /* for sigset_t */
|
||||
|
||||
struct lwp;
|
||||
struct proc;
|
||||
struct timespec;
|
||||
struct cpu_info;
|
||||
struct socket;
|
||||
|
||||
int selcommon(register_t *, int, fd_set *, fd_set *, fd_set *,
|
||||
struct timespec *, sigset_t *);
|
||||
void selrecord(struct lwp *selector, struct selinfo *);
|
||||
void selnotify(struct selinfo *, int, long);
|
||||
void selsysinit(struct cpu_info *);
|
||||
void selinit(struct selinfo *);
|
||||
void seldestroy(struct selinfo *);
|
||||
int pollsock(struct socket *, const struct timespec *, int);
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
#include <sys/sigtypes.h>
|
||||
#include <time.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
int pselect(int, fd_set * __restrict, fd_set * __restrict,
|
||||
fd_set * __restrict, const struct timespec * __restrict,
|
||||
const sigset_t * __restrict) __RENAME(__pselect50);
|
||||
int select(int, fd_set * __restrict, fd_set * __restrict,
|
||||
fd_set * __restrict, struct timeval * __restrict) __RENAME(__select50);
|
||||
#endif /* __LIBC12_SOURCE__ */
|
||||
__END_DECLS
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_SYS_SELECT_H_ */
|
||||
121
nbsd_include/sys/sem.h
Normal file
121
nbsd_include/sys/sem.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* $NetBSD: sem.h,v 1.29 2009/01/19 19:39:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SVID compatible sem.h file
|
||||
*
|
||||
* Author: Daniel Boulet
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SEM_H_
|
||||
#define _SYS_SEM_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
struct semid_ds {
|
||||
struct ipc_perm sem_perm; /* operation permission struct */
|
||||
time_t sem_otime; /* last semop() time */
|
||||
unsigned long int __unused1;
|
||||
time_t sem_ctime; /* last time changed by semctl() */
|
||||
unsigned long int __unused2;
|
||||
unsigned long int sem_nsems; /* number of semaphores in set */
|
||||
unsigned long int __unused3;
|
||||
unsigned long int __unused4;
|
||||
};
|
||||
|
||||
/*
|
||||
* semop's sops parameter structure
|
||||
*/
|
||||
struct sembuf {
|
||||
unsigned short sem_num; /* semaphore # */
|
||||
short sem_op; /* semaphore operation */
|
||||
short sem_flg; /* operation flags */
|
||||
};
|
||||
#define SEM_UNDO 0x1000 /* undo changes on process exit */
|
||||
|
||||
/*
|
||||
* commands for semctl
|
||||
*/
|
||||
#define GETPID 11 /* get sempid */
|
||||
#define GETVAL 12 /* get semval */
|
||||
#define GETALL 13 /* get all semval's */
|
||||
#define GETNCNT 14 /* get semncnt */
|
||||
#define GETZCNT 15 /* get semzcnt */
|
||||
#define SETVAL 16 /* set semval */
|
||||
#define SETALL 17 /* set all semval's */
|
||||
|
||||
#ifdef __USE_MISC
|
||||
|
||||
/* ipcs ctl cmds */
|
||||
# define SEM_STAT 18
|
||||
# define SEM_INFO 19
|
||||
|
||||
/*
|
||||
* semaphore info struct
|
||||
*/
|
||||
struct seminfo {
|
||||
int32_t semmap; /* # of entries in semaphore map */
|
||||
int32_t semmni; /* # of semaphore identifiers */
|
||||
int32_t semmns; /* # of semaphores in system */
|
||||
int32_t semmnu; /* # of undo structures in system */
|
||||
int32_t semmsl; /* max # of semaphores per id */
|
||||
int32_t semopm; /* max # of operations per semop call */
|
||||
int32_t semume; /* max # of undo entries per process */
|
||||
int32_t semusz; /* size in bytes of undo structure */
|
||||
int32_t semvmx; /* semaphore maximum value */
|
||||
int32_t semaem; /* adjust on exit max value */
|
||||
};
|
||||
|
||||
#endif /* __USE_MISC */
|
||||
|
||||
/*
|
||||
* Configuration parameters
|
||||
*/
|
||||
#define SEMMNI 128
|
||||
#define SEMMSL 250
|
||||
#define SEMMNS (SEMMSL*SEMMNI)
|
||||
|
||||
#define SEMOPM 32
|
||||
#define SEMVMX 32767
|
||||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int semctl(int, int, int, ...);
|
||||
int semget(key_t, int, int);
|
||||
int semop(int, struct sembuf *, size_t);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_SEM_H_ */
|
||||
37
nbsd_include/sys/sha1.h
Normal file
37
nbsd_include/sys/sha1.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* $NetBSD: sha1.h,v 1.14 2009/11/06 20:31:19 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* SHA-1 in C
|
||||
* By Steve Reid <steve@edmweb.com>
|
||||
* 100% Public Domain
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SHA1_H_
|
||||
#define _SYS_SHA1_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define SHA1_DIGEST_LENGTH 20
|
||||
#define SHA1_DIGEST_STRING_LENGTH 41
|
||||
|
||||
typedef struct {
|
||||
uint32_t state[5];
|
||||
uint32_t count[2];
|
||||
uint8_t buffer[64];
|
||||
} SHA1_CTX;
|
||||
|
||||
__BEGIN_DECLS
|
||||
void SHA1Transform(uint32_t[5], const uint8_t[64]);
|
||||
void SHA1Init(SHA1_CTX *);
|
||||
void SHA1Update(SHA1_CTX *, const uint8_t *, unsigned int);
|
||||
void SHA1Final(uint8_t[SHA1_DIGEST_LENGTH], SHA1_CTX *);
|
||||
#ifndef _KERNEL
|
||||
char *SHA1End(SHA1_CTX *, char *);
|
||||
char *SHA1FileChunk(const char *, char *, off_t, off_t);
|
||||
char *SHA1File(const char *, char *);
|
||||
char *SHA1Data(const uint8_t *, size_t, char *);
|
||||
#endif /* _KERNEL */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_SHA1_H_ */
|
||||
120
nbsd_include/sys/sha2.h
Normal file
120
nbsd_include/sys/sha2.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* $NetBSD: sha2.h,v 1.3 2009/05/26 08:04:12 joerg Exp $ */
|
||||
/* $KAME: sha2.h,v 1.4 2003/07/20 00:28:38 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* sha2.h
|
||||
*
|
||||
* Version 1.0.0beta1
|
||||
*
|
||||
* Written by Aaron D. Gifford <me@aarongifford.com>
|
||||
*
|
||||
* Copyright 2000 Aaron D. Gifford. 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 copyright holder nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``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 AUTHOR(S) OR CONTRIBUTOR(S) 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SHA2_H__
|
||||
#define __SHA2_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*** SHA-224/256/384/512 Various Length Definitions ***********************/
|
||||
#define SHA224_BLOCK_LENGTH 64
|
||||
#define SHA224_DIGEST_LENGTH 28
|
||||
#define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA256_BLOCK_LENGTH 64
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA384_BLOCK_LENGTH 128
|
||||
#define SHA384_DIGEST_LENGTH 48
|
||||
#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA512_BLOCK_LENGTH 128
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Context Structures *******************************/
|
||||
typedef struct _SHA256_CTX {
|
||||
uint32_t state[8];
|
||||
uint64_t bitcount;
|
||||
uint8_t buffer[SHA256_BLOCK_LENGTH];
|
||||
} SHA256_CTX;
|
||||
|
||||
typedef struct _SHA512_CTX {
|
||||
uint64_t state[8];
|
||||
uint64_t bitcount[2];
|
||||
uint8_t buffer[SHA512_BLOCK_LENGTH];
|
||||
} SHA512_CTX;
|
||||
|
||||
typedef SHA256_CTX SHA224_CTX;
|
||||
typedef SHA512_CTX SHA384_CTX;
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Function Prototypes ******************************/
|
||||
__BEGIN_DECLS
|
||||
int SHA224_Init(SHA224_CTX *);
|
||||
int SHA224_Update(SHA224_CTX*, const uint8_t*, size_t);
|
||||
int SHA224_Final(uint8_t[SHA224_DIGEST_LENGTH], SHA224_CTX*);
|
||||
#ifndef _KERNEL
|
||||
char *SHA224_End(SHA224_CTX *, char[SHA224_DIGEST_STRING_LENGTH]);
|
||||
char *SHA224_FileChunk(const char *, char *, off_t, off_t);
|
||||
char *SHA224_File(const char *, char *);
|
||||
char *SHA224_Data(const uint8_t *, size_t, char[SHA224_DIGEST_STRING_LENGTH]);
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
int SHA256_Init(SHA256_CTX *);
|
||||
int SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
|
||||
int SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
|
||||
#ifndef _KERNEL
|
||||
char *SHA256_End(SHA256_CTX *, char[SHA256_DIGEST_STRING_LENGTH]);
|
||||
char *SHA256_FileChunk(const char *, char *, off_t, off_t);
|
||||
char *SHA256_File(const char *, char *);
|
||||
char *SHA256_Data(const uint8_t *, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
int SHA384_Init(SHA384_CTX*);
|
||||
int SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
|
||||
int SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
|
||||
#ifndef _KERNEL
|
||||
char *SHA384_End(SHA384_CTX *, char[SHA384_DIGEST_STRING_LENGTH]);
|
||||
char *SHA384_FileChunk(const char *, char *, off_t, off_t);
|
||||
char *SHA384_File(const char *, char *);
|
||||
char *SHA384_Data(const uint8_t *, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
int SHA512_Init(SHA512_CTX*);
|
||||
int SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
|
||||
int SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
|
||||
#ifndef _KERNEL
|
||||
char *SHA512_End(SHA512_CTX *, char[SHA512_DIGEST_STRING_LENGTH]);
|
||||
char *SHA512_FileChunk(const char *, char *, off_t, off_t);
|
||||
char *SHA512_File(const char *, char *);
|
||||
char *SHA512_Data(const uint8_t *, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
|
||||
#endif /* !_KERNEL */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __SHA2_H__ */
|
||||
148
nbsd_include/sys/shm.h
Normal file
148
nbsd_include/sys/shm.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/* $NetBSD: shm.h,v 1.48 2009/01/19 19:39:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Adam Glass
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Adam Glass.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* As defined+described in "X/Open System Interfaces and Headers"
|
||||
* Issue 4, p. XXX
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SHM_H_
|
||||
#define _SYS_SHM_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#define SHM_RDONLY 010000 /* Attach read-only (else read-write) */
|
||||
#define SHM_RND 020000 /* Round attach address to SHMLBA */
|
||||
|
||||
/* Segment low boundry address multiple */
|
||||
#define SHMLBA getpagesize()
|
||||
#define SHMMNI 4096
|
||||
#define SHMSEG 32 /* max shared segs per process */
|
||||
|
||||
typedef unsigned int shmatt_t;
|
||||
|
||||
struct shmid_ds {
|
||||
struct ipc_perm shm_perm; /* operation permission structure */
|
||||
size_t shm_segsz; /* size of segment in bytes */
|
||||
time_t shm_atime; /* time of last shmat() */
|
||||
time_t shm_dtime; /* time of last shmdt() */
|
||||
time_t shm_ctime; /* time of last change by shmctl() */
|
||||
pid_t shm_cpid; /* process ID of creator */
|
||||
pid_t shm_lpid; /* process ID of last shm operation */
|
||||
shmatt_t shm_nattch; /* number of current attaches */
|
||||
};
|
||||
|
||||
|
||||
/* shm_mode upper byte flags */
|
||||
#define SHM_DEST 01000 /* segment will be destroyed on last detach */
|
||||
#define SHM_LOCKED 02000 /* segment will not be swapped */
|
||||
|
||||
/* ipcs ctl commands */
|
||||
#define SHM_STAT 13
|
||||
#define SHM_INFO 14
|
||||
|
||||
|
||||
#if defined(_NETBSD_SOURCE) || defined(__minix)
|
||||
/*
|
||||
* Permission definitions used in shmflag arguments to shmat(2) and shmget(2).
|
||||
* Provided for source compatibility only; do not use in new code!
|
||||
*/
|
||||
#define SHM_R 0400
|
||||
#define SHM_W 0200
|
||||
|
||||
/*
|
||||
* System 5 style catch-all structure for shared memory constants that
|
||||
* might be of interest to user programs. Do we really want/need this?
|
||||
*/
|
||||
struct shminfo {
|
||||
unsigned long int shmmax; /* max shared memory segment size (bytes) */
|
||||
unsigned long int shmmin; /* min shared memory segment size (bytes) */
|
||||
unsigned long int shmmni; /* max number of shared memory identifiers */
|
||||
unsigned long int shmseg; /* max shared memory segments per process */
|
||||
unsigned long int shmall; /* max amount of shared memory (pages) */
|
||||
};
|
||||
|
||||
#ifdef __minix
|
||||
struct shm_info
|
||||
{
|
||||
int used_ids;
|
||||
unsigned long int shm_tot; /* total allocated shm */
|
||||
unsigned long int shm_rss; /* total resident shm */
|
||||
unsigned long int shm_swp; /* total swapped shm */
|
||||
unsigned long int swap_attempts;
|
||||
unsigned long int swap_successes;
|
||||
};
|
||||
#endif /* __minix */
|
||||
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
__BEGIN_DECLS
|
||||
void *shmat(int, const void *, int);
|
||||
int shmctl(int, int, struct shmid_ds *) __RENAME(__shmctl50);
|
||||
int shmdt(const void *);
|
||||
int shmget(key_t, size_t, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_SHM_H_ */
|
||||
240
nbsd_include/sys/siginfo.h
Normal file
240
nbsd_include/sys/siginfo.h
Normal file
@@ -0,0 +1,240 @@
|
||||
/* $NetBSD: siginfo.h,v 1.19 2009/03/27 11:05:43 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SIGINFO_H_
|
||||
#define _SYS_SIGINFO_H_
|
||||
|
||||
#include <machine/signal.h> /* XXX: __HAVE_SIGINFO */
|
||||
#ifdef _KERNEL
|
||||
#include <sys/queue.h>
|
||||
#endif
|
||||
|
||||
typedef union sigval {
|
||||
int sival_int;
|
||||
void *sival_ptr;
|
||||
} sigval_t;
|
||||
|
||||
struct _ksiginfo {
|
||||
int _signo;
|
||||
int _code;
|
||||
int _errno;
|
||||
#ifdef _LP64
|
||||
/* In _LP64 the union starts on an 8-byte boundary. */
|
||||
int _pad;
|
||||
#endif
|
||||
union {
|
||||
struct {
|
||||
pid_t _pid;
|
||||
uid_t _uid;
|
||||
sigval_t _value;
|
||||
} _rt;
|
||||
|
||||
struct {
|
||||
pid_t _pid;
|
||||
uid_t _uid;
|
||||
int _status;
|
||||
clock_t _utime;
|
||||
clock_t _stime;
|
||||
} _child;
|
||||
|
||||
struct {
|
||||
void *_addr;
|
||||
int _trap;
|
||||
} _fault;
|
||||
|
||||
struct {
|
||||
long _band;
|
||||
int _fd;
|
||||
} _poll;
|
||||
} _reason;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
typedef struct ksiginfo {
|
||||
u_long ksi_flags; /* 4 or 8 bytes (LP64) */
|
||||
CIRCLEQ_ENTRY(ksiginfo) ksi_list;
|
||||
struct _ksiginfo ksi_info;
|
||||
lwpid_t ksi_lid; /* 0, or directed to LWP */
|
||||
} ksiginfo_t;
|
||||
|
||||
#define KSI_TRAP 0x01 /* signal caused by trap */
|
||||
#define KSI_EMPTY 0x02 /* no additional information */
|
||||
#define KSI_QUEUED 0x04 /* on a sigpend_t queue */
|
||||
#define KSI_FROMPOOL 0x08 /* allocated from the ksiginfo pool */
|
||||
|
||||
/* Macros to initialize a ksiginfo_t. */
|
||||
#define KSI_INIT(ksi) \
|
||||
do { \
|
||||
memset((ksi), 0, sizeof(*(ksi))); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define KSI_INIT_EMPTY(ksi) \
|
||||
do { \
|
||||
KSI_INIT((ksi)); \
|
||||
(ksi)->ksi_flags = KSI_EMPTY; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define KSI_INIT_TRAP(ksi) \
|
||||
do { \
|
||||
KSI_INIT((ksi)); \
|
||||
(ksi)->ksi_flags = KSI_TRAP; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
/* Copy the part of ksiginfo_t without the queue pointers */
|
||||
#define KSI_COPY(fksi, tksi) \
|
||||
do { \
|
||||
(tksi)->ksi_info = (fksi)->ksi_info; \
|
||||
(tksi)->ksi_flags = (fksi)->ksi_flags; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
|
||||
/* Predicate macros to test how a ksiginfo_t was generated. */
|
||||
#define KSI_TRAP_P(ksi) (((ksi)->ksi_flags & KSI_TRAP) != 0)
|
||||
#define KSI_EMPTY_P(ksi) (((ksi)->ksi_flags & KSI_EMPTY) != 0)
|
||||
|
||||
/*
|
||||
* Old-style signal handler "code" arguments were only non-zero for
|
||||
* signals caused by traps.
|
||||
*/
|
||||
#define KSI_TRAPCODE(ksi) (KSI_TRAP_P(ksi) ? (ksi)->ksi_trap : 0)
|
||||
#endif /* _KERNEL */
|
||||
|
||||
typedef union siginfo {
|
||||
char si_pad[128]; /* Total size; for future expansion */
|
||||
struct _ksiginfo _info;
|
||||
} siginfo_t;
|
||||
|
||||
/** Field access macros */
|
||||
#define si_signo _info._signo
|
||||
#define si_code _info._code
|
||||
#define si_errno _info._errno
|
||||
|
||||
#define si_value _info._reason._rt._value
|
||||
#define si_pid _info._reason._child._pid
|
||||
#define si_uid _info._reason._child._uid
|
||||
#define si_status _info._reason._child._status
|
||||
#define si_utime _info._reason._child._utime
|
||||
#define si_stime _info._reason._child._stime
|
||||
|
||||
#define si_addr _info._reason._fault._addr
|
||||
#define si_trap _info._reason._fault._trap
|
||||
|
||||
#define si_band _info._reason._poll._band
|
||||
#define si_fd _info._reason._poll._fd
|
||||
|
||||
#ifdef _KERNEL
|
||||
/** Field access macros */
|
||||
#define ksi_signo ksi_info._signo
|
||||
#define ksi_code ksi_info._code
|
||||
#define ksi_errno ksi_info._errno
|
||||
|
||||
#define ksi_value ksi_info._reason._rt._value
|
||||
#define ksi_pid ksi_info._reason._child._pid
|
||||
#define ksi_uid ksi_info._reason._child._uid
|
||||
#define ksi_status ksi_info._reason._child._status
|
||||
#define ksi_utime ksi_info._reason._child._utime
|
||||
#define ksi_stime ksi_info._reason._child._stime
|
||||
|
||||
#define ksi_addr ksi_info._reason._fault._addr
|
||||
#define ksi_trap ksi_info._reason._fault._trap
|
||||
|
||||
#define ksi_band ksi_info._reason._poll._band
|
||||
#define ksi_fd ksi_info._reason._poll._fd
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/** si_code */
|
||||
/* SIGILL */
|
||||
#define ILL_ILLOPC 1 /* Illegal opcode */
|
||||
#define ILL_ILLOPN 2 /* Illegal operand */
|
||||
#define ILL_ILLADR 3 /* Illegal addressing mode */
|
||||
#define ILL_ILLTRP 4 /* Illegal trap */
|
||||
#define ILL_PRVOPC 5 /* Privileged opcode */
|
||||
#define ILL_PRVREG 6 /* Privileged register */
|
||||
#define ILL_COPROC 7 /* Coprocessor error */
|
||||
#define ILL_BADSTK 8 /* Internal stack error */
|
||||
|
||||
/* SIGFPE */
|
||||
#define FPE_INTOVF 1 /* integer divide by zero */
|
||||
#define FPE_INTDIV 2 /* integer overflow */
|
||||
#define FPE_FLTDIV 3 /* floating-point divide by zero */
|
||||
#define FPE_FLTOVF 4 /* floating-point overflow */
|
||||
#define FPE_FLTUND 5 /* floating-point underflow */
|
||||
#define FPE_FLTRES 6 /* floating-point inexact result */
|
||||
#define FPE_FLTINV 7 /* floating-point invalid operation */
|
||||
#define FPE_FLTSUB 8 /* subscript out of range */
|
||||
|
||||
/* SIGSEGV */
|
||||
#define SEGV_MAPERR 1 /* Address not mapped to object */
|
||||
#define SEGV_ACCERR 2 /* Invalid permissions for mapped object*/
|
||||
|
||||
/* SIGBUS */
|
||||
#define BUS_ADRALN 1 /* Invalid address alignment */
|
||||
#define BUS_ADRERR 2 /* Non-existent physical address */
|
||||
#define BUS_OBJERR 3 /* Object specific hardware error */
|
||||
|
||||
/* SIGTRAP */
|
||||
#define TRAP_BRKPT 1 /* Process breakpoint */
|
||||
#define TRAP_TRACE 2 /* Process trace trap */
|
||||
|
||||
/* SIGCHLD */
|
||||
#define CLD_EXITED 1 /* Child has exited */
|
||||
#define CLD_KILLED 2 /* Child has terminated abnormally but */
|
||||
/* did not create a core file */
|
||||
#define CLD_DUMPED 3 /* Child has terminated abnormally and */
|
||||
/* created a core file */
|
||||
#define CLD_TRAPPED 4 /* Traced child has trapped */
|
||||
#define CLD_STOPPED 5 /* Child has stopped */
|
||||
#define CLD_CONTINUED 6 /* Stopped child has continued */
|
||||
|
||||
/* SIGPOLL */
|
||||
#define POLL_IN 1 /* Data input available */
|
||||
#define POLL_OUT 2 /* Output buffers available */
|
||||
#define POLL_MSG 3 /* Input message available */
|
||||
#define POLL_ERR 4 /* I/O Error */
|
||||
#define POLL_PRI 5 /* High priority input available */
|
||||
#define POLL_HUP 6 /* Device disconnected */
|
||||
|
||||
|
||||
/** si_code */
|
||||
#define SI_USER 0 /* Sent by kill(2) */
|
||||
#define SI_QUEUE -1 /* Sent by the sigqueue(2) */
|
||||
#define SI_TIMER -2 /* Generated by expiration of a timer */
|
||||
/* set by timer_settime(2) */
|
||||
#define SI_ASYNCIO -3 /* Generated by completion of an */
|
||||
/* asynchronous I/O signal */
|
||||
#define SI_MESGQ -4 /* Generated by arrival of a message on */
|
||||
/* an empty message queue */
|
||||
#if defined(_KERNEL) || defined(_NETBSD_SOURCE)
|
||||
#define SI_LWP -5 /* Generated by _lwp_kill(2) */
|
||||
#define SI_NOINFO 32767 /* No signal specific info available */
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_SIGINFO_H_ */
|
||||
214
nbsd_include/sys/signal.h
Normal file
214
nbsd_include/sys/signal.h
Normal file
@@ -0,0 +1,214 @@
|
||||
#ifndef _SYS_SIGNAL_H_
|
||||
#define _SYS_SIGNAL_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/sigtypes.h>
|
||||
|
||||
#define _NSIG 26
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define NSIG _NSIG
|
||||
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
|
||||
/* Regular signals. */
|
||||
#define SIGHUP 1 /* hangup */
|
||||
#define SIGINT 2 /* interrupt (DEL) */
|
||||
#define SIGQUIT 3 /* quit (ASCII FS) */
|
||||
#define SIGILL 4 /* illegal instruction */
|
||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
||||
#define SIGABRT 6 /* IOT instruction */
|
||||
#define SIGBUS 7 /* bus error */
|
||||
#define SIGFPE 8 /* floating point exception */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGUSR1 10 /* user defined signal # 1 */
|
||||
#define SIGSEGV 11 /* segmentation violation */
|
||||
#define SIGUSR2 12 /* user defined signal # 2 */
|
||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
||||
#define SIGALRM 14 /* alarm clock */
|
||||
#define SIGTERM 15 /* software termination signal from kill */
|
||||
#define SIGEMT 16 /* EMT instruction */
|
||||
#define SIGCHLD 17 /* child process terminated or stopped */
|
||||
#define SIGWINCH 21 /* window size has changed */
|
||||
#define SIGVTALRM 24 /* virtual alarm */
|
||||
#define SIGPROF 25 /* profiler alarm */
|
||||
|
||||
/* POSIX requires the following signals to be defined, even if they are
|
||||
* not supported. Here are the definitions, but they are not supported.
|
||||
*/
|
||||
#define SIGCONT 18 /* continue if stopped */
|
||||
#define SIGSTOP 19 /* stop signal */
|
||||
#define SIGTSTP 20 /* interactive stop signal */
|
||||
#define SIGTTIN 22 /* background process wants to read */
|
||||
#define SIGTTOU 23 /* background process wants to write */
|
||||
|
||||
#define _NSIG 26 /* highest signal number plus one */
|
||||
#define NSIG _NSIG
|
||||
|
||||
#ifdef _MINIX
|
||||
#define SIGIOT SIGABRT /* for people who speak PDP-11 */
|
||||
|
||||
/* MINIX specific signals. These signals are not used by user proceses,
|
||||
* but meant to inform system processes, like the PM, about system events.
|
||||
* The order here determines the order signals are processed by system
|
||||
* processes in user-space. Higher-priority signals should be first.
|
||||
*/
|
||||
/* Signals delivered by a signal manager. */
|
||||
#define SIGSNDELAY 26 /* end of delay for signal delivery */
|
||||
|
||||
#define SIGS_FIRST SIGHUP /* first system signal */
|
||||
#define SIGS_LAST SIGSNDELAY /* last system signal */
|
||||
#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
|
||||
|
||||
/* Signals delivered by the kernel. */
|
||||
#define SIGKMEM 27 /* kernel memory request pending */
|
||||
#define SIGKMESS 28 /* new kernel message */
|
||||
#define SIGKSIGSM 29 /* kernel signal pending for signal manager */
|
||||
#define SIGKSIG 30 /* kernel signal pending */
|
||||
|
||||
#define SIGK_FIRST SIGKMEM /* first kernel signal */
|
||||
#define SIGK_LAST SIGKSIG /* last kernel signal */
|
||||
#define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST)
|
||||
|
||||
/* Termination signals for Minix system processes. */
|
||||
#define SIGS_IS_LETHAL(sig) \
|
||||
(sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \
|
||||
|| sig == SIGEMT || sig == SIGABRT)
|
||||
#define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \
|
||||
|| (sig == SIGKILL || sig == SIGPIPE))
|
||||
#define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT)
|
||||
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
typedef void (*__sighandler_t)(int);
|
||||
|
||||
/* Macros used as function pointers. */
|
||||
#define SIG_ERR ((__sighandler_t) -1) /* error return */
|
||||
#define SIG_DFL ((__sighandler_t) 0) /* default signal handling */
|
||||
#define SIG_IGN ((__sighandler_t) 1) /* ignore signal */
|
||||
#define SIG_HOLD ((__sighandler_t) 2) /* block signal */
|
||||
#define SIG_CATCH ((__sighandler_t) 3) /* catch signal */
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#include <sys/siginfo.h>
|
||||
#endif
|
||||
|
||||
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
||||
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
#include <sys/ucontext.h>
|
||||
#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
|
||||
|
||||
/*
|
||||
* Signal vector "template" used in sigaction call.
|
||||
*/
|
||||
struct sigaction {
|
||||
union {
|
||||
void (*_sa_handler)(int);
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
void (*_sa_sigaction)(int, siginfo_t *, void *);
|
||||
#endif
|
||||
} _sa_u; /* signal handler */
|
||||
sigset_t sa_mask; /* signal mask to apply */
|
||||
int sa_flags; /* see signal options below */
|
||||
};
|
||||
|
||||
#define sa_handler _sa_u._sa_handler
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define sa_sigaction _sa_u._sa_sigaction
|
||||
#endif
|
||||
|
||||
#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
|
||||
|
||||
/* Fields for sa_flags. */
|
||||
#define SA_ONSTACK 0x0001 /* deliver signal on alternate stack */
|
||||
#define SA_RESETHAND 0x0002 /* reset signal handler when signal caught */
|
||||
#define SA_NODEFER 0x0004 /* don't block signal while catching it */
|
||||
#define SA_RESTART 0x0008 /* automatic system call restart */
|
||||
#define SA_SIGINFO 0x0010 /* extended signal handling */
|
||||
#define SA_NOCLDWAIT 0x0020 /* don't create zombies */
|
||||
#define SA_NOCLDSTOP 0x0040 /* don't receive SIGCHLD when child stops */
|
||||
|
||||
/* POSIX requires these values for use with sigprocmask(2). */
|
||||
#define SIG_BLOCK 0 /* for blocking signals */
|
||||
#define SIG_UNBLOCK 1 /* for unblocking signals */
|
||||
#define SIG_SETMASK 2 /* for setting the signal mask */
|
||||
#define SIG_INQUIRE 4 /* for internal use only */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
typedef void (*sig_t)(int); /* type of signal function */
|
||||
#endif
|
||||
|
||||
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
||||
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
/*
|
||||
* Flags used with stack_t/struct sigaltstack.
|
||||
*/
|
||||
#define SS_ONSTACK 1 /* Process is executing on an alternate stack */
|
||||
#define SS_DISABLE 2 /* Alternate stack is disabled */
|
||||
|
||||
#define MINSIGSTKSZ 2048 /* Minimal stack size is 2k */
|
||||
#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
|
||||
#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
|
||||
|
||||
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
||||
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
/*
|
||||
* Structure used in sigstack call.
|
||||
*/
|
||||
struct sigstack {
|
||||
void *ss_sp; /* signal stack pointer */
|
||||
int ss_onstack; /* current status */
|
||||
};
|
||||
#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
|
||||
|
||||
#if defined(_NETBSD_SOURCE) && !defined(_KERNEL)
|
||||
/*
|
||||
* Macro for converting signal number to a mask suitable for
|
||||
* sigblock().
|
||||
*/
|
||||
#define sigmask(n) __sigmask(n)
|
||||
|
||||
#define BADSIG SIG_ERR
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
struct sigevent {
|
||||
int sigev_notify;
|
||||
int sigev_signo;
|
||||
union sigval sigev_value;
|
||||
void (*sigev_notify_function)(union sigval);
|
||||
void /* pthread_attr_t */ *sigev_notify_attributes;
|
||||
};
|
||||
|
||||
#define SIGEV_NONE 0
|
||||
#define SIGEV_SIGNAL 1
|
||||
#define SIGEV_THREAD 2
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define SIGEV_SA 3
|
||||
#endif
|
||||
#endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */
|
||||
|
||||
#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
|
||||
/*
|
||||
* For historical reasons; programs expect signal's return value to be
|
||||
* defined by <sys/signal.h>.
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
void (*signal(int, void (*)(int)))(int);
|
||||
__END_DECLS
|
||||
#endif /* !_SYS_SIGNAL_H_ */
|
||||
|
||||
|
||||
|
||||
|
||||
68
nbsd_include/sys/sigtypes.h
Normal file
68
nbsd_include/sys/sigtypes.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _SYS_SIGTYPES_H_
|
||||
#define _SYS_SIGTYPES_H_
|
||||
|
||||
/*
|
||||
* This header file defines various signal-related types. We also keep
|
||||
* the macros to manipulate sigset_t here, to encapsulate knowledge of
|
||||
* its internals.
|
||||
*/
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <machine/int_types.h>
|
||||
#include <machine/ansi.h>
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
/*
|
||||
* Macro for manipulating signal masks.
|
||||
*/
|
||||
#define __sigmask(n) (1 << (((unsigned int)(n) - 1)))
|
||||
#define __sigaddset(s, n) \
|
||||
do { \
|
||||
*(s) = *(unsigned long *)(s) | __sigmask(n); \
|
||||
} while(0)
|
||||
#define __sigdelset(s, n) \
|
||||
do { \
|
||||
*(s) = *(unsigned long *)(s) & ~__sigmask(n); \
|
||||
} while (0)
|
||||
|
||||
#define __sigismember(s, n) (((*(const unsigned long *)(s)) & __sigmask(n)) != 0)
|
||||
#define __sigemptyset(s) (*(unsigned long *)(s) = 0)
|
||||
#define __sigsetequal(s1, s2) (*(unsigned long *)(s1) = *(unsigned long *)(s2))
|
||||
#define __sigfillset(s) (*(long *)(s) = -1L)
|
||||
#define __sigplusset(s, t) \
|
||||
do { \
|
||||
*(t) = *(unsigned long *)(t) | *(unsigned long *)(s); \
|
||||
} while (0)
|
||||
#define __sigminusset(s, t) \
|
||||
do { \
|
||||
*(t) = *(unsigned long *)(t) & ~*(unsigned long *)(s); \
|
||||
} while (0)
|
||||
#define __sigandset(s, t) \
|
||||
do { \
|
||||
*(t) = *(unsigned long *)(t) & *(unsigned long *)(s); \
|
||||
} while (0)
|
||||
|
||||
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
||||
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
typedef struct
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
sigaltstack
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
{
|
||||
void *ss_sp; /* signal stack base */
|
||||
size_t ss_size; /* signal stack length */
|
||||
int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
|
||||
} stack_t;
|
||||
|
||||
#endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
|
||||
|
||||
#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || ... */
|
||||
#endif /* !_SYS_SIGTYPES_H_ */
|
||||
301
nbsd_include/sys/socket.h
Normal file
301
nbsd_include/sys/socket.h
Normal file
@@ -0,0 +1,301 @@
|
||||
#ifndef _SYS_SOCKET_H_
|
||||
#define _SYS_SOCKET_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/*
|
||||
* Definitions related to sockets: types, address families, options.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Data types.
|
||||
*/
|
||||
#include <sys/ansi.h>
|
||||
|
||||
#ifndef sa_family_t
|
||||
typedef __sa_family_t sa_family_t;
|
||||
#define sa_family_t __sa_family_t
|
||||
#endif
|
||||
|
||||
#ifndef socklen_t
|
||||
typedef __socklen_t socklen_t;
|
||||
#define socklen_t __socklen_t
|
||||
#endif
|
||||
|
||||
#include <machine/ansi.h>
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SSIZE_T_
|
||||
typedef _BSD_SSIZE_T_ ssize_t;
|
||||
#undef _BSD_SSIZE_T_
|
||||
#endif
|
||||
|
||||
#include <sys/uio.h>
|
||||
|
||||
/*
|
||||
* Socket types.
|
||||
*/
|
||||
#define SOCK_STREAM 1 /* stream socket */
|
||||
#define SOCK_DGRAM 2 /* datagram socket */
|
||||
#define SOCK_RAW 3 /* raw-protocol interface */
|
||||
#define SOCK_RDM 4 /* reliably-delivered message */
|
||||
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
||||
|
||||
/*
|
||||
* Option flags per-socket.
|
||||
*/
|
||||
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
||||
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
||||
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
||||
#define SO_TYPE 0x0010 /* get socket type */
|
||||
|
||||
#define SO_PASSCRED 0x0012
|
||||
#define SO_PEERCRED 0x0014
|
||||
|
||||
#define SO_SNDBUF 0x1001 /* send buffer size */
|
||||
#define SO_RCVBUF 0x1002 /* receive buffer size */
|
||||
#define SO_ERROR 0x1007 /* get error status and clear */
|
||||
|
||||
|
||||
/*
|
||||
* Level number for (get/set)sockopt() to apply to socket itself.
|
||||
*/
|
||||
#define SOL_SOCKET 0xffff /* options for socket level */
|
||||
|
||||
/*
|
||||
* Address families.
|
||||
*/
|
||||
#define AF_UNSPEC 0 /* unspecified */
|
||||
#define AF_LOCAL 1 /* local to host */
|
||||
#define AF_UNIX AF_LOCAL /* backward compatibility */
|
||||
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
||||
#define AF_IMPLINK 3 /* arpanet imp addresses */
|
||||
#define AF_PUP 4 /* pup protocols: e.g. BSP */
|
||||
#define AF_CHAOS 5 /* mit CHAOS protocols */
|
||||
#define AF_NS 6 /* XEROX NS protocols */
|
||||
#define AF_ISO 7 /* ISO protocols */
|
||||
#define AF_OSI AF_ISO
|
||||
#define AF_ECMA 8 /* european computer manufacturers */
|
||||
#define AF_DATAKIT 9 /* datakit protocols */
|
||||
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
||||
#define AF_SNA 11 /* IBM SNA */
|
||||
#define AF_DECnet 12 /* DECnet */
|
||||
#define AF_DLI 13 /* DEC Direct data link interface */
|
||||
#define AF_LAT 14 /* LAT */
|
||||
#define AF_HYLINK 15 /* NSC Hyperchannel */
|
||||
#define AF_APPLETALK 16 /* Apple Talk */
|
||||
#define AF_ROUTE 17 /* Internal Routing Protocol */
|
||||
#define AF_LINK 18 /* Link layer interface */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
|
||||
#endif
|
||||
#define AF_COIP 20 /* connection-oriented IP, aka ST II */
|
||||
#define AF_CNT 21 /* Computer Network Technology */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
|
||||
#endif
|
||||
#define AF_IPX 23 /* Novell Internet Protocol */
|
||||
#define AF_INET6 24 /* IP version 6 */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
|
||||
#endif
|
||||
#define AF_ISDN 26 /* Integrated Services Digital Network*/
|
||||
#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
|
||||
#define AF_NATM 27 /* native ATM access */
|
||||
#define AF_ARP 28 /* (rev.) addr. res. prot. (RFC 826) */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define pseudo_AF_KEY 29 /* Internal key management protocol */
|
||||
#define pseudo_AF_HDRCMPLT 30 /* Used by BPF to not rewrite hdrs
|
||||
in interface output routine */
|
||||
#endif
|
||||
#define AF_BLUETOOTH 31 /* Bluetooth: HCI, SCO, L2CAP, RFCOMM */
|
||||
#define AF_IEEE80211 32 /* IEEE80211 */
|
||||
|
||||
#define AF_MAX 33
|
||||
|
||||
#ifndef gid_t
|
||||
typedef __gid_t gid_t; /* group id */
|
||||
#define gid_t __gid_t
|
||||
#endif
|
||||
|
||||
#ifndef uid_t
|
||||
typedef __uid_t uid_t; /* user id */
|
||||
#define uid_t __uid_t
|
||||
#endif
|
||||
|
||||
#include <sys/ucred.h>
|
||||
|
||||
/*
|
||||
* Structure used by kernel to store most
|
||||
* addresses.
|
||||
*/
|
||||
struct sockaddr
|
||||
{
|
||||
sa_family_t sa_family;
|
||||
char sa_data[8]; /* Big enough for sockaddr_in */
|
||||
};
|
||||
|
||||
/*
|
||||
* RFC 2553: protocol-independent placeholder for socket addresses
|
||||
*/
|
||||
#define _SS_MAXSIZE 128
|
||||
#define _SS_ALIGNSIZE (sizeof(__int64_t))
|
||||
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - 1)
|
||||
#define _SS_PAD2SIZE (_SS_MAXSIZE - 1 - \
|
||||
_SS_PAD1SIZE - _SS_ALIGNSIZE)
|
||||
|
||||
#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
struct sockaddr_storage {
|
||||
sa_family_t ss_family; /* address family */
|
||||
char __ss_pad1[_SS_PAD1SIZE];
|
||||
__int64_t __ss_align;/* force desired structure storage alignment */
|
||||
char __ss_pad2[_SS_PAD2SIZE];
|
||||
};
|
||||
#define sstosa(__ss) ((struct sockaddr *)(__ss))
|
||||
#define sstocsa(__ss) ((const struct sockaddr *)(__ss))
|
||||
#endif /* _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
|
||||
|
||||
/*
|
||||
* Protocol families, same as address families for now.
|
||||
*/
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
#define PF_LOCAL AF_LOCAL
|
||||
#define PF_UNIX PF_LOCAL /* backward compatibility */
|
||||
#define PF_FILE PF_LOCAL /* Minix compatibility */
|
||||
#define PF_INET AF_INET
|
||||
#define PF_IMPLINK AF_IMPLINK
|
||||
#define PF_PUP AF_PUP
|
||||
#define PF_CHAOS AF_CHAOS
|
||||
#define PF_NS AF_NS
|
||||
#define PF_ISO AF_ISO
|
||||
#define PF_OSI AF_ISO
|
||||
#define PF_ECMA AF_ECMA
|
||||
#define PF_DATAKIT AF_DATAKIT
|
||||
#define PF_CCITT AF_CCITT
|
||||
#define PF_SNA AF_SNA
|
||||
#define PF_DECnet AF_DECnet
|
||||
#define PF_DLI AF_DLI
|
||||
#define PF_LAT AF_LAT
|
||||
#define PF_HYLINK AF_HYLINK
|
||||
#define PF_APPLETALK AF_APPLETALK
|
||||
#define PF_ROUTE AF_ROUTE
|
||||
#define PF_LINK AF_LINK
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
|
||||
#endif
|
||||
#define PF_COIP AF_COIP
|
||||
#define PF_CNT AF_CNT
|
||||
#define PF_INET6 AF_INET6
|
||||
#define PF_IPX AF_IPX /* same format as AF_NS */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
|
||||
#define PF_PIP pseudo_AF_PIP
|
||||
#endif
|
||||
#define PF_ISDN AF_ISDN /* same as E164 */
|
||||
#define PF_E164 AF_E164
|
||||
#define PF_NATM AF_NATM
|
||||
#define PF_ARP AF_ARP
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define PF_KEY pseudo_AF_KEY /* like PF_ROUTE, only for key mgmt */
|
||||
#endif
|
||||
#define PF_BLUETOOTH AF_BLUETOOTH
|
||||
|
||||
#define PF_MAX AF_MAX
|
||||
|
||||
/*
|
||||
* Message header for recvmsg and sendmsg calls.
|
||||
* Used value-result for recvmsg, value only for sendmsg.
|
||||
*/
|
||||
struct msghdr {
|
||||
void *msg_name; /* optional address */
|
||||
socklen_t msg_namelen; /* size of address */
|
||||
struct iovec *msg_iov; /* scatter/gather array */
|
||||
int msg_iovlen; /* # elements in msg_iov */
|
||||
void *msg_control; /* ancillary data, see below */
|
||||
socklen_t msg_controllen; /* ancillary data buffer len */
|
||||
int msg_flags; /* flags on received message */
|
||||
};
|
||||
|
||||
/*
|
||||
* Header for ancillary data objects in msg_control buffer.
|
||||
* Used for additional information with/about a datagram
|
||||
* not expressible by flags. The format is a sequence
|
||||
* of message elements headed by cmsghdr structures.
|
||||
*/
|
||||
struct cmsghdr {
|
||||
socklen_t cmsg_len; /* data byte count, including hdr */
|
||||
int cmsg_level; /* originating protocol */
|
||||
int cmsg_type; /* protocol-specific type */
|
||||
/* followed by u_char cmsg_data[]; */
|
||||
};
|
||||
|
||||
#define CMSG_FIRSTHDR(mhdr) \
|
||||
( (mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
|
||||
(struct cmsghdr *)(mhdr)->msg_control : \
|
||||
(struct cmsghdr *)NULL )
|
||||
|
||||
#define CMSG_ALIGN(len) \
|
||||
( (len % sizeof(long) == 0) ? \
|
||||
len : \
|
||||
len + sizeof(long) - (len % sizeof(long)) )
|
||||
|
||||
#define CMSG_NXTHDR(mhdr, cmsg) \
|
||||
( ((cmsg) == NULL) ? CMSG_FIRSTHDR(mhdr) : \
|
||||
(((unsigned char *)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len) \
|
||||
+ CMSG_ALIGN(sizeof(struct cmsghdr)) > \
|
||||
(unsigned char *)((mhdr)->msg_control) + \
|
||||
(mhdr)->msg_controllen) ? \
|
||||
(struct cmsghdr *)NULL : \
|
||||
(struct cmsghdr *)((unsigned char *)(cmsg) + \
|
||||
CMSG_ALIGN((cmsg)->cmsg_len))) )
|
||||
|
||||
#define CMSG_DATA(cmsg) \
|
||||
( (unsigned char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)) )
|
||||
|
||||
#define CMSG_SPACE(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(l))
|
||||
#define CMSG_LEN(l) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (l))
|
||||
|
||||
/* "Socket"-level control message types: */
|
||||
#define SCM_RIGHTS 0x01
|
||||
#define SCM_CREDENTIALS 0x02
|
||||
#define SCM_SECURITY 0x04
|
||||
|
||||
|
||||
/*
|
||||
* Types of socket shutdown(2).
|
||||
*/
|
||||
#define SHUT_RD 0 /* Disallow further receives. */
|
||||
#define SHUT_WR 1 /* Disallow further sends. */
|
||||
#define SHUT_RDWR 2 /* Disallow further sends/receives. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
||||
__BEGIN_DECLS
|
||||
int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
|
||||
int bind(int, const struct sockaddr *, socklen_t);
|
||||
int connect(int, const struct sockaddr *, socklen_t);
|
||||
int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
|
||||
int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
|
||||
int getsockopt(int, int, int, void *__restrict, socklen_t * __restrict);
|
||||
int listen(int, int);
|
||||
ssize_t recv(int, void *, size_t, int);
|
||||
ssize_t recvfrom(int, void *__restrict, size_t, int,
|
||||
struct sockaddr * __restrict, socklen_t * __restrict);
|
||||
ssize_t recvmsg(int, struct msghdr *, int);
|
||||
ssize_t send(int, const void *, size_t, int);
|
||||
ssize_t sendto(int, const void *,
|
||||
size_t, int, const struct sockaddr *, socklen_t);
|
||||
ssize_t sendmsg(int, const struct msghdr *, int);
|
||||
int setsockopt(int, int, int, const void *, socklen_t);
|
||||
int shutdown(int, int);
|
||||
int sockatmark(int);
|
||||
int socket(int, int, int);
|
||||
int socketpair(int, int, int, int *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_SOCKET_H_ */
|
||||
179
nbsd_include/sys/stat.h
Normal file
179
nbsd_include/sys/stat.h
Normal file
@@ -0,0 +1,179 @@
|
||||
#ifndef _SYS_STAT_H_
|
||||
#define _SYS_STAT_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/types.h> /* XXX */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define __MINIX_EMULATE_NETBSD_STAT
|
||||
|
||||
/*
|
||||
* __MINIX_EMULATE_NETBSD_STAT
|
||||
*
|
||||
* Userspace flag to emulate netbsd stat structure. Please note that
|
||||
* this might be dangerous, and should be enabled only when we're sure
|
||||
* that the program doesn't use the emulated information for doing
|
||||
* something harmful.
|
||||
* It is meant to be temporary, until we add a new syscall.
|
||||
*/
|
||||
#ifdef __MINIX_EMULATE_NETBSD_STAT
|
||||
#define __netbsd_stat stat
|
||||
#else
|
||||
#define __minix_stat stat
|
||||
#endif
|
||||
|
||||
struct __minix_stat {
|
||||
dev_t st_dev; /* major/minor device number */
|
||||
ino_t st_ino; /* i-node number */
|
||||
mode_t st_mode; /* file mode, protection bits, etc. */
|
||||
nlink_t st_nlink; /* # links; */
|
||||
uid_t st_uid; /* uid of the file's owner */
|
||||
gid_t st_gid; /* gid */
|
||||
dev_t st_rdev;
|
||||
off_t st_size; /* file size */
|
||||
time_t st_atime; /* time of last access */
|
||||
time_t st_mtime; /* time of last data modification */
|
||||
time_t st_ctime; /* time of last file status change */
|
||||
};
|
||||
|
||||
struct __netbsd_stat {
|
||||
dev_t st_dev; /* major/minor device number */
|
||||
ino_t st_ino; /* i-node number */
|
||||
mode_t st_mode; /* file mode, protection bits, etc. */
|
||||
nlink_t st_nlink; /* # links; */
|
||||
uid_t st_uid; /* uid of the file's owner */
|
||||
gid_t st_gid; /* gid */
|
||||
dev_t st_rdev;
|
||||
off_t st_size; /* file size */
|
||||
time_t st_atime; /* time of last access */
|
||||
time_t st_mtime; /* time of last data modification */
|
||||
time_t st_ctime; /* time of last file status change */
|
||||
|
||||
/* XXX: Currently not supported by Minix, and here are just emulated. */
|
||||
struct timespec st_atimespec;/* time of last access */
|
||||
struct timespec st_mtimespec;/* time of last data modification */
|
||||
struct timespec st_ctimespec;/* time of last file status change */
|
||||
struct timespec st_birthtimespec; /* time of creation */
|
||||
blkcnt_t st_blocks; /* blocks allocated for file */
|
||||
blksize_t st_blksize; /* optimal blocksize for I/O */
|
||||
uint32_t st_flags; /* user defined flags for file */
|
||||
uint32_t st_gen; /* file generation number */
|
||||
uint32_t st_spare[2];
|
||||
};
|
||||
|
||||
#ifdef __MINIX_EMULATE_NETBSD_STAT
|
||||
#define st_atimensec st_atimespec.tv_nsec
|
||||
#define st_mtimensec st_mtimespec.tv_nsec
|
||||
#define st_ctimensec st_ctimespec.tv_nsec
|
||||
#define st_birthtime st_birthtimespec.tv_sec
|
||||
#define st_birthtimensec st_birthtimespec.tv_nsec
|
||||
#endif
|
||||
|
||||
#define S_ISUID 0004000 /* set user id on execution */
|
||||
#define S_ISGID 0002000 /* set group id on execution */
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define S_ISTXT 0001000 /* sticky bit */
|
||||
#endif
|
||||
|
||||
#define S_IRWXU 0000700 /* RWX mask for owner */
|
||||
#define S_IRUSR 0000400 /* R for owner */
|
||||
#define S_IWUSR 0000200 /* W for owner */
|
||||
#define S_IXUSR 0000100 /* X for owner */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define S_IREAD S_IRUSR
|
||||
#define S_IWRITE S_IWUSR
|
||||
#define S_IEXEC S_IXUSR
|
||||
#endif
|
||||
|
||||
#define S_IRWXG 0000070 /* RWX mask for group */
|
||||
#define S_IRGRP 0000040 /* R for group */
|
||||
#define S_IWGRP 0000020 /* W for group */
|
||||
#define S_IXGRP 0000010 /* X for group */
|
||||
|
||||
#define S_IRWXO 0000007 /* RWX mask for other */
|
||||
#define S_IROTH 0000004 /* R for other */
|
||||
#define S_IWOTH 0000002 /* W for other */
|
||||
#define S_IXOTH 0000001 /* X for other */
|
||||
|
||||
#define _S_IFMT 0170000 /* type of file mask */
|
||||
#define _S_IFIFO 0010000 /* named pipe (fifo) */
|
||||
#define _S_IFCHR 0020000 /* character special */
|
||||
#define _S_IFDIR 0040000 /* directory */
|
||||
#define _S_IFBLK 0060000 /* block special */
|
||||
#define _S_IFREG 0100000 /* regular */
|
||||
#define _S_IFLNK 0120000 /* symbolic link */
|
||||
#define _S_IFSOCK 0140000 /* socket */
|
||||
#define _S_ISVTX 0001000 /* save swapped text even after use */
|
||||
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#define S_IFMT _S_IFMT
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#define S_IFBLK _S_IFBLK
|
||||
#define S_IFREG _S_IFREG
|
||||
#define S_IFLNK _S_IFLNK
|
||||
#define S_ISVTX _S_ISVTX
|
||||
#endif
|
||||
#if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE)
|
||||
#define S_IFSOCK _S_IFSOCK
|
||||
#endif
|
||||
|
||||
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */
|
||||
#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */
|
||||
#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */
|
||||
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */
|
||||
#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */
|
||||
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */
|
||||
#endif
|
||||
#if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */
|
||||
#endif
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
|
||||
/* 7777 */
|
||||
#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
|
||||
/* 0666 */
|
||||
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
||||
|
||||
#define S_BLKSIZE 512 /* block size used in the stat struct */
|
||||
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
#if defined(__minix)
|
||||
#include <machine/vmparam.h>
|
||||
/* Convenient constant to use when st_blocksize field is required. */
|
||||
#define MINIX_ST_BLKSIZE PAGE_SIZE
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int chmod(const char *, mode_t);
|
||||
int mkdir(const char *, mode_t);
|
||||
int mkfifo(const char *, mode_t);
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
int stat(const char *, struct stat *);
|
||||
int fstat(int, struct stat *);
|
||||
#endif
|
||||
mode_t umask(mode_t);
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
int fchmod(int, mode_t);
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
int lstat(const char *, struct stat *);
|
||||
int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50);
|
||||
#endif
|
||||
#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_KERNEL && !_STANDALONE */
|
||||
#endif /* !_SYS_STAT_H_ */
|
||||
64
nbsd_include/sys/statvfs.h
Normal file
64
nbsd_include/sys/statvfs.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef _SYS_STATVFS_H_
|
||||
#define _SYS_STATVFS_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/stdint.h>
|
||||
#include <machine/ansi.h>
|
||||
#include <sys/ansi.h>
|
||||
|
||||
#define _VFS_NAMELEN 32
|
||||
#define _VFS_MNAMELEN 1024
|
||||
|
||||
#ifndef fsblkcnt_t
|
||||
typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */
|
||||
#define fsblkcnt_t __fsblkcnt_t
|
||||
#endif
|
||||
|
||||
#ifndef fsfilcnt_t
|
||||
typedef __fsfilcnt_t fsfilcnt_t; /* fs file count */
|
||||
#define fsfilcnt_t __fsfilcnt_t
|
||||
#endif
|
||||
|
||||
#ifndef uid_t
|
||||
typedef __uid_t uid_t; /* user id */
|
||||
#define uid_t __uid_t
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#define _SIZE_T
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
|
||||
struct statvfs {
|
||||
unsigned long f_bsize; /* File system block size. */
|
||||
unsigned long f_frsize; /* Fundamental file system block size. */
|
||||
fsblkcnt_t f_blocks; /* Total number of blocks on file system */
|
||||
/* in units of f_frsize. */
|
||||
fsblkcnt_t f_bfree; /* Total number of free blocks. */
|
||||
fsblkcnt_t f_bavail; /* Number of free blocks available to */
|
||||
/* non-privileged process. */
|
||||
fsfilcnt_t f_files; /* Total number of file serial numbers. */
|
||||
fsfilcnt_t f_ffree; /* Total number of free file serial numbers. */
|
||||
fsfilcnt_t f_favail; /* Number of file serial numbers available */
|
||||
/* to non-privileged process. */
|
||||
unsigned long f_fsid; /* File system ID. */
|
||||
unsigned long f_flag; /* Bit mask of f_flag values. */
|
||||
unsigned long f_namemax; /* Maximum filename length. */
|
||||
unsigned char __padding[32]; /* Padding for future compatibility */
|
||||
};
|
||||
|
||||
/* Possible values for statvfs->f_flag */
|
||||
#define ST_RDONLY 0x1
|
||||
#define ST_NOSUID 0x2
|
||||
#ifdef __minix
|
||||
#define ST_NOTRUNC 0x4
|
||||
#endif /* !__minix*/
|
||||
|
||||
__BEGIN_DECLS
|
||||
int statvfs(const char *__restrict, struct statvfs *__restrict);
|
||||
int fstatvfs(int, struct statvfs *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_STATVFS_H_ */
|
||||
100
nbsd_include/sys/stdint.h
Normal file
100
nbsd_include/sys/stdint.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* $NetBSD: stdint.h,v 1.6 2008/04/28 20:24:11 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus Klein.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_STDINT_H_
|
||||
#define _SYS_STDINT_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/int_types.h>
|
||||
|
||||
#ifndef int8_t
|
||||
typedef __int8_t int8_t;
|
||||
#define int8_t __int8_t
|
||||
#endif
|
||||
|
||||
#ifndef uint8_t
|
||||
typedef __uint8_t uint8_t;
|
||||
#define uint8_t __uint8_t
|
||||
#endif
|
||||
|
||||
#ifndef int16_t
|
||||
typedef __int16_t int16_t;
|
||||
#define int16_t __int16_t
|
||||
#endif
|
||||
|
||||
#ifndef uint16_t
|
||||
typedef __uint16_t uint16_t;
|
||||
#define uint16_t __uint16_t
|
||||
#endif
|
||||
|
||||
#ifndef int32_t
|
||||
typedef __int32_t int32_t;
|
||||
#define int32_t __int32_t
|
||||
#endif
|
||||
|
||||
#ifndef uint32_t
|
||||
typedef __uint32_t uint32_t;
|
||||
#define uint32_t __uint32_t
|
||||
#endif
|
||||
|
||||
#ifndef int64_t
|
||||
typedef __int64_t int64_t;
|
||||
#define int64_t __int64_t
|
||||
#endif
|
||||
|
||||
#ifndef uint64_t
|
||||
typedef __uint64_t uint64_t;
|
||||
#define uint64_t __uint64_t
|
||||
#endif
|
||||
|
||||
#ifndef intptr_t
|
||||
typedef __intptr_t intptr_t;
|
||||
#define intptr_t __intptr_t
|
||||
#endif
|
||||
|
||||
#ifndef uintptr_t
|
||||
typedef __uintptr_t uintptr_t;
|
||||
#define uintptr_t __uintptr_t
|
||||
#endif
|
||||
|
||||
#include <machine/int_mwgwtypes.h>
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||
#include <machine/int_limits.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||
#include <machine/int_const.h>
|
||||
#endif
|
||||
|
||||
#include <machine/wchar_limits.h>
|
||||
|
||||
#endif /* !_SYS_STDINT_H_ */
|
||||
22
nbsd_include/sys/sysctl.h
Normal file
22
nbsd_include/sys/sysctl.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef _SYS_SYSCTL_H
|
||||
#define _SYS_SYSCTL_H
|
||||
|
||||
/*
|
||||
* sysctl() is not supported. Warn non-libc programs including this header.
|
||||
*/
|
||||
#ifndef _LIBC
|
||||
#warning Including sysctl.h header. sysctl() is not supported in Minix.
|
||||
#endif /* !_LIBC */
|
||||
|
||||
/*
|
||||
* Used by gmon.
|
||||
*/
|
||||
struct clockinfo {
|
||||
int hz; /* clock frequency */
|
||||
int tick; /* micro-seconds per hz tick */
|
||||
int tickadj; /* clock skew rate for adjtime() */
|
||||
int stathz; /* statistics clock frequency */
|
||||
int profhz; /* profiling clock frequency */
|
||||
};
|
||||
|
||||
#endif /* _SYS_SYSCTL_H */
|
||||
72
nbsd_include/sys/syslimits.h
Normal file
72
nbsd_include/sys/syslimits.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef _SYS_SYSLIMITS_H_
|
||||
#define _SYS_SYSLIMITS_H_
|
||||
|
||||
#include <minix/limits.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/* Values actually implemented by MINIX (Tables 2-4, 2-5, 2-6, and 2-7). */
|
||||
/* Some of these old names had better be defined when not POSIX. */
|
||||
#define _NO_LIMIT 160 /* arbitrary number; limit not enforced */
|
||||
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
|
||||
#if _EM_WSIZE > 2
|
||||
#define ARG_MAX 262144 /* # bytes of args + environ for exec() */
|
||||
#else
|
||||
#define ARG_MAX 4096 /* args + environ on small machines */
|
||||
#endif
|
||||
|
||||
#ifndef CHILD_MAX
|
||||
#define CHILD_MAX _NO_LIMIT /* max simultaneous processes */
|
||||
#endif
|
||||
|
||||
#define GID_MAX CHAR_MAX /* max value for a gid_t */
|
||||
#define LINK_MAX SHRT_MAX /* # links a file may have */
|
||||
#define MAX_CANON 255 /* size of the canonical input queue */
|
||||
#define MAX_INPUT 255 /* size of the type-ahead buffer */
|
||||
#define NAME_MAX 60 /* # chars in a file name (actually DIRSZ) */
|
||||
#define NGROUPS_MAX 8 /* max. number of supplemental groups */
|
||||
#define UID_MAX SHRT_MAX /* max value for a uid_t */
|
||||
#ifndef OPEN_MAX
|
||||
#define OPEN_MAX __MINIX_OPEN_MAX /* max open files per process */
|
||||
#endif
|
||||
#define PATH_MAX __MINIX_PATH_MAX /* # chars in a path name */
|
||||
#define PIPE_BUF 7168 /* # bytes in atomic write to a pipe */
|
||||
|
||||
#define BC_BASE_MAX INT_MAX /* max ibase/obase values in bc(1) */
|
||||
#define BC_DIM_MAX 65535 /* max array elements in bc(1) */
|
||||
#define BC_SCALE_MAX INT_MAX /* max scale value in bc(1) */
|
||||
#define BC_STRING_MAX INT_MAX /* max const string length in bc(1) */
|
||||
#define COLL_WEIGHTS_MAX 2 /* max weights for order keyword */
|
||||
#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */
|
||||
#define LINE_MAX 2048 /* max bytes in an input line */
|
||||
#define RE_DUP_MAX 255 /* max RE's in interval notation */
|
||||
|
||||
/*
|
||||
* IEEE Std 1003.1c-95, adopted in X/Open CAE Specification Issue 5 Version 2
|
||||
*/
|
||||
#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define LOGIN_NAME_MAX 17 /* max login name length incl. NUL */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* X/Open CAE Specification Issue 5 Version 2
|
||||
*/
|
||||
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
#define IOV_MAX 1024 /* max # of iovec's for readv(2) etc. */
|
||||
#define NZERO 20 /* default "nice" */
|
||||
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
|
||||
#endif /* !_ANSI_SOURCE */
|
||||
|
||||
#ifdef __minix
|
||||
#define STREAM_MAX 8 /* == _POSIX_STREAM_MAX */
|
||||
#define TZNAME_MAX 6 /* == _POSIX_TZNAME_MAX */
|
||||
#define TIME_MAX LONG_MAX
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_SYSLIMITS_H_ */
|
||||
|
||||
241
nbsd_include/sys/syslog.h
Normal file
241
nbsd_include/sys/syslog.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/* $NetBSD: syslog.h,v 1.32 2008/10/31 16:12:18 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1988, 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.
|
||||
*
|
||||
* @(#)syslog.h 8.1 (Berkeley) 6/2/93
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SYSLOG_H_
|
||||
#define _SYS_SYSLOG_H_
|
||||
|
||||
#define _PATH_LOG "/var/run/log"
|
||||
|
||||
/*
|
||||
* priorities/facilities are encoded into a single 32-bit quantity, where the
|
||||
* bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
|
||||
* (0-big number). Both the priorities and the facilities map roughly
|
||||
* one-to-one to strings in the syslogd(8) source code. This mapping is
|
||||
* included in this file.
|
||||
*
|
||||
* priorities (these are ordered)
|
||||
*/
|
||||
#define LOG_EMERG 0 /* system is unusable */
|
||||
#define LOG_ALERT 1 /* action must be taken immediately */
|
||||
#define LOG_CRIT 2 /* critical conditions */
|
||||
#define LOG_ERR 3 /* error conditions */
|
||||
#define LOG_WARNING 4 /* warning conditions */
|
||||
#define LOG_NOTICE 5 /* normal but significant condition */
|
||||
#define LOG_INFO 6 /* informational */
|
||||
#define LOG_DEBUG 7 /* debug-level messages */
|
||||
|
||||
#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
|
||||
/* extract priority */
|
||||
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
|
||||
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
|
||||
|
||||
#ifdef SYSLOG_NAMES
|
||||
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
|
||||
/* mark "facility" */
|
||||
#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0)
|
||||
typedef struct _code {
|
||||
char *c_name;
|
||||
int c_val;
|
||||
} CODE;
|
||||
|
||||
CODE prioritynames[] = {
|
||||
{ "alert", LOG_ALERT },
|
||||
{ "crit", LOG_CRIT },
|
||||
{ "debug", LOG_DEBUG },
|
||||
{ "emerg", LOG_EMERG },
|
||||
{ "err", LOG_ERR },
|
||||
{ "error", LOG_ERR }, /* DEPRECATED */
|
||||
{ "info", LOG_INFO },
|
||||
{ "none", INTERNAL_NOPRI }, /* INTERNAL */
|
||||
{ "notice", LOG_NOTICE },
|
||||
{ "panic", LOG_EMERG }, /* DEPRECATED */
|
||||
{ "warn", LOG_WARNING }, /* DEPRECATED */
|
||||
{ "warning", LOG_WARNING },
|
||||
{ NULL, -1 }
|
||||
};
|
||||
#endif
|
||||
|
||||
/* facility codes */
|
||||
#define LOG_KERN (0<<3) /* kernel messages */
|
||||
#define LOG_USER (1<<3) /* random user-level messages */
|
||||
#define LOG_MAIL (2<<3) /* mail system */
|
||||
#define LOG_DAEMON (3<<3) /* system daemons */
|
||||
#define LOG_AUTH (4<<3) /* security/authorization messages */
|
||||
#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
|
||||
#define LOG_LPR (6<<3) /* line printer subsystem */
|
||||
#define LOG_NEWS (7<<3) /* network news subsystem */
|
||||
#define LOG_UUCP (8<<3) /* UUCP subsystem */
|
||||
#define LOG_CRON (9<<3) /* clock daemon */
|
||||
#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
|
||||
#define LOG_FTP (11<<3) /* ftp daemon */
|
||||
|
||||
/* other codes through 15 reserved for system use */
|
||||
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL2 (18<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL3 (19<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL4 (20<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL5 (21<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL6 (22<<3) /* reserved for local use */
|
||||
#define LOG_LOCAL7 (23<<3) /* reserved for local use */
|
||||
|
||||
#define LOG_NFACILITIES 24 /* current number of facilities */
|
||||
#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
|
||||
/* facility of pri */
|
||||
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
|
||||
|
||||
#ifdef SYSLOG_NAMES
|
||||
CODE facilitynames[] = {
|
||||
{ "auth", LOG_AUTH },
|
||||
{ "authpriv", LOG_AUTHPRIV },
|
||||
{ "cron", LOG_CRON },
|
||||
{ "daemon", LOG_DAEMON },
|
||||
{ "ftp", LOG_FTP },
|
||||
{ "kern", LOG_KERN },
|
||||
{ "lpr", LOG_LPR },
|
||||
{ "mail", LOG_MAIL },
|
||||
{ "mark", INTERNAL_MARK }, /* INTERNAL */
|
||||
{ "news", LOG_NEWS },
|
||||
{ "security", LOG_AUTH }, /* DEPRECATED */
|
||||
{ "syslog", LOG_SYSLOG },
|
||||
{ "user", LOG_USER },
|
||||
{ "uucp", LOG_UUCP },
|
||||
{ "local0", LOG_LOCAL0 },
|
||||
{ "local1", LOG_LOCAL1 },
|
||||
{ "local2", LOG_LOCAL2 },
|
||||
{ "local3", LOG_LOCAL3 },
|
||||
{ "local4", LOG_LOCAL4 },
|
||||
{ "local5", LOG_LOCAL5 },
|
||||
{ "local6", LOG_LOCAL6 },
|
||||
{ "local7", LOG_LOCAL7 },
|
||||
{ NULL, -1 }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* arguments to setlogmask.
|
||||
*/
|
||||
#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
|
||||
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
|
||||
|
||||
/*
|
||||
* Option flags for openlog.
|
||||
*
|
||||
* LOG_ODELAY no longer does anything.
|
||||
* LOG_NDELAY is the inverse of what it used to be.
|
||||
*/
|
||||
#define LOG_PID 0x01 /* log the pid with each message */
|
||||
#define LOG_CONS 0x02 /* log on the console if errors in sending */
|
||||
#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
|
||||
#define LOG_NDELAY 0x08 /* don't delay open */
|
||||
#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
|
||||
#define LOG_PERROR 0x20 /* log to stderr as well */
|
||||
|
||||
#ifndef _KERNEL
|
||||
|
||||
/* Used by reentrant functions */
|
||||
|
||||
struct syslog_data {
|
||||
int log_file;
|
||||
int connected;
|
||||
int opened;
|
||||
int log_stat;
|
||||
const char *log_tag;
|
||||
int log_fac;
|
||||
int log_mask;
|
||||
};
|
||||
|
||||
#define SYSLOG_DATA_INIT { \
|
||||
.log_file = -1, \
|
||||
.log_fac = LOG_USER, \
|
||||
.log_mask = 0xff, \
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two
|
||||
* places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
|
||||
* of them here we may collide with the utility's includes. It's unreasonable
|
||||
* for utilities to have to include one of them to include syslog.h, so we get
|
||||
* _BSD_VA_LIST_ from <machine/ansi.h> and use it.
|
||||
*/
|
||||
#include <machine/ansi.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
void closelog(void);
|
||||
void openlog(const char *, int, int);
|
||||
int setlogmask(int);
|
||||
void syslog(int, const char *, ...)
|
||||
__attribute__((__format__(__printf__,2,3)));
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
void vsyslog(int, const char *, _BSD_VA_LIST_)
|
||||
__attribute__((__format__(__printf__,2,0)));
|
||||
void closelog_r(struct syslog_data *);
|
||||
void openlog_r(const char *, int, int, struct syslog_data *);
|
||||
int setlogmask_r(int, struct syslog_data *);
|
||||
void syslog_r(int, struct syslog_data *, const char *, ...)
|
||||
__attribute__((__format__(__printf__,3,4)));
|
||||
void vsyslog_r(int, struct syslog_data *, const char *, _BSD_VA_LIST_)
|
||||
__attribute__((__format__(__printf__,3,0)));
|
||||
void syslogp(int, const char *, const char *, const char *, ...)
|
||||
__attribute__((__format__(__printf__,4,5)));
|
||||
void vsyslogp(int, const char *, const char *, const char *, _BSD_VA_LIST_)
|
||||
__attribute__((__format__(__printf__,4,0)));
|
||||
void syslogp_r(int, struct syslog_data *, const char *, const char *,
|
||||
const char *, ...)
|
||||
__attribute__((__format__(__printf__,5,6)));
|
||||
void vsyslogp_r(int, struct syslog_data *, const char *, const char *,
|
||||
const char *, _BSD_VA_LIST_)
|
||||
__attribute__((__format__(__printf__,5,0)));
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#else /* !_KERNEL */
|
||||
|
||||
void logpri(int);
|
||||
void log(int, const char *, ...)
|
||||
__attribute__((__format__(__printf__,2,3)));
|
||||
void vlog(int, const char *, _BSD_VA_LIST_)
|
||||
__attribute__((__format__(__printf__,2,0)));
|
||||
void addlog(const char *, ...)
|
||||
__attribute__((__format__(__printf__,1,2)));
|
||||
void logwakeup(void);
|
||||
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
#endif /* !_SYS_SYSLOG_H_ */
|
||||
17
nbsd_include/sys/termios.h
Normal file
17
nbsd_include/sys/termios.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _SYS_TERMIOS_H_
|
||||
#define _SYS_TERMIOS_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <minix/termios.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
void cfmakeraw(struct termios *);
|
||||
int cfsetspeed(struct termios *, speed_t);
|
||||
#endif /* defined(_NETBSD_SOURCE) */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_TERMIOS_H_ */
|
||||
|
||||
#include <sys/ttydefaults.h>
|
||||
266
nbsd_include/sys/time.h
Normal file
266
nbsd_include/sys/time.h
Normal file
@@ -0,0 +1,266 @@
|
||||
#ifndef _SYS_TIME_H_
|
||||
#define _SYS_TIME_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Structure returned by gettimeofday(2) system call,
|
||||
* and used in other calls.
|
||||
*/
|
||||
struct timeval {
|
||||
time_t tv_sec; /* seconds */
|
||||
suseconds_t tv_usec; /* and microseconds */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure defined by POSIX.1b to be like a timeval.
|
||||
*/
|
||||
struct timespec {
|
||||
time_t tv_sec; /* seconds */
|
||||
long tv_nsec; /* and nanoseconds */
|
||||
};
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
|
||||
(ts)->tv_sec = (tv)->tv_sec; \
|
||||
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \
|
||||
(tv)->tv_sec = (ts)->tv_sec; \
|
||||
(tv)->tv_usec = (suseconds_t)(ts)->tv_nsec / 1000; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
/*
|
||||
* Note: timezone is obsolete. All timezone handling is now in
|
||||
* userland. Its just here for back compatibility.
|
||||
*/
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes west of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
/* Operations on timevals. */
|
||||
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0L
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||
#define timeradd(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) { \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define timersub(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) { \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
|
||||
/*
|
||||
* hide bintime for _STANDALONE because this header is used for hpcboot.exe,
|
||||
* which is built with compilers which don't recognize LL suffix.
|
||||
* http://mail-index.NetBSD.org/tech-userlevel/2008/02/27/msg000181.html
|
||||
*/
|
||||
#if !defined(_STANDALONE)
|
||||
struct bintime {
|
||||
time_t sec;
|
||||
uint64_t frac;
|
||||
};
|
||||
|
||||
static __inline void
|
||||
bintime_addx(struct bintime *bt, uint64_t x)
|
||||
{
|
||||
uint64_t u;
|
||||
|
||||
u = bt->frac;
|
||||
bt->frac += x;
|
||||
if (u > bt->frac)
|
||||
bt->sec++;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
bintime_add(struct bintime *bt, const struct bintime *bt2)
|
||||
{
|
||||
uint64_t u;
|
||||
|
||||
u = bt->frac;
|
||||
bt->frac += bt2->frac;
|
||||
if (u > bt->frac)
|
||||
bt->sec++;
|
||||
bt->sec += bt2->sec;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
bintime_sub(struct bintime *bt, const struct bintime *bt2)
|
||||
{
|
||||
uint64_t u;
|
||||
|
||||
u = bt->frac;
|
||||
bt->frac -= bt2->frac;
|
||||
if (u < bt->frac)
|
||||
bt->sec--;
|
||||
bt->sec -= bt2->sec;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Background information:
|
||||
*
|
||||
* When converting between timestamps on parallel timescales of differing
|
||||
* resolutions it is historical and scientific practice to round down rather
|
||||
* than doing 4/5 rounding.
|
||||
*
|
||||
* The date changes at midnight, not at noon.
|
||||
*
|
||||
* Even at 15:59:59.999999999 it's not four'o'clock.
|
||||
*
|
||||
* time_second ticks after N.999999999 not after N.4999999999
|
||||
*/
|
||||
|
||||
static __inline void
|
||||
bintime2timespec(const struct bintime *bt, struct timespec *ts)
|
||||
{
|
||||
|
||||
ts->tv_sec = bt->sec;
|
||||
ts->tv_nsec =
|
||||
(long)(((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
timespec2bintime(const struct timespec *ts, struct bintime *bt)
|
||||
{
|
||||
|
||||
bt->sec = ts->tv_sec;
|
||||
/* 18446744073 = int(2^64 / 1000000000) */
|
||||
bt->frac = ts->tv_nsec * (uint64_t)18446744073LL;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
bintime2timeval(const struct bintime *bt, struct timeval *tv)
|
||||
{
|
||||
|
||||
tv->tv_sec = bt->sec;
|
||||
tv->tv_usec =
|
||||
(suseconds_t)(((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
timeval2bintime(const struct timeval *tv, struct bintime *bt)
|
||||
{
|
||||
|
||||
bt->sec = tv->tv_sec;
|
||||
/* 18446744073709 = int(2^64 / 1000000) */
|
||||
bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
|
||||
}
|
||||
#endif /* !defined(_STANDALONE) */
|
||||
|
||||
/* Operations on timespecs. */
|
||||
#define timespecclear(tsp) (tsp)->tv_sec = (time_t)((tsp)->tv_nsec = 0L)
|
||||
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
|
||||
#define timespeccmp(tsp, usp, cmp) \
|
||||
(((tsp)->tv_sec == (usp)->tv_sec) ? \
|
||||
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
|
||||
((tsp)->tv_sec cmp (usp)->tv_sec))
|
||||
#define timespecadd(tsp, usp, vsp) \
|
||||
do { \
|
||||
(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
|
||||
(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
|
||||
if ((vsp)->tv_nsec >= 1000000000L) { \
|
||||
(vsp)->tv_sec++; \
|
||||
(vsp)->tv_nsec -= 1000000000L; \
|
||||
} \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define timespecsub(tsp, usp, vsp) \
|
||||
do { \
|
||||
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
|
||||
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
|
||||
if ((vsp)->tv_nsec < 0) { \
|
||||
(vsp)->tv_sec--; \
|
||||
(vsp)->tv_nsec += 1000000000L; \
|
||||
} \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define timespec2ns(x) (((uint64_t)(x)->tv_sec) * 1000000000L + (x)->tv_nsec)
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
/*
|
||||
* Names of the interval timers, and structure
|
||||
* defining a timer setting.
|
||||
*/
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval; /* timer interval */
|
||||
struct timeval it_value; /* current value */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure defined by POSIX.1b to be like a itimerval, but with
|
||||
* timespecs. Used in the timer_*() system calls.
|
||||
*/
|
||||
struct itimerspec {
|
||||
struct timespec it_interval;
|
||||
struct timespec it_value;
|
||||
};
|
||||
|
||||
#ifndef __minix
|
||||
#define CLOCK_REALTIME 0
|
||||
#define CLOCK_VIRTUAL 1
|
||||
#define CLOCK_PROF 2
|
||||
#define CLOCK_MONOTONIC 3
|
||||
#endif
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define TIMER_RELTIME 0x0 /* relative timer */
|
||||
#endif
|
||||
#define TIMER_ABSTIME 0x1 /* absolute timer */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/timevar.h>
|
||||
#else /* !_KERNEL */
|
||||
#ifndef _STANDALONE
|
||||
#if (_POSIX_C_SOURCE - 0) >= 200112L || \
|
||||
(defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
||||
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <time.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
#ifndef __LIBC12_SOURCE__
|
||||
#if (_POSIX_C_SOURCE - 0) >= 200112L || \
|
||||
defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||
int getitimer(int, struct itimerval *) __RENAME(__getitimer50);
|
||||
int gettimeofday(struct timeval * __restrict, void *__restrict);
|
||||
int setitimer(int, const struct itimerval * __restrict,
|
||||
struct itimerval * __restrict) __RENAME(__setitimer50);
|
||||
#endif /* _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||
|
||||
#if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H)
|
||||
#ifndef __minix
|
||||
int adjtime(const struct timeval *, struct timeval *) __RENAME(__adjtime50);
|
||||
int futimes(int, const struct timeval [2]) __RENAME(__futimes50);
|
||||
int lutimes(const char *, const struct timeval [2]) __RENAME(__lutimes50);
|
||||
#endif /* !__minix */
|
||||
int settimeofday(const struct timeval * __restrict,
|
||||
const void *__restrict) __RENAME(__settimeofday50);
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
#endif /* __LIBC12_SOURCE__ */
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_STANDALONE */
|
||||
#endif /* !_KERNEL */
|
||||
#endif /* !_SYS_TIME_H_ */
|
||||
24
nbsd_include/sys/times.h
Normal file
24
nbsd_include/sys/times.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _SYS_TIMES_H_
|
||||
#define _SYS_TIMES_H_
|
||||
|
||||
#include <machine/ansi.h>
|
||||
|
||||
#ifdef _BSD_CLOCK_T_
|
||||
typedef _BSD_CLOCK_T_ clock_t;
|
||||
#undef _BSD_CLOCK_T_
|
||||
#endif
|
||||
|
||||
struct tms {
|
||||
clock_t tms_utime; /* User CPU time */
|
||||
clock_t tms_stime; /* System CPU time */
|
||||
clock_t tms_cutime; /* User CPU time of terminated child procs */
|
||||
clock_t tms_cstime; /* System CPU time of terminated child procs */
|
||||
};
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
clock_t times(struct tms *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_TIMES_H_ */
|
||||
741
nbsd_include/sys/tree.h
Normal file
741
nbsd_include/sys/tree.h
Normal file
@@ -0,0 +1,741 @@
|
||||
/* $NetBSD: tree.h,v 1.16 2008/03/21 13:07:15 ad Exp $ */
|
||||
/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TREE_H_
|
||||
#define _SYS_TREE_H_
|
||||
|
||||
/*
|
||||
* This file defines data structures for different types of trees:
|
||||
* splay trees and red-black trees.
|
||||
*
|
||||
* A splay tree is a self-organizing data structure. Every operation
|
||||
* on the tree causes a splay to happen. The splay moves the requested
|
||||
* node to the root of the tree and partly rebalances it.
|
||||
*
|
||||
* This has the benefit that request locality causes faster lookups as
|
||||
* the requested nodes move to the top of the tree. On the other hand,
|
||||
* every lookup causes memory writes.
|
||||
*
|
||||
* The Balance Theorem bounds the total access time for m operations
|
||||
* and n inserts on an initially empty tree as O((m + n)lg n). The
|
||||
* amortized cost for a sequence of m accesses to a splay tree is O(lg n);
|
||||
*
|
||||
* A red-black tree is a binary search tree with the node color as an
|
||||
* extra attribute. It fulfills a set of conditions:
|
||||
* - every search path from the root to a leaf consists of the
|
||||
* same number of black nodes,
|
||||
* - each red node (except for the root) has a black parent,
|
||||
* - each leaf node is black.
|
||||
*
|
||||
* Every operation on a red-black tree is bounded as O(lg n).
|
||||
* The maximum height of a red-black tree is 2lg (n+1).
|
||||
*/
|
||||
|
||||
#define SPLAY_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *sph_root; /* root of the tree */ \
|
||||
}
|
||||
|
||||
#define SPLAY_INITIALIZER(root) \
|
||||
{ NULL }
|
||||
|
||||
#define SPLAY_INIT(root) do { \
|
||||
(root)->sph_root = NULL; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *spe_left; /* left element */ \
|
||||
struct type *spe_right; /* right element */ \
|
||||
}
|
||||
|
||||
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
|
||||
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
|
||||
#define SPLAY_ROOT(head) (head)->sph_root
|
||||
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
|
||||
|
||||
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
|
||||
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
|
||||
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
|
||||
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
||||
(head)->sph_root = tmp; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
|
||||
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
||||
(head)->sph_root = tmp; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_LINKLEFT(head, tmp, field) do { \
|
||||
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
||||
tmp = (head)->sph_root; \
|
||||
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_LINKRIGHT(head, tmp, field) do { \
|
||||
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
||||
tmp = (head)->sph_root; \
|
||||
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
|
||||
SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
|
||||
SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
|
||||
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
/* Generates prototypes and inline functions */
|
||||
|
||||
#define SPLAY_PROTOTYPE(name, type, field, cmp) \
|
||||
void name##_SPLAY(struct name *, struct type *); \
|
||||
void name##_SPLAY_MINMAX(struct name *, int); \
|
||||
struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
|
||||
struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
|
||||
\
|
||||
/* Finds the node with the same key as elm */ \
|
||||
static __inline struct type * \
|
||||
name##_SPLAY_FIND(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
if (SPLAY_EMPTY(head)) \
|
||||
return(NULL); \
|
||||
name##_SPLAY(head, elm); \
|
||||
if ((cmp)(elm, (head)->sph_root) == 0) \
|
||||
return (head->sph_root); \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
static __inline struct type * \
|
||||
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
name##_SPLAY(head, elm); \
|
||||
if (SPLAY_RIGHT(elm, field) != NULL) { \
|
||||
elm = SPLAY_RIGHT(elm, field); \
|
||||
while (SPLAY_LEFT(elm, field) != NULL) { \
|
||||
elm = SPLAY_LEFT(elm, field); \
|
||||
} \
|
||||
} else \
|
||||
elm = NULL; \
|
||||
return (elm); \
|
||||
} \
|
||||
\
|
||||
static __inline struct type * \
|
||||
name##_SPLAY_MIN_MAX(struct name *head, int val) \
|
||||
{ \
|
||||
name##_SPLAY_MINMAX(head, val); \
|
||||
return (SPLAY_ROOT(head)); \
|
||||
}
|
||||
|
||||
/* Main splay operation.
|
||||
* Moves node close to the key of elm to top
|
||||
*/
|
||||
#define SPLAY_GENERATE(name, type, field, cmp) \
|
||||
struct type * \
|
||||
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
if (SPLAY_EMPTY(head)) { \
|
||||
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
|
||||
} else { \
|
||||
int __comp; \
|
||||
name##_SPLAY(head, elm); \
|
||||
__comp = (cmp)(elm, (head)->sph_root); \
|
||||
if(__comp < 0) { \
|
||||
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
|
||||
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
|
||||
SPLAY_LEFT((head)->sph_root, field) = NULL; \
|
||||
} else if (__comp > 0) { \
|
||||
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
|
||||
SPLAY_LEFT(elm, field) = (head)->sph_root; \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = NULL; \
|
||||
} else \
|
||||
return ((head)->sph_root); \
|
||||
} \
|
||||
(head)->sph_root = (elm); \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
struct type * \
|
||||
name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *__tmp; \
|
||||
if (SPLAY_EMPTY(head)) \
|
||||
return (NULL); \
|
||||
name##_SPLAY(head, elm); \
|
||||
if ((cmp)(elm, (head)->sph_root) == 0) { \
|
||||
if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
|
||||
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
|
||||
} else { \
|
||||
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
|
||||
name##_SPLAY(head, elm); \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
|
||||
} \
|
||||
return (elm); \
|
||||
} \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
name##_SPLAY(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type __node, *__left, *__right, *__tmp; \
|
||||
int __comp; \
|
||||
\
|
||||
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
|
||||
__left = __right = &__node; \
|
||||
\
|
||||
while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
|
||||
if (__comp < 0) { \
|
||||
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if ((cmp)(elm, __tmp) < 0){ \
|
||||
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
||||
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKLEFT(head, __right, field); \
|
||||
} else if (__comp > 0) { \
|
||||
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if ((cmp)(elm, __tmp) > 0){ \
|
||||
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
||||
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKRIGHT(head, __left, field); \
|
||||
} \
|
||||
} \
|
||||
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
|
||||
} \
|
||||
\
|
||||
/* Splay with either the minimum or the maximum element \
|
||||
* Used to find minimum or maximum element in tree. \
|
||||
*/ \
|
||||
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
|
||||
{ \
|
||||
struct type __node, *__left, *__right, *__tmp; \
|
||||
\
|
||||
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
|
||||
__left = __right = &__node; \
|
||||
\
|
||||
while (1) { \
|
||||
if (__comp < 0) { \
|
||||
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if (__comp < 0){ \
|
||||
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
||||
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKLEFT(head, __right, field); \
|
||||
} else if (__comp > 0) { \
|
||||
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if (__comp > 0) { \
|
||||
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
||||
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKRIGHT(head, __left, field); \
|
||||
} \
|
||||
} \
|
||||
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
|
||||
}
|
||||
|
||||
#define SPLAY_NEGINF -1
|
||||
#define SPLAY_INF 1
|
||||
|
||||
#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
|
||||
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
|
||||
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
|
||||
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
|
||||
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
|
||||
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
|
||||
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
|
||||
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
|
||||
|
||||
#define SPLAY_FOREACH(x, name, head) \
|
||||
for ((x) = SPLAY_MIN(name, head); \
|
||||
(x) != NULL; \
|
||||
(x) = SPLAY_NEXT(name, head, x))
|
||||
|
||||
/* Macros that define a red-black tree */
|
||||
#define RB_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *rbh_root; /* root of the tree */ \
|
||||
}
|
||||
|
||||
#define RB_INITIALIZER(root) \
|
||||
{ NULL }
|
||||
|
||||
#define RB_INIT(root) do { \
|
||||
(root)->rbh_root = NULL; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define RB_BLACK 0
|
||||
#define RB_RED 1
|
||||
#define RB_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *rbe_left; /* left element */ \
|
||||
struct type *rbe_right; /* right element */ \
|
||||
struct type *rbe_parent; /* parent element */ \
|
||||
int rbe_color; /* node color */ \
|
||||
}
|
||||
|
||||
#define RB_LEFT(elm, field) (elm)->field.rbe_left
|
||||
#define RB_RIGHT(elm, field) (elm)->field.rbe_right
|
||||
#define RB_PARENT(elm, field) (elm)->field.rbe_parent
|
||||
#define RB_COLOR(elm, field) (elm)->field.rbe_color
|
||||
#define RB_ROOT(head) (head)->rbh_root
|
||||
#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
|
||||
|
||||
#define RB_SET(elm, parent, field) do { \
|
||||
RB_PARENT(elm, field) = parent; \
|
||||
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
|
||||
RB_COLOR(elm, field) = RB_RED; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define RB_SET_BLACKRED(black, red, field) do { \
|
||||
RB_COLOR(black, field) = RB_BLACK; \
|
||||
RB_COLOR(red, field) = RB_RED; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#ifndef RB_AUGMENT
|
||||
#define RB_AUGMENT(x) (void)(x)
|
||||
#endif
|
||||
|
||||
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
|
||||
(tmp) = RB_RIGHT(elm, field); \
|
||||
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
|
||||
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
|
||||
} \
|
||||
RB_AUGMENT(elm); \
|
||||
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
|
||||
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
|
||||
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
else \
|
||||
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
} else \
|
||||
(head)->rbh_root = (tmp); \
|
||||
RB_LEFT(tmp, field) = (elm); \
|
||||
RB_PARENT(elm, field) = (tmp); \
|
||||
RB_AUGMENT(tmp); \
|
||||
if ((RB_PARENT(tmp, field))) \
|
||||
RB_AUGMENT(RB_PARENT(tmp, field)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
|
||||
(tmp) = RB_LEFT(elm, field); \
|
||||
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
|
||||
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
|
||||
} \
|
||||
RB_AUGMENT(elm); \
|
||||
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
|
||||
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
|
||||
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
else \
|
||||
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
} else \
|
||||
(head)->rbh_root = (tmp); \
|
||||
RB_RIGHT(tmp, field) = (elm); \
|
||||
RB_PARENT(elm, field) = (tmp); \
|
||||
RB_AUGMENT(tmp); \
|
||||
if ((RB_PARENT(tmp, field))) \
|
||||
RB_AUGMENT(RB_PARENT(tmp, field)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
/* Generates prototypes and inline functions */
|
||||
#define RB_PROTOTYPE(name, type, field, cmp) \
|
||||
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
|
||||
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
|
||||
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
|
||||
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
|
||||
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
|
||||
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
|
||||
attr struct type *name##_RB_REMOVE(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_INSERT(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_FIND(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_NFIND(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_NEXT(struct type *); \
|
||||
attr struct type *name##_RB_PREV(struct type *); \
|
||||
attr struct type *name##_RB_MINMAX(struct name *, int); \
|
||||
\
|
||||
|
||||
/* Main rb operation.
|
||||
* Moves node close to the key of elm to top
|
||||
*/
|
||||
#define RB_GENERATE(name, type, field, cmp) \
|
||||
RB_GENERATE_INTERNAL(name, type, field, cmp,)
|
||||
#define RB_GENERATE_STATIC(name, type, field, cmp) \
|
||||
RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
|
||||
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
|
||||
attr void \
|
||||
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *parent, *gparent, *tmp; \
|
||||
while ((parent = RB_PARENT(elm, field)) != NULL && \
|
||||
RB_COLOR(parent, field) == RB_RED) { \
|
||||
gparent = RB_PARENT(parent, field); \
|
||||
if (parent == RB_LEFT(gparent, field)) { \
|
||||
tmp = RB_RIGHT(gparent, field); \
|
||||
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_COLOR(tmp, field) = RB_BLACK; \
|
||||
RB_SET_BLACKRED(parent, gparent, field);\
|
||||
elm = gparent; \
|
||||
continue; \
|
||||
} \
|
||||
if (RB_RIGHT(parent, field) == elm) { \
|
||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||
tmp = parent; \
|
||||
parent = elm; \
|
||||
elm = tmp; \
|
||||
} \
|
||||
RB_SET_BLACKRED(parent, gparent, field); \
|
||||
RB_ROTATE_RIGHT(head, gparent, tmp, field); \
|
||||
} else { \
|
||||
tmp = RB_LEFT(gparent, field); \
|
||||
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_COLOR(tmp, field) = RB_BLACK; \
|
||||
RB_SET_BLACKRED(parent, gparent, field);\
|
||||
elm = gparent; \
|
||||
continue; \
|
||||
} \
|
||||
if (RB_LEFT(parent, field) == elm) { \
|
||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||
tmp = parent; \
|
||||
parent = elm; \
|
||||
elm = tmp; \
|
||||
} \
|
||||
RB_SET_BLACKRED(parent, gparent, field); \
|
||||
RB_ROTATE_LEFT(head, gparent, tmp, field); \
|
||||
} \
|
||||
} \
|
||||
RB_COLOR(head->rbh_root, field) = RB_BLACK; \
|
||||
} \
|
||||
\
|
||||
attr void \
|
||||
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp; \
|
||||
while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
|
||||
elm != RB_ROOT(head)) { \
|
||||
if (RB_LEFT(parent, field) == elm) { \
|
||||
tmp = RB_RIGHT(parent, field); \
|
||||
if (RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_SET_BLACKRED(tmp, parent, field); \
|
||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||
tmp = RB_RIGHT(parent, field); \
|
||||
} \
|
||||
if ((RB_LEFT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
|
||||
(RB_RIGHT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
elm = parent; \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
} else { \
|
||||
if (RB_RIGHT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
|
||||
struct type *oleft; \
|
||||
if ((oleft = RB_LEFT(tmp, field)) \
|
||||
!= NULL) \
|
||||
RB_COLOR(oleft, field) = RB_BLACK;\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
RB_ROTATE_RIGHT(head, tmp, oleft, field);\
|
||||
tmp = RB_RIGHT(parent, field); \
|
||||
} \
|
||||
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
|
||||
RB_COLOR(parent, field) = RB_BLACK; \
|
||||
if (RB_RIGHT(tmp, field)) \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
|
||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||
elm = RB_ROOT(head); \
|
||||
break; \
|
||||
} \
|
||||
} else { \
|
||||
tmp = RB_LEFT(parent, field); \
|
||||
if (RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_SET_BLACKRED(tmp, parent, field); \
|
||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||
tmp = RB_LEFT(parent, field); \
|
||||
} \
|
||||
if ((RB_LEFT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
|
||||
(RB_RIGHT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
elm = parent; \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
} else { \
|
||||
if (RB_LEFT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
|
||||
struct type *oright; \
|
||||
if ((oright = RB_RIGHT(tmp, field)) \
|
||||
!= NULL) \
|
||||
RB_COLOR(oright, field) = RB_BLACK;\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
RB_ROTATE_LEFT(head, tmp, oright, field);\
|
||||
tmp = RB_LEFT(parent, field); \
|
||||
} \
|
||||
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
|
||||
RB_COLOR(parent, field) = RB_BLACK; \
|
||||
if (RB_LEFT(tmp, field)) \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
|
||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||
elm = RB_ROOT(head); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
if (elm) \
|
||||
RB_COLOR(elm, field) = RB_BLACK; \
|
||||
} \
|
||||
\
|
||||
attr struct type * \
|
||||
name##_RB_REMOVE(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *child, *parent, *old = elm; \
|
||||
int color; \
|
||||
if (RB_LEFT(elm, field) == NULL) \
|
||||
child = RB_RIGHT(elm, field); \
|
||||
else if (RB_RIGHT(elm, field) == NULL) \
|
||||
child = RB_LEFT(elm, field); \
|
||||
else { \
|
||||
struct type *left; \
|
||||
elm = RB_RIGHT(elm, field); \
|
||||
while ((left = RB_LEFT(elm, field)) != NULL) \
|
||||
elm = left; \
|
||||
child = RB_RIGHT(elm, field); \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
color = RB_COLOR(elm, field); \
|
||||
if (child) \
|
||||
RB_PARENT(child, field) = parent; \
|
||||
if (parent) { \
|
||||
if (RB_LEFT(parent, field) == elm) \
|
||||
RB_LEFT(parent, field) = child; \
|
||||
else \
|
||||
RB_RIGHT(parent, field) = child; \
|
||||
RB_AUGMENT(parent); \
|
||||
} else \
|
||||
RB_ROOT(head) = child; \
|
||||
if (RB_PARENT(elm, field) == old) \
|
||||
parent = elm; \
|
||||
(elm)->field = (old)->field; \
|
||||
if (RB_PARENT(old, field)) { \
|
||||
if (RB_LEFT(RB_PARENT(old, field), field) == old)\
|
||||
RB_LEFT(RB_PARENT(old, field), field) = elm;\
|
||||
else \
|
||||
RB_RIGHT(RB_PARENT(old, field), field) = elm;\
|
||||
RB_AUGMENT(RB_PARENT(old, field)); \
|
||||
} else \
|
||||
RB_ROOT(head) = elm; \
|
||||
RB_PARENT(RB_LEFT(old, field), field) = elm; \
|
||||
if (RB_RIGHT(old, field)) \
|
||||
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
|
||||
if (parent) { \
|
||||
left = parent; \
|
||||
do { \
|
||||
RB_AUGMENT(left); \
|
||||
} while ((left = RB_PARENT(left, field)) != NULL); \
|
||||
} \
|
||||
goto color; \
|
||||
} \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
color = RB_COLOR(elm, field); \
|
||||
if (child) \
|
||||
RB_PARENT(child, field) = parent; \
|
||||
if (parent) { \
|
||||
if (RB_LEFT(parent, field) == elm) \
|
||||
RB_LEFT(parent, field) = child; \
|
||||
else \
|
||||
RB_RIGHT(parent, field) = child; \
|
||||
RB_AUGMENT(parent); \
|
||||
} else \
|
||||
RB_ROOT(head) = child; \
|
||||
color: \
|
||||
if (color == RB_BLACK) \
|
||||
name##_RB_REMOVE_COLOR(head, parent, child); \
|
||||
return (old); \
|
||||
} \
|
||||
\
|
||||
/* Inserts a node into the RB tree */ \
|
||||
attr struct type * \
|
||||
name##_RB_INSERT(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp; \
|
||||
struct type *parent = NULL; \
|
||||
int comp = 0; \
|
||||
tmp = RB_ROOT(head); \
|
||||
while (tmp) { \
|
||||
parent = tmp; \
|
||||
comp = (cmp)(elm, parent); \
|
||||
if (comp < 0) \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
else if (comp > 0) \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
else \
|
||||
return (tmp); \
|
||||
} \
|
||||
RB_SET(elm, parent, field); \
|
||||
if (parent != NULL) { \
|
||||
if (comp < 0) \
|
||||
RB_LEFT(parent, field) = elm; \
|
||||
else \
|
||||
RB_RIGHT(parent, field) = elm; \
|
||||
RB_AUGMENT(parent); \
|
||||
} else \
|
||||
RB_ROOT(head) = elm; \
|
||||
name##_RB_INSERT_COLOR(head, elm); \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
/* Finds the node with the same key as elm */ \
|
||||
attr struct type * \
|
||||
name##_RB_FIND(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp = RB_ROOT(head); \
|
||||
int comp; \
|
||||
while (tmp) { \
|
||||
comp = cmp(elm, tmp); \
|
||||
if (comp < 0) \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
else if (comp > 0) \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
else \
|
||||
return (tmp); \
|
||||
} \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
/* Finds the first node greater than or equal to the search key */ \
|
||||
attr struct type * \
|
||||
name##_RB_NFIND(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp = RB_ROOT(head); \
|
||||
struct type *res = NULL; \
|
||||
int comp; \
|
||||
while (tmp) { \
|
||||
comp = cmp(elm, tmp); \
|
||||
if (comp < 0) { \
|
||||
res = tmp; \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
} \
|
||||
else if (comp > 0) \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
else \
|
||||
return (tmp); \
|
||||
} \
|
||||
return (res); \
|
||||
} \
|
||||
\
|
||||
/* ARGSUSED */ \
|
||||
attr struct type * \
|
||||
name##_RB_NEXT(struct type *elm) \
|
||||
{ \
|
||||
if (RB_RIGHT(elm, field)) { \
|
||||
elm = RB_RIGHT(elm, field); \
|
||||
while (RB_LEFT(elm, field)) \
|
||||
elm = RB_LEFT(elm, field); \
|
||||
} else { \
|
||||
if (RB_PARENT(elm, field) && \
|
||||
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
else { \
|
||||
while (RB_PARENT(elm, field) && \
|
||||
(elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
|
||||
elm = RB_PARENT(elm, field); \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
} \
|
||||
} \
|
||||
return (elm); \
|
||||
} \
|
||||
\
|
||||
/* ARGSUSED */ \
|
||||
attr struct type * \
|
||||
name##_RB_PREV(struct type *elm) \
|
||||
{ \
|
||||
if (RB_LEFT(elm, field)) { \
|
||||
elm = RB_LEFT(elm, field); \
|
||||
while (RB_RIGHT(elm, field)) \
|
||||
elm = RB_RIGHT(elm, field); \
|
||||
} else { \
|
||||
if (RB_PARENT(elm, field) && \
|
||||
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
else { \
|
||||
while (RB_PARENT(elm, field) && \
|
||||
(elm == RB_LEFT(RB_PARENT(elm, field), field)))\
|
||||
elm = RB_PARENT(elm, field); \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
} \
|
||||
} \
|
||||
return (elm); \
|
||||
} \
|
||||
\
|
||||
attr struct type * \
|
||||
name##_RB_MINMAX(struct name *head, int val) \
|
||||
{ \
|
||||
struct type *tmp = RB_ROOT(head); \
|
||||
struct type *parent = NULL; \
|
||||
while (tmp) { \
|
||||
parent = tmp; \
|
||||
if (val < 0) \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
else \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
} \
|
||||
return (parent); \
|
||||
}
|
||||
|
||||
#define RB_NEGINF -1
|
||||
#define RB_INF 1
|
||||
|
||||
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
|
||||
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
|
||||
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
|
||||
#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y)
|
||||
#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
|
||||
#define RB_PREV(name, x, y) name##_RB_PREV(y)
|
||||
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
|
||||
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
|
||||
|
||||
#define RB_FOREACH(x, name, head) \
|
||||
for ((x) = RB_MIN(name, head); \
|
||||
(x) != NULL; \
|
||||
(x) = name##_RB_NEXT(x))
|
||||
|
||||
#define RB_FOREACH_REVERSE(x, name, head) \
|
||||
for ((x) = RB_MAX(name, head); \
|
||||
(x) != NULL; \
|
||||
(x) = name##_RB_PREV(x))
|
||||
|
||||
#endif /* _SYS_TREE_H_ */
|
||||
6
nbsd_include/sys/ttycom.h
Normal file
6
nbsd_include/sys/ttycom.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef _SYS_TERMIOS_H_
|
||||
#define _SYS_TERMIOS_H_
|
||||
|
||||
#include <minix/termios.h>
|
||||
|
||||
#endif /* !_SYS_TERMIOS_H_ */
|
||||
45
nbsd_include/sys/ttydefaults.h
Normal file
45
nbsd_include/sys/ttydefaults.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* System wide defaults for terminal state.
|
||||
*/
|
||||
#ifndef _SYS_TTYDEFAULTS_H_
|
||||
#define _SYS_TTYDEFAULTS_H_
|
||||
|
||||
/* NetBSD-like definition of values aready set up in termios.h */
|
||||
|
||||
/*
|
||||
* Defaults on "first" open.
|
||||
*/
|
||||
#define TTYDEF_IFLAG (BRKINT | ICRNL | IXON | IXANY)
|
||||
#define TTYDEF_OFLAG (OPOST | ONLCR )
|
||||
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE)
|
||||
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
|
||||
#define TTYDEF_SPEED (B9600)
|
||||
|
||||
/*
|
||||
* Control Character Defaults
|
||||
*/
|
||||
#define CTRL(x) (x&037)
|
||||
#define CEOF CTRL('d')
|
||||
#define CEOL _POSIX_VDISABLE
|
||||
#define CERASE CTRL('h')
|
||||
#define CINTR CTRL('c')
|
||||
#define CSTATUS CTRL('t')
|
||||
#define CKILL CTRL('u')
|
||||
#define CMIN 1
|
||||
#define CQUIT 034 /* FS, ^\ */
|
||||
#define CSUSP CTRL('z')
|
||||
#define CTIME 0
|
||||
#define CDSUSP CTRL('y')
|
||||
#define CSTART CTRL('q')
|
||||
#define CSTOP CTRL('s')
|
||||
#define CLNEXT CTRL('v')
|
||||
#define CDISCARD CTRL('o')
|
||||
#define CWERASE CTRL('w')
|
||||
#define CREPRINT CTRL('r')
|
||||
#define CEOT CEOF
|
||||
/* compat */
|
||||
#define CBRK CEOL
|
||||
#define CRPRNT CREPRINT
|
||||
#define CFLUSH CDISCARD
|
||||
|
||||
#endif /* _SYS_TTYDEFAULTS_H_ */
|
||||
396
nbsd_include/sys/types.h
Normal file
396
nbsd_include/sys/types.h
Normal file
@@ -0,0 +1,396 @@
|
||||
/* $NetBSD: types.h,v 1.86 2009/03/07 21:59:25 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)types.h 8.4 (Berkeley) 1/21/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TYPES_H_
|
||||
#define _SYS_TYPES_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/* Machine type dependent parameters. */
|
||||
#include <machine/types.h>
|
||||
|
||||
#include <machine/ansi.h>
|
||||
#include <machine/int_types.h>
|
||||
|
||||
#include <sys/ansi.h>
|
||||
|
||||
#ifndef int8_t
|
||||
typedef __int8_t int8_t;
|
||||
#define int8_t __int8_t
|
||||
#endif
|
||||
|
||||
#ifndef uint8_t
|
||||
typedef __uint8_t uint8_t;
|
||||
#define uint8_t __uint8_t
|
||||
#endif
|
||||
|
||||
#ifndef int16_t
|
||||
typedef __int16_t int16_t;
|
||||
#define int16_t __int16_t
|
||||
#endif
|
||||
|
||||
#ifndef uint16_t
|
||||
typedef __uint16_t uint16_t;
|
||||
#define uint16_t __uint16_t
|
||||
#endif
|
||||
|
||||
#ifndef int32_t
|
||||
typedef __int32_t int32_t;
|
||||
#define int32_t __int32_t
|
||||
#endif
|
||||
|
||||
#ifndef uint32_t
|
||||
typedef __uint32_t uint32_t;
|
||||
#define uint32_t __uint32_t
|
||||
#endif
|
||||
|
||||
#ifndef int64_t
|
||||
typedef __int64_t int64_t;
|
||||
#define int64_t __int64_t
|
||||
#endif
|
||||
|
||||
#ifndef uint64_t
|
||||
typedef __uint64_t uint64_t;
|
||||
#define uint64_t __uint64_t
|
||||
#endif
|
||||
|
||||
typedef uint8_t u_int8_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint64_t u_int64_t;
|
||||
|
||||
#ifdef __minix
|
||||
typedef uint8_t u8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef uint64_t u64_t;
|
||||
|
||||
typedef int8_t i8_t;
|
||||
typedef int16_t i16_t;
|
||||
typedef int32_t i32_t;
|
||||
typedef int64_t i64_t;
|
||||
|
||||
|
||||
/* some Minix specific types that do not conflict with posix */
|
||||
typedef u32_t zone_t; /* zone number */
|
||||
typedef u32_t block_t; /* block number */
|
||||
typedef u32_t bit_t; /* bit number in a bit map */
|
||||
typedef u16_t zone1_t; /* zone number for V1 file systems */
|
||||
typedef u32_t bitchunk_t; /* collection of bits in a bitmap */
|
||||
|
||||
/* ANSI C makes writing down the promotion of unsigned types very messy. When
|
||||
* sizeof(short) == sizeof(int), there is no promotion, so the type stays
|
||||
* unsigned. When the compiler is not ANSI, there is usually no loss of
|
||||
* unsignedness, and there are usually no prototypes so the promoted type
|
||||
* doesn't matter. The use of types like Ino_t is an attempt to use ints
|
||||
* (which are not promoted) while providing information to the reader.
|
||||
*/
|
||||
|
||||
typedef unsigned long Ino_t;
|
||||
|
||||
#endif /* __minix */
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
typedef unsigned char unchar; /* Sys V compatibility */
|
||||
typedef unsigned short ushort; /* Sys V compatibility */
|
||||
typedef unsigned int uint; /* Sys V compatibility */
|
||||
typedef unsigned long ulong; /* Sys V compatibility */
|
||||
#endif
|
||||
|
||||
typedef uint64_t u_quad_t; /* quads */
|
||||
typedef int64_t quad_t;
|
||||
typedef quad_t * qaddr_t;
|
||||
|
||||
/*
|
||||
* The types longlong_t and u_longlong_t exist for use with the
|
||||
* Sun-derived XDR routines involving these types, and their usage
|
||||
* in other contexts is discouraged. Further note that these types
|
||||
* may not be equivalent to "long long" and "unsigned long long",
|
||||
* they are only guaranteed to be signed and unsigned 64-bit types
|
||||
* respectively. Portable programs that need 64-bit types should use
|
||||
* the C99 types int64_t and uint64_t instead.
|
||||
*/
|
||||
|
||||
typedef int64_t longlong_t; /* for XDR */
|
||||
typedef uint64_t u_longlong_t; /* for XDR */
|
||||
|
||||
typedef int64_t blkcnt_t; /* fs block count */
|
||||
typedef uint32_t blksize_t; /* fs optimal block size */
|
||||
|
||||
#ifndef fsblkcnt_t
|
||||
typedef __fsblkcnt_t fsblkcnt_t; /* fs block count (statvfs) */
|
||||
#define fsblkcnt_t __fsblkcnt_t
|
||||
#endif
|
||||
|
||||
#ifndef fsfilcnt_t
|
||||
typedef __fsfilcnt_t fsfilcnt_t; /* fs file count */
|
||||
#define fsfilcnt_t __fsfilcnt_t
|
||||
#endif
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
/* We don't and shouldn't use caddr_t in the kernel anymore */
|
||||
#ifndef caddr_t
|
||||
typedef __caddr_t caddr_t; /* core address */
|
||||
#define caddr_t __caddr_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __daddr_t
|
||||
typedef __daddr_t daddr_t; /* disk address */
|
||||
#undef __daddr_t
|
||||
#else
|
||||
typedef int64_t daddr_t; /* disk address */
|
||||
#endif
|
||||
|
||||
|
||||
typedef short dev_t; /* device number */
|
||||
typedef uint32_t fixpt_t; /* fixed point number */
|
||||
|
||||
#ifndef gid_t
|
||||
typedef __gid_t gid_t; /* group id */
|
||||
#define gid_t __gid_t
|
||||
#endif
|
||||
|
||||
typedef int idtype_t; /* type of the id */
|
||||
typedef uint32_t id_t; /* group id, process id or user id */
|
||||
typedef unsigned long ino_t; /* inode number */
|
||||
typedef long key_t; /* IPC key (for Sys V IPC) */
|
||||
|
||||
#ifndef mode_t
|
||||
typedef __mode_t mode_t; /* permissions */
|
||||
#define mode_t __mode_t
|
||||
#endif
|
||||
|
||||
typedef short nlink_t; /* link count */
|
||||
|
||||
#ifndef off_t
|
||||
typedef __off_t off_t; /* file offset */
|
||||
#define off_t __off_t
|
||||
#endif
|
||||
|
||||
#ifndef pid_t
|
||||
typedef __pid_t pid_t; /* process id */
|
||||
#define pid_t __pid_t
|
||||
#endif
|
||||
|
||||
typedef int32_t lwpid_t; /* LWP id */
|
||||
typedef unsigned long rlim_t; /* resource limit */
|
||||
typedef int32_t segsz_t; /* segment size */
|
||||
typedef int32_t swblk_t; /* swap offset */
|
||||
|
||||
#ifndef uid_t
|
||||
typedef __uid_t uid_t; /* user id */
|
||||
#define uid_t __uid_t
|
||||
#endif
|
||||
|
||||
|
||||
typedef int mqd_t;
|
||||
|
||||
typedef unsigned long cpuid_t;
|
||||
|
||||
typedef int psetid_t;
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
/*
|
||||
* Boolean type definitions for the kernel environment. User-space
|
||||
* boolean definitions are found in <stdbool.h>.
|
||||
*/
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
/*
|
||||
* Deprecated Mach-style boolean_t type. Should not be used by new code.
|
||||
*/
|
||||
typedef int boolean_t;
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL || _STANDALONE */
|
||||
|
||||
#if defined(_KERNEL) || defined(_LIBC)
|
||||
/*
|
||||
* semctl(2)'s argument structure. This is here for the benefit of
|
||||
* <sys/syscallargs.h>. It is not in the user's namespace in SUSv2.
|
||||
* The SUSv2 semctl(2) takes variable arguments.
|
||||
*/
|
||||
union __semun {
|
||||
int val; /* value for SETVAL */
|
||||
struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
|
||||
unsigned short *array; /* array for GETALL & SETALL */
|
||||
};
|
||||
#include <sys/stdint.h>
|
||||
#endif /* _KERNEL || _LIBC */
|
||||
|
||||
/*
|
||||
* These belong in unistd.h, but are placed here too to ensure that
|
||||
* long arguments will be promoted to off_t if the program fails to
|
||||
* include that header or explicitly cast them to off_t.
|
||||
*/
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#ifndef __OFF_T_SYSCALLS_DECLARED
|
||||
#define __OFF_T_SYSCALLS_DECLARED
|
||||
#ifndef _KERNEL
|
||||
#include <sys/cdefs.h>
|
||||
__BEGIN_DECLS
|
||||
off_t lseek(int, off_t, int);
|
||||
int ftruncate(int, off_t);
|
||||
int truncate(const char *, off_t);
|
||||
__END_DECLS
|
||||
#endif /* !_KERNEL */
|
||||
#endif /* __OFF_T_SYSCALLS_DECLARED */
|
||||
#endif /* defined(_NETBSD_SOURCE) */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
typedef int32_t __devmajor_t, __devminor_t;
|
||||
#define devmajor_t __devmajor_t
|
||||
#define devminor_t __devminor_t
|
||||
#define NODEVMAJOR (-1)
|
||||
|
||||
/* Major, minor numbers, dev_t's. */
|
||||
#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */
|
||||
#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */
|
||||
#define minor(dev) ((devminor_t)(((dev) >> MINOR) & 0xff))
|
||||
#define major(dev) ((devmajor_t)(((dev) >> MAJOR) & 0xff))
|
||||
#define makedev(major, minor) \
|
||||
((dev_t) (((major) << MAJOR) | ((minor) << MINOR)))
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_CLOCK_T_
|
||||
typedef _BSD_CLOCK_T_ clock_t;
|
||||
#undef _BSD_CLOCK_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#define _SIZE_T
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SSIZE_T_
|
||||
typedef _BSD_SSIZE_T_ ssize_t;
|
||||
#undef _BSD_SSIZE_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_TIME_T_
|
||||
typedef _BSD_TIME_T_ time_t;
|
||||
#undef _BSD_TIME_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_CLOCKID_T_
|
||||
typedef _BSD_CLOCKID_T_ clockid_t;
|
||||
#undef _BSD_CLOCKID_T_
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
#ifdef _BSD_TIMER_T_
|
||||
typedef _BSD_TIMER_T_ timer_t;
|
||||
#undef _BSD_TIMER_T_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SUSECONDS_T_
|
||||
typedef _BSD_SUSECONDS_T_ suseconds_t;
|
||||
#undef _BSD_SUSECONDS_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_USECONDS_T_
|
||||
typedef _BSD_USECONDS_T_ useconds_t;
|
||||
#undef _BSD_USECONDS_T_
|
||||
#endif
|
||||
|
||||
#ifdef _NETBSD_SOURCE
|
||||
#include <sys/fd_set.h>
|
||||
#define NBBY __NBBY
|
||||
|
||||
typedef struct kauth_cred *kauth_cred_t;
|
||||
|
||||
typedef int pri_t;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__STDC__) && (defined(_KERNEL) || defined(_KMEMUSER))
|
||||
/*
|
||||
* Forward structure declarations for function prototypes. We include the
|
||||
* common structures that cross subsystem boundaries here; others are mostly
|
||||
* used in the same place that the structure is defined.
|
||||
*/
|
||||
struct lwp;
|
||||
typedef struct lwp lwp_t;
|
||||
struct user;
|
||||
struct __ucontext;
|
||||
struct proc;
|
||||
typedef struct proc proc_t;
|
||||
struct pgrp;
|
||||
struct rusage;
|
||||
struct file;
|
||||
typedef struct file file_t;
|
||||
struct buf;
|
||||
typedef struct buf buf_t;
|
||||
struct tty;
|
||||
struct uio;
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define SET(t, f) ((t) |= (f))
|
||||
#define ISSET(t, f) ((t) & (f))
|
||||
#define CLR(t, f) ((t) &= ~(f))
|
||||
#endif
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#include <pthread_types.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
#endif /* !_SYS_TYPES_H_ */
|
||||
38
nbsd_include/sys/ucontext.h
Normal file
38
nbsd_include/sys/ucontext.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef _SYS_UCONTEXT_H_
|
||||
#define _SYS_UCONTEXT_H_
|
||||
|
||||
#include <sys/sigtypes.h>
|
||||
#include <machine/mcontext.h>
|
||||
|
||||
typedef struct __ucontext ucontext_t;
|
||||
|
||||
struct __ucontext {
|
||||
unsigned int uc_flags; /* Properties of ucontext */
|
||||
ucontext_t *uc_link; /* Next context to resume when current is finished */
|
||||
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 */
|
||||
};
|
||||
|
||||
#ifndef _UC_UCONTEXT_ALIGN
|
||||
#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) */
|
||||
|
||||
#define NCARGS 6
|
||||
|
||||
#ifdef __minix
|
||||
__BEGIN_DECLS
|
||||
void resumecontext(ucontext_t *ucp);
|
||||
|
||||
/* These functions get and set ucontext structure through PM/kernel. They don't
|
||||
* manipulate the stack. */
|
||||
int getuctx(ucontext_t *ucp);
|
||||
int setuctx(const ucontext_t *ucp);
|
||||
__END_DECLS
|
||||
#endif /* __minix */
|
||||
|
||||
#endif /* !_SYS_UCONTEXT_H_ */
|
||||
13
nbsd_include/sys/ucred.h
Normal file
13
nbsd_include/sys/ucred.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __SYS_UCRED_H
|
||||
#define __SYS_UCRED_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct ucred
|
||||
{
|
||||
pid_t pid;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
};
|
||||
|
||||
#endif
|
||||
37
nbsd_include/sys/uio.h
Normal file
37
nbsd_include/sys/uio.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _SYS_UIO_H_
|
||||
#define _SYS_UIO_H_
|
||||
|
||||
#include <machine/ansi.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#ifdef _BSD_SIZE_T_
|
||||
typedef _BSD_SIZE_T_ size_t;
|
||||
#undef _BSD_SIZE_T_
|
||||
#endif
|
||||
|
||||
#ifdef _BSD_SSIZE_T_
|
||||
typedef _BSD_SSIZE_T_ ssize_t;
|
||||
#undef _BSD_SSIZE_T_
|
||||
#endif
|
||||
|
||||
struct iovec {
|
||||
void *iov_base; /* Base address. */
|
||||
size_t iov_len; /* Length. */
|
||||
};
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
/*
|
||||
* Limits
|
||||
*/
|
||||
/* Deprecated: use IOV_MAX from <limits.h> instead. */
|
||||
#define UIO_MAXIOV 1024 /* max 1K of iov's */
|
||||
#endif /* _NETBSD_SOURCE */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
ssize_t readv(int, const struct iovec *, int);
|
||||
ssize_t writev(int, const struct iovec *, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_UIO_H_ */
|
||||
34
nbsd_include/sys/un.h
Normal file
34
nbsd_include/sys/un.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _SYS_UN_H_
|
||||
#define _SYS_UN_H_
|
||||
|
||||
#include <sys/ansi.h>
|
||||
#include <sys/featuretest.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef sa_family_t
|
||||
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 {
|
||||
sa_family_t sun_family;
|
||||
char sun_path[UNIX_PATH_MAX];
|
||||
};
|
||||
|
||||
#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.
|
||||
*/
|
||||
#define SUN_LEN(unp) \
|
||||
((size_t)((sizeof(*(unp)) - sizeof((unp)->sun_path)) + strlen((unp)->sun_path)))
|
||||
|
||||
#endif /* _SYS_UN_H_ */
|
||||
208
nbsd_include/sys/unistd.h
Normal file
208
nbsd_include/sys/unistd.h
Normal file
@@ -0,0 +1,208 @@
|
||||
/* $NetBSD: unistd.h,v 1.52 2009/08/30 16:38:48 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 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.
|
||||
*
|
||||
* @(#)unistd.h 8.2 (Berkeley) 1/7/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_UNISTD_H_
|
||||
#define _SYS_UNISTD_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/* compile-time symbolic constants */
|
||||
#define _POSIX_JOB_CONTROL 1
|
||||
/* implementation supports job control */
|
||||
|
||||
/*
|
||||
* According to POSIX 1003.1:
|
||||
* "The saved set-user-ID capability allows a program to regain the
|
||||
* effective user ID established at the last exec call."
|
||||
* However, the setuid/setgid function as specified by POSIX 1003.1 does
|
||||
* not allow changing the effective ID from the super-user without also
|
||||
* changed the saved ID, so it is impossible to get super-user privileges
|
||||
* back later. Instead we provide this feature independent of the current
|
||||
* effective ID through the seteuid/setegid function. In addition, we do
|
||||
* not use the saved ID as specified by POSIX 1003.1 in setuid/setgid,
|
||||
* because this would make it impossible for a set-user-ID executable
|
||||
* owned by a user other than the super-user to permanently revoke its
|
||||
* extra privileges.
|
||||
*/
|
||||
#ifdef _NOT_AVAILABLE
|
||||
#define _POSIX_SAVED_IDS 1
|
||||
/* saved set-user-ID and set-group-ID */
|
||||
#endif
|
||||
|
||||
#define _POSIX_VERSION 200112L
|
||||
#define _POSIX2_VERSION 200112L
|
||||
|
||||
/* execution-time symbolic constants */
|
||||
|
||||
/*
|
||||
* POSIX options and option groups we unconditionally do or don't
|
||||
* implement. Those options which are implemented (or not) entirely
|
||||
* in user mode are defined in <unistd.h>. Please keep this list in
|
||||
* alphabetical order.
|
||||
*
|
||||
* Anything which is defined as zero below **must** have an
|
||||
* implementation for the corresponding sysconf() which is able to
|
||||
* determine conclusively whether or not the feature is supported.
|
||||
* Anything which is defined as other than -1 below **must** have
|
||||
* complete headers, types, and function declarations as specified by
|
||||
* the POSIX standard; however, if the relevant sysconf() function
|
||||
* returns -1, the functions may be stubbed out.
|
||||
*/
|
||||
/* Advisory information */
|
||||
#undef _POSIX_ADVISORY_INFO
|
||||
/* asynchronous I/O is available */
|
||||
#define _POSIX_ASYNCHRONOUS_IO 200112L
|
||||
/* barriers */
|
||||
#define _POSIX_BARRIERS 200112L
|
||||
/* chown requires correct privileges */
|
||||
#define _POSIX_CHOWN_RESTRICTED 1
|
||||
/* clock selection */
|
||||
#define _POSIX_CLOCK_SELECTION -1
|
||||
/* CPU type */
|
||||
#undef _POSIX_CPUTYPE
|
||||
/* file synchronization is available */
|
||||
#define _POSIX_FSYNC 1
|
||||
/* support IPv6 */
|
||||
#define _POSIX_IPV6 0
|
||||
/* job control is available */
|
||||
#define _POSIX_JOB_CONTROL 1
|
||||
/* memory mapped files */
|
||||
#define _POSIX_MAPPED_FILES 1
|
||||
/* memory locking whole address space */
|
||||
#define _POSIX_MEMLOCK 1
|
||||
/* memory locking address ranges */
|
||||
#define _POSIX_MEMLOCK_RANGE 1
|
||||
/* memory access protections */
|
||||
#define _POSIX_MEMORY_PROTECTION 1
|
||||
/* message passing is available */
|
||||
#define _POSIX_MESSAGE_PASSING 200112L
|
||||
/* monotonic clock */
|
||||
#define _POSIX_MONOTONIC_CLOCK 200112L
|
||||
/* too-long path comp generate errors */
|
||||
#define _POSIX_NO_TRUNC 1
|
||||
/* prioritized I/O */
|
||||
#define _POSIX_PRIORITIZED_IO -1
|
||||
/* priority scheduling */
|
||||
#define _POSIX_PRIORITY_SCHEDULING 200112L
|
||||
/* raw sockets */
|
||||
#define _POSIX_RAW_SOCKETS 200112L
|
||||
/* read/write locks */
|
||||
#define _POSIX_READER_WRITER_LOCKS 200112L
|
||||
/* realtime signals */
|
||||
#undef _POSIX_REALTIME_SIGNALS
|
||||
/* regular expressions */
|
||||
#define _POSIX_REGEXP 1
|
||||
/* semaphores */
|
||||
#define _POSIX_SEMAPHORES 0
|
||||
/* shared memory */
|
||||
#undef _POSIX_SHARED_MEMORY_OBJECTS
|
||||
/* shell */
|
||||
#define _POSIX_SHELL 1
|
||||
/* spin locks */
|
||||
#define _POSIX_SPIN_LOCKS 200112L
|
||||
/* sporadic server */
|
||||
#undef _POSIX_SPORADIC_SERVER
|
||||
/* synchronized I/O is available */
|
||||
#define _POSIX_SYNCHRONIZED_IO 1
|
||||
/* threads */
|
||||
#define _POSIX_THREADS 200112L
|
||||
/* pthread_attr for stack size */
|
||||
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
|
||||
/* pthread_attr for stack address */
|
||||
#define _POSIX_THREAD_ATTR_STACKADDR 200112L
|
||||
/* _r functions */
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
|
||||
/* timeouts */
|
||||
#undef _POSIX_TIMEOUTS
|
||||
/* timers */
|
||||
#define _POSIX_TIMERS 200112L
|
||||
/* typed memory objects */
|
||||
#undef _POSIX_TYPED_MEMORY_OBJECTS
|
||||
/* may disable terminal spec chars */
|
||||
#define _POSIX_VDISABLE __CAST(unsigned char, '\377')
|
||||
|
||||
/* C binding */
|
||||
#define _POSIX2_C_BIND 200112L
|
||||
|
||||
/* XPG4.2 shared memory */
|
||||
#define _XOPEN_SHM 0
|
||||
|
||||
/* access function */
|
||||
#define F_OK 0 /* test for existence of file */
|
||||
#define X_OK 0x01 /* test for execute or search permission */
|
||||
#define W_OK 0x02 /* test for write permission */
|
||||
#define R_OK 0x04 /* test for read permission */
|
||||
|
||||
/* whence values for lseek(2) */
|
||||
#define SEEK_SET 0 /* set file offset to offset */
|
||||
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
||||
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
/* whence values for lseek(2); renamed by POSIX 1003.1 */
|
||||
#define L_SET SEEK_SET
|
||||
#define L_INCR SEEK_CUR
|
||||
#define L_XTND SEEK_END
|
||||
#endif
|
||||
|
||||
/* configurable pathname variables; use as argument to pathconf(3) */
|
||||
#define _PC_LINK_MAX 1 /* link count */
|
||||
#define _PC_MAX_CANON 2 /* size of the canonical input queue */
|
||||
#define _PC_MAX_INPUT 3 /* type-ahead buffer size */
|
||||
#define _PC_NAME_MAX 4 /* file name size */
|
||||
#define _PC_PATH_MAX 5 /* pathname size */
|
||||
#define _PC_PIPE_BUF 6 /* pipe size */
|
||||
#define _PC_NO_TRUNC 7 /* treatment of long name components */
|
||||
#define _PC_VDISABLE 8 /* tty disable */
|
||||
#define _PC_CHOWN_RESTRICTED 9 /* chown restricted or not */
|
||||
|
||||
/* configurable system variables; use as argument to sysconf(3) */
|
||||
/*
|
||||
* XXX The value of _SC_CLK_TCK is embedded in <time.h>.
|
||||
* XXX The value of _SC_PAGESIZE is embedded in <sys/shm.h>.
|
||||
*/
|
||||
#define _SC_ARG_MAX 1
|
||||
#define _SC_CHILD_MAX 2
|
||||
#define _SC_CLOCKS_PER_SEC 3
|
||||
#define _SC_CLK_TCK 3
|
||||
#define _SC_NGROUPS_MAX 4
|
||||
#define _SC_OPEN_MAX 5
|
||||
#define _SC_JOB_CONTROL 6
|
||||
#define _SC_SAVED_IDS 7
|
||||
#define _SC_VERSION 8
|
||||
#define _SC_STREAM_MAX 9
|
||||
#define _SC_TZNAME_MAX 10
|
||||
#define _SC_PAGESIZE 11
|
||||
#define _SC_PAGE_SIZE _SC_PAGESIZE
|
||||
|
||||
#endif /* !_SYS_UNISTD_H_ */
|
||||
48
nbsd_include/sys/utsname.h
Normal file
48
nbsd_include/sys/utsname.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _SYS_UTSNAME_H_
|
||||
#define _SYS_UTSNAME_H_
|
||||
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
#define _SYS_NMLN 256
|
||||
|
||||
#if defined(_NETBSD_SOURCE)
|
||||
#define SYS_NMLN _SYS_NMLN
|
||||
#endif
|
||||
|
||||
struct utsname {
|
||||
char sysname[_SYS_NMLN]; /* Name of this OS. */
|
||||
char nodename[_SYS_NMLN]; /* Name of this network node. */
|
||||
char release[_SYS_NMLN]; /* Release level. */
|
||||
char version[_SYS_NMLN]; /* Version level. */
|
||||
char machine[_SYS_NMLN]; /* Hardware type. */
|
||||
char arch[_SYS_NMLN];
|
||||
};
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int uname(struct utsname *);
|
||||
#ifdef __minix
|
||||
int sysuname(int _req, int _field, char *_value, size_t _len);
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#ifdef __minix
|
||||
/* req: Get or set a string. */
|
||||
#define _UTS_GET 0
|
||||
#define _UTS_SET 1
|
||||
|
||||
/* field: What field to get or set. These values can't be changed lightly. */
|
||||
#define _UTS_ARCH 0
|
||||
#define _UTS_KERNEL 1
|
||||
#define _UTS_MACHINE 2
|
||||
#define _UTS_HOSTNAME 3
|
||||
#define _UTS_NODENAME 4
|
||||
#define _UTS_RELEASE 5
|
||||
#define _UTS_VERSION 6
|
||||
#define _UTS_SYSNAME 7
|
||||
#define _UTS_BUS 8
|
||||
#define _UTS_MAX 9 /* Number of strings. */
|
||||
#endif /* __minix */
|
||||
|
||||
#endif /* !_SYS_UTSNAME_H_ */
|
||||
82
nbsd_include/sys/uuid.h
Normal file
82
nbsd_include/sys/uuid.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* $NetBSD: uuid.h,v 1.5 2008/11/18 14:01:03 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Marcel Moolenaar
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: /repoman/r/ncvs/src/sys/sys/uuid.h,v 1.3 2003/05/31 16:47:07 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_UUID_H_
|
||||
#define _SYS_UUID_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/* Length of a node address (an IEEE 802 address). */
|
||||
#define _UUID_NODE_LEN 6
|
||||
|
||||
/* Length of a printed UUID. */
|
||||
#define _UUID_STR_LEN 38
|
||||
|
||||
/*
|
||||
* See also:
|
||||
* http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
|
||||
* http://www.opengroup.org/onlinepubs/009629399/apdxa.htm
|
||||
*
|
||||
* A DCE 1.1 compatible source representation of UUIDs.
|
||||
*/
|
||||
struct uuid {
|
||||
uint32_t time_low;
|
||||
uint16_t time_mid;
|
||||
uint16_t time_hi_and_version;
|
||||
uint8_t clock_seq_hi_and_reserved;
|
||||
uint8_t clock_seq_low;
|
||||
uint8_t node[_UUID_NODE_LEN];
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define UUID_NODE_LEN _UUID_NODE_LEN
|
||||
#define UUID_STR_LEN _UUID_STR_LEN
|
||||
|
||||
int uuid_snprintf(char *, size_t, const struct uuid *);
|
||||
int uuid_printf(const struct uuid *);
|
||||
void uuid_dec_be(const void *, struct uuid *);
|
||||
void uuid_dec_le(const void *, struct uuid *);
|
||||
void uuid_enc_be(void *, const struct uuid *);
|
||||
void uuid_enc_le(void *, const struct uuid *);
|
||||
void uuid_init(void);
|
||||
int uuidgen(struct uuid *, int);
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
typedef struct uuid uuid_t;
|
||||
|
||||
__BEGIN_DECLS
|
||||
int uuidgen(struct uuid *, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_UUID_H_ */
|
||||
64
nbsd_include/sys/wait.h
Normal file
64
nbsd_include/sys/wait.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef _SYS_WAIT_H_
|
||||
#define _SYS_WAIT_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/featuretest.h>
|
||||
|
||||
/* The <sys/wait.h> header contains macros related to wait(). The value
|
||||
* returned by wait() and waitpid() depends on whether the process
|
||||
* terminated by an exit() call, was killed by a signal, or was stopped
|
||||
* due to job control, as follows:
|
||||
*
|
||||
* High byte Low byte
|
||||
* +---------------------+
|
||||
* exit(status) | status | 0 |
|
||||
* +---------------------+
|
||||
* killed by signal | 0 | signal |
|
||||
* +---------------------+
|
||||
* stopped (job control) | signal | 0177 |
|
||||
* +---------------------+
|
||||
*/
|
||||
|
||||
/*
|
||||
* Macros to test the exit status returned by wait
|
||||
* and extract the relevant values.
|
||||
*/
|
||||
|
||||
#define _LOW(v) ( (v) & 0377)
|
||||
#define _HIGH(v) ( ((v) >> 8) & 0377)
|
||||
|
||||
#define WIFEXITED(s) (_LOW(s) == 0) /* normal exit */
|
||||
#define WEXITSTATUS(s) (_HIGH(s)) /* exit status */
|
||||
#define WTERMSIG(s) (_LOW(s) & 0177) /* sig value */
|
||||
#define WIFSIGNALED(s) ((((unsigned int)(s)-1) & 0xFFFFU) < 0xFFU) /* signaled */
|
||||
#define WIFSTOPPED(s) (_LOW(s) == 0177) /* stopped */
|
||||
#define WSTOPSIG(s) (_HIGH(s) & 0377) /* stop signal */
|
||||
|
||||
/*
|
||||
* Option bits for the third argument of waitpid. WNOHANG causes the
|
||||
* wait to not hang if there are no stopped or terminated processes, rather
|
||||
* returning an error indication in this case (pid==0). WUNTRACED
|
||||
* indicates that the caller should receive status about untraced children
|
||||
* which stop due to signals. If children are stopped and a wait without
|
||||
* this option is done, it is as though they were still running... nothing
|
||||
* about them is returned.
|
||||
*/
|
||||
#define WNOHANG 0x00000001 /* don't hang in wait */
|
||||
#define WUNTRACED 0x00000002 /* tell about stopped,
|
||||
untraced children */
|
||||
|
||||
/* POSIX extensions and 4.2/4.3 compatibility: */
|
||||
|
||||
/*
|
||||
* Tokens for special values of the "pid" parameter to waitpid.
|
||||
*/
|
||||
#define WAIT_ANY (-1) /* any process */
|
||||
#define WAIT_MYPGRP 0 /* any process in my process group */
|
||||
|
||||
__BEGIN_DECLS
|
||||
pid_t wait(int *);
|
||||
pid_t waitpid(pid_t, int *, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_WAIT_H_ */
|
||||
Reference in New Issue
Block a user