diff options
author | millert <> | 2003-05-08 23:26:30 +0000 |
---|---|---|
committer | millert <> | 2003-05-08 23:26:30 +0000 |
commit | cc7ac4251d9e79f59912cefe0a1327534890ca07 (patch) | |
tree | 1c26f297e22f3f1fe18f87a223c6bdff66a0e471 /src | |
parent | 904702870b8643c3707b8b8747e4c6814f2afa54 (diff) | |
download | openbsd-cc7ac4251d9e79f59912cefe0a1327534890ca07.tar.gz openbsd-cc7ac4251d9e79f59912cefe0a1327534890ca07.tar.bz2 openbsd-cc7ac4251d9e79f59912cefe0a1327534890ca07.zip |
move insque(3) and remque(3) from libcompat -> libc; they are now POSIX
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/Makefile.inc | 17 | ||||
-rw-r--r-- | src/lib/libc/stdlib/insque.3 | 100 | ||||
-rw-r--r-- | src/lib/libc/stdlib/insque.c | 52 | ||||
-rw-r--r-- | src/lib/libc/stdlib/remque.c | 48 |
4 files changed, 209 insertions, 8 deletions
diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc index d2034982fe..6403926382 100644 --- a/src/lib/libc/stdlib/Makefile.inc +++ b/src/lib/libc/stdlib/Makefile.inc | |||
@@ -5,11 +5,11 @@ | |||
5 | 5 | ||
6 | SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \ | 6 | SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \ |
7 | calloc.c cfree.c exit.c ecvt.c gcvt.c getenv.c getopt.c getopt_long.c \ | 7 | calloc.c cfree.c exit.c ecvt.c gcvt.c getenv.c getopt.c getopt_long.c \ |
8 | getsubopt.c heapsort.c l64a.c lsearch.c malloc.c merge.c multibyte.c \ | 8 | getsubopt.c heapsort.c insque.c l64a.c lsearch.c malloc.c merge.c \ |
9 | putenv.c qsort.c radixsort.c rand.c random.c realpath.c setenv.c \ | 9 | multibyte.c putenv.c qsort.c radixsort.c rand.c random.c realpath.c \ |
10 | strtod.c strtol.c strtoll.c strtoul.c strtoull.c system.c tfind.c \ | 10 | setenv.c strtod.c strtol.c strtoll.c strtoul.c strtoull.c system.c \ |
11 | tsearch.c _rand48.c drand48.c erand48.c jrand48.c lcong48.c lrand48.c \ | 11 | tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c lcong48.c \ |
12 | mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c | 12 | lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c |
13 | 13 | ||
14 | .if (${MACHINE_ARCH} == "m68k") | 14 | .if (${MACHINE_ARCH} == "m68k") |
15 | SRCS+= abs.S div.c labs.c ldiv.c | 15 | SRCS+= abs.S div.c labs.c ldiv.c |
@@ -34,13 +34,14 @@ SRCS+= abs.c div.c labs.c ldiv.c | |||
34 | 34 | ||
35 | MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \ | 35 | MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \ |
36 | bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \ | 36 | bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \ |
37 | getsubopt.3 labs.3 ldiv.3 lsearch.3 malloc.3 memory.3 qabs.3 qdiv.3 \ | 37 | getsubopt.3 insque.3 labs.3 ldiv.3 lsearch.3 malloc.3 memory.3 qabs.3 \ |
38 | qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 strtod.3 \ | 38 | qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \ |
39 | strtol.3 strtoul.3 system.3 tsearch.3 | 39 | strtod.3 strtol.3 strtoul.3 system.3 tsearch.3 |
40 | 40 | ||
41 | MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3 | 41 | MLINKS+=ecvt.3 fcvt.3 ecvt.3 gcvt.3 |
42 | MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 | 42 | MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 |
43 | MLINKS+=getopt_long.3 getopt_long_only.3 | 43 | MLINKS+=getopt_long.3 getopt_long_only.3 |
44 | MLINKS+=insque.3 remque.3 | ||
44 | MLINKS+=lsearch.3 lfind.3 | 45 | MLINKS+=lsearch.3 lfind.3 |
45 | MLINKS+=malloc.3 free.3 malloc.3 realloc.3 malloc.3 calloc.3 | 46 | MLINKS+=malloc.3 free.3 malloc.3 realloc.3 malloc.3 calloc.3 |
46 | MLINKS+=malloc.3 cfree.3 malloc.3 malloc.conf.5 | 47 | MLINKS+=malloc.3 cfree.3 malloc.3 malloc.conf.5 |
diff --git a/src/lib/libc/stdlib/insque.3 b/src/lib/libc/stdlib/insque.3 new file mode 100644 index 0000000000..b87adb87bc --- /dev/null +++ b/src/lib/libc/stdlib/insque.3 | |||
@@ -0,0 +1,100 @@ | |||
1 | .\" $OpenBSD: insque.3,v 1.1 2003/05/08 23:26:30 millert Exp $ | ||
2 | .\" Copyright (c) 1993 John Brezak | ||
3 | .\" All rights reserved. | ||
4 | .\" | ||
5 | .\" Redistribution and use in source and binary forms, with or without | ||
6 | .\" modification, are permitted provided that the following conditions | ||
7 | .\" are met: | ||
8 | .\" 1. Redistributions of source code must retain the above copyright | ||
9 | .\" notice, this list of conditions and the following disclaimer. | ||
10 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer in the | ||
12 | .\" documentation and/or other materials provided with the distribution. | ||
13 | .\" 3. The name of the author may be used to endorse or promote products | ||
14 | .\" derived from this software without specific prior written permission. | ||
15 | .\" | ||
16 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND | ||
17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE | ||
20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
26 | .\" SUCH DAMAGE. | ||
27 | .\" | ||
28 | .\" | ||
29 | .Dd August 12, 1993 | ||
30 | .Dt INSQUE 3 | ||
31 | .Os | ||
32 | .Sh NAME | ||
33 | .Nm insque , | ||
34 | .Nm remque | ||
35 | .Nd insert/remove element from a queue | ||
36 | .Sh SYNOPSIS | ||
37 | .Fd #include <search.h> | ||
38 | .Ft void | ||
39 | .Fn insque "void *elem" "void *pred" | ||
40 | .Ft void | ||
41 | .Fn remque "void *elem" | ||
42 | .Sh DESCRIPTION | ||
43 | .Bf -symbolic | ||
44 | These interfaces have been superceded by the | ||
45 | .Xr queue 3 | ||
46 | macros and are provided for compatibility with legacy code. | ||
47 | .Ef | ||
48 | .Pp | ||
49 | .Fn insque | ||
50 | and | ||
51 | .Fn remque | ||
52 | manipulate queues built from doubly linked lists. | ||
53 | The queue can be either circular or linear. | ||
54 | Each element in the queue must be of the following form: | ||
55 | .Bd -literal | ||
56 | struct qelem { | ||
57 | struct qelem *q_forw; | ||
58 | struct qelem *q_back; | ||
59 | char q_data[]; | ||
60 | }; | ||
61 | .Ed | ||
62 | .Pp | ||
63 | The first two elements in the struct must be pointers of the | ||
64 | same type that point to the previous and next elements in | ||
65 | the queue respectively. | ||
66 | Any subsequent data in the struct is application-dependent. | ||
67 | .Pp | ||
68 | The | ||
69 | .Fn insque | ||
70 | function inserts | ||
71 | .Fa elem | ||
72 | into a queue immediately after | ||
73 | .Fa pred . | ||
74 | .Pp | ||
75 | The | ||
76 | .Fn remque | ||
77 | function removes | ||
78 | .Fa elem | ||
79 | from the queue. | ||
80 | .Sh DIAGNOSTICS | ||
81 | These functions are not atomic unless that machine architecture allows it. | ||
82 | .Sh SEE ALSO | ||
83 | .Xr queue 3 | ||
84 | .Sh STANDARDS | ||
85 | The | ||
86 | .Fn lsearch | ||
87 | and | ||
88 | .Fn lfind | ||
89 | functions conform to the | ||
90 | .St -p1003.1-01 | ||
91 | and | ||
92 | .St -xpg4.3 . | ||
93 | specifications. | ||
94 | .Sh HISTORY | ||
95 | The | ||
96 | .Fn insque | ||
97 | and | ||
98 | .Fn remque | ||
99 | functions are derived from the insque and remque instructions on a | ||
100 | .Tn VAX . | ||
diff --git a/src/lib/libc/stdlib/insque.c b/src/lib/libc/stdlib/insque.c new file mode 100644 index 0000000000..549246c71f --- /dev/null +++ b/src/lib/libc/stdlib/insque.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* $OpenBSD: insque.c,v 1.1 2003/05/08 23:26:30 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1993 John Brezak | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | ||
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
27 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
28 | * POSSIBILITY OF SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #if defined(LIBC_SCCS) && !defined(lint) | ||
32 | static char *rcsid = "$OpenBSD: insque.c,v 1.1 2003/05/08 23:26:30 millert Exp $"; | ||
33 | #endif /* LIBC_SCCS and not lint */ | ||
34 | |||
35 | #include <search.h> | ||
36 | |||
37 | struct qelem { | ||
38 | struct qelem *q_forw; | ||
39 | struct qelem *q_back; | ||
40 | }; | ||
41 | |||
42 | void | ||
43 | insque(void *entry, void *pred) | ||
44 | { | ||
45 | struct qelem *e = (struct qelem *) entry; | ||
46 | struct qelem *p = (struct qelem *) pred; | ||
47 | |||
48 | e->q_forw = p->q_forw; | ||
49 | e->q_back = p; | ||
50 | p->q_forw->q_back = e; | ||
51 | p->q_forw = e; | ||
52 | } | ||
diff --git a/src/lib/libc/stdlib/remque.c b/src/lib/libc/stdlib/remque.c new file mode 100644 index 0000000000..f4c5769a8c --- /dev/null +++ b/src/lib/libc/stdlib/remque.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* $OpenBSD: remque.c,v 1.1 2003/05/08 23:26:30 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1993 John Brezak | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR | ||
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
27 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
28 | * POSSIBILITY OF SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #if defined(LIBC_SCCS) && !defined(lint) | ||
32 | static char *rcsid = "$OpenBSD: remque.c,v 1.1 2003/05/08 23:26:30 millert Exp $"; | ||
33 | #endif /* LIBC_SCCS and not lint */ | ||
34 | |||
35 | #include <search.h> | ||
36 | |||
37 | struct qelem { | ||
38 | struct qelem *q_forw; | ||
39 | struct qelem *q_back; | ||
40 | }; | ||
41 | |||
42 | void | ||
43 | remque(void *element) | ||
44 | { | ||
45 | struct qelem *e = (struct qelem *) element; | ||
46 | e->q_forw->q_back = e->q_back; | ||
47 | e->q_back->q_forw = e->q_forw; | ||
48 | } | ||