summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2000-07-26 21:12:35 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2000-07-26 21:12:35 +0000
commita964be6d2c35243e54bf5ce12c15339d331189cb (patch)
tree26495eba10a5d04d8137457f832b376b573dd186 /lib/libc
parentdc30028e8a31a0604280582224f03e9c70ec1ec0 (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/posixshm.c69
-rw-r--r--lib/libc/gen/shm_open.3194
-rw-r--r--lib/libc/stdlib/tdelete.c66
-rw-r--r--lib/libc/stdlib/tfind.c47
-rw-r--r--lib/libc/stdlib/tsearch.3118
-rw-r--r--lib/libc/stdlib/tsearch.c57
-rw-r--r--lib/libc/stdlib/twalk.c57
7 files changed, 0 insertions, 608 deletions
diff --git a/lib/libc/gen/posixshm.c b/lib/libc/gen/posixshm.c
deleted file mode 100644
index e437940ba881..000000000000
--- a/lib/libc/gen/posixshm.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2000 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. 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$
- */
-
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-int
-shm_open(const char *path, int flags, mode_t mode)
-{
- int fd;
- struct stat stab;
-
- if ((flags & O_ACCMODE) == O_WRONLY)
- return (EINVAL);
-
- fd = _open(path, flags, mode);
- if (fd != -1) {
- if (fstat(fd, &stab) != 0 || !S_ISREG(stab.st_mode)) {
- _close(fd);
- errno = EINVAL;
- return (-1);
- }
-
- if (_fcntl(fd, F_SETFL, (int)FPOSIXSHM) != 0) {
- _close(fd);
- return (-1);
- }
- }
- return (fd);
-}
-
-int
-shm_unlink(const char *path)
-{
- return (unlink(path));
-}
diff --git a/lib/libc/gen/shm_open.3 b/lib/libc/gen/shm_open.3
deleted file mode 100644
index d8af8794529e..000000000000
--- a/lib/libc/gen/shm_open.3
+++ /dev/null
@@ -1,194 +0,0 @@
-.\"
-.\" Copyright 2000 Massachusetts Institute of Technology
-.\"
-.\" Permission to use, copy, modify, and distribute this software and
-.\" its documentation for any purpose and without fee is hereby
-.\" granted, provided that both the above copyright notice and this
-.\" permission notice appear in all copies, that both the above
-.\" copyright notice and this permission notice appear in all
-.\" supporting documentation, and that the name of M.I.T. not be used
-.\" in advertising or publicity pertaining to distribution of the
-.\" software without specific, written prior permission. M.I.T. makes
-.\" no representations about the suitability of this software for any
-.\" purpose. It is provided "as is" without express or implied
-.\" warranty.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
-.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
-.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
-.\" SHALL M.I.T. 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 March 24, 2000
-.Dt SHM_OPEN 3
-.Os
-.Sh NAME
-.Nm shm_open
-.Nd open or create a shared memory object
-.Nm shm_unlink
-.Nd remove a shared memory object
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/mman.h>
-.Ft int
-.Fn shm_open "const char *path" "int flags" "mode_t mode"
-.Ft int
-.Fn shm_unlink "const char *path"
-.Sh DESCRIPTION
-The
-.Nm shm_open
-function opens (or optionally creates) a
-.Tn POSIX
-shared memory object named
-.Fa path .
-The
-.Nm shm_unlink
-function removes a shared memory object named
-.Fa path .
-.Pp
-In the
-.Fx
-implementation,
-.Tn POSIX
-shared memory objects are implemented as ordinary files.
-The
-.Nm shm_open
-and
-.Nm shm_unlink
-act as wrappers around the
-.Xr open 2
-and
-.Xr unlink 2
-routines, and
-.Fa path ,
-.Fa flags ,
-and
-.Fa mode
-arguments are as specified for those functions.
-The
-.Fa flags
-argument is checked to ensure that the access mode specified is not
-.Dv O_WRONLY
-(which is not defined for shared memory objects).
-.Pp
-In addition, the
-.Fx
-implementation causes
-.Fn mmap
-of a descriptor returned by
-.Nm shm_open
-to behave as if the
-.Dv MAP_NOSYNC
-flag had been specified to
-.Xr mmap 2 .
-(It does so by setting a special file flag using
-.Xr fcntl 2 . )
-.Pp
-The
-.Nm shm_unlink
-function makes no effort to ensure that
-.Fa path
-refers to a shared memory object.
-.Sh PORTABILITY
-The
-.Fa path
-argument does not necessarily represent a pathname (although it does in this
-and most other implementations).
-Two processes opening the same
-.Fa path
-are guaranteed to access the same shared memory object if and only if
-.Fa path
-begins with a slash
-.Pq Ql \&/
-character.
-.Pp
-Only the
-.Dv O_RDONLY ,
-.Dv O_RDWR ,
-.Dv O_CREAT ,
-.Dv O_EXCL ,
-and
-.Dv O_TRUNC
-flags may be used in portable programs.
-.Pp
-The result of using
-.Xr open 2 ,
-.Xr read 2 ,
-or
-.Xr write 2
-on a shared memory object, or on the descriptor returned by
-.Fn shm_open ,
-is undefined.
-It is also undefined whether the shared memory object itself, or its
-contents, persist across reboots.
-.Sh RETURN VALUES
-If successful,
-.Fn shm_open
-returns a non-negative integer;
-.Fn shm_unlink
-returns zero.
-Both functions return -1 on failure, and set
-.Va errno
-to indicate the error.
-.Sh ERRORS
-The
-.Fn shm_open
-and
-.Fn shm_unlink
-functions can fail with any error defined for
-.Fn open
-and
-.Fn unlink ,
-respectively. In addition, the following errors are defined for
-.Fn shm_open :
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The object named by
-.Fa path
-is not a shared memory object
-(i.e., it is not a regular file).
-.It Bq Er EINVAL
-The
-.Fa flags
-argument to
-.Fn shm_open
-specifies an access mode of
-.Dv O_WRONLY .
-.El
-.Sh SEE ALSO
-.Xr mmap 2 ,
-.Xr munmap 2 ,
-.Xr open 2 ,
-.Xr unlink 2
-.Sh STANDARDS
-The
-.Nm shm_open
-and
-.Nm shm_unlink
-functions are believed to conform to
-.St -p1003.1b .
-.Sh HISTORY
-The
-.Nm shm_open
-and
-.Nm shm_unlink
-functions first appeared in
-.Fx 5.0 .
-.Sh AUTHORS
-.An Garrett A. Wollman Aq wollman@FreeBSD.org
-(C library support and this manual page)
-.Pp
-.An Matthew Dillon Aq dillon@FreeBSD.org
-.Pq Dv MAP_NOSYNC
-
diff --git a/lib/libc/stdlib/tdelete.c b/lib/libc/stdlib/tdelete.c
deleted file mode 100644
index daf4aa71400f..000000000000
--- a/lib/libc/stdlib/tdelete.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* $NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tree search generalized from Knuth (6.2.2) Algorithm T just like
- * the AT&T man page says.
- *
- * The node_t structure is for internal use only, lint doesn't grok it.
- *
- * Written by reading the System V Interface Definition, not the code.
- *
- * Totally public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#define _SEARCH_PRIVATE
-#include <search.h>
-#include <stdlib.h>
-
-
-/* delete node with given key */
-void *
-tdelete(vkey, vrootp, compar)
- const void *vkey; /* key to be deleted */
- void **vrootp; /* address of the root of tree */
- int (*compar) __P((const void *, const void *));
-{
- node_t **rootp = (node_t **)vrootp;
- node_t *p, *q, *r;
- int cmp;
-
- if (rootp == NULL || (p = *rootp) == NULL)
- return NULL;
-
- while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) {
- p = *rootp;
- rootp = (cmp < 0) ?
- &(*rootp)->llink : /* follow llink branch */
- &(*rootp)->rlink; /* follow rlink branch */
- if (*rootp == NULL)
- return NULL; /* key not found */
- }
- r = (*rootp)->rlink; /* D1: */
- if ((q = (*rootp)->llink) == NULL) /* Left NULL? */
- q = r;
- else if (r != NULL) { /* Right link is NULL? */
- if (r->llink == NULL) { /* D2: Find successor */
- r->llink = q;
- q = r;
- } else { /* D3: Find NULL link */
- for (q = r->llink; q->llink != NULL; q = r->llink)
- r = q;
- r->llink = q->rlink;
- q->llink = (*rootp)->llink;
- q->rlink = (*rootp)->rlink;
- }
- }
- free(*rootp); /* D4: Free node */
- *rootp = q; /* link parent to new node */
- return p;
-}
diff --git a/lib/libc/stdlib/tfind.c b/lib/libc/stdlib/tfind.c
deleted file mode 100644
index b2c4b9618bb7..000000000000
--- a/lib/libc/stdlib/tfind.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* $NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tree search generalized from Knuth (6.2.2) Algorithm T just like
- * the AT&T man page says.
- *
- * The node_t structure is for internal use only, lint doesn't grok it.
- *
- * Written by reading the System V Interface Definition, not the code.
- *
- * Totally public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#define _SEARCH_PRIVATE
-#include <stdlib.h>
-#include <search.h>
-
-/* find a node, or return 0 */
-void *
-tfind(vkey, vrootp, compar)
- const void *vkey; /* key to be found */
- void **vrootp; /* address of the tree root */
- int (*compar) __P((const void *, const void *));
-{
- node_t **rootp = (node_t **)vrootp;
-
- if (rootp == NULL)
- return NULL;
-
- while (*rootp != NULL) { /* T1: */
- int r;
-
- if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */
- return *rootp; /* key found */
- rootp = (r < 0) ?
- &(*rootp)->llink : /* T3: follow left branch */
- &(*rootp)->rlink; /* T4: follow right branch */
- }
- return NULL;
-}
diff --git a/lib/libc/stdlib/tsearch.3 b/lib/libc/stdlib/tsearch.3
deleted file mode 100644
index 4dcf658cadca..000000000000
--- a/lib/libc/stdlib/tsearch.3
+++ /dev/null
@@ -1,118 +0,0 @@
-.\" $NetBSD$
-.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
-.\" 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. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED ``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.
-.\"
-.\" OpenBSD: tsearch.3,v 1.2 1998/06/21 22:13:49 millert Exp
-.\" $FreeBSD$
-.\"
-.Dd June 15, 1997
-.Dt TSEARCH 3
-.Os
-.Sh NAME
-.Nm tsearch, tfind, tdelete, twalk
-.Nd manipulate binary search trees
-.Sh SYNOPSIS
-.Fd #include <search.h>
-.Ft void *
-.Fn tdelete "const void *key" "void **rootp", "int (*compar) (const void *, const void *)"
-.Ft void *
-.Fn tfind "const void *key" "const void **rootp", "int (*compar) (const void *, const void *)"
-.Ft void *
-.Fn tsearch "const void *key", "void **rootp", "int (*compar) (const void *, const void *)"
-.Ft void
-.Fn twalk "const void *root" "void (*compar) (const void *, VISIT, int)"
-.Sh DESCRIPTION
-The
-.Fn tdelete ,
-.Fn tfind ,
-.Fn tsearch ,
-and
-.Fn twalk
-functions manage binary search trees based on algorithms T and D
-from Knuth (6.2.2). The comparison function passed in by
-the user has the same style of return values as
-.Xr strcmp 3 .
-.Pp
-.Fn Tfind
-searches for the datum matched by the argument
-.Fa key
-in the binary tree rooted at
-.Fa rootp ,
-returning a pointer to the datum if it is found and NULL
-if it is not.
-.Pp
-.Fn Tsearch
-is identical to
-.Fn tfind
-except that if no match is found,
-.Fa key
-is inserted into the tree and a pointer to it is returned. If
-.Fa rootp
-points to a NULL value a new binary search tree is created.
-.Pp
-.Fn Tdelete
-deletes a node from the specified binary search tree and returns
-a pointer to the parent of the node to be deleted.
-It takes the same arguments as
-.Fn tfind
-and
-.Fn tsearch .
-If the node to be deleted is the root of the binary search tree,
-.Fa rootp
-will be adjusted.
-.Pp
-.Fn Twalk
-walks the binary search tree rooted in
-.fa root
-and calls the function
-.Fa action
-on each node.
-.Fa Action
-is called with three arguments: a pointer to the current node,
-a value from the enum
-.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;"
-specifying the traversal type, and a node level (where level
-zero is the root of the tree).
-.Sh SEE ALSO
-.Xr bsearch 3 ,
-.Xr hsearch 3 ,
-.Xr lsearch 3
-.Sh RETURN VALUES
-The
-.Fn tsearch
-function returns NULL if allocation of a new node fails (usually
-due to a lack of free memory).
-.Pp
-.Fn Tfind ,
-.Fn tsearch ,
-and
-.Fn tdelete
-return NULL if
-.Fa rootp
-is NULL or the datum cannot be found.
-.Pp
-The
-.Fn twalk
-function returns no value.
diff --git a/lib/libc/stdlib/tsearch.c b/lib/libc/stdlib/tsearch.c
deleted file mode 100644
index 85832ce480a3..000000000000
--- a/lib/libc/stdlib/tsearch.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* $NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tree search generalized from Knuth (6.2.2) Algorithm T just like
- * the AT&T man page says.
- *
- * The node_t structure is for internal use only, lint doesn't grok it.
- *
- * Written by reading the System V Interface Definition, not the code.
- *
- * Totally public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#define _SEARCH_PRIVATE
-#include <search.h>
-#include <stdlib.h>
-
-/* find or insert datum into search tree */
-void *
-tsearch(vkey, vrootp, compar)
- const void *vkey; /* key to be located */
- void **vrootp; /* address of tree root */
- int (*compar) __P((const void *, const void *));
-{
- node_t *q;
- node_t **rootp = (node_t **)vrootp;
-
- if (rootp == NULL)
- return NULL;
-
- while (*rootp != NULL) { /* Knuth's T1: */
- int r;
-
- if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */
- return *rootp; /* we found it! */
-
- rootp = (r < 0) ?
- &(*rootp)->llink : /* T3: follow left branch */
- &(*rootp)->rlink; /* T4: follow right branch */
- }
-
- q = malloc(sizeof(node_t)); /* T5: key not found */
- if (q != 0) { /* make new node */
- *rootp = q; /* link new node to old */
- /* LINTED const castaway ok */
- q->key = (void *)vkey; /* initialize new node */
- q->llink = q->rlink = NULL;
- }
- return q;
-}
diff --git a/lib/libc/stdlib/twalk.c b/lib/libc/stdlib/twalk.c
deleted file mode 100644
index eab71df638ca..000000000000
--- a/lib/libc/stdlib/twalk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* $NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Tree search generalized from Knuth (6.2.2) Algorithm T just like
- * the AT&T man page says.
- *
- * The node_t structure is for internal use only, lint doesn't grok it.
- *
- * Written by reading the System V Interface Definition, not the code.
- *
- * Totally public domain.
- */
-
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
-#define _SEARCH_PRIVATE
-#include <search.h>
-#include <stdlib.h>
-
-static void trecurse __P((const node_t *,
- void (*action)(const void *, VISIT, int), int level));
-
-/* Walk the nodes of a tree */
-static void
-trecurse(root, action, level)
- const node_t *root; /* Root of the tree to be walked */
- void (*action) __P((const void *, VISIT, int));
- int level;
-{
-
- if (root->llink == NULL && root->rlink == NULL)
- (*action)(root, leaf, level);
- else {
- (*action)(root, preorder, level);
- if (root->llink != NULL)
- trecurse(root->llink, action, level + 1);
- (*action)(root, postorder, level);
- if (root->rlink != NULL)
- trecurse(root->rlink, action, level + 1);
- (*action)(root, endorder, level);
- }
-}
-
-/* Walk the nodes of a tree */
-void
-twalk(vroot, action)
- const void *vroot; /* Root of the tree to be walked */
- void (*action) __P((const void *, VISIT, int));
-{
- if (vroot != NULL && action != NULL)
- trecurse(vroot, action, 0);
-}