• R/O
  • HTTP
  • SSH
  • HTTPS

mingw-org-wsl: Commit

The MinGW.org Windows System Libraries


Commit MetaInfo

Revisionc27255fcbab3a43a6db4f15e5c5eb7109189eb0d (tree)
Time2018-12-05 03:06:30
AuthorKeith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Implement POSIX.1-1996 linked-list queue management API.

Change Summary

Incremental Difference

--- a/mingwrt/ChangeLog
+++ b/mingwrt/ChangeLog
@@ -1,3 +1,15 @@
1+2018-12-04 Keith Marshall <keith@users.osdn.me>
2+
3+ Implement POSIX.1-1996 linked-list queue management API.
4+
5+ * mingwex/insque.c mingwex/remque.c: New files; they implement the
6+ POSIX.1-1996 insque(), and remque() functions, respectively.
7+
8+ * include/search.h (insque, remque): Declare function prototypes.
9+
10+ * Makefile.in (libmingwex.a): Add dependencies on...
11+ (insque.$OBJEXT, remque.$OBJEXT): ...these.
12+
113 2018-11-25 Keith Marshall <keith@users.osdn.me>
214
315 Emulate _fseeki64()/_ftelli64() API on legacy platforms.
--- a/mingwrt/Makefile.in
+++ b/mingwrt/Makefile.in
@@ -449,10 +449,9 @@ $(addsuffix fmt.$(OBJEXT),varo crto geto seto crtn getn setn): %.$(OBJEXT): ofmt
449449 libmingwex.a: $(addsuffix .$(OBJEXT), mingw-aligned-malloc mingw-fseek)
450450 libmingwex.a: $(addsuffix .$(OBJEXT), glob getopt basename dirname nsleep)
451451 libmingwex.a: $(addsuffix .$(OBJEXT), clockapi clockres clockset clocktime)
452-libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam setenv)
453-
454-libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
452+libmingwex.a: $(addsuffix .$(OBJEXT), insque remque tdelete tfind tsearch twalk)
455453 libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn strerror_r strtok_r)
454+libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam setenv)
456455 libmingwex.a: $(addsuffix .$(OBJEXT), getdelim gettimeofday)
457456
458457 vpath %.s ${mingwrt_srcdir}/mingwex
--- a/mingwrt/include/search.h
+++ b/mingwrt/include/search.h
@@ -6,7 +6,7 @@
66 * $Id$
77 *
88 * Written by Danny Smith <dannysmith@users.sourceforge.net>
9- * Copyright (C) 2003, 2004, 2007, 2016, MinGW.org Project.
9+ * Copyright (C) 2003, 2004, 2007, 2016, 2018, MinGW.org Project.
1010 *
1111 *
1212 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -126,6 +126,9 @@ __MINGW_ATTRIB_NONNULL(2) __MINGW_ATTRIB_NONNULL(3);
126126 __cdecl void twalk (const void *, void (*)(const void *, VISIT, int))
127127 __MINGW_ATTRIB_NONNULL(1) __MINGW_ATTRIB_NONNULL(2);
128128
129+__cdecl void insque (void *, void *);
130+__cdecl void remque (void *);
131+
129132 #endif /* _POSIX_C_SOURCE */
130133
131134 #if !defined _NO_OLDNAMES || defined _POSIX_C_SOURCE
--- /dev/null
+++ b/mingwrt/mingwex/insque.c
@@ -0,0 +1,81 @@
1+/*
2+ * insque.c
3+ *
4+ * POSIX.1-1996 compatible doubly-linked list management API; provides the
5+ * insque() function, for element insertion at an arbitrary position within
6+ * a linear, or circular, doubly-linked list.
7+ *
8+ *
9+ * $Id$
10+ *
11+ * Written by Keith Marshall <keith@users.osdn.me>
12+ * Copyright (C) 2018, MinGW.org Project.
13+ *
14+ *
15+ * Permission is hereby granted, free of charge, to any person obtaining a
16+ * copy of this software and associated documentation files (the "Software"),
17+ * to deal in the Software without restriction, including without limitation
18+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19+ * and/or sell copies of the Software, and to permit persons to whom the
20+ * Software is furnished to do so, subject to the following conditions:
21+ *
22+ * The above copyright notice, this permission notice, and the following
23+ * disclaimer shall be included in all copies or substantial portions of
24+ * the Software.
25+ *
26+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
29+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
32+ * DEALINGS IN THE SOFTWARE.
33+ *
34+ */
35+#include <search.h>
36+#include <stddef.h>
37+
38+/* This private structure definition specifies the minimal layout of a
39+ * doubly-linked list element; client code will typically append extra
40+ * data fields, but the first two fields must be pointers to identical
41+ * structures.
42+ */
43+struct qnode { struct qnode *fwdlink, *bkwdlink; };
44+
45+/* Providing the actual implementation as an inline function, with its
46+ * arguments specified as pointers to structures of the preceding type,
47+ * offers a conventient mechanism for mapping the generic pointers of
48+ * the public API to the minimal required form.
49+ */
50+__CRT_ALIAS void do_insque( struct qnode *element, struct qnode *pred )
51+{
52+ /* Insert "element" into the list containing "pred", with insertion
53+ * point immediately following "pred"; becomes a no-op, if "element"
54+ * is specified as NULL...
55+ */
56+ if( element != NULL )
57+ {
58+ /* ...otherwise, sets the forward link of "element" to the current
59+ * forward link of "pred", (or to NULL, if "pred" is NULL), and the
60+ * backward link of the successor to "pred", if any, to point back
61+ * to "element"...
62+ */
63+ if( (element->fwdlink = (pred != NULL) ? pred->fwdlink : NULL) != NULL )
64+ element->fwdlink->bkwdlink = element;
65+
66+ /* ...and completes the linking, by setting the backward link of
67+ * "element" to point to "pred", and the forward link of "pred",
68+ * (if "pred" isn't NULL), to point to "element".
69+ */
70+ if( (element->bkwdlink = pred) != NULL )
71+ pred->fwdlink = element;
72+ }
73+}
74+
75+/* The public API simply expands the inline implementation, mapping
76+ * the generic pointer arguments to the minimally specified structure.
77+ */
78+void insque( void *element, void *pred )
79+{ do_insque( (struct qnode *)(element), (struct qnode *)(pred) ); }
80+
81+/* $RCSfile$: end of file */
--- /dev/null
+++ b/mingwrt/mingwex/remque.c
@@ -0,0 +1,77 @@
1+/*
2+ * remque.c
3+ *
4+ * POSIX.1-1996 compatible doubly-linked list management API; provides the
5+ * remque() function, for removal of an element from an arbitrary position
6+ * within a linear, or circular, doubly-linked list.
7+ *
8+ *
9+ * $Id$
10+ *
11+ * Written by Keith Marshall <keith@users.osdn.me>
12+ * Copyright (C) 2018, MinGW.org Project.
13+ *
14+ *
15+ * Permission is hereby granted, free of charge, to any person obtaining a
16+ * copy of this software and associated documentation files (the "Software"),
17+ * to deal in the Software without restriction, including without limitation
18+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19+ * and/or sell copies of the Software, and to permit persons to whom the
20+ * Software is furnished to do so, subject to the following conditions:
21+ *
22+ * The above copyright notice, this permission notice, and the following
23+ * disclaimer shall be included in all copies or substantial portions of
24+ * the Software.
25+ *
26+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
29+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
32+ * DEALINGS IN THE SOFTWARE.
33+ *
34+ */
35+#include <search.h>
36+#include <stddef.h>
37+
38+/* This private structure definition specifies the minimal layout of a
39+ * doubly-linked list element; client code will typically append extra
40+ * data fields, but the first two fields must be pointers to identical
41+ * structures.
42+ */
43+struct qnode { struct qnode *fwdlink, *bkwdlink; };
44+
45+/* Providing the actual implementation as an inline function, with its
46+ * argument specified as a pointer to a structure of the preceding type,
47+ * offers a conventient mechanism for mapping the generic pointer of the
48+ * public API to the minimal required form.
49+ */
50+__CRT_ALIAS void do_remque( struct qnode *element )
51+{
52+ /* Remove "element" from the list which contains it; becomes a
53+ * no-op, if "element" is NULL...
54+ */
55+ if( element != NULL )
56+ {
57+ /* ...otherwise, updates the backward link in the successor of
58+ * "element", if any, to point to the predecessor of "element"...
59+ */
60+ if( element->fwdlink != NULL )
61+ element->fwdlink->bkwdlink = element->bkwdlink;
62+
63+ /* ...and the forward link in the predecessor of "element", if
64+ * any, to point to the successor of "element".
65+ */
66+ if( element->bkwdlink != NULL )
67+ element->bkwdlink->fwdlink = element->fwdlink;
68+ }
69+}
70+
71+/* The public API simply expands the inline implementation, mapping
72+ * the generic pointer argument to the minimally specified structure.
73+ */
74+void remque( void *element )
75+{ do_remque( (struct qnode *)(element) ); }
76+
77+/* $RCSfile$: end of file */
Show on old repository browser