diff --git a/lib/libc/gen/fmtcheck.3 b/lib/libc/gen/fmtcheck.3 index 782526d52134..ecd70fb8b309 100644 --- a/lib/libc/gen/fmtcheck.3 +++ b/lib/libc/gen/fmtcheck.3 @@ -1,115 +1,108 @@ .\" Copyright (c) 2000 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This file was contributed to The NetBSD Foundation by Allen Briggs. .\" .\" 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 the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation 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 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. .\" .\" $FreeBSD$ .Dd October 16, 2002 .Os .Dt FMTCHECK 3 .Sh NAME .Nm fmtcheck .Nd sanitizes user-supplied .Xr printf 3 Ns -style format string .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In stdio.h .Ft const char * .Fn fmtcheck "const char *fmt_suspect" "const char *fmt_default" .Sh DESCRIPTION The .Fn fmtcheck scans .Fa fmt_suspect and .Fa fmt_default to determine if .Fa fmt_suspect will consume the same argument types as .Fa fmt_default and to ensure that .Fa fmt_suspect is a valid format string. .Pp The .Xr printf 3 family of functions cannot verify the types of arguments that they are passed at run-time. In some cases, like .Xr catgets 3 , it is useful or necessary to use a user-supplied format string with no guarantee that the format string matches the specified arguments. .Pp The .Fn fmtcheck was designed to be used in these cases, as in: .Bd -literal -offset indent printf(fmtcheck(user_format, standard_format), arg1, arg2); .Ed .Pp In the check, field widths, fillers, precisions, etc.\& are ignored (unless the field width or precision is an asterisk .Ql * instead of a digit string). Also, any text other than the format specifiers is completely ignored. .Sh RETURN VALUES If .Fa fmt_suspect is a valid format and consumes the same argument types as .Fa fmt_default , then the .Fn fmtcheck will return .Fa fmt_suspect . Otherwise, it will return .Fa fmt_default . .Sh SECURITY CONSIDERATIONS Note that the formats may be quite different as long as they accept the same arguments. For example, .Qq Li "%p %o %30s %#llx %-10.*e %n" is compatible with .Qq Li "This number %lu %d%% and string %s has %qd numbers and %.*g floats (%n)" . However, .Qq Li %o is not equivalent to .Qq Li %lx because the first requires an integer and the second requires a long. .Sh SEE ALSO .Xr printf 3 .Sh BUGS The .Fn fmtcheck function does not recognize positional parameters. diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3 index 30dd299a7a44..44d2a36ffa4a 100644 --- a/lib/libc/gen/stringlist.3 +++ b/lib/libc/gen/stringlist.3 @@ -1,135 +1,128 @@ .\" $NetBSD: stringlist.3,v 1.5 1999/03/22 19:44:46 garbled Exp $ .\" .\" Copyright (c) 1997, 1999 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This file was 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation 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 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 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. .\" .\" $FreeBSD$ .\" .Dd November 28, 1999 .Os .Dt STRINGLIST 3 .Sh NAME .Nm stringlist , .Nm sl_init , .Nm sl_add , .Nm sl_free , .Nm sl_find .Nd stringlist manipulation functions .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In stringlist.h .Ft StringList * .Fn sl_init .Ft int .Fn sl_add "StringList *sl" "char *item" .Ft void .Fn sl_free "StringList *sl" "int freeall" .Ft char * .Fn sl_find "StringList *sl" "char *item" .Sh DESCRIPTION The .Nm functions manipulate stringlists, which are lists of strings that extend automatically if necessary. .Pp The .Vt StringList structure has the following definition: .Bd -literal -offset indent typedef struct _stringlist { char **sl_str; size_t sl_max; size_t sl_cur; } StringList; .Ed .Pp .Bl -tag -width "sl_str" -offset indent .It Va sl_str a pointer to the base of the array containing the list. .It Va sl_max the size of .Va sl_str . .It Va sl_cur the offset in .Va sl_str of the current element. .El .Pp The following stringlist manipulation functions are available: .Bl -tag -width "sl_init()" .It Fn sl_init Create a stringlist. Returns a pointer to a .Vt StringList , or .Dv NULL in case of failure. .It Fn sl_free Releases memory occupied by .Fa sl and the .Fa sl->sl_str array. If .Fa freeall is non-zero, then each of the items within .Fa sl->sl_str is released as well. .It Fn sl_add Add .Fa item to .Fa sl->sl_str at .Fa sl->sl_cur , extending the size of .Fa sl->sl_str . Returns zero upon success, \-1 upon failure. .It Fn sl_find Find .Fa item in .Fa sl , returning NULL if it is not found. .El .Sh SEE ALSO .Xr free 3 , .Xr malloc 3 .Sh HISTORY The .Nm functions appeared in .Fx 2.2.6 and .Nx 1.3 . diff --git a/lib/libc/include/reentrant.h b/lib/libc/include/reentrant.h index 8ab328bc6279..22a2325d821c 100644 --- a/lib/libc/include/reentrant.h +++ b/lib/libc/include/reentrant.h @@ -1,135 +1,128 @@ /*- * Copyright (c) 1997,98 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by J.T. Conklin. * * 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 the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation 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 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. * * $FreeBSD$ */ /* * Requirements: * * 1. The thread safe mechanism should be lightweight so the library can * be used by non-threaded applications without unreasonable overhead. * * 2. There should be no dependency on a thread engine for non-threaded * applications. * * 3. There should be no dependency on any particular thread engine. * * 4. The library should be able to be compiled without support for thread * safety. * * * Rationale: * * One approach for thread safety is to provide discrete versions of the * library: one thread safe, the other not. The disadvantage of this is * that libc is rather large, and two copies of a library which are 99%+ * identical is not an efficent use of resources. * * Another approach is to provide a single thread safe library. However, * it should not add significant run time or code size overhead to non- * threaded applications. * * Since the NetBSD C library is used in other projects, it should be * easy to replace the mutual exclusion primitives with ones provided by * another system. Similarly, it should also be easy to remove all * support for thread safety completely if the target environment does * not support threads. * * * Implementation Details: * * The mutex primitives used by the library (mutex_t, mutex_lock, etc.) * are macros which expand to the cooresponding primitives provided by * the thread engine or to nothing. The latter is used so that code is * not unreasonably cluttered with #ifdefs when all thread safe support * is removed. * * The mutex macros can be directly mapped to the mutex primitives from * pthreads, however it should be reasonably easy to wrap another mutex * implementation so it presents a similar interface. * * Stub implementations of the mutex functions are provided with *weak* * linkage. These functions simply return success. When linked with a * thread library (i.e. -lpthread), the functions will override the * stubs. */ #include #include #include "libc_private.h" #define mutex_t pthread_mutex_t #define cond_t pthread_cond_t #define rwlock_t pthread_rwlock_t #define once_t pthread_once_t #define thread_key_t pthread_key_t #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER #define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER #define ONCE_INITIALIZER PTHREAD_ONCE_INIT #define mutex_init(m, a) _pthread_mutex_init(m, a) #define mutex_lock(m) if (__isthreaded) \ _pthread_mutex_lock(m) #define mutex_unlock(m) if (__isthreaded) \ _pthread_mutex_unlock(m) #define mutex_trylock(m) (__isthreaded ? 0 : _pthread_mutex_trylock(m)) #define cond_init(c, a, p) _pthread_cond_init(c, a) #define cond_signal(m) if (__isthreaded) \ _pthread_cond_signal(m) #define cond_broadcast(m) if (__isthreaded) \ _pthread_cond_broadcast(m) #define cond_wait(c, m) if (__isthreaded) \ _pthread_cond_wait(c, m) #define rwlock_init(l, a) _pthread_rwlock_init(l, a) #define rwlock_rdlock(l) if (__isthreaded) \ _pthread_rwlock_rdlock(l) #define rwlock_wrlock(l) if (__isthreaded) \ _pthread_rwlock_wrlock(l) #define rwlock_unlock(l) if (__isthreaded) \ _pthread_rwlock_unlock(l) #define thr_keycreate(k, d) _pthread_key_create(k, d) #define thr_setspecific(k, p) _pthread_setspecific(k, p) #define thr_getspecific(k) _pthread_getspecific(k) #define thr_sigsetmask(f, n, o) _pthread_sigmask(f, n, o) #define thr_once(o, i) _pthread_once(o, i) #define thr_self() _pthread_self() #define thr_exit(x) _pthread_exit(x) #define thr_main() _pthread_main_np() diff --git a/lib/libc/sys/mlockall.2 b/lib/libc/sys/mlockall.2 index db4c4a933e4c..d09ce27b644d 100644 --- a/lib/libc/sys/mlockall.2 +++ b/lib/libc/sys/mlockall.2 @@ -1,140 +1,133 @@ .\" $NetBSD: mlockall.2,v 1.11 2003/04/16 13:34:54 wiz 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation 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 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. .\" .\" $FreeBSD$ .\" .Dd June 12, 1999 .Dt MLOCKALL 2 .Os .Sh NAME .Nm mlockall , .Nm munlockall .Nd lock (unlock) the address space of a process .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/mman.h .Ft int .Fn mlockall "int flags" .Ft int .Fn munlockall "void" .Sh DESCRIPTION The .Fn mlockall system call locks into memory the physical pages associated with the address space of a process until the address space is unlocked, the process exits, or execs another program image. .Pp The following flags affect the behavior of .Fn mlockall : .Bl -tag -width ".Dv MCL_CURRENT" .It Dv MCL_CURRENT Lock all pages currently mapped into the process's address space. .It Dv MCL_FUTURE Lock all pages mapped into the process's address space in the future, at the time the mapping is established. Note that this may cause future mappings to fail if those mappings cause resource limits to be exceeded. .El .Pp Since physical memory is a potentially scarce resource, processes are limited in how much they can lock down. A single process can lock the minimum of a system-wide .Dq wired pages limit and the per-process .Dv RLIMIT_MEMLOCK resource limit. .Pp The .Fn munlockall call unlocks any locked memory regions in the process address space. Any regions mapped after an .Fn munlockall call will not be locked. .Sh RETURN VALUES A return value of 0 indicates that the call succeeded and all pages in the range have either been locked or unlocked. A return value of \-1 indicates an error occurred and the locked status of all pages in the range remains unchanged. In this case, the global location .Va errno is set to indicate the error. .Sh ERRORS .Fn mlockall will fail if: .Bl -tag -width Er .It Bq Er EINVAL The .Fa flags argument is zero, or includes unimplemented flags. .It Bq Er ENOMEM Locking the indicated range would exceed either the system or per-process limit for locked memory. .It Bq Er EAGAIN Some or all of the memory mapped into the process's address space could not be locked when the call was made. .It Bq Er EPERM The calling process does not have the appropriate privilege to perform the requested operation. .El .Sh SEE ALSO .Xr mincore 2 , .Xr mlock 2 , .Xr mmap 2 , .Xr munmap 2 , .Xr setrlimit 2 .Sh STANDARDS The .Fn mlockall and .Fn munlockall functions are believed to conform to .St -p1003.1-2001 . .Sh HISTORY The .Fn mlockall and .Fn munlockall functions first appeared in .Fx 5.1 . .Sh BUGS The per-process resource limit is a limit on the amount of virtual memory locked, while the system-wide limit is for the number of locked physical pages. Hence a process with two distinct locked mappings of the same physical page counts as 2 pages against the per-process limit and as only a single page in the system limit. diff --git a/lib/libc/sys/ntp_adjtime.2 b/lib/libc/sys/ntp_adjtime.2 index 5f5185f4976c..65ff8a3f0dfe 100644 --- a/lib/libc/sys/ntp_adjtime.2 +++ b/lib/libc/sys/ntp_adjtime.2 @@ -1,322 +1,315 @@ .\" $NetBSD: ntp_adjtime.2,v 1.6 2003/04/16 13:34:55 wiz Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Thomas Klausner. .\" .\" 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 the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation 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 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$ .\" .Dd July 13, 2005 .Dt NTP_ADJTIME 2 .Os .Sh NAME .Nm ntp_adjtime , .Nm ntp_gettime .Nd Network Time Protocol (NTP) daemon interface system calls .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/timex.h .Ft int .Fn ntp_adjtime "struct timex *" .Ft int .Fn ntp_gettime "struct ntptimeval *" .Sh DESCRIPTION The two system calls .Fn ntp_adjtime and .Fn ntp_gettime are the kernel interface to the Network Time Protocol (NTP) daemon .Xr ntpd 8 . .Pp The .Fn ntp_adjtime function is used by the NTP daemon to adjust the system clock to an externally derived time. The time offset and related variables which are set by .Fn ntp_adjtime are used by .Fn hardclock to adjust the phase and frequency of the phase- or frequency-lock loop (PLL resp. FLL) which controls the system clock. .Pp The .Fn ntp_gettime function provides the time, maximum error (sync distance) and estimated error (dispersion) to client user application programs. .Pp In the following, all variables that refer PPS are only relevant if the .Em PPS_SYNC option is enabled in the kernel. .Pp .Fn ntp_adjtime has as argument a .Va struct timex * of the following form: .Bd -literal struct timex { unsigned int modes; /* clock mode bits (wo) */ long offset; /* time offset (us) (rw) */ long freq; /* frequency offset (scaled ppm) (rw) */ long maxerror; /* maximum error (us) (rw) */ long esterror; /* estimated error (us) (rw) */ int status; /* clock status bits (rw) */ long constant; /* pll time constant (rw) */ long precision; /* clock precision (us) (ro) */ long tolerance; /* clock frequency tolerance (scaled * ppm) (ro) */ /* * The following read-only structure members are implemented * only if the PPS signal discipline is configured in the * kernel. */ long ppsfreq; /* pps frequency (scaled ppm) (ro) */ long jitter; /* pps jitter (us) (ro) */ int shift; /* interval duration (s) (shift) (ro) */ long stabil; /* pps stability (scaled ppm) (ro) */ long jitcnt; /* jitter limit exceeded (ro) */ long calcnt; /* calibration intervals (ro) */ long errcnt; /* calibration errors (ro) */ long stbcnt; /* stability limit exceeded (ro) */ }; .Ed .Pp The members of this struct have the following meanings when used as argument for .Fn ntp_adjtime : .Bl -tag -width tolerance -compact .It Fa modes Defines what settings should be changed with the current .Fn ntp_adjtime call (write-only). Bitwise OR of the following: .Bl -tag -width MOD_TIMECONST -compact -offset indent .It MOD_OFFSET set time offset .It MOD_FREQUENCY set frequency offset .It MOD_MAXERROR set maximum time error .It MOD_ESTERROR set estimated time error .It MOD_STATUS set clock status bits .It MOD_TIMECONST set PLL time constant .It MOD_CLKA set clock A .It MOD_CLKB set clock B .El .It Fa offset Time offset (in microseconds), used by the PLL/FLL to adjust the system time in small increments (read-write). .It Fa freq Frequency offset (scaled ppm) (read-write). .It Fa maxerror Maximum error (in microseconds). Initialized by an .Fn ntp_adjtime call, and increased by the kernel once each second to reflect the maximum error bound growth (read-write). .It Fa esterror Estimated error (in microseconds). Set and read by .Fn ntp_adjtime , but unused by the kernel (read-write). .It Fa status System clock status bits (read-write). Bitwise OR of the following: .Bl -tag -width STA_PPSJITTER -compact -offset indent .It STA_PLL Enable PLL updates (read-write). .It STA_PPSFREQ Enable PPS freq discipline (read-write). .It STA_PPSTIME Enable PPS time discipline (read-write). .It STA_FLL Select frequency-lock mode (read-write). .It STA_INS Insert leap (read-write). .It STA_DEL Delete leap (read-write). .It STA_UNSYNC Clock unsynchronized (read-write). .It STA_FREQHOLD Hold frequency (read-write). .It STA_PPSSIGNAL PPS signal present (read-only). .It STA_PPSJITTER PPS signal jitter exceeded (read-only). .It STA_PPSWANDER PPS signal wander exceeded (read-only). .It STA_PPSERROR PPS signal calibration error (read-only). .It STA_CLOCKERR Clock hardware fault (read-only). .El .It Fa constant PLL time constant, determines the bandwidth, or .Dq stiffness , of the PLL (read-write). .It Fa precision Clock precision (in microseconds). In most cases the same as the kernel tick variable (see .Xr hz 9 ) . If a precision clock counter or external time-keeping signal is available, it could be much lower (and depend on the state of the signal) (read-only). .It Fa tolerance Maximum frequency error, or tolerance of the CPU clock oscillator (scaled ppm). Ordinarily a property of the architecture, but could change under the influence of external time-keeping signals (read-only). .It Fa ppsfreq PPS frequency offset produced by the frequency median filter (scaled ppm) (read-only). .It Fa jitter PPS jitter measured by the time median filter in microseconds (read-only). .It Fa shift Logarithm to base 2 of the interval duration in seconds (PPS, read-only). .It Fa stabil PPS stability (scaled ppm); dispersion (wander) measured by the frequency median filter (read-only). .It Fa jitcnt Number of seconds that have been discarded because the jitter measured by the time median filter exceeded the limit .Em MAXTIME (PPS, read-only). .It Fa calcnt Count of calibration intervals (PPS, read-only). .It Fa errcnt Number of calibration intervals that have been discarded because the wander exceeded the limit .Em MAXFREQ or where the calibration interval jitter exceeded two ticks (PPS, read-only). .It Fa stbcnt Number of calibration intervals that have been discarded because the frequency wander exceeded the limit .Em MAXFREQ Ns /4 (PPS, read-only). .El After the .Fn ntp_adjtime call, the .Va struct timex * structure contains the current values of the corresponding variables. .Pp .Fn ntp_gettime has as argument a .Va struct ntptimeval * with the following members: .Bd -literal struct ntptimeval { struct timeval time; /* current time (ro) */ long maxerror; /* maximum error (us) (ro) */ long esterror; /* estimated error (us) (ro) */ }; .Ed .Pp These have the following meaning: .Bl -tag -width tolerance -compact .It Fa time Current time (read-only). .It Fa maxerror Maximum error in microseconds (read-only). .It Fa esterror Estimated error in microseconds (read-only). .El .Sh RETURN VALUES .Fn ntp_adjtime and .Fn ntp_gettime return the current state of the clock on success, or any of the errors of .Xr copyin 9 and .Xr copyout 9 . .Fn ntp_adjtime may additionally return .Er EPERM if the user calling .Fn ntp_adjtime does not have sufficient permissions. .Pp Possible states of the clock are: .Bl -tag -width TIME_ERROR -compact -offset indent .It TIME_OK Everything okay, no leap second warning. .It TIME_INS .Dq insert leap second warning. At the end of the day, a leap second will be inserted after 23:59:59. .It TIME_DEL .Dq delete leap second warning. At the end of the day, second 23:59:59 will be skipped. .It TIME_OOP Leap second in progress. .It TIME_WAIT Leap second has occurred within the last few seconds.. .It TIME_ERROR Clock not synchronized. .El .Sh ERRORS The .Fn ntp_adjtime system call may return .Er EPERM if the caller does not have sufficient permissions. .Sh SEE ALSO .Xr options 4 , .Xr ntpd 8 , .Xr hardclock 9 , .Xr hz 9 .Bl -tag -width indent .It Pa http://www.bipm.fr/enus/5_Scientific/c_time/time_1.html .It Pa http://www.boulder.nist.gov/timefreq/general/faq.htm .It Pa ftp://time.nist.gov/pub/leap-seconds.list .El .Sh BUGS Take note that this .Tn API is extremely complex and stateful. Users should not attempt modification without first reviewing the .Xr ntpd 8 sources in depth. diff --git a/lib/libc/sys/utrace.2 b/lib/libc/sys/utrace.2 index a83c18551ad0..517728880cbb 100644 --- a/lib/libc/sys/utrace.2 +++ b/lib/libc/sys/utrace.2 @@ -1,86 +1,79 @@ .\" $NetBSD: utrace.2,v 1.11 2003/04/24 12:17:49 wiz Exp $ .\" .\" Copyright (c) 2000 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Gregory McGarry . .\" .\" 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 the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation 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 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$ .\" .Dd December 28, 2000 .Dt UTRACE 2 .Os .Sh NAME .Nm utrace .Nd insert user record in ktrace log .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/types.h .In sys/param.h .In sys/time.h .In sys/uio.h .In sys/ktrace.h .Ft int .Fn utrace "const void *addr" "size_t len" .Sh DESCRIPTION Adds a record to the process trace with information supplied by user. The record contains .Fa len bytes from memory pointed to by .Fa addr . This call only has an effect if the calling process is being traced. .Sh RETURN VALUES .Rv -std .Sh ERRORS .Bl -tag -width Er .It Bq Er EINVAL Specified data length .Fa len was bigger than .Dv KTR_USER_MAXLEN . .It Bq Er ENOMEM Insufficient memory to honor the request. .It Bq Er ENOSYS Currently running kernel was compiled without .Xr ktrace 2 support .Pq Cd "options KTRACE" . .El .Sh SEE ALSO .Xr kdump 1 , .Xr ktrace 1 , .Xr ktrace 2 .Sh HISTORY The .Fn utrace system call first appeared in .Fx 2.2 .