From bceabc95c1c85d793200446fa85f1ddc6313ea29 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 9 Oct 2013 22:42:09 +0200 Subject: Move files to match FreeBSD layout --- rtemsbsd/include/rtems/bsd/sys/_types.h | 105 +++++++++ rtemsbsd/include/rtems/bsd/sys/errno.h | 194 ++++++++++++++++ rtemsbsd/include/rtems/bsd/sys/lock.h | 319 ++++++++++++++++++++++++++ rtemsbsd/include/rtems/bsd/sys/param.h | 332 +++++++++++++++++++++++++++ rtemsbsd/include/rtems/bsd/sys/resource.h | 176 +++++++++++++++ rtemsbsd/include/rtems/bsd/sys/time.h | 351 +++++++++++++++++++++++++++++ rtemsbsd/include/rtems/bsd/sys/timespec.h | 10 + rtemsbsd/include/rtems/bsd/sys/types.h | 360 ++++++++++++++++++++++++++++++ rtemsbsd/include/rtems/bsd/sys/unistd.h | 188 ++++++++++++++++ 9 files changed, 2035 insertions(+) create mode 100644 rtemsbsd/include/rtems/bsd/sys/_types.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/errno.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/lock.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/param.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/resource.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/time.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/timespec.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/types.h create mode 100644 rtemsbsd/include/rtems/bsd/sys/unistd.h (limited to 'rtemsbsd/include/rtems/bsd/sys') diff --git a/rtemsbsd/include/rtems/bsd/sys/_types.h b/rtemsbsd/include/rtems/bsd/sys/_types.h new file mode 100644 index 00000000..b9f4d392 --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/_types.h @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 2002 Mike Barcroft + * 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 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS__TYPES_HH_ +#define _SYS__TYPES_HH_ + +#include +#include + +/* + * Standard type definitions. + */ +typedef __uint32_t __blksize_t; /* file block size */ +typedef __int64_t __blkcnt_t; /* file block count */ +typedef __int32_t __clockid_t; /* clock_gettime()... */ +typedef __uint32_t __fflags_t; /* file flags */ +typedef __uint64_t __fsblkcnt_t; +typedef __uint64_t __fsfilcnt_t; +typedef __uint32_t __gid_t; +typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */ +typedef __uint32_t __ino_t; /* inode number */ +typedef long __key_t; /* IPC key (for Sys V IPC) */ +typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */ +typedef __uint16_t __mode_t; /* permissions */ +typedef int __accmode_t; /* access permissions */ +typedef int __nl_item; +typedef __uint16_t __nlink_t; /* link count */ +typedef __int64_t __off_t; /* file offset */ +typedef __int32_t __pid_t; /* process [group] */ +typedef __int64_t __rlim_t; /* resource limit - intentionally */ + /* signed, because of legacy code */ + /* that uses -1 for RLIM_INFINITY */ +typedef __uint8_t __sa_family_t; +typedef __uint32_t __socklen_t; +typedef long __suseconds_t; /* microseconds (signed) */ +typedef struct __timer *__timer_t; /* timer_gettime()... */ +typedef struct __mq *__mqd_t; /* mq_open()... */ +typedef __uint32_t __uid_t; +typedef unsigned int __useconds_t; /* microseconds (unsigned) */ +typedef int __cpuwhich_t; /* which parameter for cpuset. */ +typedef int __cpulevel_t; /* level parameter for cpuset. */ +typedef int __cpusetid_t; /* cpuset identifier. */ + +/* + * Unusual type definitions. + */ +/* + * rune_t is declared to be an ``int'' instead of the more natural + * ``unsigned long'' or ``long''. Two things are happening here. It is not + * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, + * it looks like 10646 will be a 31 bit standard. This means that if your + * ints cannot hold 32 bits, you will be in trouble. The reason an int was + * chosen over a long is that the is*() and to*() routines take ints (says + * ANSI C), but they use __ct_rune_t instead of int. + * + * NOTE: rune_t is not covered by ANSI nor other standards, and should not + * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and + * rune_t must be the same type. Also, wint_t must be no narrower than + * wchar_t, and should be able to hold all members of the largest + * character set plus one extra value (WEOF), and must be at least 16 bits. + */ +typedef int __ct_rune_t; /* arg type for ctype funcs */ +typedef __ct_rune_t __rune_t; /* rune_t (see above) */ +typedef __ct_rune_t __wchar_t; /* wchar_t (see above) */ +typedef __ct_rune_t __wint_t; /* wint_t (see above) */ + +typedef __uint32_t __dev_t; /* device number */ + +typedef __uint32_t __fixpt_t; /* fixed point number */ + +/* + * mbstate_t is an opaque object to keep conversion state during multibyte + * stream conversions. + */ +typedef union { + char __mbstate8[128]; + __int64_t _mbstateL; /* for alignment */ +} __mbstate_t; + +#endif /* !_SYS__TYPES_HH_ */ diff --git a/rtemsbsd/include/rtems/bsd/sys/errno.h b/rtemsbsd/include/rtems/bsd/sys/errno.h new file mode 100644 index 00000000..9b68014d --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/errno.h @@ -0,0 +1,194 @@ +/*- + * Copyright (c) 1982, 1986, 1989, 1993 + * 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. + * 4. 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. + * + * @(#)errno.h 8.5 (Berkeley) 1/21/94 + * $FreeBSD$ + */ + +#ifndef _SYS_ERRNO_HH_ +#define _SYS_ERRNO_HH_ + +#ifndef _KERNEL +#include +__BEGIN_DECLS +int * __error(void); +__END_DECLS +#define errno (* __error()) +#endif + +#ifndef __rtems__ +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* Input/output error */ +#define ENXIO 6 /* Device not configured */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file descriptor */ +#define ECHILD 10 /* No child processes */ +#define EDEADLK 11 /* Resource deadlock avoided */ + /* 11 was EAGAIN */ +#define ENOMEM 12 /* Cannot allocate memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#ifndef _POSIX_SOURCE +#define ENOTBLK 15 /* Block device required */ +#endif +#define EBUSY 16 /* Device busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* Operation not supported by device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* Too many open files in system */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Inappropriate ioctl for device */ +#ifndef _POSIX_SOURCE +#define ETXTBSY 26 /* Text file busy */ +#endif +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only filesystem */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ + +/* math software */ +#define EDOM 33 /* Numerical argument out of domain */ +#define ERANGE 34 /* Result too large */ + +/* non-blocking and interrupt i/o */ +#define EAGAIN 35 /* Resource temporarily unavailable */ +#ifndef _POSIX_SOURCE +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define EINPROGRESS 36 /* Operation now in progress */ +#define EALREADY 37 /* Operation already in progress */ + +/* ipc/network software -- argument errors */ +#define ENOTSOCK 38 /* Socket operation on non-socket */ +#define EDESTADDRREQ 39 /* Destination address required */ +#define EMSGSIZE 40 /* Message too long */ +#define EPROTOTYPE 41 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 42 /* Protocol not available */ +#define EPROTONOSUPPORT 43 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ +#define EOPNOTSUPP 45 /* Operation not supported */ +#define ENOTSUP EOPNOTSUPP /* Operation not supported */ +#define EPFNOSUPPORT 46 /* Protocol family not supported */ +#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ +#define EADDRINUSE 48 /* Address already in use */ +#define EADDRNOTAVAIL 49 /* Can't assign requested address */ + +/* ipc/network software -- operational errors */ +#define ENETDOWN 50 /* Network is down */ +#define ENETUNREACH 51 /* Network is unreachable */ +#define ENETRESET 52 /* Network dropped connection on reset */ +#define ECONNABORTED 53 /* Software caused connection abort */ +#define ECONNRESET 54 /* Connection reset by peer */ +#define ENOBUFS 55 /* No buffer space available */ +#define EISCONN 56 /* Socket is already connected */ +#define ENOTCONN 57 /* Socket is not connected */ +#define ESHUTDOWN 58 /* Can't send after socket shutdown */ +#define ETOOMANYREFS 59 /* Too many references: can't splice */ +#define ETIMEDOUT 60 /* Operation timed out */ +#define ECONNREFUSED 61 /* Connection refused */ + +#define ELOOP 62 /* Too many levels of symbolic links */ +#endif /* _POSIX_SOURCE */ +#define ENAMETOOLONG 63 /* File name too long */ + +/* should be rearranged */ +#ifndef _POSIX_SOURCE +#define EHOSTDOWN 64 /* Host is down */ +#define EHOSTUNREACH 65 /* No route to host */ +#endif /* _POSIX_SOURCE */ +#define ENOTEMPTY 66 /* Directory not empty */ + +/* quotas & mush */ +#ifndef _POSIX_SOURCE +#define EPROCLIM 67 /* Too many processes */ +#define EUSERS 68 /* Too many users */ +#define EDQUOT 69 /* Disc quota exceeded */ + +/* Network File System */ +#define ESTALE 70 /* Stale NFS file handle */ +#define EREMOTE 71 /* Too many levels of remote in path */ +#define EBADRPC 72 /* RPC struct is bad */ +#define ERPCMISMATCH 73 /* RPC version wrong */ +#define EPROGUNAVAIL 74 /* RPC prog. not avail */ +#define EPROGMISMATCH 75 /* Program version wrong */ +#define EPROCUNAVAIL 76 /* Bad procedure for program */ +#endif /* _POSIX_SOURCE */ + +#define ENOLCK 77 /* No locks available */ +#define ENOSYS 78 /* Function not implemented */ + +#ifndef _POSIX_SOURCE +#define EFTYPE 79 /* Inappropriate file type or format */ +#define EAUTH 80 /* Authentication error */ +#define ENEEDAUTH 81 /* Need authenticator */ +#define EIDRM 82 /* Identifier removed */ +#define ENOMSG 83 /* No message of desired type */ +#define EOVERFLOW 84 /* Value too large to be stored in data type */ +#define ECANCELED 85 /* Operation canceled */ +#define EILSEQ 86 /* Illegal byte sequence */ +#define ENOATTR 87 /* Attribute not found */ + +#define EDOOFUS 88 /* Programming error */ +#endif /* _POSIX_SOURCE */ + +#define EBADMSG 89 /* Bad message */ +#define EMULTIHOP 90 /* Multihop attempted */ +#define ENOLINK 91 /* Link has been severed */ +#define EPROTO 92 /* Protocol error */ + +#ifndef _POSIX_SOURCE +#define ENOTCAPABLE 93 /* Capabilities insufficient */ +#endif /* _POSIX_SOURCE */ + +#ifndef _POSIX_SOURCE +#define ELAST 93 /* Must be equal largest errno */ +#endif /* _POSIX_SOURCE */ +#endif /* __rtems__ */ + +#ifdef _KERNEL +/* pseudo-errors returned inside kernel to modify return to process */ +#define ERESTART (-1) /* restart syscall */ +#define EJUSTRETURN (-2) /* don't modify regs, just return */ +#define ENOIOCTL (-3) /* ioctl not handled by this layer */ +#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */ +#endif + +#endif diff --git a/rtemsbsd/include/rtems/bsd/sys/lock.h b/rtemsbsd/include/rtems/bsd/sys/lock.h new file mode 100644 index 00000000..f86ec765 --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/lock.h @@ -0,0 +1,319 @@ +/*- + * Copyright (c) 1997 Berkeley Software Design, 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. Berkeley Software Design Inc's name may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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 BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ + * $FreeBSD$ + */ + +#ifndef _SYS_LOCK_HH_ +#define _SYS_LOCK_HH_ + +#include +#include + +struct lock_list_entry; +struct thread; + +/* + * Lock classes. Each lock has a class which describes characteristics + * common to all types of locks of a given class. + * + * Spin locks in general must always protect against preemption, as it is + * an error to perform any type of context switch while holding a spin lock. + * Also, for an individual lock to be recursable, its class must allow + * recursion and the lock itself must explicitly allow recursion. + * + * The 'lc_ddb_show' function pointer is used to dump class-specific + * data for the 'show lock' DDB command. The 'lc_lock' and + * 'lc_unlock' function pointers are used in sleep(9) and cv_wait(9) + * to lock and unlock locks while blocking on a sleep queue. The + * return value of 'lc_unlock' will be passed to 'lc_lock' on resume + * to allow communication of state between the two routines. + */ + +struct lock_class { + const char *lc_name; + u_int lc_flags; + void (*lc_assert)(struct lock_object *lock, int what); + void (*lc_ddb_show)(struct lock_object *lock); + void (*lc_lock)(struct lock_object *lock, int how); + int (*lc_owner)(struct lock_object *lock, struct thread **owner); + int (*lc_unlock)(struct lock_object *lock); +}; + +#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */ +#define LC_SPINLOCK 0x00000002 /* Spin lock. */ +#define LC_SLEEPABLE 0x00000004 /* Sleeping allowed with this lock. */ +#define LC_RECURSABLE 0x00000008 /* Locks of this type may recurse. */ +#define LC_UPGRADABLE 0x00000010 /* Upgrades and downgrades permitted. */ + +#define LO_CLASSFLAGS 0x0000ffff /* Class specific flags. */ +#define LO_INITIALIZED 0x00010000 /* Lock has been initialized. */ +#define LO_WITNESS 0x00020000 /* Should witness monitor this lock. */ +#define LO_QUIET 0x00040000 /* Don't log locking operations. */ +#define LO_RECURSABLE 0x00080000 /* Lock may recurse. */ +#define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */ +#define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */ +#define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */ +#define LO_CLASSMASK 0x0f000000 /* Class index bitmask. */ +#define LO_NOPROFILE 0x10000000 /* Don't profile this lock */ + +/* + * Lock classes are statically assigned an index into the gobal lock_classes + * array. Debugging code looks up the lock class for a given lock object + * by indexing the array. + */ +#define LO_CLASSSHIFT 24 +#define LO_CLASSINDEX(lock) ((((lock)->lo_flags) & LO_CLASSMASK) >> LO_CLASSSHIFT) +#define LOCK_CLASS(lock) (lock_classes[LO_CLASSINDEX((lock))]) +#define LOCK_CLASS_MAX (LO_CLASSMASK >> LO_CLASSSHIFT) + +/* + * Option flags passed to lock operations that witness also needs to know + * about or that are generic across all locks. + */ +#define LOP_NEWORDER 0x00000001 /* Define a new lock order. */ +#define LOP_QUIET 0x00000002 /* Don't log locking operations. */ +#define LOP_TRYLOCK 0x00000004 /* Don't check lock order. */ +#define LOP_EXCLUSIVE 0x00000008 /* Exclusive lock. */ +#define LOP_DUPOK 0x00000010 /* Don't check for duplicate acquires */ + +/* Flags passed to witness_assert. */ +#define LA_MASKASSERT 0x000000ff /* Mask for witness defined asserts. */ +#define LA_UNLOCKED 0x00000000 /* Lock is unlocked. */ +#define LA_LOCKED 0x00000001 /* Lock is at least share locked. */ +#define LA_SLOCKED 0x00000002 /* Lock is exactly share locked. */ +#define LA_XLOCKED 0x00000004 /* Lock is exclusively locked. */ +#define LA_RECURSED 0x00000008 /* Lock is recursed. */ +#define LA_NOTRECURSED 0x00000010 /* Lock is not recursed. */ + +#ifdef _KERNEL +/* + * If any of WITNESS, INVARIANTS, or KTR_LOCK KTR tracing has been enabled, + * then turn on LOCK_DEBUG. When this option is on, extra debugging + * facilities such as tracking the file and line number of lock operations + * are enabled. Also, mutex locking operations are not inlined to avoid + * bloat from all the extra debugging code. We also have to turn on all the + * calling conventions for this debugging code in modules so that modules can + * work with both debug and non-debug kernels. + */ +#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || defined(INVARIANT_SUPPORT) || defined(KTR) || defined(LOCK_PROFILING) +#define LOCK_DEBUG 1 +#else +#define LOCK_DEBUG 0 +#endif + +/* + * In the LOCK_DEBUG case, use the filename and line numbers for debugging + * operations. Otherwise, use default values to avoid the unneeded bloat. + */ +#if LOCK_DEBUG > 0 +#define LOCK_FILE __FILE__ +#define LOCK_LINE __LINE__ +#else +#define LOCK_FILE NULL +#define LOCK_LINE 0 +#endif + +/* + * Macros for KTR_LOCK tracing. + * + * opname - name of this operation (LOCK/UNLOCK/SLOCK, etc.) + * lo - struct lock_object * for this lock + * flags - flags passed to the lock operation + * recurse - this locks recursion level (or 0 if class is not recursable) + * result - result of a try lock operation + * file - file name + * line - line number + */ +#define LOCK_LOG_TEST(lo, flags) \ + (((flags) & LOP_QUIET) == 0 && ((lo)->lo_flags & LO_QUIET) == 0) + +#define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do { \ + if (LOCK_LOG_TEST((lo), (flags))) \ + CTR6(KTR_LOCK, opname " (%s) %s %p r = %d at %s:%d", \ + LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ + (lo), (u_int)(recurse), (file), (line)); \ +} while (0) + +#define LOCK_LOG_TRY(opname, lo, flags, result, file, line) do { \ + if (LOCK_LOG_TEST((lo), (flags))) \ + CTR6(KTR_LOCK, "TRY_" opname " (%s) %s %p result=%d at %s:%d",\ + LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ + (lo), (u_int)(result), (file), (line)); \ +} while (0) + +#define LOCK_LOG_INIT(lo, flags) do { \ + if (LOCK_LOG_TEST((lo), (flags))) \ + CTR4(KTR_LOCK, "%s: %p (%s) %s", __func__, (lo), \ + LOCK_CLASS(lo)->lc_name, (lo)->lo_name); \ +} while (0) + +#define LOCK_LOG_DESTROY(lo, flags) LOCK_LOG_INIT(lo, flags) + +#define lock_initalized(lo) ((lo)->lo_flags & LO_INITIALIZED) + +/* + * Helpful macros for quickly coming up with assertions with informative + * panic messages. + */ +#define MPASS(ex) MPASS4(ex, #ex, __FILE__, __LINE__) +#define MPASS2(ex, what) MPASS4(ex, what, __FILE__, __LINE__) +#define MPASS3(ex, file, line) MPASS4(ex, #ex, file, line) +#define MPASS4(ex, what, file, line) \ + KASSERT((ex), ("Assertion %s failed at %s:%d", what, file, line)) + +extern struct lock_class lock_class_mtx_sleep; +extern struct lock_class lock_class_mtx_spin; +extern struct lock_class lock_class_sx; +extern struct lock_class lock_class_rw; +extern struct lock_class lock_class_rm; +extern struct lock_class lock_class_lockmgr; + +extern struct lock_class *lock_classes[]; + +void lock_init(struct lock_object *, struct lock_class *, + const char *, const char *, int); +void lock_destroy(struct lock_object *); +void spinlock_enter(void); +void spinlock_exit(void); +void witness_init(struct lock_object *, const char *); +void witness_destroy(struct lock_object *); +int witness_defineorder(struct lock_object *, struct lock_object *); +void witness_checkorder(struct lock_object *, int, const char *, int, + struct lock_object *); +void witness_lock(struct lock_object *, int, const char *, int); +void witness_upgrade(struct lock_object *, int, const char *, int); +void witness_downgrade(struct lock_object *, int, const char *, int); +void witness_unlock(struct lock_object *, int, const char *, int); +void witness_save(struct lock_object *, const char **, int *); +void witness_restore(struct lock_object *, const char *, int); +int witness_list_locks(struct lock_list_entry **, + int (*)(const char *, ...)); +int witness_warn(int, struct lock_object *, const char *, ...); +void witness_assert(struct lock_object *, int, const char *, int); +void witness_display_spinlock(struct lock_object *, struct thread *, + int (*)(const char *, ...)); +int witness_line(struct lock_object *); +void witness_norelease(struct lock_object *); +void witness_releaseok(struct lock_object *); +const char *witness_file(struct lock_object *); +void witness_thread_exit(struct thread *); + +#ifdef WITNESS + +/* Flags for witness_warn(). */ +#define WARN_GIANTOK 0x01 /* Giant is exempt from this check. */ +#define WARN_PANIC 0x02 /* Panic if check fails. */ +#define WARN_SLEEPOK 0x04 /* Sleepable locks are exempt from check. */ + +#define WITNESS_INIT(lock, type) \ + witness_init((lock), (type)) + +#define WITNESS_DESTROY(lock) \ + witness_destroy(lock) + +#define WITNESS_CHECKORDER(lock, flags, file, line, interlock) \ + witness_checkorder((lock), (flags), (file), (line), (interlock)) + +#define WITNESS_DEFINEORDER(lock1, lock2) \ + witness_defineorder((struct lock_object *)(lock1), \ + (struct lock_object *)(lock2)) + +#define WITNESS_LOCK(lock, flags, file, line) \ + witness_lock((lock), (flags), (file), (line)) + +#define WITNESS_UPGRADE(lock, flags, file, line) \ + witness_upgrade((lock), (flags), (file), (line)) + +#define WITNESS_DOWNGRADE(lock, flags, file, line) \ + witness_downgrade((lock), (flags), (file), (line)) + +#define WITNESS_UNLOCK(lock, flags, file, line) \ + witness_unlock((lock), (flags), (file), (line)) + +#define WITNESS_CHECK(flags, lock, fmt, ...) \ + witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) + +#define WITNESS_WARN(flags, lock, fmt, ...) \ + witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) + +#define WITNESS_SAVE_DECL(n) \ + const char * __CONCAT(n, __wf); \ + int __CONCAT(n, __wl) + +#define WITNESS_SAVE(lock, n) \ + witness_save((lock), &__CONCAT(n, __wf), &__CONCAT(n, __wl)) + +#define WITNESS_RESTORE(lock, n) \ + witness_restore((lock), __CONCAT(n, __wf), __CONCAT(n, __wl)) + +#define WITNESS_NORELEASE(lock) \ + witness_norelease(&(lock)->lock_object) + +#define WITNESS_RELEASEOK(lock) \ + witness_releaseok(&(lock)->lock_object) + +#define WITNESS_FILE(lock) \ + witness_file(lock) + +#define WITNESS_LINE(lock) \ + witness_line(lock) + +#else /* WITNESS */ +#define WITNESS_INIT(lock, type) (void)0 +#define WITNESS_DESTROY(lock) (void)0 +#define WITNESS_DEFINEORDER(lock1, lock2) 0 +#define WITNESS_CHECKORDER(lock, flags, file, line, interlock) (void)0 +#define WITNESS_LOCK(lock, flags, file, line) (void)0 +#define WITNESS_UPGRADE(lock, flags, file, line) (void)0 +#define WITNESS_DOWNGRADE(lock, flags, file, line) (void)0 +#define WITNESS_UNLOCK(lock, flags, file, line) (void)0 +#define WITNESS_CHECK(flags, lock, fmt, ...) 0 +#define WITNESS_WARN(flags, lock, fmt, ...) (void)0 +#define WITNESS_SAVE_DECL(n) (void)0 +#define WITNESS_SAVE(lock, n) (void)0 +#define WITNESS_RESTORE(lock, n) (void)0 +#define WITNESS_NORELEASE(lock) (void)0 +#define WITNESS_RELEASEOK(lock) (void)0 +#define WITNESS_FILE(lock) ("?") +#define WITNESS_LINE(lock) (0) +#endif /* WITNESS */ + +/* + * Helper macros to allow developers to add explicit lock order checks + * wherever they please without having to actually grab a lock to do so. + */ +#define witness_check(l) \ + WITNESS_CHECKORDER(&(l)->lock_object, LOP_EXCLUSIVE, LOCK_FILE, \ + LOCK_LINE, NULL) + +#define witness_check_shared(l) \ + WITNESS_CHECKORDER(&(l)->lock_object, 0, LOCK_FILE, LOCK_LINE, NULL) + +#endif /* _KERNEL */ +#endif /* _SYS_LOCK_HH_ */ diff --git a/rtemsbsd/include/rtems/bsd/sys/param.h b/rtemsbsd/include/rtems/bsd/sys/param.h new file mode 100644 index 00000000..cd00ea4c --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/param.h @@ -0,0 +1,332 @@ +/*- + * Copyright (c) 1982, 1986, 1989, 1993 + * 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. + * 4. 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. + * + * @(#)param.h 8.3 (Berkeley) 4/4/95 + * $FreeBSD$ + */ + +#ifndef _SYS_PARAM_HH_ +#define _SYS_PARAM_HH_ + +#include + +#define BSD 199506 /* System version (year & month). */ +#define BSD4_3 1 +#define BSD4_4 1 + +/* + * __FreeBSD_version numbers are documented in the Porter's Handbook. + * If you bump the version for any reason, you should update the documentation + * there. + * Currently this lives here: + * + * doc/en_US.ISO8859-1/books/porters-handbook/book.sgml + * + * scheme is: Rxx + * 'R' is in the range 0 to 4 if this is a release branch or + * x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is + * in the range 5 to 9. + */ +#undef __FreeBSD_version +#define __FreeBSD_version 802000 /* Master, propagated to newvers */ + +#ifdef _KERNEL +#define P_OSREL_SIGSEGV 700004 +#define P_OSREL_MAP_ANON 800104 +#endif + +#ifndef LOCORE +#include +#endif + +/* + * 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 ) + * MAXLOGNAME should be == UT_NAMESIZE+1 (see ) + */ +#include + +#define MAXCOMLEN 19 /* max command name remembered */ +#define MAXINTERP 32 /* max interpreter file name length */ +#define MAXLOGNAME 17 /* max login name length (incl. NUL) */ +#define MAXUPRC CHILD_MAX /* max simultaneous processes */ +#define NCARGS ARG_MAX /* max bytes for an exec function */ +#define NGROUPS (NGROUPS_MAX+1) /* max number groups */ +#define NOFILE OPEN_MAX /* max open files per process */ +#define NOGROUP 65535 /* marker for empty group set member */ +#define MAXHOSTNAMELEN 256 /* max hostname size */ +#define SPECNAMELEN 63 /* max length of devicename */ + +/* More types and definitions used throughout the kernel. */ +#ifdef _KERNEL +#include +#include +#ifndef LOCORE +#include +#include +#endif + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#endif + +#ifndef _KERNEL +/* Signals. */ +#include +#endif + +/* Machine type dependent parameters. */ +#include +#ifndef _KERNEL +#include +#endif + +#ifndef _NO_NAMESPACE_POLLUTION + +#ifndef DEV_BSHIFT +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#endif +#define DEV_BSIZE (1<>PAGE_SHIFT) +#endif + +/* + * btodb() is messy and perhaps slow because `bytes' may be an off_t. We + * want to shift an unsigned type to avoid sign extension and we don't + * want to widen `bytes' unnecessarily. Assume that the result fits in + * a daddr_t. + */ +#ifndef btodb +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + (sizeof (bytes) > sizeof(long) \ + ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ + : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) +#endif + +#ifndef dbtob +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((off_t)(db) << DEV_BSHIFT) +#endif + +#endif /* _NO_NAMESPACE_POLLUTION */ + +#define PRIMASK 0x0ff +#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ +#define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ +#define PBDRY 0x400 /* for PCATCH stop is done on the user boundary */ + +#define NZERO 0 /* default "nice" */ + +#define NBBY 8 /* number of bits in a byte */ +#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 */ + +/* + * File system parameters and macros. + * + * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes + * per block. MAXBSIZE may be made larger without effecting + * any existing filesystems as long as it does not exceed MAXPHYS, + * and may be made smaller at the risk of not being able to use + * filesystems which require a block size exceeding MAXBSIZE. + * + * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the + * minimum KVM memory reservation the kernel is willing to make. + * Filesystems can of course request smaller chunks. Actual + * backing memory uses a chunk size of a page (PAGE_SIZE). + * + * If you make BKVASIZE too small you risk seriously fragmenting + * the buffer KVM map which may slow things down a bit. If you + * make it too big the kernel will not be able to optimally use + * the KVM memory reserved for the buffer cache and will wind + * up with too-few buffers. + * + * The default is 16384, roughly 2x the block size used by a + * normal UFS filesystem. + */ +#define MAXBSIZE 65536 /* must be power of 2 */ +#define BKVASIZE 16384 /* must be power of 2 */ +#define BKVAMASK (BKVASIZE-1) + +/* + * 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. + */ +#define MAXPATHLEN PATH_MAX +#define MAXSYMLINKS 32 + +/* Bit map related macros. */ +#define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a,i) \ + (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a,i) \ + ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) + +/* Macros for counting and rounding. */ +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#define rounddown(x, y) (((x)/(y))*(y)) +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ +#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ +#define powerof2(x) ((((x)-1)&(x))==0) + +/* Macros for min/max. */ +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +#ifdef _KERNEL +/* + * Basic byte order function prototypes for non-inline functions. + */ +#ifndef LOCORE +#ifndef _BYTEORDER_PROTOTYPED +#define _BYTEORDER_PROTOTYPED +__BEGIN_DECLS +__uint32_t htonl(__uint32_t); +__uint16_t htons(__uint16_t); +__uint32_t ntohl(__uint32_t); +__uint16_t ntohs(__uint16_t); +__END_DECLS +#endif +#endif + +#ifndef lint +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif /* !_BYTEORDER_FUNC_DEFINED */ +#endif /* lint */ +#endif /* _KERNEL */ + +/* + * Scale factor for scaled integers used to count %cpu time and load avgs. + * + * The number of CPU `tick's that map to a unique `%age' can be expressed + * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that + * can be calculated (assuming 32 bits) can be closely approximated using + * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). + * + * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', + * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. + */ +#define FSHIFT 11 /* bits to right of fixed binary point */ +#define FSCALE (1<> (PAGE_SHIFT - DEV_BSHIFT)) + +#define ctodb(db) /* calculates pages to devblks */ \ + ((db) << (PAGE_SHIFT - DEV_BSHIFT)) + +/* + * Given the pointer x to the member m of the struct s, return + * a pointer to the containing structure. + */ +#define member2struct(s, m, x) \ + ((struct s *)(void *)((char *)(x) - offsetof(struct s, m))) + +#endif /* _SYS_PARAM_HH_ */ diff --git a/rtemsbsd/include/rtems/bsd/sys/resource.h b/rtemsbsd/include/rtems/bsd/sys/resource.h new file mode 100644 index 00000000..74a43c34 --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/resource.h @@ -0,0 +1,176 @@ +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. 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. + * + * @(#)resource.h 8.4 (Berkeley) 1/9/95 + * $FreeBSD$ + */ + +#ifndef _SYS_RESOURCE_HH_ +#define _SYS_RESOURCE_HH_ + +#include +#include +#include + +/* + * 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 utilization information. + * + * All fields are only modified by curthread and + * no locks are required to read. + */ + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN -1 +#define RUSAGE_THREAD 1 + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* max resident set size */ +#define ru_first ru_ixrss + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data " */ + long ru_isrss; /* integral unshared stack " */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +#define ru_last ru_nivcsw +}; + +/* + * Resource limits + */ +#define RLIMIT_CPU 0 /* maximum cpu time in seconds */ +#define RLIMIT_FSIZE 1 /* maximum file size */ +#define RLIMIT_DATA 2 /* data size */ +#define RLIMIT_STACK 3 /* stack size */ +#define RLIMIT_CORE 4 /* core file size */ +#define RLIMIT_RSS 5 /* resident set size */ +#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ +#define RLIMIT_NPROC 7 /* number of processes */ +#define RLIMIT_NOFILE 8 /* number of open files */ +#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ +#define RLIMIT_VMEM 10 /* virtual process size (inclusive of mmap) */ +#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */ +#define RLIMIT_NPTS 11 /* pseudo-terminals */ +#define RLIMIT_SWAP 12 /* swap used */ + +#define RLIM_NLIMITS 13 /* number of resource limits */ + +#define RLIM_INFINITY ((rlim_t)(((uint64_t)1 << 63) - 1)) +/* XXX Missing: RLIM_SAVED_MAX, RLIM_SAVED_CUR */ + + +/* + * Resource limit string identifiers + */ + +#ifdef _RLIMIT_IDENT +static char *rlimit_ident[RLIM_NLIMITS] = { + "cpu", + "fsize", + "data", + "stack", + "core", + "rss", + "memlock", + "nproc", + "nofile", + "sbsize", + "vmem", + "npts", + "swap", +}; +#endif + +#ifndef _RLIM_T_DECLARED +typedef __rlim_t rlim_t; +#define _RLIM_T_DECLARED +#endif + +struct rlimit { + rlim_t rlim_cur; /* current (soft) limit */ + rlim_t rlim_max; /* maximum value for rlim_cur */ +}; + +#if __BSD_VISIBLE + +struct orlimit { + __int32_t rlim_cur; /* current (soft) limit */ + __int32_t rlim_max; /* maximum value for rlim_cur */ +}; + +struct loadavg { + __fixpt_t ldavg[3]; + long fscale; +}; + +#define CP_USER 0 +#define CP_NICE 1 +#define CP_SYS 2 +#define CP_INTR 3 +#define CP_IDLE 4 +#define CPUSTATES 5 + +#endif /* __BSD_VISIBLE */ + +#ifdef _KERNEL + +extern struct loadavg averunnable; +void read_cpu_time(long *cp_time); /* Writes array of CPUSTATES */ + +#else + +__BEGIN_DECLS +/* XXX 2nd arg to [gs]etpriority() should be an id_t */ +int getpriority(int, int); +int getrlimit(int, struct rlimit *); +int getrusage(int, struct rusage *); +int setpriority(int, int, int); +int setrlimit(int, const struct rlimit *); +__END_DECLS + +#endif /* _KERNEL */ +#endif /* !_SYS_RESOURCE_HH_ */ diff --git a/rtemsbsd/include/rtems/bsd/sys/time.h b/rtemsbsd/include/rtems/bsd/sys/time.h new file mode 100644 index 00000000..f34af077 --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/time.h @@ -0,0 +1,351 @@ +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. 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. + * + * @(#)time.h 8.5 (Berkeley) 5/4/95 + * $FreeBSD$ + */ + +#ifndef _SYS_TIME_HH_ +#define _SYS_TIME_HH_ + +#include +#include +#include + +#ifndef __rtems__ +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; +#endif + +#define DST_NONE 0 /* not on dst */ +#define DST_USA 1 /* USA style dst */ +#define DST_AUST 2 /* Australian style dst */ +#define DST_WET 3 /* Western European dst */ +#define DST_MET 4 /* Middle European dst */ +#define DST_EET 5 /* Eastern European dst */ +#define DST_CAN 6 /* Canada */ + +#if __BSD_VISIBLE +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 = ((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 = ((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 /* __BSD_VISIBLE */ + +#ifdef _KERNEL + +/* Operations on timespecs */ +#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) +#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) +#define timespeccmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#define timespecadd(vvp, uvp) \ + do { \ + (vvp)->tv_sec += (uvp)->tv_sec; \ + (vvp)->tv_nsec += (uvp)->tv_nsec; \ + if ((vvp)->tv_nsec >= 1000000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_nsec -= 1000000000; \ + } \ + } while (0) +#define timespecsub(vvp, uvp) \ + do { \ + (vvp)->tv_sec -= (uvp)->tv_sec; \ + (vvp)->tv_nsec -= (uvp)->tv_nsec; \ + if ((vvp)->tv_nsec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_nsec += 1000000000; \ + } \ + } while (0) + +/* Operations on timevals. */ + +#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) +#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timevalcmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) + +/* timevaladd and timevalsub are not inlined */ + +#endif /* _KERNEL */ + +#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */ + +#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#ifndef __rtems__ +#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 (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 (0) +#endif +#endif + +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +#ifndef __rtems__ +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; +#endif + +/* + * Getkerninfo clock information structure + */ +struct clockinfo { + int hz; /* clock frequency */ + int tick; /* micro-seconds per hz tick */ + int spare; + int stathz; /* statistics clock frequency */ + int profhz; /* profiling clock frequency */ +}; + +/* These macros are also in time.h. */ +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#define CLOCK_VIRTUAL 1 +#define CLOCK_PROF 2 +#define CLOCK_MONOTONIC 4 +#define CLOCK_UPTIME 5 /* FreeBSD-specific. */ +#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ +#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ +#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ +#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ +#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ +#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ +#define CLOCK_SECOND 13 /* FreeBSD-specific. */ +#define CLOCK_THREAD_CPUTIME_ID 14 +#endif + +#ifndef TIMER_ABSTIME +#define TIMER_RELTIME 0x0 /* relative timer */ +#define TIMER_ABSTIME 0x1 /* absolute timer */ +#endif + +#ifdef _KERNEL + +/* + * Kernel to clock driver interface. + */ +void inittodr(time_t base); +void resettodr(void); + +extern time_t time_second; +extern time_t time_uptime; +extern struct timeval boottime; + +/* + * Functions for looking at our clock: [get]{bin,nano,micro}[up]time() + * + * Functions without the "get" prefix returns the best timestamp + * we can produce in the given format. + * + * "bin" == struct bintime == seconds + 64 bit fraction of seconds. + * "nano" == struct timespec == seconds + nanoseconds. + * "micro" == struct timeval == seconds + microseconds. + * + * Functions containing "up" returns time relative to boot and + * should be used for calculating time intervals. + * + * Functions without "up" returns GMT time. + * + * Functions with the "get" prefix returns a less precise result + * much faster than the functions without "get" prefix and should + * be used where a precision of 10 msec is acceptable or where + * performance is priority. (NB: "precision", _not_ "resolution" !) + * + */ + +void binuptime(struct bintime *bt); +void nanouptime(struct timespec *tsp); +void microuptime(struct timeval *tvp); + +void bintime(struct bintime *bt); +void nanotime(struct timespec *tsp); +void microtime(struct timeval *tvp); + +void getbinuptime(struct bintime *bt); +void getnanouptime(struct timespec *tsp); +void getmicrouptime(struct timeval *tvp); + +void getbintime(struct bintime *bt); +void getnanotime(struct timespec *tsp); +void getmicrotime(struct timeval *tvp); + +/* Other functions */ +int itimerdecr(struct itimerval *itp, int usec); +int itimerfix(struct timeval *tv); +int ppsratecheck(struct timeval *, int *, int); +int ratecheck(struct timeval *, const struct timeval *); +void timevaladd(struct timeval *t1, const struct timeval *t2); +void timevalsub(struct timeval *t1, const struct timeval *t2); +int tvtohz(struct timeval *tv); +#else /* !_KERNEL */ +#include + +#include +#include + +__BEGIN_DECLS +int setitimer(int, const struct itimerval *, struct itimerval *); +int utimes(const char *, const struct timeval *); + +#if __BSD_VISIBLE +int adjtime(const struct timeval *, struct timeval *); +int futimes(int, const struct timeval *); +int futimesat(int, const char *, const struct timeval [2]); +int lutimes(const char *, const struct timeval *); +int settimeofday(const struct timeval *, const struct timezone *); +#endif + +#ifndef __rtems__ +#if __XSI_VISIBLE +int getitimer(int, struct itimerval *); +int gettimeofday(struct timeval *, struct timezone *); +#endif +#endif + +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_TIME_HH_ */ diff --git a/rtemsbsd/include/rtems/bsd/sys/timespec.h b/rtemsbsd/include/rtems/bsd/sys/timespec.h new file mode 100644 index 00000000..4ec4147e --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/timespec.h @@ -0,0 +1,10 @@ +#define TIMEVAL_TO_TIMESPEC(tv, ts) \ + do { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ + } while (0) +#define TIMESPEC_TO_TIMEVAL(tv, ts) \ + do { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ + } while (0) diff --git a/rtemsbsd/include/rtems/bsd/sys/types.h b/rtemsbsd/include/rtems/bsd/sys/types.h new file mode 100644 index 00000000..38ae5c68 --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/types.h @@ -0,0 +1,360 @@ +/*- + * 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. + * 4. 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.6 (Berkeley) 2/19/95 + * $FreeBSD$ + */ + +#ifndef _SYS_TYPES_HH_ +#define _SYS_TYPES_HH_ + +#include + +/* Machine type dependent parameters. */ +#include +#include + +#include + +#if __BSD_VISIBLE +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#ifndef _KERNEL +typedef unsigned short ushort; /* Sys V compatibility */ +typedef unsigned int uint; /* Sys V compatibility */ +#endif +#endif + +/* + * XXX POSIX sized integrals that should appear only in . + */ +#ifndef _INT8_T_DECLARED +typedef __int8_t int8_t; +#define _INT8_T_DECLARED +#endif + +#ifndef _INT16_T_DECLARED +typedef __int16_t int16_t; +#define _INT16_T_DECLARED +#endif + +#ifndef _INT32_T_DECLARED +typedef __int32_t int32_t; +#define _INT32_T_DECLARED +#endif + +#ifndef _INT64_T_DECLARED +typedef __int64_t int64_t; +#define _INT64_T_DECLARED +#endif + +#ifndef _UINT8_T_DECLARED +typedef __uint8_t uint8_t; +#define _UINT8_T_DECLARED +#endif + +#ifndef _UINT16_T_DECLARED +typedef __uint16_t uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef __uint64_t uint64_t; +#define _UINT64_T_DECLARED +#endif + +#ifndef _INTPTR_T_DECLARED +typedef __intptr_t intptr_t; +typedef __uintptr_t uintptr_t; +#define _INTPTR_T_DECLARED +#endif + +#ifndef __rtems__ +typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */ +typedef __uint16_t u_int16_t; +typedef __uint32_t u_int32_t; +typedef __uint64_t u_int64_t; + +typedef __uint64_t u_quad_t; /* quads (deprecated) */ +typedef __int64_t quad_t; +typedef quad_t * qaddr_t; + +typedef char * caddr_t; /* core address */ +#endif /* __rtems__ */ +typedef __const char * c_caddr_t; /* core address, pointer to const */ +typedef __volatile char *v_caddr_t; /* core address, pointer to volatile */ + +#ifndef _BLKSIZE_T_DECLARED +typedef __blksize_t blksize_t; +#define _BLKSIZE_T_DECLARED +#endif + +typedef __cpuwhich_t cpuwhich_t; +typedef __cpulevel_t cpulevel_t; +typedef __cpusetid_t cpusetid_t; + +#ifndef _BLKCNT_T_DECLARED +typedef __blkcnt_t blkcnt_t; +#define _BLKCNT_T_DECLARED +#endif + +#ifndef _CLOCK_T_DECLARED +typedef __clock_t clock_t; +#define _CLOCK_T_DECLARED +#endif + +#ifndef _CLOCKID_T_DECLARED +typedef __clockid_t clockid_t; +#define _CLOCKID_T_DECLARED +#endif + +typedef __cpumask_t cpumask_t; +typedef __critical_t critical_t; /* Critical section value */ +#ifndef __rtems__ +typedef __int64_t daddr_t; /* disk address */ +#endif /* __rtems__ */ + +#ifndef _DEV_T_DECLARED +typedef __dev_t dev_t; /* device number or struct cdev */ +#define _DEV_T_DECLARED +#endif + +#ifndef _FFLAGS_T_DECLARED +typedef __fflags_t fflags_t; /* file flags */ +#define _FFLAGS_T_DECLARED +#endif + +typedef __fixpt_t fixpt_t; /* fixed point number */ + +#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */ +typedef __fsblkcnt_t fsblkcnt_t; +typedef __fsfilcnt_t fsfilcnt_t; +#define _FSBLKCNT_T_DECLARED +#endif + +#ifndef _GID_T_DECLARED +typedef __gid_t gid_t; /* group id */ +#define _GID_T_DECLARED +#endif + +#ifndef _IN_ADDR_T_DECLARED +typedef __uint32_t in_addr_t; /* base type for internet address */ +#define _IN_ADDR_T_DECLARED +#endif + +#ifndef _IN_PORT_T_DECLARED +typedef __uint16_t in_port_t; +#define _IN_PORT_T_DECLARED +#endif + +#ifndef _ID_T_DECLARED +typedef __id_t id_t; /* can hold a uid_t or pid_t */ +#define _ID_T_DECLARED +#endif + +#ifndef _INO_T_DECLARED +typedef __ino_t ino_t; /* inode number */ +#define _INO_T_DECLARED +#endif + +#ifndef _KEY_T_DECLARED +typedef __key_t key_t; /* IPC key (for Sys V IPC) */ +#define _KEY_T_DECLARED +#endif + +#ifndef _LWPID_T_DECLARED +typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */ +#define _LWPID_T_DECLARED +#endif + +#ifndef _MODE_T_DECLARED +typedef __mode_t mode_t; /* permissions */ +#define _MODE_T_DECLARED +#endif + +#ifndef _ACCMODE_T_DECLARED +typedef __accmode_t accmode_t; /* access permissions */ +#define _ACCMODE_T_DECLARED +#endif + +#ifndef _NLINK_T_DECLARED +typedef __nlink_t nlink_t; /* link count */ +#define _NLINK_T_DECLARED +#endif + +#ifndef _OFF_T_DECLARED +typedef __off_t off_t; /* file offset */ +#define _OFF_T_DECLARED +#endif + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; /* process id */ +#define _PID_T_DECLARED +#endif + +typedef __register_t register_t; + +#ifndef _RLIM_T_DECLARED +typedef __rlim_t rlim_t; /* resource limit */ +#define _RLIM_T_DECLARED +#endif + +typedef __segsz_t segsz_t; /* segment size (in pages) */ + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + +#ifndef _SSIZE_T_DECLARED +typedef __ssize_t ssize_t; +#define _SSIZE_T_DECLARED +#endif + +#ifndef _SUSECONDS_T_DECLARED +typedef __suseconds_t suseconds_t; /* microseconds (signed) */ +#define _SUSECONDS_T_DECLARED +#endif + +#ifndef _TIME_T_DECLARED +typedef __time_t time_t; +#define _TIME_T_DECLARED +#endif + +#ifndef _TIMER_T_DECLARED +typedef __timer_t timer_t; +#define _TIMER_T_DECLARED +#endif + +#ifndef _MQD_T_DECLARED +typedef __mqd_t mqd_t; +#define _MQD_T_DECLARED +#endif + +typedef __u_register_t u_register_t; + +#ifndef _UID_T_DECLARED +typedef __uid_t uid_t; /* user id */ +#define _UID_T_DECLARED +#endif + +#ifndef _USECONDS_T_DECLARED +typedef __useconds_t useconds_t; /* microseconds (unsigned) */ +#define _USECONDS_T_DECLARED +#endif + +typedef __vm_offset_t vm_offset_t; +typedef __vm_ooffset_t vm_ooffset_t; +typedef __vm_paddr_t vm_paddr_t; +typedef __vm_pindex_t vm_pindex_t; +typedef __vm_size_t vm_size_t; + +#ifdef _KERNEL +typedef int boolean_t; +typedef struct device *device_t; +typedef __intfptr_t intfptr_t; + +/*- + * XXX this is fixed width for historical reasons. It should have had type + * __int_fast32_t. Fixed-width types should not be used unless binary + * compatibility is essential. Least-width types should be used even less + * since they provide smaller benefits. + * XXX should be MD. + * XXX this is bogus in -current, but still used for spl*(). + */ +typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */ + +typedef __uintfptr_t uintfptr_t; +typedef __uint64_t uoff_t; +typedef char vm_memattr_t; /* memory attribute codes */ +typedef struct vm_page *vm_page_t; + +#ifndef __rtems__ +#define offsetof(type, field) __offsetof(type, field) +#endif /* __rtems__ */ + +#endif /* !_KERNEL */ + +/* + * The following are all things that really shouldn't exist in this header, + * since its purpose is to provide typedefs, not miscellaneous doodads. + */ +#if __BSD_VISIBLE + +#include + +/* + * minor() gives a cookie instead of an index since we don't want to + * change the meanings of bits 0-15 or waste time and space shifting + * bits 16-31 for devices that don't use them. + */ +#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ +#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ +#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ + +/* + * These declarations belong elsewhere, but are repeated here and in + * to give broken programs a better chance of working with + * 64-bit off_t's. + */ +#ifndef _KERNEL +__BEGIN_DECLS +#ifndef _FTRUNCATE_DECLARED +#define _FTRUNCATE_DECLARED +int ftruncate(int, off_t); +#endif +#ifndef _LSEEK_DECLARED +#define _LSEEK_DECLARED +off_t lseek(int, off_t, int); +#endif +#ifndef _MMAP_DECLARED +#define _MMAP_DECLARED +void * mmap(void *, size_t, int, int, int, off_t); +#endif +#ifndef _TRUNCATE_DECLARED +#define _TRUNCATE_DECLARED +int truncate(const char *, off_t); +#endif +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* __BSD_VISIBLE */ + +#endif /* !_SYS_TYPES_HH_ */ diff --git a/rtemsbsd/include/rtems/bsd/sys/unistd.h b/rtemsbsd/include/rtems/bsd/sys/unistd.h new file mode 100644 index 00000000..2918d563 --- /dev/null +++ b/rtemsbsd/include/rtems/bsd/sys/unistd.h @@ -0,0 +1,188 @@ +/*- + * 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. + * 4. 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 + * $FreeBSD$ + */ + +#ifndef _SYS_UNISTD_HH_ +#define _SYS_UNISTD_HH_ + +#include + +/* + * 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 . 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. + */ +#define _POSIX_ADVISORY_INFO -1 +#define _POSIX_ASYNCHRONOUS_IO 0 +#define _POSIX_CHOWN_RESTRICTED 1 +#define _POSIX_CLOCK_SELECTION -1 +#define _POSIX_CPUTIME -1 +#define _POSIX_FSYNC 200112L +#define _POSIX_IPV6 0 +#define _POSIX_JOB_CONTROL 1 +#define _POSIX_MAPPED_FILES 200112L +#define _POSIX_MEMLOCK -1 +#define _POSIX_MEMLOCK_RANGE 200112L +#define _POSIX_MEMORY_PROTECTION 200112L +#define _POSIX_MESSAGE_PASSING 200112L +#define _POSIX_MONOTONIC_CLOCK 200112L +#define _POSIX_NO_TRUNC 1 +#define _POSIX_PRIORITIZED_IO -1 +#define _POSIX_PRIORITY_SCHEDULING 200112L +#define _POSIX_RAW_SOCKETS 200112L +#define _POSIX_REALTIME_SIGNALS 200112L +#define _POSIX_SEMAPHORES -1 +#define _POSIX_SHARED_MEMORY_OBJECTS 200112L +#define _POSIX_SPORADIC_SERVER -1 +#define _POSIX_SYNCHRONIZED_IO -1 +#define _POSIX_TIMEOUTS 200112L +#define _POSIX_TIMERS 200112L +#define _POSIX_TYPED_MEMORY_OBJECTS -1 +#define _POSIX_VDISABLE 0xff + +#if __XSI_VISIBLE +#define _XOPEN_SHM 1 +#define _XOPEN_STREAMS -1 +#endif + +/* + * Although we have saved user/group IDs, we do not use them in setuid + * as described in POSIX 1003.1, because the feature does not work for + * root. We use the saved IDs in seteuid/setegid, which are not currently + * part of the POSIX 1003.1 specification. XXX revisit for 1003.1-2001 + * as this is now mandatory. + */ +#ifdef _NOT_AVAILABLE +#define _POSIX_SAVED_IDS 1 /* saved set-user-ID and set-group-ID */ +#endif + +/* Define the POSIX.1 version we target for compliance. */ +#define _POSIX_VERSION 200112L + +/* 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) */ +#ifndef SEEK_SET +#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 */ +#endif +#if __BSD_VISIBLE +#define SEEK_DATA 3 /* set file offset to next data past offset */ +#define SEEK_HOLE 4 /* set file offset to next hole past offset */ +#endif + +#ifndef _POSIX_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 */ +#define _PC_LINK_MAX 1 +#define _PC_MAX_CANON 2 +#define _PC_MAX_INPUT 3 +#define _PC_NAME_MAX 4 +#define _PC_PATH_MAX 5 +#define _PC_PIPE_BUF 6 +#define _PC_CHOWN_RESTRICTED 7 +#define _PC_NO_TRUNC 8 +#define _PC_VDISABLE 9 + +#if __POSIX_VISIBLE >= 199309 +#define _PC_ASYNC_IO 53 +#define _PC_PRIO_IO 54 +#define _PC_SYNC_IO 55 +#endif + +#if __POSIX_VISIBLE >= 200112 +#define _PC_ALLOC_SIZE_MIN 10 +#define _PC_FILESIZEBITS 12 +#define _PC_REC_INCR_XFER_SIZE 14 +#define _PC_REC_MAX_XFER_SIZE 15 +#define _PC_REC_MIN_XFER_SIZE 16 +#define _PC_REC_XFER_ALIGN 17 +#define _PC_SYMLINK_MAX 18 +#endif + +#if __BSD_VISIBLE +#define _PC_ACL_EXTENDED 59 +#define _PC_ACL_PATH_MAX 60 +#define _PC_CAP_PRESENT 61 +#define _PC_INF_PRESENT 62 +#define _PC_MAC_PRESENT 63 +#define _PC_ACL_NFS4 64 +#endif + +/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */ +#define _PC_MIN_HOLE_SIZE 21 + +#if __BSD_VISIBLE +/* + * rfork() options. + * + * XXX currently, some operations without RFPROC set are not supported. + */ +#define RFNAMEG (1<<0) /* UNIMPL new plan9 `name space' */ +#define RFENVG (1<<1) /* UNIMPL copy plan9 `env space' */ +#define RFFDG (1<<2) /* copy fd table */ +#define RFNOTEG (1<<3) /* UNIMPL create new plan9 `note group' */ +#define RFPROC (1<<4) /* change child (else changes curproc) */ +#define RFMEM (1<<5) /* share `address space' */ +#define RFNOWAIT (1<<6) /* give child to init */ +#define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */ +#define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */ +#define RFCFDG (1<<12) /* close all fds, zero fd table */ +#define RFTHREAD (1<<13) /* enable kernel thread support */ +#define RFSIGSHARE (1<<14) /* share signal handlers */ +#define RFLINUXTHPN (1<<16) /* do linux clone exit parent notification */ +#define RFSTOPPED (1<<17) /* leave child in a stopped state */ +#define RFHIGHPID (1<<18) /* use a pid higher than 10 (idleproc) */ +#define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */ +#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPPWAIT) + +#endif /* __BSD_VISIBLE */ + +#endif /* !_SYS_UNISTD_HH_ */ -- cgit v1.2.3