diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/Makefile.inc | 6 | ||||
-rw-r--r-- | lib/libc/gen/Symbol.map | 4 | ||||
-rw-r--r-- | lib/libc/gen/getpagesizes.3 | 99 | ||||
-rw-r--r-- | lib/libc/gen/getpagesizes.c | 78 | ||||
-rw-r--r-- | lib/libc/sys/setfib.2 | 4 | ||||
-rw-r--r-- | lib/libdisk/change.c | 11 | ||||
-rw-r--r-- | lib/libjail/jail.3 | 102 | ||||
-rw-r--r-- | lib/libthr/thread/thr_spec.c | 12 | ||||
-rw-r--r-- | lib/libthr/thread/thr_umtx.h | 7 |
9 files changed, 264 insertions, 59 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 8837038..b06f846 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -15,7 +15,7 @@ SRCS+= __getosreldate.c __xuname.c \ getbootfile.c getbsize.c \ getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \ gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \ - getosreldate.c getpagesize.c \ + getosreldate.c getpagesize.c getpagesizes.c \ getpeereid.c getprogname.c getpwent.c getttyent.c \ getusershell.c getvfsbyname.c glob.c \ initgroups.c isatty.c isinf.c isnan.c jrand48.c lcong48.c \ @@ -51,8 +51,8 @@ MAN+= alarm.3 arc4random.3 \ getbootfile.3 getbsize.3 getcap.3 getcontext.3 getcwd.3 \ getdiskbyname.3 getdomainname.3 getfsent.3 \ getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \ - getmntinfo.3 getnetgrent.3 getosreldate.3 \ - getpagesize.3 getpass.3 getpeereid.3 getprogname.3 getpwent.3 \ + getmntinfo.3 getnetgrent.3 getosreldate.3 getpagesize.3 \ + getpagesizes.3 getpass.3 getpeereid.3 getprogname.3 getpwent.3 \ getttyent.3 getusershell.3 getvfsbyname.3 \ glob.3 initgroups.3 isgreater.3 ldexp.3 lockf.3 makecontext.3 \ modf.3 \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 4f1efaf..197430a 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -366,6 +366,10 @@ FBSD_1.1 { tcsetsid; }; +FBSD_1.2 { + getpagesizes; +}; + FBSDprivate_1.0 { /* needed by thread libraries */ __thr_jtable; diff --git a/lib/libc/gen/getpagesizes.3 b/lib/libc/gen/getpagesizes.3 new file mode 100644 index 0000000..959df81 --- /dev/null +++ b/lib/libc/gen/getpagesizes.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 2009 Alan L. Cox <alc@cs.rice.edu> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 September 21, 2009 +.Dt GETPAGESIZES 3 +.Os +.Sh NAME +.Nm getpagesizes +.Nd "get system page sizes" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/mman.h +.Ft int +.Fn getpagesizes "size_t pagesize[]" "int nelem" +.Sh DESCRIPTION +The +.Fn getpagesizes +function retrieves page size information from the system. +When it is called with +.Fa pagesize +specified as +.Dv NULL +and +.Fa nelem +specified as 0, it returns the number of distinct page sizes that are +supported by the system. +Otherwise, it assigns up to +.Fa nelem +of the system-supported page sizes to consecutive elements of the +array referenced by +.Fa pagesize . +These page sizes are expressed in bytes. +In this case, +.Fn getpagesizes +returns the number of such page sizes that it assigned to the array. +.Sh RETURN VALUES +If successful, the +.Fn getpagesizes +function returns either the number of page sizes that are supported by +the system or the number of supported page sizes that it assigned to +the array referenced by +.Fa pagesize . +Otherwise, it returns the value\~\-1 and sets +.Va errno +to indicate the error. +.Sh ERRORS +The +.Fn getpagesizes +function will succeed unless: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa pagesize +argument is +.Dv NULL +and the +.Fa nelem +argument is non-zero. +.It Bq Er EINVAL +The +.Fa nelem +argument is less than zero. +.El +.Sh SEE ALSO +.Xr getpagesize 3 +.Sh HISTORY +The +.Fn getpagesizes +function first appeared in Solaris 9. +This manual page was written in conjunction with a new but compatible +implementation that was first released in +.Fx 7.3 . +.Sh AUTHORS +This manual page was written by +.An Alan L. Cox Aq alc@cs.rice.edu . diff --git a/lib/libc/gen/getpagesizes.c b/lib/libc/gen/getpagesizes.c new file mode 100644 index 0000000..b0de939 --- /dev/null +++ b/lib/libc/gen/getpagesizes.c @@ -0,0 +1,78 @@ +/*- + * Copyright (c) 2009 Alan L. Cox <alc@cs.rice.edu> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/mman.h> +#include <sys/sysctl.h> + +#include <errno.h> + +/* + * Retrieves page size information from the system. Specifically, returns the + * number of distinct page sizes that are supported by the system, if + * "pagesize" is NULL and "nelem" is 0. Otherwise, assigns up to "nelem" of + * the system-supported page sizes to consecutive elements of the array + * referenced by "pagesize", and returns the number of such page sizes that it + * assigned to the array. These page sizes are expressed in bytes. + * + * The implementation of this function does not directly or indirectly call + * malloc(3) or any other dynamic memory allocator that may itself call this + * function. + */ +int +getpagesizes(size_t pagesize[], int nelem) +{ + static u_long ps[MAXPAGESIZES]; + static int nops; + size_t size; + int i; + + if (nelem < 0 || (nelem > 0 && pagesize == NULL)) { + errno = EINVAL; + return (-1); + } + /* Cache the result of the sysctl(2). */ + if (nops == 0) { + size = sizeof(ps); + if (sysctlbyname("hw.pagesizes", ps, &size, NULL, 0) == -1) + return (-1); + /* Count the number of page sizes that are supported. */ + nops = size / sizeof(ps[0]); + while (nops > 0 && ps[nops - 1] == 0) + nops--; + } + if (pagesize == NULL) + return (nops); + /* Return up to "nelem" page sizes from the cached result. */ + if (nelem > nops) + nelem = nops; + for (i = 0; i < nelem; i++) + pagesize[i] = ps[i]; + return (nelem); +} diff --git a/lib/libc/sys/setfib.2 b/lib/libc/sys/setfib.2 index ca08202..a65a064 100644 --- a/lib/libc/sys/setfib.2 +++ b/lib/libc/sys/setfib.2 @@ -67,8 +67,8 @@ if the .Fa fib argument is greater than the current system maximum. .Sh SEE ALSO -.Xr setsockopt 2 , -.Xr setfib 8 +.Xr setfib 1 , +.Xr setsockopt 2 .Sh STANDARDS The .Fn setfib diff --git a/lib/libdisk/change.c b/lib/libdisk/change.c index 297ac11..5f0c9c6 100644 --- a/lib/libdisk/change.c +++ b/lib/libdisk/change.c @@ -36,17 +36,22 @@ Sanitize_Bios_Geom(struct disk *disk) if (disk->bios_cyl >= 65536) sane = 0; - if (disk->bios_hd > 256) - sane = 0; #ifdef PC98 + if (disk->bios_hd >= 256) + sane = 0; if (disk->bios_sect >= 256) + sane = 0; #else + if (disk->bios_hd > 256) + sane = 0; if (disk->bios_sect > 63) -#endif sane = 0; +#endif +#if 0 /* Disable a check on a disk size. It's too strict. */ if (disk->bios_cyl * disk->bios_hd * disk->bios_sect != disk->chunks->size) sane = 0; +#endif if (sane) return; diff --git a/lib/libjail/jail.3 b/lib/libjail/jail.3 index 7fec585..4207b02 100644 --- a/lib/libjail/jail.3 +++ b/lib/libjail/jail.3 @@ -39,7 +39,7 @@ .Nm jailparam_set , .Nm jailparam_get , .Nm jailparam_export , -.Nm jailparam_free , +.Nm jailparam_free .Nd create and manage system jails .Sh LIBRARY .Lb libjail @@ -89,14 +89,16 @@ knowing the parameter formats. The .Fn jail_getid function returns the JID of the jail identified by -.Ar name , +.Fa name , or \-1 if the jail does not exist. .Pp The .Fn jail_getname function returns the name of the jail identified by -.Ar jid , -or NULL if the jail does not exist. +.Fa jid , +or +.Dv NULL +if the jail does not exist. .Pp The .Fn jail_setv @@ -116,7 +118,7 @@ returned parameters. The .Fn jailparam_all function sets -.Ar jpp +.Fa jpp to a list of all known jail parameters, and returns the number of parameters. The list should later be freed with @@ -127,14 +129,15 @@ and The .Fn jailparam_init function clears a parameter record and copies the -.Ar name -to it. After use, it should be freed with +.Fa name +to it. +After use, it should be freed with .Fn jailparam_free . .Pp The .Fn jailparam_import function adds a -.Ar value +.Fa value to a parameter record, converting it from a string to its native form. The .Fn jailparam_import_raw @@ -151,7 +154,7 @@ and .Pp The .Fn jailparam_get -function function passes a list of parameters to +function passes a list of parameters to .Xr jail_get 2 . The parameters are assumed to have been created with .Fn jailparam_init @@ -163,7 +166,7 @@ with one parameter (the key) having been given a value with The .Fn jailparam_export function returns the string equivalent of a parameter value. -The returned string should freed after use. +The returned string should be freed after use. .Pp The .Fn jailparam_free @@ -171,6 +174,43 @@ function frees the stored names and values in a parameter list. If the list itself came from .Fn jailparam_all , it should be freed as well. +.Sh RETURN VALUES +The +.Fn jail_getid , +.Fn jail_setv , +.Fn jail_getv , +.Fn jailparam_set +and +.Fn jailparam_get +functions return a JID on success, or \-1 on error. +.Pp +The +.Fn jail_getname +and +.Fn jailparam_export +functions return a dynamically allocated string on success, or +.Dv NULL +on error. +.Pp +The +.Fn jailparam_all +function returns the number of parameters on success, or \-1 on error. +.Pp +The +.Fn jailparam_init , +.Fn jailparam_import +and +.Fn jailparam_import_raw +functions return 0 on success, or \-1 on error. +.Pp +Whenever an error is returned, +.Va errno +is set, and the global string +.Va jail_errmsg +contains a description of the error, possibly from +.Xr jail_set 2 +or +.Xr jail_get 2 . .Sh EXAMPLES Set the hostname of jail .Dq foo @@ -209,41 +249,6 @@ jailparam_get(params, 2, 0); hostname = jailparam_export(¶ms[1]); jailparam_free(params, 2); .Ed -.Sh RETURN VALUES -The -.Fn jail_getid , -.Fn jail_setv , -.Fn jail_getv , -.Fn jailparam_set -and -.Fn jailparam_get -functions return a JID on success, or \-1 on error. -.Pp -The -.Fn jail_getname -and -.Fn jailparam_export -functions return a dynamically allocated string on success, or NULL on error. -.Pp -The -.Fn jailparam_all -function returns the number of parameters on success, or \-1 on error. -.Pp -The -.Fn jailparam_init , -.Fn jailparam_import -and -.Fn jailparam_import_raw -functions return 0 on success, or \-1 on error. -.Pp -Whenever an error is returned, -.Va errno -is set, and the global string -.Va jail_errmsg -contains a descrption of the error, possibly from -.Xr jail_set 2 -or -.Xr jail_get 2 . .Sh ERRORS The .Nm jail @@ -256,16 +261,17 @@ or In addition, the following errors are possible: .Bl -tag -width Er .It Bq Er EINVAL -A prameter value cannot be convert from the passed string to its +A parameter value cannot be converted from the passed string to its internal form. .It Bq Er ENOENT The named parameter does not exist. .It Bq Er ENOENT A parameter is of an unknown type. +.El .Sh SEE ALSO .Xr jail 2 , -.Xr jail 8 , -.Xr sysctl 3 +.Xr sysctl 3 , +.Xr jail 8 .Sh HISTORY The .Nm jail diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c index 06d1287..0740d6b 100644 --- a/lib/libthr/thread/thr_spec.c +++ b/lib/libthr/thread/thr_spec.c @@ -131,9 +131,19 @@ _thread_cleanupspecific(void) curthread->specific[key].data = NULL; curthread->specific_data_count--; } + else if (curthread->specific[key].data != NULL) { + /* + * This can happen if the key is deleted via + * pthread_key_delete without first setting the value + * to NULL in all threads. POSIX says that the + * destructor is not invoked in this case. + */ + curthread->specific[key].data = NULL; + curthread->specific_data_count--; + } /* - * If there is a destructore, call it + * If there is a destructor, call it * with the key table entry unlocked: */ if (destructor != NULL) { diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h index 41b5f96..a6e462e 100644 --- a/lib/libthr/thread/thr_umtx.h +++ b/lib/libthr/thread/thr_umtx.h @@ -171,8 +171,11 @@ _thr_rwlock_unlock(struct urwlock *rwlock) for (;;) { if (__predict_false(URWLOCK_READER_COUNT(state) == 0)) return (EPERM); - if (!((state & URWLOCK_WRITE_WAITERS) && URWLOCK_READER_COUNT(state) == 1)) { - if (atomic_cmpset_rel_32(&rwlock->rw_state, state, state-1)) + if (!((state & (URWLOCK_WRITE_WAITERS | + URWLOCK_READ_WAITERS)) && + URWLOCK_READER_COUNT(state) == 1)) { + if (atomic_cmpset_rel_32(&rwlock->rw_state, + state, state-1)) return (0); state = rwlock->rw_state; } else { |